# What's my PIN number?

My PIN number is 1077, but that's too difficult to remember. I know from muscle memory that it's a digit, followed by a different digit, then followed by two of the same digit, which is different to the other two digits before it. As a pattern, we can say it is ABCC (where each letter represents a digit, and the same letter represents the same digit).

There are 15 possible PIN patterns. They are, along with some examples:

AAAA -> 5555    AAAB -> 7773    AABA -> 4484    AABB -> 3377    AABC -> 2265
ABAA -> 0300    ABAB -> 5252    ABAC -> 2325    ABBA -> 7667    ABBB -> 4888
ABBC -> 4880    ABCA -> 1041    ABCB -> 7080    ABCC -> 2600    ABCD -> 0857


You are to take 4 values as input representing the pattern of my PIN number. These values can be any reasonable value, such as the integers 1, 2, 3, 4, the letters A, B, C, D as strings, etc. You may choose what these values are, but please be mindful of this standard loophole when choosing values that aren't as simple as digits or characters.

You should then output all possible 4 digit combinations that fit the input pattern. You may output in any order, and in any format that clearly shows the 4 digits of each (so as integers doesn't work as you'll exclude leading zeros), and that clearly shows each combination together. One example could be outputting each digit separated by newlines and each combination separated by 3 newlines, or outputting a list of lists.

This is , so the shortest code in bytes wins.

## Test cases

There is a fixed set of inputs, so we can have a comprehensive set of test cases. However, the output for ABCD has 5040 numbers, which is rather long. This program generates the complete I/O set. Below are just the first 25 (all 10 for AAAA), in lexicographic order:

AAAA -> 0000, 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999
AAAB -> 0001, 0002, 0003, 0004, 0005, 0006, 0007, 0008, 0009, 1110, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 2220, 2221, 2223, 2224, 2225, 2226, 2227
AABA -> 0010, 0020, 0030, 0040, 0050, 0060, 0070, 0080, 0090, 1101, 1121, 1131, 1141, 1151, 1161, 1171, 1181, 1191, 2202, 2212, 2232, 2242, 2252, 2262, 2272
AABB -> 0011, 0022, 0033, 0044, 0055, 0066, 0077, 0088, 0099, 1100, 1122, 1133, 1144, 1155, 1166, 1177, 1188, 1199, 2200, 2211, 2233, 2244, 2255, 2266, 2277
AABC -> 0012, 0013, 0014, 0015, 0016, 0017, 0018, 0019, 0021, 0023, 0024, 0025, 0026, 0027, 0028, 0029, 0031, 0032, 0034, 0035, 0036, 0037, 0038, 0039, 0041
ABAA -> 0100, 0200, 0300, 0400, 0500, 0600, 0700, 0800, 0900, 1011, 1211, 1311, 1411, 1511, 1611, 1711, 1811, 1911, 2022, 2122, 2322, 2422, 2522, 2622, 2722
ABAB -> 0101, 0202, 0303, 0404, 0505, 0606, 0707, 0808, 0909, 1010, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020, 2121, 2323, 2424, 2525, 2626, 2727
ABAC -> 0102, 0103, 0104, 0105, 0106, 0107, 0108, 0109, 0201, 0203, 0204, 0205, 0206, 0207, 0208, 0209, 0301, 0302, 0304, 0305, 0306, 0307, 0308, 0309, 0401
ABBA -> 0110, 0220, 0330, 0440, 0550, 0660, 0770, 0880, 0990, 1001, 1221, 1331, 1441, 1551, 1661, 1771, 1881, 1991, 2002, 2112, 2332, 2442, 2552, 2662, 2772
ABBB -> 0111, 0222, 0333, 0444, 0555, 0666, 0777, 0888, 0999, 1000, 1222, 1333, 1444, 1555, 1666, 1777, 1888, 1999, 2000, 2111, 2333, 2444, 2555, 2666, 2777
ABBC -> 0112, 0113, 0114, 0115, 0116, 0117, 0118, 0119, 0221, 0223, 0224, 0225, 0226, 0227, 0228, 0229, 0331, 0332, 0334, 0335, 0336, 0337, 0338, 0339, 0441
ABCA -> 0120, 0130, 0140, 0150, 0160, 0170, 0180, 0190, 0210, 0230, 0240, 0250, 0260, 0270, 0280, 0290, 0310, 0320, 0340, 0350, 0360, 0370, 0380, 0390, 0410
ABCB -> 0121, 0131, 0141, 0151, 0161, 0171, 0181, 0191, 0212, 0232, 0242, 0252, 0262, 0272, 0282, 0292, 0313, 0323, 0343, 0353, 0363, 0373, 0383, 0393, 0414
ABCC -> 0122, 0133, 0144, 0155, 0166, 0177, 0188, 0199, 0211, 0233, 0244, 0255, 0266, 0277, 0288, 0299, 0311, 0322, 0344, 0355, 0366, 0377, 0388, 0399, 0411
ABCD -> 0123, 0124, 0125, 0126, 0127, 0128, 0129, 0132, 0134, 0135, 0136, 0137, 0138, 0139, 0142, 0143, 0145, 0146, 0147, 0148, 0149, 0152, 0153, 0154, 0156

• The contents of my bank account for anyone who outgolfs/matches my 11 byte Jelly answer ;) Aug 3 '21 at 23:21
• @UnrelatedString Essentially, yes. But given that the input will always be one of the 15 shown in the test cases (exact format aside), you shouldn't have to worry about that Aug 3 '21 at 23:31
• @DLosc Well, I had $0.93 in it a thousand years ago, so it can't be that much, right? :P Aug 4 '21 at 0:20 • Personal Identification Number number Aug 4 '21 at 2:11 • @jonrandy The question is a trick question. Clearly a personal identification number number doesn't exist, so the proper out put is to print nothing. – Yakk Aug 4 '21 at 14:04 ## 19 Answers # Jelly, 8 bytes ⁵Œ!’³ịⱮQ  Times out on TIO, takes about two minutes on my machine: % time python3 -m jelly eu '⁵Œ!’³ịⱮQ' "[1,2,3,1]" [[0, 1, 2, 0], [0, 1, 3, 0], [0, 1, 4, 0], [0, 1, 5, 0], [0, 1, 6, 0], [0, 1, 7, 0], [0, 1, 8, 0], [0, 1, 9, 0], [0, 2, 1, 0], [0, 2, 3, 0], [0, 2, 4, 0], [0, 2, 5, 0], [0, 2, 6, 0], [0, 2, 7, 0], [0, 2, 8, 0], [0, 2, 9, 0], [0, 3, 1, 0], [0, 3, 2, 0], [0, 3, 4, 0], [0, 3, 5, 0], [0, 3, 6, 0], [0, 3, 7, 0], [0, 3, 8, 0], [0, 3, 9, 0], [0, 4, 1, 0], [0, 4, 2, 0], [0, 4, 3, 0], [0, 4, 5, 0], [0, 4, 6, 0], [0, 4, 7, 0], [0, 4, 8, 0], [0, 4, 9, 0], [0, 5, 1, 0], [0, 5, 2, 0], [0, 5, 3, 0], [0, 5, 4, 0], [0, 5, 6, 0], [0, 5, 7, 0], [0, 5, 8, 0], [0, 5, 9, 0], [0, 6, 1, 0], [0, 6, 2, 0], [0, 6, 3, 0], [0, 6, 4, 0], [0, 6, 5, 0], [0, 6, 7, 0], [0, 6, 8, 0], [0, 6, 9, 0], [0, 7, 1, 0], [0, 7, 2, 0], [0, 7, 3, 0], [0, 7, 4, 0], [0, 7, 5, 0], [0, 7, 6, 0], [0, 7, 8, 0], [0, 7, 9, 0], [0, 8, 1, 0], [0, 8, 2, 0], [0, 8, 3, 0], [0, 8, 4, 0], [0, 8, 5, 0], [0, 8, 6, 0], [0, 8, 7, 0], [0, 8, 9, 0], [0, 9, 1, 0], [0, 9, 2, 0], [0, 9, 3, 0], [0, 9, 4, 0], [0, 9, 5, 0], [0, 9, 6, 0], [0, 9, 7, 0], [0, 9, 8, 0], [1, 0, 2, 1], [1, 0, 3, 1], [1, 0, 4, 1], [1, 0, 5, 1], [1, 0, 6, 1], [1, 0, 7, 1], [1, 0, 8, 1], [1, 0, 9, 1], [1, 2, 0, 1], [1, 2, 3, 1], [1, 2, 4, 1], [1, 2, 5, 1], [1, 2, 6, 1], [1, 2, 7, 1], [1, 2, 8, 1], [1, 2, 9, 1], [1, 3, 0, 1], [1, 3, 2, 1], [1, 3, 4, 1], [1, 3, 5, 1], [1, 3, 6, 1], [1, 3, 7, 1], [1, 3, 8, 1], [1, 3, 9, 1], [1, 4, 0, 1], [1, 4, 2, 1], [1, 4, 3, 1], [1, 4, 5, 1], [1, 4, 6, 1], [1, 4, 7, 1], [1, 4, 8, 1], [1, 4, 9, 1], [1, 5, 0, 1], [1, 5, 2, 1], [1, 5, 3, 1], [1, 5, 4, 1], [1, 5, 6, 1], [1, 5, 7, 1], [1, 5, 8, 1], [1, 5, 9, 1], [1, 6, 0, 1], [1, 6, 2, 1], [1, 6, 3, 1], [1, 6, 4, 1], [1, 6, 5, 1], [1, 6, 7, 1], [1, 6, 8, 1], [1, 6, 9, 1], [1, 7, 0, 1], [1, 7, 2, 1], [1, 7, 3, 1], [1, 7, 4, 1], [1, 7, 5, 1], [1, 7, 6, 1], [1, 7, 8, 1], [1, 7, 9, 1], [1, 8, 0, 1], [1, 8, 2, 1], [1, 8, 3, 1], [1, 8, 4, 1], [1, 8, 5, 1], [1, 8, 6, 1], [1, 8, 7, 1], [1, 8, 9, 1], [1, 9, 0, 1], [1, 9, 2, 1], [1, 9, 3, 1], [1, 9, 4, 1], [1, 9, 5, 1], [1, 9, 6, 1], [1, 9, 7, 1], [1, 9, 8, 1], [2, 0, 1, 2], [2, 0, 3, 2], [2, 0, 4, 2], [2, 0, 5, 2], [2, 0, 6, 2], [2, 0, 7, 2], [2, 0, 8, 2], [2, 0, 9, 2], [2, 1, 0, 2], [2, 1, 3, 2], [2, 1, 4, 2], [2, 1, 5, 2], [2, 1, 6, 2], [2, 1, 7, 2], [2, 1, 8, 2], [2, 1, 9, 2], [2, 3, 0, 2], [2, 3, 1, 2], [2, 3, 4, 2], [2, 3, 5, 2], [2, 3, 6, 2], [2, 3, 7, 2], [2, 3, 8, 2], [2, 3, 9, 2], [2, 4, 0, 2], [2, 4, 1, 2], [2, 4, 3, 2], [2, 4, 5, 2], [2, 4, 6, 2], [2, 4, 7, 2], [2, 4, 8, 2], [2, 4, 9, 2], [2, 5, 0, 2], [2, 5, 1, 2], [2, 5, 3, 2], [2, 5, 4, 2], [2, 5, 6, 2], [2, 5, 7, 2], [2, 5, 8, 2], [2, 5, 9, 2], [2, 6, 0, 2], [2, 6, 1, 2], [2, 6, 3, 2], [2, 6, 4, 2], [2, 6, 5, 2], [2, 6, 7, 2], [2, 6, 8, 2], [2, 6, 9, 2], [2, 7, 0, 2], [2, 7, 1, 2], [2, 7, 3, 2], [2, 7, 4, 2], [2, 7, 5, 2], [2, 7, 6, 2], [2, 7, 8, 2], [2, 7, 9, 2], [2, 8, 0, 2], [2, 8, 1, 2], [2, 8, 3, 2], [2, 8, 4, 2], [2, 8, 5, 2], [2, 8, 6, 2], [2, 8, 7, 2], [2, 8, 9, 2], [2, 9, 0, 2], [2, 9, 1, 2], [2, 9, 3, 2], [2, 9, 4, 2], [2, 9, 5, 2], [2, 9, 6, 2], [2, 9, 7, 2], [2, 9, 8, 2], [3, 0, 1, 3], [3, 0, 2, 3], [3, 0, 4, 3], [3, 0, 5, 3], [3, 0, 6, 3], [3, 0, 7, 3], [3, 0, 8, 3], [3, 0, 9, 3], [3, 1, 0, 3], [3, 1, 2, 3], [3, 1, 4, 3], [3, 1, 5, 3], [3, 1, 6, 3], [3, 1, 7, 3], [3, 1, 8, 3], [3, 1, 9, 3], [3, 2, 0, 3], [3, 2, 1, 3], [3, 2, 4, 3], [3, 2, 5, 3], [3, 2, 6, 3], [3, 2, 7, 3], [3, 2, 8, 3], [3, 2, 9, 3], [3, 4, 0, 3], [3, 4, 1, 3], [3, 4, 2, 3], [3, 4, 5, 3], [3, 4, 6, 3], [3, 4, 7, 3], [3, 4, 8, 3], [3, 4, 9, 3], [3, 5, 0, 3], [3, 5, 1, 3], [3, 5, 2, 3], [3, 5, 4, 3], [3, 5, 6, 3], [3, 5, 7, 3], [3, 5, 8, 3], [3, 5, 9, 3], [3, 6, 0, 3], [3, 6, 1, 3], [3, 6, 2, 3], [3, 6, 4, 3], [3, 6, 5, 3], [3, 6, 7, 3], [3, 6, 8, 3], [3, 6, 9, 3], [3, 7, 0, 3], [3, 7, 1, 3], [3, 7, 2, 3], [3, 7, 4, 3], [3, 7, 5, 3], [3, 7, 6, 3], [3, 7, 8, 3], [3, 7, 9, 3], [3, 8, 0, 3], [3, 8, 1, 3], [3, 8, 2, 3], [3, 8, 4, 3], [3, 8, 5, 3], [3, 8, 6, 3], [3, 8, 7, 3], [3, 8, 9, 3], [3, 9, 0, 3], [3, 9, 1, 3], [3, 9, 2, 3], [3, 9, 4, 3], [3, 9, 5, 3], [3, 9, 6, 3], [3, 9, 7, 3], [3, 9, 8, 3], [4, 0, 1, 4], [4, 0, 2, 4], [4, 0, 3, 4], [4, 0, 5, 4], [4, 0, 6, 4], [4, 0, 7, 4], [4, 0, 8, 4], [4, 0, 9, 4], [4, 1, 0, 4], [4, 1, 2, 4], [4, 1, 3, 4], [4, 1, 5, 4], [4, 1, 6, 4], [4, 1, 7, 4], [4, 1, 8, 4], [4, 1, 9, 4], [4, 2, 0, 4], [4, 2, 1, 4], [4, 2, 3, 4], [4, 2, 5, 4], [4, 2, 6, 4], [4, 2, 7, 4], [4, 2, 8, 4], [4, 2, 9, 4], [4, 3, 0, 4], [4, 3, 1, 4], [4, 3, 2, 4], [4, 3, 5, 4], [4, 3, 6, 4], [4, 3, 7, 4], [4, 3, 8, 4], [4, 3, 9, 4], [4, 5, 0, 4], [4, 5, 1, 4], [4, 5, 2, 4], [4, 5, 3, 4], [4, 5, 6, 4], [4, 5, 7, 4], [4, 5, 8, 4], [4, 5, 9, 4], [4, 6, 0, 4], [4, 6, 1, 4], [4, 6, 2, 4], [4, 6, 3, 4], [4, 6, 5, 4], [4, 6, 7, 4], [4, 6, 8, 4], [4, 6, 9, 4], [4, 7, 0, 4], [4, 7, 1, 4], [4, 7, 2, 4], [4, 7, 3, 4], [4, 7, 5, 4], [4, 7, 6, 4], [4, 7, 8, 4], [4, 7, 9, 4], [4, 8, 0, 4], [4, 8, 1, 4], [4, 8, 2, 4], [4, 8, 3, 4], [4, 8, 5, 4], [4, 8, 6, 4], [4, 8, 7, 4], [4, 8, 9, 4], [4, 9, 0, 4], [4, 9, 1, 4], [4, 9, 2, 4], [4, 9, 3, 4], [4, 9, 5, 4], [4, 9, 6, 4], [4, 9, 7, 4], [4, 9, 8, 4], [5, 0, 1, 5], [5, 0, 2, 5], [5, 0, 3, 5], [5, 0, 4, 5], [5, 0, 6, 5], [5, 0, 7, 5], [5, 0, 8, 5], [5, 0, 9, 5], [5, 1, 0, 5], [5, 1, 2, 5], [5, 1, 3, 5], [5, 1, 4, 5], [5, 1, 6, 5], [5, 1, 7, 5], [5, 1, 8, 5], [5, 1, 9, 5], [5, 2, 0, 5], [5, 2, 1, 5], [5, 2, 3, 5], [5, 2, 4, 5], [5, 2, 6, 5], [5, 2, 7, 5], [5, 2, 8, 5], [5, 2, 9, 5], [5, 3, 0, 5], [5, 3, 1, 5], [5, 3, 2, 5], [5, 3, 4, 5], [5, 3, 6, 5], [5, 3, 7, 5], [5, 3, 8, 5], [5, 3, 9, 5], [5, 4, 0, 5], [5, 4, 1, 5], [5, 4, 2, 5], [5, 4, 3, 5], [5, 4, 6, 5], [5, 4, 7, 5], [5, 4, 8, 5], [5, 4, 9, 5], [5, 6, 0, 5], [5, 6, 1, 5], [5, 6, 2, 5], [5, 6, 3, 5], [5, 6, 4, 5], [5, 6, 7, 5], [5, 6, 8, 5], [5, 6, 9, 5], [5, 7, 0, 5], [5, 7, 1, 5], [5, 7, 2, 5], [5, 7, 3, 5], [5, 7, 4, 5], [5, 7, 6, 5], [5, 7, 8, 5], [5, 7, 9, 5], [5, 8, 0, 5], [5, 8, 1, 5], [5, 8, 2, 5], [5, 8, 3, 5], [5, 8, 4, 5], [5, 8, 6, 5], [5, 8, 7, 5], [5, 8, 9, 5], [5, 9, 0, 5], [5, 9, 1, 5], [5, 9, 2, 5], [5, 9, 3, 5], [5, 9, 4, 5], [5, 9, 6, 5], [5, 9, 7, 5], [5, 9, 8, 5], [6, 0, 1, 6], [6, 0, 2, 6], [6, 0, 3, 6], [6, 0, 4, 6], [6, 0, 5, 6], [6, 0, 7, 6], [6, 0, 8, 6], [6, 0, 9, 6], [6, 1, 0, 6], [6, 1, 2, 6], [6, 1, 3, 6], [6, 1, 4, 6], [6, 1, 5, 6], [6, 1, 7, 6], [6, 1, 8, 6], [6, 1, 9, 6], [6, 2, 0, 6], [6, 2, 1, 6], [6, 2, 3, 6], [6, 2, 4, 6], [6, 2, 5, 6], [6, 2, 7, 6], [6, 2, 8, 6], [6, 2, 9, 6], [6, 3, 0, 6], [6, 3, 1, 6], [6, 3, 2, 6], [6, 3, 4, 6], [6, 3, 5, 6], [6, 3, 7, 6], [6, 3, 8, 6], [6, 3, 9, 6], [6, 4, 0, 6], [6, 4, 1, 6], [6, 4, 2, 6], [6, 4, 3, 6], [6, 4, 5, 6], [6, 4, 7, 6], [6, 4, 8, 6], [6, 4, 9, 6], [6, 5, 0, 6], [6, 5, 1, 6], [6, 5, 2, 6], [6, 5, 3, 6], [6, 5, 4, 6], [6, 5, 7, 6], [6, 5, 8, 6], [6, 5, 9, 6], [6, 7, 0, 6], [6, 7, 1, 6], [6, 7, 2, 6], [6, 7, 3, 6], [6, 7, 4, 6], [6, 7, 5, 6], [6, 7, 8, 6], [6, 7, 9, 6], [6, 8, 0, 6], [6, 8, 1, 6], [6, 8, 2, 6], [6, 8, 3, 6], [6, 8, 4, 6], [6, 8, 5, 6], [6, 8, 7, 6], [6, 8, 9, 6], [6, 9, 0, 6], [6, 9, 1, 6], [6, 9, 2, 6], [6, 9, 3, 6], [6, 9, 4, 6], [6, 9, 5, 6], [6, 9, 7, 6], [6, 9, 8, 6], [7, 0, 1, 7], [7, 0, 2, 7], [7, 0, 3, 7], [7, 0, 4, 7], [7, 0, 5, 7], [7, 0, 6, 7], [7, 0, 8, 7], [7, 0, 9, 7], [7, 1, 0, 7], [7, 1, 2, 7], [7, 1, 3, 7], [7, 1, 4, 7], [7, 1, 5, 7], [7, 1, 6, 7], [7, 1, 8, 7], [7, 1, 9, 7], [7, 2, 0, 7], [7, 2, 1, 7], [7, 2, 3, 7], [7, 2, 4, 7], [7, 2, 5, 7], [7, 2, 6, 7], [7, 2, 8, 7], [7, 2, 9, 7], [7, 3, 0, 7], [7, 3, 1, 7], [7, 3, 2, 7], [7, 3, 4, 7], [7, 3, 5, 7], [7, 3, 6, 7], [7, 3, 8, 7], [7, 3, 9, 7], [7, 4, 0, 7], [7, 4, 1, 7], [7, 4, 2, 7], [7, 4, 3, 7], [7, 4, 5, 7], [7, 4, 6, 7], [7, 4, 8, 7], [7, 4, 9, 7], [7, 5, 0, 7], [7, 5, 1, 7], [7, 5, 2, 7], [7, 5, 3, 7], [7, 5, 4, 7], [7, 5, 6, 7], [7, 5, 8, 7], [7, 5, 9, 7], [7, 6, 0, 7], [7, 6, 1, 7], [7, 6, 2, 7], [7, 6, 3, 7], [7, 6, 4, 7], [7, 6, 5, 7], [7, 6, 8, 7], [7, 6, 9, 7], [7, 8, 0, 7], [7, 8, 1, 7], [7, 8, 2, 7], [7, 8, 3, 7], [7, 8, 4, 7], [7, 8, 5, 7], [7, 8, 6, 7], [7, 8, 9, 7], [7, 9, 0, 7], [7, 9, 1, 7], [7, 9, 2, 7], [7, 9, 3, 7], [7, 9, 4, 7], [7, 9, 5, 7], [7, 9, 6, 7], [7, 9, 8, 7], [8, 0, 1, 8], [8, 0, 2, 8], [8, 0, 3, 8], [8, 0, 4, 8], [8, 0, 5, 8], [8, 0, 6, 8], [8, 0, 7, 8], [8, 0, 9, 8], [8, 1, 0, 8], [8, 1, 2, 8], [8, 1, 3, 8], [8, 1, 4, 8], [8, 1, 5, 8], [8, 1, 6, 8], [8, 1, 7, 8], [8, 1, 9, 8], [8, 2, 0, 8], [8, 2, 1, 8], [8, 2, 3, 8], [8, 2, 4, 8], [8, 2, 5, 8], [8, 2, 6, 8], [8, 2, 7, 8], [8, 2, 9, 8], [8, 3, 0, 8], [8, 3, 1, 8], [8, 3, 2, 8], [8, 3, 4, 8], [8, 3, 5, 8], [8, 3, 6, 8], [8, 3, 7, 8], [8, 3, 9, 8], [8, 4, 0, 8], [8, 4, 1, 8], [8, 4, 2, 8], [8, 4, 3, 8], [8, 4, 5, 8], [8, 4, 6, 8], [8, 4, 7, 8], [8, 4, 9, 8], [8, 5, 0, 8], [8, 5, 1, 8], [8, 5, 2, 8], [8, 5, 3, 8], [8, 5, 4, 8], [8, 5, 6, 8], [8, 5, 7, 8], [8, 5, 9, 8], [8, 6, 0, 8], [8, 6, 1, 8], [8, 6, 2, 8], [8, 6, 3, 8], [8, 6, 4, 8], [8, 6, 5, 8], [8, 6, 7, 8], [8, 6, 9, 8], [8, 7, 0, 8], [8, 7, 1, 8], [8, 7, 2, 8], [8, 7, 3, 8], [8, 7, 4, 8], [8, 7, 5, 8], [8, 7, 6, 8], [8, 7, 9, 8], [8, 9, 0, 8], [8, 9, 1, 8], [8, 9, 2, 8], [8, 9, 3, 8], [8, 9, 4, 8], [8, 9, 5, 8], [8, 9, 6, 8], [8, 9, 7, 8], [9, 0, 1, 9], [9, 0, 2, 9], [9, 0, 3, 9], [9, 0, 4, 9], [9, 0, 5, 9], [9, 0, 6, 9], [9, 0, 7, 9], [9, 0, 8, 9], [9, 1, 0, 9], [9, 1, 2, 9], [9, 1, 3, 9], [9, 1, 4, 9], [9, 1, 5, 9], [9, 1, 6, 9], [9, 1, 7, 9], [9, 1, 8, 9], [9, 2, 0, 9], [9, 2, 1, 9], [9, 2, 3, 9], [9, 2, 4, 9], [9, 2, 5, 9], [9, 2, 6, 9], [9, 2, 7, 9], [9, 2, 8, 9], [9, 3, 0, 9], [9, 3, 1, 9], [9, 3, 2, 9], [9, 3, 4, 9], [9, 3, 5, 9], [9, 3, 6, 9], [9, 3, 7, 9], [9, 3, 8, 9], [9, 4, 0, 9], [9, 4, 1, 9], [9, 4, 2, 9], [9, 4, 3, 9], [9, 4, 5, 9], [9, 4, 6, 9], [9, 4, 7, 9], [9, 4, 8, 9], [9, 5, 0, 9], [9, 5, 1, 9], [9, 5, 2, 9], [9, 5, 3, 9], [9, 5, 4, 9], [9, 5, 6, 9], [9, 5, 7, 9], [9, 5, 8, 9], [9, 6, 0, 9], [9, 6, 1, 9], [9, 6, 2, 9], [9, 6, 3, 9], [9, 6, 4, 9], [9, 6, 5, 9], [9, 6, 7, 9], [9, 6, 8, 9], [9, 7, 0, 9], [9, 7, 1, 9], [9, 7, 2, 9], [9, 7, 3, 9], [9, 7, 4, 9], [9, 7, 5, 9], [9, 7, 6, 9], [9, 7, 8, 9], [9, 8, 0, 9], [9, 8, 1, 9], [9, 8, 2, 9], [9, 8, 3, 9], [9, 8, 4, 9], [9, 8, 5, 9], [9, 8, 6, 9], [9, 8, 7, 9]] 108.00s user 0.90s system 99% cpu 1:49.73 total  Accepts a pattern in the format [1,2,2,3]. ⁵Œ!’ All permutations of [0..9]. ³ịⱮ For each such permutation, use the input as index vector: e.g. for input [1,2,2,3], turn 3862149075 into 3886. Q Eliminate duplicates.  # Factor + math.combinatorics, 50 bytes [ 10 iota [ nths ] with map-permutations members ]  Try it online! Port of @Lynn's Jelly answer. • 10 iota The digits from 0 to 9. • [ ... ] with Include the input in a quotation. • [ nths ] map-permutations Map the permutations of 0-9 to the indices given by the input. • members Remove duplicates. # Python 3, 86 bytes lambda*r:{eval('x[%d],'*4%r)for x in permutations(range(10),5)} from itertools import*  Try it online! Fix and -3 thanks to @dingledooper -2 thanks to @tsh (f() outputs unsorted list, so footer code is added to display sorted and joined by newlines) Very fast. Fixed time complexity of $$\O(120960) = O(10P5×4)\$$, it could be $$\6×\$$ faster if we could take input numbers decremented by 1. • @dingledooper fixed Aug 4 '21 at 2:05 • Maybe you can take input as [0,1,1,2] instead of [1,2,2,3] to remove the -1 in x[y-1]. But anyway, you may keep input as is while use this code: lambda r:{tuple(x[y]for y in r)for x in permutations(range(10),5)} – tsh Aug 4 '21 at 2:38 • -3 bytes making use of eval and iterable unpacking. Aug 4 '21 at 3:02 • You can replace permutations(range(10),5) with permutation(range(10)), making it really slow (still $O(1)$ :)) but two bytes shorter. – Lynn Aug 4 '21 at 18:30 • @Lynn thanks for the tip! Though I want to keep it performance oriented Aug 5 '21 at 5:55 # J, 27 24 23 bytes (-:&="1#])&(>,{4$<i.10)


Try it online!

• (>,{4$<i.10) Generates all 10K pins. • -:&="1#] Filter those by equality to the input after transforming both by "Self Classify" =. Self classify gives a boolean signature for each unique member of a list, thereby encoding the "mask" that we're trying to match. Eg, = 'AABC' returns: 1 1 0 0 0 0 1 0 0 0 0 1  ### bonus [:~.]{"1(i.@!A.i.)@10 for 21 bytes using Lynn's clever approach. Executes decently fast. # Vyxal, 8 bytes 9ʀṖƛ?İ;U  Try it Online! Will time out. (But work in theory, because taking 0..n (n<9) permutations finish properly in time) 9ʀṖ # 0..9 permutations ƛ # For each ?İ # Index with input ;U # Close and remove duplicates  • @tsh sorry fault in explanation, the code was correct Aug 4 '21 at 2:52 # R >= 4.1 plus gtools, 41 bytes \(x)gtools::permutations(10,max(x))[,x]-1  Try it online! A function that takes a vector of integers and returns a matrix with the PINs in rows and the digits in columns. It would be nice to have a base R equivalent of combn for permutations. Thanks to @Mark for pointing out the flaw in my previous answer which did permutations with replacement rather than without. • In your example you call f(c(1,2,3,3)) but the output includes c(0,0,0,0) which doesn't meet the pattern requirements. While it does force the third and fourth digit to be identical, it doesn't force the first two to be different and also different from the 3rd/4th. Also, if you call f(c(5,4,3,3)) you get very unexpected results. – Mark Aug 4 '21 at 15:50 • @Mark I’ve fixed the first issue. The second would be an invalid input to the function so I haven’t handled that. Aug 4 '21 at 16:11 • I was just testing if it would accept any arbitrary number to define the pattern. There's some duplication of results if you specify for example f(c(1,2,5,5)) but it works. I'm still trying to fully grok this :D – Mark Aug 4 '21 at 17:30 • @Mark fair enough - the code is now simpler. It generates all possible permutations without replacement of max(x) items from the numbers 1 to 10. It then indexes the columns of the resultant matrix using x and then subtracts one (to get digits 0 to 9). Aug 4 '21 at 17:33 # Jelly, 11 bytes Ġ⁵ṗ4¤ĠṢ⁼ɗƇ’  Try it online! Works equally well when given a list of digits ([1, 2, 3, 4]) or a string ("ABCD"). ### How it works Ġ⁵ṗ4¤ĠṢ⁼ɗƇ’ Monadic link. Left arg: PIN pattern Ġ Group indices by identical values (which gives the pattern to filter the combinations for) ⁵ṗ4¤ĠṢ⁼ɗƇ Monad-dyad pair: ⁵ṗ4¤ Create a list of 4-digit combinations using 1-10 Ƈ Filter from the above list by: ĠṢ⁼ɗ Is the list of sorted groups identical to the input's? ’ Decrement to get a list of 0-9 combinations  • Nice approach, and different to mine :) Aug 3 '21 at 23:44 • congrats on caird's bank account Aug 3 '21 at 23:53 # Jelly (fork), 8 bytes 9Żṗ4Qi$Ƙ


Try it online! (my original Jelly answer)

Didn't take long for Lynn to outgolf my original Jelly answer, so I thought I'd show my approach, using my fork because ⁼¥Ƈ annoys me.

## How it works

9Żṗ4Qi$Ƙ - Main link. Takes [a,b,c,d] on the left 9Ż - Zero-range of 9; Yield [0,1,2,3,4,5,6,7,8,9] ṗ4 - Fourth cartesian power; All length-4 lists with elements from that range$Ƙ - Keep those elements [x,y,z,w] for which the following equals [a,b,c,d]:
Q    -   Unique elements
i   -   Their indices in [x,y,z,w]


In this case, i in my fork has been modified so that using it on flat lists is equivalent to iⱮ, as otherwise it outputs 0 (not found): Try it online! Additionally, Ƙ has been added to supplant ⁼¥Ƈ as it gets used a lot.

# 05AB1E, 8 bytes

9Ýœε¹è}Ù


Try it online!

-2 Thanks to @ovs

• I don't think you need the 4£
– ovs
Aug 4 '21 at 6:29

# Japt, 10 bytes

Input is an array of integers 1-4. Output is an array of integer arrays. Careful running this one; even with all 4 input integers the same, it takes about 10.5 seconds to complete.

Ao á mgU â


Try it (Limits the lengths of the permutations to 4)

Ao á mgU â     :Implicit input of array U
A              :10
o             :Range [0,A)
á           :Permutations
m         :Map
gU       :  Get elements at 0-based indices in U
â     :Deduplicate


# Jelly, 8 bytes

Ṁ⁵œ!’ị@€


Try it online!

Another Jelly 8-byter. This works similarly to my R answer, and completes quickly on TIO.

Ṁ        | Max
⁵œ!     | Permutations of (10, max(x))
’    | Decrease by 1
ị@€ | Index original argument into each permutation


# Google Sheets, 366 354 352 301 203 189

Ending parens discounted.

## Setup

• Input: A1, (any format)

• A2: Cache every relevant character comparison result

=ArrayFormula(MID(A1,{1;2;3},1)=MID(A1,{2,3,4},1))

• E1:

=SEQUENCE(1e4,1,)

• Set Column E to format all 4 digits. (Custom format 0000. We'll add +4 for this)

• F1: Split digits into columns

=ArrayFormula(MID(E:E,{1,2,3,4},1))

• J1 (result):

=FILTER(E:E,(F:F=G:G=A2)*(F:F=H:H=B2)*(F:F=I:I=C2)*(G:G=H:H=B3)*(G:G=I:I=C3)*(H:H=I:I=C4))


## Notes

• At a high level, it enumerates all possible PINs with SEQUENCE, then applies several filter conditions to remove unwanted result.
• Each filter condition checks PINs that either both match or both don't match in the corresponding places (= is like XNOR in that regard)
• * acts like and AND
• Is there a difference between Google Sheets and Excel in this formatting? I just tried putting it in Excel and it mostly works, but I think it's not producing all the results, or in some cases it's producing too many, e.g.: AAAA gives all 4-digit combos for 1-9 (but not 0), but it also gives the 3-digit combos. And ABCD only gives 4536 results, not the expected 5040. Strange... Aug 5 '21 at 21:03
• @DarrelHoffman Yeah, Sheets and Excel have some little differences. (Forgive me, it takes me a long time to test stuff because it's hard for me to get to something that has Excel 2019 on it.) For one, leaving off the final argument of Sequence defaults to 1, not 0 in Excel. Second, setting a custom format will not work in Excel. You can use =TEXT(SEQUENCE(...),"0000") to get around this. Lastly, the filter may not work correctly, leaving a bunch of 0s after the last row of real data when the input is changed. Aug 5 '21 at 22:29

# JavaScript (V8), 87 bytes

Expects a pattern made of non-digit characters. Prints the results.

f=(s,m=/\D/.exec(s),g=n=>n--&&g(n,s.match(n)||f(s.split(m).join(n))))=>m?g(10):print(s)


Try it online!

# JavaScript (ES10), 100 bytes

Expects a pattern made of 1, 2, 3, 4. Returns an array of strings.

s=>[...Array(x=1e4)].flatMap(_=>(S=${x++}.slice(-4)).replace(o=/./g,c=>o[c]=o[c]||++n,n=0)^s?[]:S)  Try it online! • You may want give String#replaceAll a try: f=(s,m=/\D/.exec(s),g=n=>n--&&g(n,s.match(n)||f(s.replaceAll(m,n))))=>m?g(10):print(s) (no TIO available) – tsh Aug 4 '21 at 3:01 • 84 based on your 2nd code: s=>{for(x=1e4;x<2e4;S.map(o=c=>o[c]??=n++)+''==s&&print(S))S=[...''+x++].slice(n=1)} Run as f([1,1,1,2]) – tsh Aug 4 '21 at 3:33 # JavaScript (browser), 83 bytes p=>{for(i=1e5;i++<2e5;)/.(.).*\1/.test(i+=n='')?0:p[p.map(v=>n+=i[v])]??=+alert(n)}  f = p=>{for(i=1e5;i++<2e5;)/.(.).*\1/.test(i+=n='')?0:p[p.map(v=>n+=i[v])]??=+alert(n)} alert = s => output.textContent += s + '\n' f([1,1,1,1]) alert('----') f([1,1,1,2]) <output id=output style=white-space:pre></output> Input an array of 4 numbers, each number in range 1 to 4, f([1, 2, 3, 4]) for example. # Charcoal, 29 bytes ＥΦＥＸχ⊕⌈θ⭆◧Ｉι⊕⌈θΣλ⬤ι⁼¹№ιλ⭆θ§ιλ  Try it online! Link is to verbose version of code. Takes input as a list of 0-indexed digits. Explanation:  χ Predefined variable 10 Ｘ Raised to power θ Input array ⌈ Maximum ⊕ Incremented Ｅ Map over implicit range ι Current value Ｉ Cast to string ◧ Left padded to length θ Input array ⌈ Maximum ⊕ Incremented ⭆ Map over characters and join λ Current character Σ Numeric value or 0 for space Φ Filtered where ι Current string ⬤ All digits satisfy № Count of λ Current digit ι In current string ⁼ Is equal to ¹ Literal 1 Ｅ Map over strings θ Input array ⭆ Map over values and join ι Current string § Indexed by λ Current value Implicitly print  # PHP, 128 bytes for(;$n<1e4;){$s=sprintf('%04d',$n++);$m='';$l=A;$v=[];for($d=0;$d<4;)$m.=$v[$g=$s[$d++]]??$v[$g]=$l++;$m==$argn&&print($s.~_);}


Try it online!

# Pyth, 8 bytes

Two solutions:

{@LRQ.pT
{C@RR.pT


Try it online!

Standard method - index into permutations of [0, 1, ..., 9].

Try it online!

Reverse the order of indexing - generate separate lists of all 0th, 1st, etc. elements of the permutations, then transpose.

# Python 3.8 (pre-release), 87 85 bytes

-2 thanks to @ovs

lambda s:[c for i in range(10000)if len({*s})==len({*zip(s,c:='%04i'%i)})==len({*c})]


Try it online!

# Perl 5, 107 bytes

sub{my%s;my$r;$r.=$s{$_}++?"\$_":'((?!'.join('|',map"\$_",1..keys%s).')\d)'for@_;grep/\$r/,'0000'..'9999'}


Try it online!