0
\$\begingroup\$

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!

\$\endgroup\$
  • \$\begingroup\$ Just to clarify, we can't take 2 inputs, one of each word? i.e. bash russia.sh break law? \$\endgroup\$ – Rɪᴋᴇʀ Feb 22 '17 at 16:00
  • 7
    \$\begingroup\$ 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. \$\endgroup\$ – Martin Ender Feb 22 '17 at 16:01
  • 2
    \$\begingroup\$ @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. \$\endgroup\$ – smls Feb 22 '17 at 16:16
  • 1
    \$\begingroup\$ @smls That's fair, you're free to cast a reopen vote. \$\endgroup\$ – Martin Ender Feb 22 '17 at 16:20

11 Answers 11

2
\$\begingroup\$

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!"}
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

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!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – user62131 Feb 22 '17 at 16:02
  • \$\begingroup\$ I kind of freestyled with two words, separated by a space. Added another version as well. \$\endgroup\$ – PidgeyUsedGust Feb 22 '17 at 16:13
  • \$\begingroup\$ 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. \$\endgroup\$ – user62131 Feb 22 '17 at 16:16
0
\$\begingroup\$

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 ;)

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Python 3, 57 56 bytes

print("In Soviet Russia,",*input().split()[::-1],"you!")

Try it online

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

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!
| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Jelly, 20 bytes

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

Try it online!

More fun with Jelly's compressed strings.

Ḳ“\UṙȦƒĊÑṆ»ṭṚ“©ṠẆ»ṭK
Ḳ                     Split {the input} on spaces
           ṭ          Add an additional input to the end:
 “\UṙȦƒĊÑṆ»             "In Soviet Russia," (compressed notation)
            Ṛ         Reverse the list
                  ṭ   Add another additional input to the end:
             “©ṠẆ»      "you!" (compressed notation)
                   K  Join on spaces {and implicitly output}
| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Retina, 39 37 bytes

Saved 2 bytes thanks to Martin Ender

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

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ @MartinEnder Right, thanks. Not sure what I was thinking \$\endgroup\$ – Business Cat Feb 22 '17 at 16:02
  • \$\begingroup\$ 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/… \$\endgroup\$ – Martin Ender Feb 22 '17 at 16:05
0
\$\begingroup\$

05AB1E, 20 bytes

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

Try it online!

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

GNU sed, 40 bytes

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

Try it online!

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

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!

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ 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) \$\endgroup\$ – ETHproductions Feb 22 '17 at 16:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.