## Mangarevan Counting

### June 20, 2017

Six hundred years ago, the people of the French Polynesian island of Mangareva developed a mixed-radix counting system that combined binary and decimal elements to count from 1 to 799. They had no zero. The digits 1 through 9 had their normal decimal value. Digits K, P, T and V had values 10, 20, 40 and 80, respectively, so they increased in a binary progression. A number *N* was represented as *N* = *n*V + T + P + K + *m*, where *n* and *m* were digits; note that T, P and K did not have modifiers. Thus, 73 is represented as TPK3, 219 is represented as 2VTK9, and 799 is represented as 9VTPK9 in Mangarevan. You might enjoy this article in *Nature* and this article in the *Proceedings of the National Academy of Sciences*. Arithmetic is interesting: 1VPK9 + 1 = 1VT, and 3VPK3 + 2VTK9 = 6VK2.

Your task is to write programs that translate to and from Mangarevan counting numbers. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Pages: 1 2

In Python, abusing the eval() function.

(@Praxis, your parsing function does not look right. I see it missing newlines and cut short.)

@Jussi: Fixed. Thanks. WordPress recently updated its editor, again, and every time they do something breaks.

In Python with checks on input.