Skip to content

Instantly share code, notes, and snippets.

@ugexe
Created April 3, 2019 08:14
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 ugexe/c99b81654968cc6de49eac63afc76229 to your computer and use it in GitHub Desktop.
Save ugexe/c99b81654968cc6de49eac63afc76229 to your computer and use it in GitHub Desktop.
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");
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