Last active
August 29, 2015 14:06
-
-
Save tomcha/8ebd6beb5ed4859dd768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
binmode STDIN,":encoding(UTF8)"; | |
binmode STDOUT,":utf8"; | |
binmode STDERR,":utf8"; | |
# 油揚げは1枚で2回分 | |
# 葱は1束で4回分 | |
# 玉子は10個入り | |
my %zairyou = ( | |
age => 2, | |
negi => 4, | |
tamago => 10, | |
); | |
my $i = 1; | |
my @buy_item = (); | |
while(1){ | |
if ($i % $zairyou{age} == 0){ | |
push @buy_item, '油揚げ'; | |
} | |
if ($i % $zairyou{negi} == 0){ | |
push @buy_item, '葱'; | |
} | |
if ($i % $zairyou{tamago} == 0){ | |
push @buy_item, '玉子'; | |
} | |
if (scalar @buy_item == 3){ | |
print $i."杯目、完食\n"; | |
last; | |
}elsif(scalar @buy_item == 0){ | |
print $i."杯目、衣笠丼\n"; | |
}else{ | |
print $i."杯目、" . join(',', @buy_item) . "を買いに行く\n"; | |
} | |
@buy_item = (); | |
$i++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment