Answer to David Turnbull's c-puzzle from April 6th

By: JosephBaker

2013-05-27 14:12:32

David's puzzle on April 6th was a lot of fun to work with.  If you want to see my answer, read the first few pages of:

http://joseph-baker.com/DorkBotCPuzzleOverview.pdf

My answer to David’s puzzle is:
This snippet of code coverts information from one encoding into a more intuitive 
encoding that includes error detection.
 
Input Encoding:
This program receives information encoded in the following token format:
1. ‘3’ is a binary 1
2. ‘1’ is a binary 0
3. ‘0’ is Not a Number
4. Example: 131131 represents binary ‘010010’
5. All the tokens are either 5 or 6 bits long.
 
Output Encoding:
 
The received information is output with the following characteristics:
1. An 8-bit byte is returned.
2. The received token is left justified in a binary 8-bit number.
3. A control sequence in the least-significant bits indicating:
  a. How many of the most-significant bits are in the number.
  b. If it is a 6-bit number, the least significant bit (extra bit) of the 6-
      bits is repeated to improve error detection.
  c. A unique code (‘111’) is returned if the token was Not A Number.
 
Back to archive index