Run-length encoding (RLE)
Run-length encoding (RLE) is a lossless data compression method that reduces the size of data by storing consecutive occurrences of the same value as a single value and a count.
for example: aaabcccc takes 8 bytes of memory, but if you compress it using RLE you get 3 pairs stored in binary: (a,3)(b,1)(c,4) and it will take 6 bytes. as you can see we count how many times a byte appears and store the byte followed by its count.
RLE is a simple way to compress binaries, it works best when your data has long runs of repeated bytes like yin yang images. but it can actually make things worse if your data has no repeated bytes at all, every single byte becomes two bytes: the value and a count of 1, you just doubled your file size.
it really helped me because it’s my first time using command line arguments and functions like getchar() and putchar(), it also made me understand the difference between exit() and return , exit() terminates the entire program immediately while return just exits the current function.
go check it at git hub https://github.com/yosunnyvim/rle
got inspired by https://youtu.be/bPN4OX_zZCg