SOLUTION: How many different 5-digit PINs contain the sequence 12 (order matters) 12000 counts 12121 counts 13332 doesn't count

Algebra ->  Permutations -> SOLUTION: How many different 5-digit PINs contain the sequence 12 (order matters) 12000 counts 12121 counts 13332 doesn't count      Log On


   



Question 1105054: How many different 5-digit PINs contain the sequence 12 (order matters)
12000 counts
12121 counts
13332 doesn't count

Answer by math_helper(2461) About Me  (Show Source):
You can put this solution on YOUR website!
There are 4 patterns to worry about:
12xxx —> +10%5E3+
x12xx —> +10%5E3+
xx12x —> +10%5E3+-+10+ <<< minus 10 for the 1212x pattern already counted
xxx12 —> +10%5E3+-+10+-+10+ <<< minus 20 for 12x12, x1212, both already counted
——
That's +4x10%5E3+-+30+ = 3970
——
Check using a Perl one-liner:
perl -e 'for ($i=0, $s=0; $i<100000; $i++) { if ($i =~ /12/) { $s++; } }; print "$s\n";'
3970