# In Soviet Russia, code writes you! [duplicate]

## Input

Two words separated by a space. It is assumed that the first is a verb.

## Output

The "Soviet counterpoint" to the input phrase, in the form of a punchline to an "in Soviet Russia" joke.

"break law" --> "In Soviet Russia, law break you!"


Accounting for correct grammar is unimportant.

Shortest program wins!

• Just to clarify, we can't take 2 inputs, one of each word? i.e. bash russia.sh break law? – Rɪᴋᴇʀ Feb 22 '17 at 16:00
• I've closed the challenge as a duplicate, because both challenges take two space-separated words and require them to be printed in reverse order with some fixed boilerplate string around/between them. – Martin Ender Feb 22 '17 at 16:01
• @MartinEnder: In this case the two words don't have anything between them in the output though, which allowed me to take a different approach in Perl 6. – smls Feb 22 '17 at 16:16
• @smls That's fair, you're free to cast a reopen vote. – Martin Ender Feb 22 '17 at 16:20

# Perl 6, 40 37 bytes

{"In Soviet Russia, {.words[1,0]} you!"}


{~[R,] «you! $_ Russia, Soviet In»}  It works because the « » "word list quote" recursively splits everything on whitespace. Some other answers require the input words to be passed as two separate arguments. I think that's cheating, but for the record, it would make this solution 34 bytes long (and really boring): {"In Soviet Russia,$^b $^a you!"}  # Jelly, 20 bytes “\UṙȦƒĊÑṆ»⁶³ḲṚK“æw}»  Try it online! “\UṙȦƒĊÑṆ»⁶³ḲṚK“æw}» “\UṙȦƒĊÑṆ» Set output to 'In Soviet Russia,' ⁶ Set output to ' ' {implicitly printing the previous output} ³ Set output to the input {implicitly printing the previous output} "breaks law" Ḳ Split {the input} on spaces. ['breaks', 'law'] Ṛ Reverse list. ['law', 'breaks'] K Join with spaces. "law breaks" “æw}» Set output to ' you!' {implicitly printing the previous output}  Alternatively, if there's no obligation for quotes around the input, it can be done in 19 bytes. “\UṙȦƒĊÑṆ»⁶⁴⁶³“æw}»  Try it online! • This seems to be assuming that the user split the input into spaces themself? ⁴ doesn't work with the input format that the OP gave. – user62131 Feb 22 '17 at 16:02 • I kind of freestyled with two words, separated by a space. Added another version as well. – PidgeyUsedGust Feb 22 '17 at 16:13 • Huh, now our solutions are the same length but actually somewhat different in terms of algorithm. (We aren't even using quite the same string literals.) Weird to see that happen. – user62131 Feb 22 '17 at 16:16 # TI-Basic, 68 bytes Input Str1 inString(Str1," "IN SOVIET RUSSIA, "+sub(Str1,Ans+1,Str1-Ans)+" "+sub(Str1,1,Ans-1)+" YOU!  "Accounting for correct grammar is unimportant." I guess that means I can yell everything ;) # Python 3, 57 56 bytes print("In Soviet Russia,",*input().split()[::-1],"you!")  Try it online # Gema, 32 characters * *=In Soviet Russia,$2 * you\!


Sample run:

bash-4.3$printf 'break law' | gema '* *=In Soviet Russia,$2 * you\!'
In Soviet Russia, law break you!


# Jelly, 20 bytes

Ḳ“\UṙȦƒĊÑṆ»ṭṚ“©ṠẆ»ṭK


Try it online!

More fun with Jelly's compressed strings.

Ḳ“\UṙȦƒĊÑṆ»ṭṚ“©ṠẆ»ṭK
Ḳ                     Split {the input} on spaces
“\UṙȦƒĊÑṆ»             "In Soviet Russia," (compressed notation)
Ṛ         Reverse the list
K  Join on spaces {and implicitly output}


# Retina, 39 37 bytes

Saved 2 bytes thanks to Martin Ender

(.+ )(.+)
In Soviet Russia, $2$1you!


Try it online!

• @MartinEnder Right, thanks. Not sure what I was thinking – Business Cat Feb 22 '17 at 16:02
• Just for fun, if we assume there are no digits in the input, another byte can be saved by separating the swapping from adding the boilerplate: tio.run/nexus/… – Martin Ender Feb 22 '17 at 16:05

# 05AB1E, 20 bytes

”InË·ž¦,”I#R„€î!)˜ðý


Try it online!

# GNU sed, 40 bytes

s/(.+ )(.+)/In Soviet Russia, \2 \1you!/


Try it online!

# V, 29 bytes

iIn Soviet Russia, <C-r>b <C-r>a you!


Try it online!

Note that <C-r> is actually ctrl-r, or ASCII 0x12, but since that character is unprintable, using the verbose mode to represent it is more convenient.

This is probably about as short as it can get without using compression.

# JAPT 29 Bytes

In soviet rÔëa, {V} {U} y!


input: "drink" "milk"

output: In Soviet Russia, milk drink you

explaination: {U} and {V} are the input variables. it inserts them in the string when running the code.

First code-golf ever. hope it counts!

Try it online!

• Welcome to PPCG, and thanks for using my language! Unfortunately, the input has to be given as a single string, but you can fix this by replacing {V} {U} with {¸w ¸} (¸ stands for qS, which splits a string on spaces and joins an array on spaces, and w reverses an array). Also, you can leave out the last backtick to save a byte. (Test these changes here) – ETHproductions Feb 22 '17 at 16:46