12
Turns out there are some distant aliens who know English (and have coincidentally standardized on 8-bit computer architectures). Yet they have never heard of ASCII, nor even alphabetical order.
It is believed that these aliens are picking up information from Earth. Yet they are doing so with digital equipment that reads meaningless information when no transmission is being sent...thus the signal must be contained in a way to stand out from surrounding noise.
A new standard has been created, modeled after the Arecibo Message's use of a semiprime signal length:
Universal Semiotic Coding for Information Interchange (USCII)
(See: http://uscii.hostilefork.com)
In USCII, each code is derived from a bitmap representing the character, that has a prime width and a prime height. For instance, this 5x7 representation of a letter A:
01110
10001
10001
10001
11111
10001
10001
That produces 35 bits. Yet in order to make even single-character messages stand out from the noise and look coherent, strings are embedded in a container format that helps reinforce the prime factors. The container has been chosen to also make it easy to manipulate the strings on architectures that operate on multiples of 8 bits.
With its container, the "A" above would look like:
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
1111111111111111111111111111111111100000
1111111111111111111111111111111111100000
1111111111111111111111111111111111100000
1111111111111111111111111111111111100000
1111111111111111111111111111111111100000
0111010001100011000111111100011000100000
1111111111111111111111111111111111100000
1111111111111111111111111111111111100000
1111111111111111111111111111111111100000
1111111111111111111111111111111111100000
1111111111111111111111111111111111100000
1111111111111111111111111111111111100000
1111111111111111111111111111111111100000
1111111111111111111111111111111111111111
1111111111111111111111111111111111111111
1111111111111111111111111111111111111111
1111111111111111111111111111111111111111
1111111111111111111111111111111111111111
The characters of the message are first prefixed with five solid 5x7 bitmaps, and seven solid 5x7 bitmaps added to the end. (The "meter".) Then each of these have five 0 bits tacked onto the end to make an even 40 bits.
Finally there are 7 all-zero 40-bit runs added to the beginning, and 5 all-one 40-bit runs added to the end. (The "silence".)
Your mission
You are to write an encoder. Input is a conventional ASCII string typed from the keyboard. The bitmaps you will use are from the 5x7 PIC CPU font.
(Note: It's easy enough to extract the font from the page for all the talented code golfers here, but if you want those bytes all together here they are.)
Output should be a printed string in hexadecimal.
Examples
Input:
ABCDEFG
Output:
0000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE074631FC620F463E8C7C074610845C0E4A318CB80FC21E843E0FC21E84200746178C5E0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Input:
Dear aliens: Please get me off of this planet!!!
Output:
0000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0E4A318CB80001D1FC1E0001C17C5E0002D9842000000000000001C17C5E061084211C00100421080001D1FC1E0002D98C620001F0707C003180630000000000000F463E8420061084211C0001D1FC1E0001C17C5E0001F0707C0001D1FC1E00000000000001F1787C0001D1FC1E0213E421440000000000000375AD620001D1FC1E00000000000001D18C5C01148E210801148E210800000000000001D18C5C01148E210800000000000213E4214408421E8C6200100421080001F0707C00000000000003D1F420061084211C0001C17C5E0002D98C620001D1FC1E0213E421440210840008021084000802108400080FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Clarifications
- There is no need to handle any non-printable characters for this assignment (although feedback on ideas for what those might look like is welcome)
Winning Conditions
0000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE074610845C0001D18C5C00842F8C5E0001D1FC1E00000000000746178C5E0001D18C5C061084211C01148E21080210840008021084000802108400080FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFE0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
In my opinion, aliens probably think we are crazy for sending them that stuff. – Kyle Kanos – 2014-05-12T16:02:48.153
7@KyleKanos If the aliens are smart, they'll think it's cool. The conclusion that humanity is crazy will happen shortly after someone then uses the format to transmit them information from global news outlets. – HostileFork says dont trust SE – 2014-05-13T00:36:58.543
The last line is not formatted, can you please format it like the other input and output lines? – A.L – 2014-05-13T17:01:20.223
@n.1 Is it not displaying properly in your browser? It looks fine in mine. Happy to change it if there's a technical problem, but as it describes the winning condition it is technically a "use" and not a "mention" in the use-mention distinction, so I actually had it in the body text style on purpose. :-)
– HostileFork says dont trust SE – 2014-05-14T02:46:44.347@Dr. Rebmu: in my browser on the desktop it's OK, but with the Android app the question is too wide: http://meta.stackexchange.com/q/231512/237701
– A.L – 2014-05-14T17:09:12.203