← Back to challenges

Cryptoprimes

PythonHardcryptographynumbersmath

Instructions

In this challenge, you are given a list of strings composed of the letters a-j. This list is special because it is a list of consecutive prime numbers which have been treated to a simple substitution cipher. Each of the numbers (0-9) have been substituted by one of the letters a-j. The substitution scheme is the same for all members of the list.

Your task is to develop a function that recovers the unencrypted list of primes.

Examples

cryptoprimes(["b", "c", "a", "i"]) ➞ [2, 3, 5, 7]

cryptoprimes(["bb", "bi", "bg", "bc"]) ➞ [11, 13, 17, 19]

cryptoprimes(["fgf", "fgb", "fgi", "fgd", "ffb"]) ➞ [101, 103, 107, 109, 113]

cryptoprimes(["ebhi", "ebhf", "ecaf", "ecjf", "ecjb"]) ➞ [6791, 6793, 6803, 6823, 6827]

Notes

  • There is only one possible solution for each of the test cases.
  • The cipher scheme is different for each of the test cases.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.