Limits 1s, 512 MB

You have been using a 4 digit pin code to lock your phone that, no matter how much you are trying now, can't seem to recall. Tilting your phone at an angle towards the window so that the sunlight shines on it, you see fingerprints. You see that there are 4 fingerprints distinctly appearing on the spots where the numeric buttons appear on the lock screen. You remember that the 4 digits you used were unique (i.e. you didn't have repeating digits in your pin code), and that the pin code itself was a 4 digit prime number.

Given the locations where the fingerprints appear on the numeric keypad on the lock screen, determine what the forgotten pin code is.

If you find that multiple prime number exists with certain set of 4 digits, you know that the pin code must be the permutation that forms the smallest prime number and one that doesn't start with a zero.

If you find that you cannot find any prime numbers from the locations of the fingerprints... Well, print a sad face: :-(.


The input contains 4 rows and 3 columns of digits in the following form:

1 2 3
4 5 6
7 8 9

Except that the digits on which the fingerprints appear, they are replaced with an asterisk.


Given the locations of the fingerprints, print the forgotten pin code.


1 * 3
* 5 *
7 * 9
* * *
* 5 6
7 8 9


Login to submit.



82% Solution Ratio
steinumEarliest, Dec '20
steinumFastest, 0.0s
Kabir03Lightest, 0 B
foysal20Shortest, 420B
Toph uses cookies. By continuing you agree to our Cookie Policy.