13
\$\begingroup\$

Write 3 programs that do the following task:

Let A, B, C source codes of those three programs;

  • if A runs BC is produced as output,
  • if B runs CA is produced,
  • if C runs AB is produced;

so each program writes a string (cycled for each program) and hides itself from it.

Additional, but essential constraints:

  • standard loopholes are forbidden;
  • each program must be at least 1 byte long;
  • each of three programs must be written in a different language;

It would be nice if your submission had this format:

Language A (size of A) - Language B (size of B) - Language C (size of C) - Score

A B C
<extra stuff>

Winner is someone who get the minimum score, which is the sum of sizes of three programs.

\$\endgroup\$
  • \$\begingroup\$ It would be nicer to have the score come last (to fit with the leaderboard script) \$\endgroup\$ – Leaky Nun Jul 12 '17 at 8:41
  • 1
    \$\begingroup\$ Related. Related. \$\endgroup\$ – Dead Possum Jul 12 '17 at 8:50
  • 7
    \$\begingroup\$ I wouldn't recommend deadlines. \$\endgroup\$ – Erik the Outgolfer Jul 12 '17 at 9:39
  • \$\begingroup\$ Any requirement about A, B and C being different strings? For example, can the three strings be the same? If the program prints a newline after the output, can we not count that? \$\endgroup\$ – Luis Mendo Jul 12 '17 at 20:38
  • \$\begingroup\$ It is not required A, B, C being different. Newlines are counted as part of output so newlines in the string are part of the program. \$\endgroup\$ – Blex Jul 13 '17 at 8:56
3
\$\begingroup\$

Befunge-98, Gol><> and Wumpus 47*3 = 141 bytes

"r75*1-47*0.@o&r84#o&]=74#]=\`/KHj '!_@#,k.'g00

Try it in Befunge! Try it in ><>! Try it in Wumpus!

That's right, it's the same program three times over! When run in any of the above languages, it prints the source code twice, which is the other two programs concatenated.

How It Works:

Befunge code:
  "r                               j '!_@#,k.'g00

  "   Wrapping string literal over code
   r  Reflect the pointer
  "   Wrapping string literal
                                              g00   Fetch " from cell 0,0 
                                          ,k.'      Print 47 characters
                                       _@#          If the next character is 0, exit
                                      !             Otherwise, set it to 0
                                   j '              And jump back to the beginning


Gol><> code:
  "r75*1-47*0.                \`/KH

  "             Wrapping string literal
   r            Reverse stack
    75*1-       Push "
         47*0.  Jump to cell 28,0
                              \  Continue right
                               `/K   Duplicate the top 47 characters on the stack
                                  H  Halt and output stack contents

Wumpus code:
  "r75*1-47*0.@o&r84#o&]=74#]=\

  "r75*1-47*0.  Exact same function as the ><> code, but with a bouncing string literal
                              \  Reflect left
                            ]=   Push a copy of the " to the bottom of the stack
                         74#     Push 47
                       ]=        Push a copy of the 47 to the bottom of the stack
                     o&          Print the top 47 characters
                  84#            Push a '0' to make up for the missing 0 at the end
               o&r               Reverse the stack and print the top 47 characters
              @                  And terminate
\$\endgroup\$
0
\$\begingroup\$

JScript, VBScript, Windows Batch, 345 bytes

a=new ActiveXObject("scripting.filesystemobject");b=a.opentextfile(".js");c=b.readline();d=b.readline();a.createtextfile(".bat").write("@echo "+d.substr(2)+">.vbs\n@echo '"+c+">>.vbs")
//set a=createobject("scripting.filesystemobject"):set b=a.opentextfile(".vbs"):c=b.readline:d=b.readline:a.createtextfile(".js").write(mid(d,2)+chr(10)+"//"+c)

Name the file .js, then .vbs and then .bat will be created.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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