in reply to Pin code

Hello Starz, and welcome to the Monastery!

For a systematic brute-force approach, here’s a Perl script which lists the 504 possible 4-digit PINs with the constraints you describe:

use strict; use warnings; use Algorithm::Combinatorics qw( variations ); use constant PIN => 4; my $count = 0; for my $pre (variations([ 0, 2 .. 9 ], PIN - 1)) { print join('', @$pre), "1\t"; ++$count; } print "\nTotal combinations: $count\n";

Output:

14:16 >perl 1926_SoPW.pl 0231 0241 0251 0261 0271 0281 0291 0321 0341 + 0351 0361 0371 0381 0391 0421 0431 0451 0461 0471 + 0481 0491 0521 0531 0541 0561 0571 0581 0591 0621 + 0631 0641 0651 0671 0681 0691 0721 0731 0741 0751 + 0761 0781 0791 0821 0831 0841 0851 0861 0871 0891 + 0921 0931 0941 0951 0961 0971 0981 2031 2041 2051 + 2061 2071 2081 2091 2301 2341 2351 2361 2371 2381 + 2391 2401 2431 2451 2461 2471 2481 2491 2501 2531 + 2541 2561 2571 2581 2591 2601 2631 2641 2651 2671 + 2681 2691 2701 2731 2741 2751 2761 2781 2791 2801 + 2831 2841 2851 2861 2871 2891 2901 2931 2941 2951 + 2961 2971 2981 3021 3041 3051 3061 3071 3081 3091 + 3201 3241 3251 3261 3271 3281 3291 3401 3421 3451 + 3461 3471 3481 3491 3501 3521 3541 3561 3571 3581 + 3591 3601 3621 3641 3651 3671 3681 3691 3701 3721 + 3741 3751 3761 3781 3791 3801 3821 3841 3851 3861 + 3871 3891 3901 3921 3941 3951 3961 3971 3981 4021 + 4031 4051 4061 4071 4081 4091 4201 4231 4251 4261 + 4271 4281 4291 4301 4321 4351 4361 4371 4381 4391 + 4501 4521 4531 4561 4571 4581 4591 4601 4621 4631 + 4651 4671 4681 4691 4701 4721 4731 4751 4761 4781 + 4791 4801 4821 4831 4851 4861 4871 4891 4901 4921 + 4931 4951 4961 4971 4981 5021 5031 5041 5061 5071 + 5081 5091 5201 5231 5241 5261 5271 5281 5291 5301 + 5321 5341 5361 5371 5381 5391 5401 5421 5431 5461 + 5471 5481 5491 5601 5621 5631 5641 5671 5681 5691 + 5701 5721 5731 5741 5761 5781 5791 5801 5821 5831 + 5841 5861 5871 5891 5901 5921 5931 5941 5961 5971 + 5981 6021 6031 6041 6051 6071 6081 6091 6201 6231 + 6241 6251 6271 6281 6291 6301 6321 6341 6351 6371 + 6381 6391 6401 6421 6431 6451 6471 6481 6491 6501 + 6521 6531 6541 6571 6581 6591 6701 6721 6731 6741 + 6751 6781 6791 6801 6821 6831 6841 6851 6871 6891 + 6901 6921 6931 6941 6951 6971 6981 7021 7031 7041 + 7051 7061 7081 7091 7201 7231 7241 7251 7261 7281 + 7291 7301 7321 7341 7351 7361 7381 7391 7401 7421 + 7431 7451 7461 7481 7491 7501 7521 7531 7541 7561 + 7581 7591 7601 7621 7631 7641 7651 7681 7691 7801 + 7821 7831 7841 7851 7861 7891 7901 7921 7931 7941 + 7951 7961 7981 8021 8031 8041 8051 8061 8071 8091 + 8201 8231 8241 8251 8261 8271 8291 8301 8321 8341 + 8351 8361 8371 8391 8401 8421 8431 8451 8461 8471 + 8491 8501 8521 8531 8541 8561 8571 8591 8601 8621 + 8631 8641 8651 8671 8691 8701 8721 8731 8741 8751 + 8761 8791 8901 8921 8931 8941 8951 8961 8971 9021 + 9031 9041 9051 9061 9071 9081 9201 9231 9241 9251 + 9261 9271 9281 9301 9321 9341 9351 9361 9371 9381 + 9401 9421 9431 9451 9461 9471 9481 9501 9521 9531 + 9541 9561 9571 9581 9601 9621 9631 9641 9651 9671 + 9681 9701 9721 9731 9741 9751 9761 9781 9801 9821 + 9831 9841 9851 9861 9871 Total combinations: 504 14:16 >

See https://en.wikipedia.org/wiki/Permutation#k-permutations_of_n and Algorithm::Combinatorics.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,