Last active
July 25, 2016 12:47
-
-
Save dom111/7517540 to your computer and use it in GitHub Desktop.
Less minified version of answer submission for http://codegolf.stackexchange.com/questions/15301/tut-language-translator Needs a lot of work so saving here
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
$t = e0bub0kut0dud0i0fuf0jug0hash0ay0jag0kak0lul0mum0nun0o0pup0kwak0rut0sus0tut0yu0vuv0waks0eks0yak0zuz; | |
@t = split "0", $t."0\U$t"; | |
@s = ("a".."z","A".."Z"); | |
while (<>) { | |
($-, $_) = split/ /, $_, 2; # split to list with a maximum length of two | |
# $- is auto-cast as int and sets the mode | |
%l = map { | |
# build the lookup, flipping the keys/values depending on mode | |
($- ? $t[$_] : $s[$_]) => ($- ? $s[$_] : $t[$_]) | |
} 1..51; | |
if ($-) { | |
# standard replace | |
for $k (@t) { | |
s/$k/$l{$k}/g | |
} | |
# manual flip of doubles | |
s/skwer(\w)/$1$1/gi; | |
# catch this too | |
s/(r)ud/$1/gi; | |
} | |
else { | |
s/(.)/$l{$1}||$1/ge; | |
# manually add skwers | |
for $k (@t) { | |
s/$k$k/skwer$k/g | |
} | |
# fix rd | |
s/(ru)t(d)/$1$2$2/gi; | |
} | |
$- = !$-; # flip for printing | |
print "$- $_"; | |
} | |
$t=e0bub0kut0dud0i0fuf0jug0hash0ay0jag0kak0lul0mum0nun0o0pup0kwak0rut0sus0tut0yu0vuv0waks0eks0yak0zuz;@t=split 0,$t."0\U$t";@s=(a..z,A..Z);while(<>){($-,$_)=split/ /,$_,2;%l=map{$-?$t[$_]:$s[$_]=>$-?$s[$_]:$t[$_]}1..51;if($-){for$k(keys%l){s/$k/$l{$k}/g}s/skwer(\w)/$1$1/gi;s/(r)ud/$1/gi}else{@x=split//;@x[$_]=$l{$x[$_]}||$x[$_]for 0..$#x;$_=join"",@x;for$c(@t){s/$c$c/skwer$c/g}s/rutdud/ruddud/g}$-=!$-;print"$- $_"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment