Coding for Dummies, Part 1

Not being a specialist in this area, I, nevertheless, read a lot of specialized literature to get acquainted with the subject and, breaking through the thorns to the stars, I filled, in the initial stages, a lot of cones. With all the abundance of information, I could not find simple articles on coding as such, outside the scope of special literature (so to speak, without formulas and with pictures).





The article, in the first part, is an educational program on coding as such with examples of manipulations with bit codes, and in the second I would like to touch upon the simplest ways to encode images.





0. Beginning

Since I am addressing newbies in this matter, I would not consider it shameful to refer to Wikipedia. And there, to denote the coding of information, we have such a definition - the process of converting a signal from a form convenient for direct use of information into a form convenient for transmission, storage or automatic processing.





What I lacked in the 70s and 80s was at school, if not in computer science, but, for example, in mathematics lessons - basic information on coding. The fact is that each of us is engaged in coding information every second, constantly and in general - without concentrating on the coding itself. That is, in everyday life we ​​do it all the time. So how does this happen?





Mimicry, gestures, speech, signals of different levels - a sign with an inscription, a sign on the road, traffic lights, and for the modern world - bar and bar codes, URL, hash tags.





Let's take a look at some in more detail.





1.1 Speech, facial expressions, gestures

, - . , , . , . , , - , , , .





, ? - , , - . , , , , , , , - , , .





, - , .





1.2

Indian pings

. . , , "/". , .





, . ( ), , , - . "-", "A" - "--" "ET".





1.3

, , - , , . ? , , , , , , , . - , - , - . , , , , , , 1 , - .





2.

. , , - . , , - 8 .





256 , 0 255. , ( ) 00000000, 255 11111111. , 00000001.





, 26 26 , 10 . , ( ) .





" ".





2.1

8 , , , . , , :

















18









12









11









11









9









8









4









3









2









2









2









2









1









1









1









1









1









1









1





19 ( ). 18+12+11+11+9+8+4+3+2+2+2+2+1+1+1+1+1+1+1=91 (91*8=728 ).





. , 256 19. - 19 LOG2(19)=4.25, , 5, 32 ( 4 , 16 ).





, 91*5=455 , 37.5%.





, . .





, 19 32 , .





2.2

. - , . :













,









18





0









12





1









11





00









11





01









9





10









8





11









4





000









3





001









2





010









2





011









2





100









2





101









1





110









1





111









1





0000









1





0001









1





0010









1





0011









1





0100





179 .





, , , . , "111", "", "", "" "".





2.3

- , , . . - , / .





:













,









18





0000









12





0001









11





0010









11





0011









9





0100









8





0101









4





0110









3





0111









2





10001









2





10010









2





10011









2





10100









1





10101









1





10110









1





10111









1





11000









1





11001









1





11010









1





11011





, , 0 - , 1 - . , 379 . 455 .





2 , 4 :













,









18





000









12





001









11





0100









11





0101









9





0110









8





0111









4





10000









3





10001









2





10010









2





10011









2





10100









2





10101









1





10110









1





10111









1





11000









1





11001









1





11010









1





11011









1





11100





00 - 1 , 01 - 2 , 10 11 - 3 . - 356 .





, , , 455 379, 356 .





2.4

. , .





, . .





















18





00









12





101









11





100









11





011









9





010









8





1111









4





11011









3





11001









2





111011









2





111010









2





111001









2





111000









1





1101011









1





1101010









1





1101001









1





1101000









1





1100011









1





1100010









1





110000





- 328 .





, 6 7 , , .





2.5.1

, . .





: " ".





:

















18









3









2









2









2









2









1









1









1









1









1









1









1









1





, - , , , .





:





















3





0









2





1









2





2









2





3









2





4









1





5









1





6









1





7









1





8









1





9









1





10









1





11









1





12





:





7, 0, 12, 3, 5, 0, 1, 9, 2, 10, 0, 4, 1, 3, 2, 8, 4, 6, 11





, , - . .





4 ( 0 15), , , . , , , , , 5 , 3 , , - . :





/





/





/





0 / 4





/ 18





/ 2





1 / 4





/ 5





/ 2





2 / 4





/ 10





/ 2





3 / 4





/ 12





/ 2





4 / 4





/ 12





/ 2





5 / 4





/ 31





/ 2





6 / 4





/ 17





/ 2





7 / 4





/ 20





/ 2





8 / 4





/ 10





/ 2





9 / 4





/ 18





/ 2





10 / 4





/ 26





/ 2





11 / 4





/ 17





/ 2





12 / 4





/ 21





/ 2





7





0





12





3





5





0





1





9





2





10





0





4





1





3





2





8





4





6





11





4 .





We count everything together and get 371 bits. In this case, the message itself was encoded in 19 * 4 = 76 bits. But we still need to keep the Huffman code and the symbol consistent, as in all previous cases.





Afterword

I hope the article will give you a general impression of coding and show that it is not only a military encryption clerk or a complex algorithm for mathematical geniuses.





From time to time I come across how students are trying to solve coding problems and simply cannot abstract, come up with a creative approach to this process. But coding is like a hairstyle or fashionable pants, which in this way show our social code.








All Articles