aboutsummaryrefslogtreecommitdiff
path: root/challenge-046/javier-luque/perl/ch-2.pl
blob: 4934eea3d31e3c5278d69eae49f10e9a6a00fddf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/perl
# test: perl ch-2.pl
use strict;
use warnings;
use feature qw /say/;

my @doors;
$doors[$_] = 0 for (0 .. 500);

for my $employee (1 .. 500) {
    for my $door ($employee .. 500 ) {
        next unless $door % $employee == 0;
        $doors[$door] = ($doors[$door]) ? 0 : 1;
    }
}

for my $i (1 .. 500) {
    say "Door: " . $i . " is open."
        if ($doors[$i]);
}