Skip to content

Instantly share code, notes, and snippets.

@rosscooperman
Created September 20, 2024 20:34
Show Gist options
  • Save rosscooperman/c8f94add496122ca8f7b1763ce050537 to your computer and use it in GitHub Desktop.
Save rosscooperman/c8f94add496122ca8f7b1763ce050537 to your computer and use it in GitHub Desktop.
Cuneiform Coding Test

Cuneiform Number Converter

Bablonians are widely credited with creating the first positional number system. In this way their number system was far more like ours than other ancient number systems (like Roman numerals) that we're more familiar with. Unlike us, however, Babalonians used a base 60 system with only two distinct numeric symbols. The small number of symbols is generally attributed to the fact that clay tablets were used for writing so symbols needed to be both as small as possible and as distinct as possible even with a lack of precise writing implements. The reason they used base 60 is not definitively known but one explanation is that it grew out of trade between a group using base 5 and a group using base 12. Whatever the reason, your task is to create a function that takes receives an integer and returns a string representation of the equivalent cuneiform.

Rules

  1. Each digit is represented as a cluster of symbols.
  2. Each cluster begins with a number of Cs, each representing 10, followed by a number of Is, each representing 1.
    1. For example, the number 43 is represented as CCCCIII.
  3. Each digit can represent numbers from 1 to 59, separated by a space (there is no digit for 0, it is represented by the absence of any symbol at a position).
  4. As this is a base 60 number system, each position represents a power of 60.
  5. Ensure your output is wrapped in " marks so that trailing spaces (zeroes) are evident.

Examples

  • 120 => "II "
  • 5678 => "I CCCIIII CCCIIIIIIII"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment