#!/usr/bin/perl -l use strict; use warnings; my @consonants1 = qw/ b bl br ch d dr f fr g gr h j k kl kr l m n p pl pr r s sk skl skr sl sn sp spl spr st str t tr v vr z /; my @vowels = qw/ a e i o u /; my @consonants2 = qw/ b bs d dge ds f g gs ck ll lf m n nd nt p r s st t v x z /; my $nwords = 0; my @num2word; my %word2num; for my $c1 (@consonants1){ for my $v (@vowels){ for my $c2 (@consonants2){ $num2word[$nwords] = "$c1$v$c2"; $word2num{"$c1$v$c2"} = $nwords; $nwords++; } } } while(<>){ chomp; if (/^\d+$/){ my @words; #encode while ($_ != 0){ push @words, $num2word[$_ % $nwords]; $_ = int ($_ / $nwords); } print join "-", @words; } else { #decode my $num = 0; for my $word (reverse split /-/){ $num *= $nwords; $num += $word2num{$word}; } print $num; } }