Problem 47518. Play Outside In with primes
In the word game Outside In,* you start with a word, take the first and last letters, try to think of a word in which the two letters appear together in the interior, and repeat. For example, starting with ‘MATLAB’, you might proceed as follows:
sombrero, dissolution, kidnap, pickpocket, helicopter, birthright, debtor, tawdry, katydid, backdrop, subpoena, anniversary, payback, napkin, mannequin, solemnity, psychosis, lopsided, balderdash, etc.
You can play alone or with others, and you could add other rules or objectives—e.g., all words must have six or more letters, a person who cannot think of a word is eliminated, players try to generate a list that uses all letters in the alphabet, etc.
This game has one problem: without a convenient and stable word list, it does not translate easily to Cody. So instead of words, let’s use prime numbers. In particular, start with a two-digit seed, find the smallest prime for which the two digits appear together in the interior, create a new two-digit number from the first and last digits of the prime, and repeat.
For example, if the seed is 11, then the list would start 1117, 1171, 2111, 1213, 2131, 1217,… Because the last digits of primes are constrained, you will notice similarities in lists generated from different seeds. Solvers able to plot the numbers might enjoy seeing the patterns for longer lists graphically.
Write a function to play Outside In with primes: given a two-digit seed x, generate a list of n primes following the rules above.
*I devised the game and the name, but I would be surprised if someone had not already thought of it.
Solution Stats
Problem Comments
Solution Comments
Show commentsGroup

Prime Numbers II
- 19 Problems
- 7 Finishers
- List the delete-a-digit primes
- List the dihedral primes
- List the good primes
- Determine whether a number is a prime self number
- Compute home primes in a given base
- List Proth primes
- Label primes with the Erdos-Selfridge classification
- List Honaker primes
- List the nth prime quartet prefix
- Find the smallest prime with n inside
- List prime anagrams of a number
- Determine whether a number is unprimeable
- Count the primes in Collatz sequences
- Play Outside In with primes
- Identify prime words
- Find pairs of primes with the same digit sum and a specified separation
- List composite numbers that cannot be written as the sum of two primes
- Compute the arithmetic derivative of integers
- Solve the arithmetic differential equation D(n) = n
Problem Recent Solvers9
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!