Help finding possibilities for lost passcode?

I need help finding all the possibilities to a forgotten passcode. It can be 4 digits long, all numbers, numbers can be repeated, all I can remember is it started with a 0 and theres one 2 in it. Is there a way I can get a list of every possible option with that criteria?

3 Answers

Relevance
  • 3 years ago

    There are about 300 possibilities.

  • 3 years ago

    I'd write a computer program to generate them. It's pretty easy to count them, though.

    With a leading 0, you're really only looking for 3 digit numbers that contain a 2, right? To avoid counting numbers twice, consider cases based on how many twos are in the number:

    3 twos : just one pattern: 222

    2 twos : 3 ways to pick the non-two, and 9 choices for that digit, 3*9 = 27 patterns

    1 two : 3 ways to pick which digits it the two, 9 choices for the first non-two and 9 for the second, 3*9*9 = 243 patterns

    So, you're looking for a list of 1 + 27 + 243 = 271 different numbers.

    If you're anywhere near a Python interactive mode, the expression:

    [n for n in range(1,1000) if '2' in str(n)]

    ...will generate a list for you. (Even if you don't plan to become a programmer, knowing how to use a high-level programming language like Python can be worth the time spent learning it.)

    For example, in half a minute or less, I popped up Python 3.6 and got:

    >>> [n for n in range(1,1000) if '2' in str(n)]

    [2, 12, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 42, 52, 62, 72, 82, 92, 102, 112, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 132, 142, 152, 162, 172, 182, 192, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 302, 312, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 332, 342, 352, 362, 372, 382, 392, 402, 412, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 432, 442, 452, 462, 472, 482, 492, 502, 512, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 532, 542, 552, 562, 572, 582, 592, 602, 612, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 632, 642, 652, 662, 672, 682, 692, 702, 712, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 732, 742, 752, 762, 772, 782, 792, 802, 812, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 832, 842, 852, 862, 872, 882, 892, 902, 912, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 932, 942, 952, 962, 972, 982, 992]

    >>> combos = [n for n in range(1,1000) if '2' in str(n)]

    >>> len(combos)

    271

    Those last two lines stored the result so I could check the length against my calculation above.

    Edit: Oh, on rereading you probably wanted exactly one 2 in the number. That's the shorter list of 243 numbers counted above. Python get's that almost as easily:

    >>> combos = [n for n in range(1,1000) if str(n).count('2')==1]

    >>> len(combos)

    243

    >>> combos

    [2, 12, 20, 21, 23, 24, 25, 26, 27, 28, 29, 32, 42, 52, 62, 72, 82, 92, 102, 112, 120, 121, 123, 124, 125, 126, 127, 128, 129, 132, 142, 152, 162, 172, 182, 192, 200, 201, 203, 204, 205, 206, 207, 208, 209, 210, 211, 213, 214, 215, 216, 217, 218, 219, 230, 231, 233, 234, 235, 236, 237, 238, 239, 240, 241, 243, 244, 245, 246, 247, 248, 249, 250, 251, 253, 254, 255, 256, 257, 258, 259, 260, 261, 263, 264, 265, 266, 267, 268, 269, 270, 271, 273, 274, 275, 276, 277, 278, 279, 280, 281, 283, 284, 285, 286, 287, 288, 289, 290, 291, 293, 294, 295, 296, 297, 298, 299, 302, 312, 320, 321, 323, 324, 325, 326, 327, 328, 329, 332, 342, 352, 362, 372, 382, 392, 402, 412, 420, 421, 423, 424, 425, 426, 427, 428, 429, 432, 442, 452, 462, 472, 482, 492, 502, 512, 520, 521, 523, 524, 525, 526, 527, 528, 529, 532, 542, 552, 562, 572, 582, 592, 602, 612, 620, 621, 623, 624, 625, 626, 627, 628, 629, 632, 642, 652, 662, 672, 682, 692, 702, 712, 720, 721, 723, 724, 725, 726, 727, 728, 729, 732, 742, 752, 762, 772, 782, 792, 802, 812, 820, 821, 823, 824, 825, 826, 827, 828, 829, 832, 842, 852, 862, 872, 882, 892, 902, 912, 920, 921, 923, 924, 925, 926, 927, 928, 929, 932, 942, 952, 962, 972, 982, 992]

    >>>

  • 3 years ago

    So the possibilities are, with x being any digit except 2:

    02xx

    0x2x

    0xx2

    each x has 9 possibilities, so for each of the three there are 9•9 = 81 possibilities

    multiply by 3 to get 243 possibilities.

    I'll make a list in excel and edit this.

    edit: here are the first 81:

    0200 0201 0203 0204 0205 0206 0207 0208 0209 0210 0211 0213 0214 0215 0216 0217 0218 0219 0230 0231 0233 0234 0235 0236 0237 0238 0239 0240 0241 0243 0244 0245 0246 0247 0248 0249 0250 0251 0253 0254 0255 0256 0257 0258 0259 0260 0261 0263 0264 0265 0266 0267 0268 0269 0270 0271 0273 0274 0275 0276 0277 0278 0279 0280 0281 0283 0284 0285 0286 0287 0288 0289 0290 0291 0293 0294 0295 0296 0297 0298 0299

    swap the second and third column for the next 81

    swap the second and forth column for the last 81

Still have questions? Get your answers by asking now.