Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Pin code

by FloydATC (Deacon)
on Sep 12, 2018 at 10:33 UTC ( [id://1222199]=note: print w/replies, xml ) Need Help??


in reply to Pin code

Smells like a homework assignment but here's a solution without any dependencies:

#!/usr/bin/perl use strict; use warnings; PIN: foreach my $pin ("0000" .. "9999") { # Last digit is a 1 next unless $pin =~ /1$/; # No repeating digits my %count = (); foreach my $digit (split(//, $pin)) { $count{$digit}++; next PIN if $count{$digit} > 1; } print $pin . "\n"; }
-- FloydATC

I got 99 problems, most of them have to do with printers.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1222199]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-03-28 11:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found