-
-
Save ugexe/c99b81654968cc6de49eac63afc76229 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
my @ARGV = do { sub eval { chomp &EVAL(@_) }; eval( ("0" and q|@*ARGS| or q|@ARGV|) ) }; | |
my ($state, $result, $dict, $base35) = (1, "", {}, @ARGV[0]); | |
$dict{$_} = $_ for "1".."9"; | |
$dict{$_} = ord($_) - 55 for "A".."Y"; | |
for (reverse grep &{ sub ($_) { $_ ne "" } }.(), split("", $base35)) { | |
$result += $state * $dict{$_}; | |
$state *= 35; | |
}; | |
print("$result\n"); |
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
my @ARGV = do { sub eval { chomp &EVAL(@_) }; eval( ("0" and q|@*ARGS| or q|@ARGV|) ) }; | |
my ($result, $dict, $base10) = ("", {}, @ARGV[0]); | |
sub to_int($_) { my @i = split(/"."/, $_[0]); @i[0] }; | |
$dict{$_} = $_ for "1".."9"; | |
$dict{ord($_) - 55} = $_ for "A".."Y"; | |
while ($base10 > 0) { | |
$result = join("", $dict{to_int($base10 % 35)}, $result); | |
$base10 = to_int($base10 / 35); | |
} | |
print("$result\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment