views:

55

answers:

1

I splitted the list of numbers 1-100 to files of 2 bytes. Then, I noticed that each odd number btw 11-99 needs 2 files, ie 4bytes, while each even number btw 11-99 needs 1 file, 2bytes. A file is enough for numbers btw 1-10. You can confirm the finding below.

How can you explain the finding?

What did I do?

  1. save numbers to a file, like in VIM:

    :%!python -c "for i in range(1,100): print i"

    :w! list_0_100

  2. split the file to 2 bytes' files with the GNU Split-command in Coreutils:

    $ split -b2 -d list_0_100

Finding: Each odd number btw 11-99 needs only two files, ie 4bytes. In contrast, each even number btw 11-99 needs one file, ie 2bytes:

$ head x*    

==> x07 <==
8

==> x08 <==
9

==> x09 <==
10

==> x10 <==

1
==> x11 <==

1

==> x12 <==
12

==> x13 <==

1
==> x14 <==
3

==> x15 <==
14
==> x16 <==

1
==> x17 <==
5
+3  A: 

Each number greater than 9 requires three bytes (one byte for each digit, and one more byte for the new line). Writing _ instead of the new line character (for visibility) you have this:

10_11_12_13_14

After the split:

10 _1 1_ 12 _1 3_ 14

The even numbers happen to lie in one file, but the odd number get split over two files.

Mark Byers
Thank you, I confirmed the result by having one extra space before one list. Then, each odd number btw 11-99 need only one file, instead of 2 files, no extra parity bits. Solved.
HH