Skip to content

Instantly share code, notes, and snippets.

@indication
Last active August 29, 2015 13:56
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 indication/8848996 to your computer and use it in GitHub Desktop.
Save indication/8848996 to your computer and use it in GitHub Desktop.
pizaaaaaaaaaa
my %table = (
'1' =>'.@-_/:~1'
,'2' =>'abcABC2'
,'3' =>'defDEF3'
,'4' =>'ghiGHI4'
,'5' =>'jklJKL5'
,'6' =>'mnoMNO6'
,'7' =>'pqrsPQRS7'
,'8' =>'tuvTUV8'
,'9' =>'wxyzWXYZ9'
,'E' =>''
);
foreach my $input (<STDIN>){
chomp $input;
$input =~ s/[^0-9E]//i;
my $lastword = "";
my $lastcnt = 0;
my $buffer = "";
foreach my $word (split(//,$input)){
if($lastword ne $word){
my $tbllen = length($table{$lastword});
if($lastword ne "" && $tbllen > 0){
$lastcnt = $lastcnt % $tbllen;
$buffer .= substr($table{$lastword},$lastcnt,1);
}
$lastcnt = 0;
$lastword = $word;
} else {
$lastcnt++;
}
}
print $buffer . "\r\n";
}
# perl 5.16.2
print $_ foreach (<STDIN>);
# perl 5.16.2
foreach my $str (<STDIN>){
chomp $str;
my @data = split(/ /,$str,2);
print (($#data >= 1 && $data[0] eq $data[1]) ? 'True' : 'False') . "\r\n";
}
# perl 5.16.2
my $transcode = -1;
foreach my $input (<STDIN>){
chomp $input;
my $str = $input;
$str =~ s/[^\d]//g;
my $year = int((length($str)==0) ? '0' : $str);
if($transcode == -1){
$transcode = int($year);
} else {
print "$input is" . (($year % 4 == 0 && (($year % 100 != 0) || ($year % 400 == 0))) ? "" : " not") . ' a leap year' . "\r\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment