# Help me compress this song

in my country we have a children's song which goes like this:

Priletela muha na zid, muha na zid, muha na zid.
Priletela muha na zid,
muha na zid.

Preletele mehe ne zed, mehe ne zed, mehe ne zed.
Preletele mehe ne zed,
mehe ne zed.

Prilitili mihi ni zid, mihi ni zid, mihi ni zid.
Prilitili mihi ni zid,
mihi ni zid.

Prolotolo moho no zod, moho no zod, moho no zod.
Prolotolo moho no zod,
moho no zod.

Prulutulu muhu nu zud, muhu nu zud, muhu nu zud.
Prulutulu muhu nu zud,
muhu nu zud.


As you can see, it contains a bit of redundant information. So I was wondering if it could be compressed a bit.

This is code golf — shortest code wins.

• List of similar challenges – Luis Mendo Dec 16 '20 at 10:43
• To save curious people the effort: Google Translate detects it as Croatian and says: "A fly landed on the wall, a fly on the wall, a fly on the wall." and obviously the remaining verses are nonsense. Google didn't find a dictionary containing "priletela" so I don't know for sure. Wiktionary has a similar word in Russian and Google finds it in a Slovenian song. – user253751 Dec 16 '20 at 18:20
• @user253751 the translation is correct. The first verse is understandable for anyone speaking some slavic language and is more or less valid at least in Serbian, Croatian, Macedonian and some Bulgarian dialects. Zid is masonry, but can mean wall as well. – fraxinus Dec 16 '20 at 21:58
• @user253751 It's Slovene actually, but that's close enough :) – jgosar Dec 17 '20 at 6:21
• I happened to find a video for this song. – PIG208 Dec 17 '20 at 9:24

# 05AB1E, 54 52 bytes

Thanks to Kevin Cruijssen for -2 bytes!

T"ÿ, 0, 0.
ÿ,
0.
"T.•ý‹¨ΣªßˆTδ}vØ#•.ª'x¡‡žMv=žMyÞ‡}?


Try it online!

Commented:

T                         # push 10
"ÿ, 0, 0.\nÿ,\n0.\n"     # push string literal "10, 0, 0.\n10,\n0.\n"
T                       # push 10 again
.•ý‹¨ΣªßˆTδ}vØ#•       # push compressed string "priletela xmuha na zid"
.ª                    # sentence case => "Priletela xmuha na zid"
‛x¡                 # split on 'x'  => ["Priletela ", "muha na zid"]
‡                # replace every digit of 10 with the corresponding list entry in the string literal
# this is the first verse
žM              # push the vowels "aeiou"
v      }      # for y in vowels:
=            #   print the last verse without removing it from the stack
žM          #   push the vowels
yÞ        #   the infinite list of the vowel y
‡       #   replace every vowel with y
?     # print the last verse without a trailing newline


more obfuscated and a lot slower 52-byter:

•nöðrb•ØTz… ,
«ÅвJT.•ý‹¨ΣªßˆTδ}vØ#•.ª'x¡‡žMv=žMyÞ‡}?


Don’t try it online!

•nöðrb•              # push compressed integer 211262272027
Ø             # push the 211262272028th prime 5996494318979 (slow)
Tz           # push 1/10
… ,\n      # push string " ,\n"
«     # concatenate to "0.1 ,\n"
Åв   # convert the prime into that custom base
J  # join from list of chars into a string
# this generates the same string as T"ÿ, 0, 0.\nÿ,\n0.\n" above

• You can remove © and change ® to D for -1. – Kevin Cruijssen Dec 16 '20 at 9:21
• Or better: change it to = instead, and then »¨ to ? for -2: 52 bytes – Kevin Cruijssen Dec 16 '20 at 9:23
• @KevinCruijssen thanks a lot. I actually used manual printing before, but didn't think about printing in the next iteration. – ovs Dec 16 '20 at 9:34
• @GregMartin thanks a lot, I just asked WolframAlpha and concluded from the result that it would be too much effort to compute the number, but I guess I was wrong :). The goal of the second program is to generate the verse layout string in the most convoluted way at the same byte count, and this adds another step to it ;) – ovs Dec 16 '20 at 22:57
• haha "Don't try it online" – Greg Martin Dec 17 '20 at 0:04

# Ruby 2.7, 110105 104 bytes

Saved five bytes, thanks to Dingus!
Saved a byte using Arnauld's finding.

puts z="#{y="Priletela #{$x='muha na zid'},"} #$x, #$x. #{y} #$x.","aeiou".chars.map{z.gsub /[aeiu]/,_1}


Try it online!

TIO uses an older version of Ruby, whereas in Ruby 2.7, we've numbered parameters, which saves two bytes.

• @Dingus - Oh thanks! I didn't checked the rules of this challenge.. – vrintle Dec 16 '20 at 12:39
• Credit to @Arnauld: you can save another byte by changing to /[aeiu]/. – Dingus Dec 16 '20 at 12:51

# JavaScript (ES6),  121  120 bytes

_=>["$&",..."aeiou"].map(v=>${p=Priletela ${q='muha na zid'},}${q}, ${q}.${p}
p = Priletela ${ // by defining p = "Priletela muha na zid," q = 'muha na zid' // and q = "muha na zid" }, // }${q}, ${q}.\n${p}\n${q}. // and using them to build the other parts .replace( // update the template: /[aeiu]/g, // replace each vowel ... v // ... with the replacement pattern // NB: there's no "o" in the template ) // end of replace() ).join\n\n // join with two line-feeds  • +1, Nice find that there is no o ;-) – vrintle Dec 16 '20 at 13:30 # Wolfram Language (Mathematica), 146 134 bytes w="muha na zid";a="Priletela ";s=""<>{a,w,", ",w,", ",w,". ",a,w,", ",w,"."};c=Characters@"aeiou";s<>(StringReplace[" "<>s,c->#]&/@c)  Try it online! # Python 2, 122 bytes s="Priletela muha na zid," v="aeiou_" for x in v: w=s[10:-1]+".\n";print s,s[10:],w+s+"\n"+w for y in v:s=s.replace(y,x)  Try it online! # Bash + sed, 98 bytes sed -ney/{%/\\n,eiu/aaa,a/e,e/i,i/o,o/u}/\;p<<<"${x=Priletela ${y=muha na zid}},$y, $y.%$x,%$y.%"  Try it online! # Jelly, 62 bytes 3,2µ“muha na zid”Wẋjị⁾ ¶ṭ”,Ɗ⁶;“!b^ṙzḳ“)»j)Y ØẹµØẹW;y¢)¢W¤;j⁾¶¶  Try it online! ## Explanation 3,2µ“muha na zid”Wẋjị⁾ ¶ṭ”,Ɗ⁶;“!b^ṙzḳ“)»j)Y Auxiliary niladic link 3,2 [3, 2] µ ) For each: “muha na zid”W ["muha na zid"] ẋ Repeat that many times j Ɗ Join with: ị⁾ ¶ Index with the number into " \n" ṭ”, Append that to "," ⁶; Prepend a space “!b^ṙzḳ“)»j Join ["Priletela", "."] with this Y Join with a newline ØẹµØẹW;y¢)¢W¤;j⁾¶¶ Main niladic link Øẹ "aeiou" µ ) For each: ØẹW ["aeiou"] ; Append the vowel y¢ Translate the result of the previous link with this table ¢W¤; Prepend list with result of previous link j⁾¶¶ Join with double newlines  # Red, 150 bytes e: rejoin[a:"Priletela "b:"muha na zid"c:", "b c b d:".^/"a b c"^/"b d]v: charset w:"aeiou"foreach u w[print e parse e[any[change v u | skip]]]print e  Try it online! For a start, this is my attempt in Javascript: # JavaScript (Node.js), 184 bytes a='aeiou' x='muha na zid' y='Priletela' z=${y} ${x},${x}, ${x}.\n${y} ${x},\n${x}.
console.log([z].concat(a.split('').map(e=>z.replace(new RegExp('['+a+']', "g"), e))).join('\n\n'))


Try it online!

• It needs a semicolon or a new line before console.log(). It does not compile as it is now. – axiac Dec 16 '20 at 9:41
• Thanks @axiac, fixed it. – jgosar Dec 16 '20 at 9:47
• You can save a lot of bytes by using /[aeiou]/g instead of new RegExp('['+a+']', "g"). – axiac Dec 16 '20 at 10:07
• You can save 2+2 more bytes by squeezing the assignment of x and y into their first usage, like this: z=${y='Priletela'}${x='muha na zid'}, ${x},${x}.\n${y}${x},\n${x}. . – axiac Dec 16 '20 at 10:38 # Jelly, 58 bytes I feel like ”u”aØẹe?ṙ1Øẹ,y could be golfed ”u”aØẹe?ṙ1Øẹ,y 820Dṃ“!b^ṙzḳ“¢ʋỴM$ƊEⱮ/¥ɦ8»K€YF”.0,48¦ÇƬj⁾¶¶


Try it online!

# Perl 5 (-0777p), 91 bytes

s//Priletela muha na zid/;/ /;$_.=",$', $'.$_,
$'. ";for$i(a,e,i,o,u){say;s/[aeiou]/$i/g}  Try it online! # 05AB1E, 84 bytes .•bKÜ2TÐhrŒ°•'b.•[÷‚rµ₃•™:'c.•AΩJεмF‚•:…fgj…,. ‡DžMŽh’‡1'a‡D'a'e‡D'e'i‡D'i'o‡D'o'u‡»  Try it online! # PHP 8, 170 166 bytes This is the JavaScript solution of @jgosar rewritten in PHP and improved. $a='aeiou';$x='muha na zid';$y="Priletela $x,";echo implode(" ",array_merge([$z="$y$x, $x.$y
$x."],array_map(fn($e)=>preg_replace("/[$a]/",$e,$z),str_split($a))));


The code is not wrapped on multiple lines for readability but because this way a real newline character embedded in a string uses only one byte vs. two bytes used by the escape sequence \n.

Try it online!

# Retina, 70 bytes


Pm, m, m.¶Pm,¶m.¶
P
Priletela
m
muha na zid
~(Kvaeiou
L$. \Tvo$&


Try it online! Explanation:


Pm, m, m.¶Pm,¶m.¶


Insert placeholders for the first verse.

P
Priletela
m
muha na zid


Expand the placeholders.

~(


Compose and execute a Retina script.

Kvaeiou


Create a list of transliteration targets.

L$. \Tvo$&


Expand each target into a transliteration command that transliterates vowels into the given target and outputs the verse after the transliteration. The resulting script is as follows:

\Tvov
\Tvoa
\Tvoe
\Tvoi
\Tvoo
\Tvou


Here the v represents the vowels aeiou. The o on its own usually means "insert the other set", however this has no effect on the transliteration as the vowels are already present. The exception is the Tvoo command, where the presence of o on both sides causes it to be treated as a literal, although this does not affect the expansion either.

# PHP 7.4, 164 bytes

This is the same as my solution for PHP 8 but it does not surround the value of $a (aeiou) in apostrophes or quotes and saves 2 bytes. This exploits the fact that before PHP 8, the undefined constants were reported as warning and converted to strings. This behaviour changed in PHP 8, they are now reported as errors and the code does not work any more. $a=aeiou;$x='muha na zid';$y="Priletela $x,";echo implode(" ",array_merge([$z="$y$x, $x.$y
$x."],array_map(fn($e)=>preg_replace("/[$a]/",$e,$z),str_split($a))));


In order to hide the warnings, the option -d error_reporting=0 needs to be added to the command line (or set in php.ini`).