Beta

A puzzle from a world of 5 bits

19 of 23zellerede

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.

Mathematics
Algorithms

More By Author:

Check out these other kata created by zellerede

Stats:

CreatedDec 4, 2015
PublishedDec 4, 2015
Warriors Trained118
Total Skips12
Total Code Submissions122
Total Times Completed23
Python Completions19
Haskell Completions4
JavaScript Completions4
Total Stars6
% of votes with a positive feedback rating86% of 11
Total "Very Satisfied" Votes8
Total "Somewhat Satisfied" Votes3
Total "Not Satisfied" Votes0
Total Rank Assessments12
Average Assessed Rank
5 kyu
Highest Assessed Rank
2 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • zellerede Avatar
  • JohanWiltink Avatar
  • user9644768 Avatar
  • user8436785 Avatar
Ad