A puzzle from a world of 5 bits
Description:
Imagine some extraordinary computers in a far far galaxy, which are based to compute not on two but five 'bits': 0, 1, 2, 3, 4
.
In such a computer, every register stores n
extraterrestrial 'bits', so one such register can contain integers up to 5 ^ n
.
Negative numbers are represented analogously to Two's complement, i.e. 0
turns to the maximal representable number 44...4444
when decreased by 1
. E.g. -14 = 44...4431
(with n
digits). (For this kata, the actual cutoff between negative and positive numbers is irrelevant.)
For this kata we will let the size n
of registers vary.
As mathematical operations are executed using single registers, any potential overflow bits get lost. In practice, it means that only the last n
'bits' of the result are stored. For example, if n = 2
, we get 12 * 12 == 44
on the register, because 12 * 12 = 144
holds even in number base 5
, and only the last 2
digits are kept. Similarly, 44 + 1 == 0
here.
Your task is to write a function that returns the set of all register values z
that satisfy z * z == -1
, when the size of registers, n
, is given.
The expected result set contains the string representation of the solutions on n
'bits', i.e. with potential leading zeroes.
Similar Kata:
Stats:
Created | Dec 4, 2015 |
Published | Dec 4, 2015 |
Warriors Trained | 118 |
Total Skips | 12 |
Total Code Submissions | 122 |
Total Times Completed | 23 |
Python Completions | 19 |
Haskell Completions | 4 |
JavaScript Completions | 4 |
Total Stars | 6 |
% of votes with a positive feedback rating | 86% of 11 |
Total "Very Satisfied" Votes | 8 |
Total "Somewhat Satisfied" Votes | 3 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 12 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 2 kyu |
Lowest Assessed Rank | 8 kyu |