Skip to content

Instantly share code, notes, and snippets.

@tomcha
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomcha/8ebd6beb5ed4859dd768 to your computer and use it in GitHub Desktop.
Save tomcha/8ebd6beb5ed4859dd768 to your computer and use it in GitHub Desktop.
#!/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