Cyclic strings, hidden programs

13

2

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.

Blex

Posted 2017-07-12T08:11:46.220

Reputation: 289

It would be nicer to have the score come last (to fit with the leaderboard script) – Leaky Nun – 2017-07-12T08:41:05.107

1Related. Related. – Dead Possum – 2017-07-12T08:50:43.310

7I wouldn't recommend deadlines. – Erik the Outgolfer – 2017-07-12T09:39:39.620

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? – Luis Mendo – 2017-07-12T20:38:22.647

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. – Blex – 2017-07-13T08:56:24.573

Maybe someone could pick up my work. I don't have time to finish :C Fission quine with payload (this one can't have symbols "UDRL in payload)

– Dead Possum – 2017-07-24T07:07:13.250

Ruby,Perl,Python mutual quines – Dead Possum – 2017-07-24T07:07:17.730

Is there anything to stop all three programs from just being 1 in languages that automatically evaluate and print an expression, and ignore input that isn't referenced? – xnor – 2017-10-23T16:33:49.697

I revert the question to the original state since it misleads the original question. When I say if A runs BC is produced as output I mean BC is catenation of B and C and A, B and C are strings. – Blex – 2018-01-13T20:43:12.243

Trivial solutions like lang A inputs 0 and outputs 00 and so on cyclically are possible but that sounds like taking advantage from that specific language hack. – Blex – 2018-01-13T20:45:24.637

Related – FantaC – 2018-01-13T20:50:41.347

Does outputting nothing (empty string) count? Three empty programs – dylnan – 2018-01-13T21:16:17.970

"each program must be at least 1 byte long." So no empty strings. – Blex – 2018-01-13T21:36:07.953

Answers

3

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

Jo King

Posted 2017-07-12T08:11:46.220

Reputation: 38 234

0

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.

peter ferrie

Posted 2017-07-12T08:11:46.220

Reputation: 804