Created
August 4, 2012 12:24
-
-
Save turugina/3257143 to your computer and use it in GitHub Desktop.
lldecade きみならどう書く online の回答
This file contains hidden or 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
use strict;use warnings;use utf8;my($xx,$x,$X,@x,@X)=qr!\p{xdigit}!; | |
sub X{0 eq$_||!/^0+[^0]+$/}@x=(sub{/^$xx{2}([-:])(?:$xx{2}\1){4}$xx{2}$/}, | |
sub{@X=split/\./;4==@X&&4==grep{/^\d{1,3}$/&&0<=$_&&256>$_&&X}@X}, | |
sub{@X=split/:/;8==@X&&8==grep{/^$xx{1,4}$/&&X}@X}); | |
sub x{$X=0;for$x(@x){last if$x->();++$X;}$X;}@x=map x,<STDIN>; | |
@x=map{$_*=4;$x[$_]*64+$x[$_+1]*16+$x[$_+2]*4+$x[$_+3]}0..$#x/4; | |
print join'',map chr,@x; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment