# Print “Hey Jude” from The Beatles

Your task is to write a program which prints following four verses extracted from the lyrics from The Beatles' song "Hey Jude" (© Sony/ATV Music Publishing LLC):

Hey Jude, don't make it bad\n
Take a sad song and make it better\n
Remember to let her into your heart\n
Then you can start to make it better\n
\n
Hey Jude, don't be afraid\n
You were made to go out and get her\n
The minute you let her under your skin\n
Then you begin to make it better\n
\n
Hey Jude, don't let me down\n
You have found her, now go and get her\n
Remember to let her into your heart\n
Then you can start to make it better\n
\n
Hey Jude, don't make it bad\n
Take a sad song and make it better\n
Remember to let her under your skin\n
Then you'll begin to make it\n
\n


BUT

The only input you are allowed to use to construct these four verses is this list of tokens:

"Hey Jude, don't"
" be afraid"
" let me down"
"Take a sad song and make it better"
"You"
" were made to go out"
" and get her"
" have found her, now go"
"Remember to"
"The minute you"
" let her"
"Then"
" you"
" can start"
"'ll"
" begin"
" to make it"
" better"


Note that some tokens have a space preceded and that enclosing quotes are not part of the tokens. You are free to use any format for the list and to rearrange the order of the tokens.

Your generated output has to exactly match the above four verses. Note that\n is used for newlines and an extra newline is added after each verse. You can use this file (MD5: 4551829c84a370fc5e6eb1d5c854cbec) to check your output against.

You can use following railroad diagram to understand the structure of the verses (each element represents a token):

Shortest code in bytes wins. Happy golfing.

• The part that goes Nah nah nah nah nah nah, nah nah nah, would have easier to compress. ^^ – Arnauld Feb 19 '18 at 16:14
• @Arnauld Related :P – DJMcMayhem Feb 19 '18 at 16:20
• @Arnauld obligatory XKCD xkcd.com/851_make_it_better – Nathaniel Feb 20 '18 at 0:30
• It must be hard to sing all those backslashes at the end of every line. – Tamás Sengel Feb 20 '18 at 10:36
• @bonh railroad-diagrams – arminb Feb 20 '18 at 15:03

# Jelly, 42 bytes

;⁷“Ṙç€ṘḋḷŒø|Ṁ2kḤ⁽⁼SƁẒVṿẎj]ð⁵ṀƒƤ)÷Ƒ¦Ẋ½Iɠ⁻’ṃ


Try it online!

Hardcoding version.

Input:

["Hey Jude, don't", ' make it bad', 'Take a sad song and make it better', 'Remember to', ' let her', ' into your heart', 'Then', ' you', ' can start', ' to make it', ' better', ' be afraid', 'You', ' were made to go out', ' and get her', 'The minute you', ' under your skin', ' begin', ' let me down', ' have found her, now go', "'ll"]


# JavaScript (ES6), 108 bytes

a=>01
4
9bc
efgjk

02
567
abd
efijk

03
587
9bc
efgjk

01
4
9bd
efhij

.replace(/./g,n=>a[parseInt(n,36)])


Try it online!

# Alternate version, 114 bytes

A slightly better compression, but sadly ruined by the larger decompression code.

a=>835fc3cbbd3
84db3db4bbdb3
85cd1cc3cbbd3
835fc4bbcb3

.replace(/./g,n=>a[n='0x'+n,i=n%8&&n%8-2+i]+[
[n>>3]])


Try it online!

• I did not know that the m flag is not required for multi-line template literals. Interesting. – Grant Miller Feb 27 '18 at 0:56

# Ruby + -p, 177136120118115 109 bytes (full program)

$_="abvevjlmvopqtuvvacvfghvklnvopstuvvadvfihvjlmvopqtuvvabvevjlnvoprstv".gsub(/./){|c|(eval$_)[c.ord-97]||$/}  Try it online! -41 bytes: Switch from using variables to using characters as array indexes -16 bytes: Switch to a more convenient input format -1 byte: No space needed between puts and "abv... -1 byte: Use $/ global instead of ?\n literal

-3 bytes: Use gsub(/./) instead of .chars.map

-6 bytes: Call with -p and make use of $_. Thanks Pavel! Each character in the magic string represents an index into the input array. I need the variable z so that I only read from STDIN once. I could save some cost from IO by writing a lambda accepting an array and returning a string. This requires an extra v at the end, because it's not getting a free newline from -p. # Ruby, 162110108 105 bytes (function) ->z{"abvevjlmvopqtuvvacvfghvklnvopstuvvadvfihvjlmvopqtuvvabvevjlnvoprstvv".gsub(/./){|c|z[c.ord-97]||$/}}


Try it online!

• I haven't been able to find a way to use String#unpack to be shorter than .chars with .ord-97, but there might be one. – benj2240 Feb 19 '18 at 22:01
• Here's a few bytes off: tio.run/##VY/… – Pavel Feb 20 '18 at 4:32
^(.*)¶.*
$1 }T1-E0-D F ¶  Try it online! Takes input as a newline-delimited list of strings. # Stax, 59 58 bytes îòÖ╥╬╬╞:,y╓ønä⌠╦╒ï╦≤x◘‼ε╩ⁿ◙ΓZ►e«qpôr╡"╣Ü≥┤╢┴;╡ÑkAú0:=;m╠╠x  Run and debug it The corresponding ascii representation of the same program is this. ORIpY$T&z{m6Y=>mR)_ .VQ)eN70e[:0yO8j$^RN[ Bp{IN/$|"3^;G#^&lv!FAx+@]p


ORIpY$T&z{m6Y=>mR)_ .VQ)eN70e[:0yO8j$^RN[ Bp{IN/$|"3^;G#^&lv! is a compressed literal with a value of "CDBGBLNOBQRSVWBBCEBHIJBMNPBQRUVWBBCFBHKJBLNOBQRSVWBBCDBGBLNPBQRTUVBB". The characters represent indexes into the token table. This program adds another token to represent a newline. It's not in the input, but added during execution. The rest of the program works like this. F for each character, execute the rest of the program A integer literal 10, character code of newline x+ append 10 to the input array @ get element at index, using wrap-around the list is size 22, and B is 66, so B gets the first token ] wrap the result in a singleton array. this effectively turns 10 into "\n" p print without newline  # C (gcc) function, 139 bytes i,m;f(char**s){for(i=0;i<68;)m="AB@E@JLM@OPQTU@@AC@FGH@KLN@OPSTU@@AD@FIH@JLM@OPQTU@@AB@E@JLN@OPRST@@"[i++],printf(m^64?"%s":"\n",s[m-65]);}  Try it online! • Nice. Can you explain the code? – arminb Mar 6 '18 at 13:35 • @arminb Nothing too fancy, the long "AB@E..." String contains the indices of the tokens and newlines ABC... = token[012].. '@' = newline, A token or newline is printed as 'i' iterates through that string. – PrincePolka Mar 6 '18 at 20:25 • merge the printf in for – l4m2 Apr 20 '18 at 11:07 • reverse the coding – l4m2 Apr 20 '18 at 11:09 • 126 bytes – ceilingcat Jun 28 '18 at 20:37 # Red, 133 bytes foreach c{abzezjlmzopqtuzzaczfghzklnzopstuzzadzfihzjlmzopqtuzzabzezjlnzoprstzz}[prin either c =#"z"["^/"][t/(to-integer c -#"a"+ 1)]]  Try it online! Ungolfed t is a block with the list of tokens s:{abzezjlmzopqtuzzaczfghzklnzopstuzzadzfihzjlmzopqtuzzabzezjlnzoprstzz} foreach c s[ ; for each character in s prin either c = #"z" ; if it's a 'z' ["^/"] ; print CR [t/(to-integer c - #"a" + 1)] ; otherwise find which token to print ] ; by mapping its offset to the alphabet  # D, 166 bytes import std.algorithm,std.range;T f(T)(T[]s){return"abvevjlmvopqtuvvacvfghvklnvopstuvvadvfihvjlmvopqtuvvabvevjlnvoprstvv".map!((int a){return(s~["\n"])[a-97];}).join;}  Try it online! # Mathematica, 102 bytes ""<>Append[#," "][[36^^ajikrj7lg8pya7wgtt43pvrilsik1dea1uht6mx3go33m4mjj02hb4wi9w3~IntegerDigits~23]]&  Pure function. Takes a list of strings as input and returns a string as output. Just encodes all the token indices, similarly to other answers. # Ruby, 97 bytes ->a{112.times{|i|$><<a[i%7-1+i%28/7*5]*("0@Xg(44k$,Xg0@Tz"[i/7].ord>>~i%7&1)+$/*(i%7/6+i%28/27)}}


Try it online!

Saved a few bytes with a different approach to most other answers.

The number of possible tokens in each line is as follows

Line number   Tokens
1             4
2             5
3             5
4             7


The magic string contains one character per line, which is interpreted as a bitmap of which of up to 7 available tokens is to be printed for each of the 16 lines of the song.

a[i%7-1+i%28/7*5] iterates through the tokens of each line, shifting by 5 for each new line, and with an offset of 1 to account for the fact that the first line has only 4 tokens.

For lines 1-3 only the 64's through 4's bits are used - not using the 2's and 1's bits avoids printing tokens from the next line. for line 4, all 7 bits from 64's to 1's are used.