# Third time the charm

Your task, if you wish to accept it, is to write a program that outputs a positive integer (higher than 0). If the source code is duplicated the output must remain the same. The tricky part is that if the source code is typed three times (triplicated?) the output will be multiplied by 3.

# Rules

• You must build a full program. That is, your output has to be printed to STDOUT.

• The initial source must be at least 1 byte long.

• Both the integers must be in base 10 (outputting them in any other base or with scientific notation is forbidden).

• Your program must not take input (or have an unused, empty input).

• Outputting the integers with trailing / leading spaces is allowed.

• Leading Zeroes are allowed only if the numbers of digits is consistent eg: 001 - 001 - 003 or 004 - 004 - 012

• You may not assume a newline between copies of your source.

• This is , so the shortest (original) code in each language wins!

• Default Loopholes apply.

### Example

Let's say your source code is Abc and its corresponding output is 4. If I write AbcAbc instead and run it, the output must still be 4. However if I write AbcAbcAbc and run it, the output must be 12.

Shamelessly stolen Derived from Mr. Xcoder's challenge

• Is our code allowed to read its own source code? – AdmBorkBork Mar 12 '18 at 13:45
• @AdmBorkBork I'd assume so, since this isn't tagged as quine. – Erik the Outgolfer Mar 12 '18 at 13:47
• @AdmBorkBork Yes. – workoverflow Mar 12 '18 at 14:06
• I don't think the 1 byte restriction is needed since it wouldn't be possible to tell the difference between nothing and nothing repeated 3 times. – 12Me21 Mar 13 '18 at 1:42
• @r12 "Abc" is an example for any programming language program, say if your code is (int i=1;print i;) then the duplicated code of (int i=1;print i;int i=1;print i;) must output the same number as the original code, and when the code is triplicated to (int i=1;print i;int i=1;print i;int i=1;print i;) it must show the number multiplied by 3 – workoverflow Mar 16 '18 at 16:54

## Wumpus, 6 bytes

{~)
@O


Prints 1 and 3.

### Explanation

I found a ton of 6-byte solutions by brute force search, but none for 5 bytes. That doesn't necessarily mean there aren't any at 5 bytes but they'd probably use weird characters or something.

I ended up picking this solution because it doesn't print any leading zeros (most of them do) and it has some interesting control flow. Let's start with the single program:

So the executed code is:

{~)O@

{   Turn the IP left by 60°.
~   Swap two implicit zeros on the stack, does nothing.
)   Increment the top zero to 1.
O   Print it.
@   Terminate the program.


Easy enough. Now the doubled program. Since the first line gets appended onto the second line, the grid extends to width 5 (and height 3) which changes the control flow significantly:

The IP goes around that loop exactly once, so the executed code is:

{~){~)){~O@

{~) As before, we end up with a 1 on top of the stack.
{   Turn left by 60° again.
~   Swap the 1 with the 0 underneath.
))  Increment the zero to 2.
{   Turn left by 60° again.
~   Swap the 2 with the 1 underneath.
O   Print the 1.
@   Terminate the program.


Finally, the tripled program is quite similar to the doubled one, but we get a couple more important commands onto that third line:

So the executed code is:

{~){~)){~~)O@

{~){~)){~
As before. We end up with a 1 on top of the stack and a 2 underneath.
~   Swap the 1 with the 2 underneath.
)   Increment the 2 to a 3.
O   Print the 3.
@   Terminate the program.

• i think i'm in love with this language. – conquistador Mar 14 '18 at 13:54

# Husk, 5 bytes

KΣK+1


Try it online!

Repeated twice!

Repeated thrice!

## Explanation

It's quite difficult to construct a repeatable program in Husk. Because the type system forbids a function that can be applied to itself, I have to somehow allow the first part to evaluate to a function, and the remainder to evaluate to a value, and the types of existing built-ins are designed to prevent this kind of ambiguity. The tokens of the program are

• K, which constructs a constant function. K a b is equivalent to a.
• Σ, which takes an integer n and returns the nth triangular number.
• +, which adds two numbers.
• 1, which is the literal 1.

The original program is interpreted like this:

   K Σ (K+) 1
== Σ 1
== 1


The (K+) is a nonsensical function that gets eaten by the first K.

The twice repeated program is interpreted like this:

   K Σ (K+1KΣK+) 1
== Σ 1
== 1


The function in parentheses is again eaten by the first K.

The thrice repeated program is interpreted like this:

   K (Σ (K (+1) (KΣK+) 1)) (KΣK+1)
== Σ (K (+1) (KΣK+) 1)
== Σ ((+1) 1)
== Σ (+1 1)
== Σ 2
== 3

• This takes really long time to run ... – Weijun Zhou Mar 12 '18 at 17:03
• @WeijunZhou If you have many occurrences of K in a program, type inference becomes very slow, because each of them could potentially "eat" any number of tokens and the interpreter will try all combinations... – Zgarb Mar 12 '18 at 17:09
• I see, thank you for your explanation. – Weijun Zhou Mar 12 '18 at 17:14
• @Zgarb +1 for kek +1 – workoverflow Mar 14 '18 at 8:54

# Jelly, 7 5 bytes

»‘µ*Ḃ


Try it online!

Try it doubled!

Try it tripled!

### How it works

»‘µ*Ḃ            Main link. No arguments. Implicit argument: x = 0

‘               Increment; yield x + 1 = 1.
»                Take the maximum of x and 1. Yields 1.
µ              Begin a new, monadic chain. Argument: y = 1
Ḃ            Bit; yield 1 if y is odd, 0 if it is even. Yields 1.
*             Power; yield y**1 = 1.

»‘µ*Ḃ»‘µ*Ḃ       Main link.

»‘µ*Ḃ            As before.
‘          Increment; yield y + 1 = 2.
»           Take the maximum of 1 and 2. Yields 2.
µ         Begin a new, monadic chain. Argument: z = 2
Ḃ       Bit; yield 1 if z is odd, 0 if it is even. Yields 0.
*        Power; yield z**0 = 1.

»‘µ*Ḃ»‘µ*Ḃ»‘µ*Ḃ  Main link.

»‘µ*Ḃ»‘µ*Ḃ       As before.
‘     Increment; yield z + 1 = 3.
»      Take the maximum of 1 and 3. Yields 3.
µ    Begin a new, monadic chain. Argument: w = 3
Ḃ  Bit; yield 1 if w is odd, 0 if it is even. Yields 1.
*   Power; yield w**1 = 3.


main=print.div 3$4 -1--  Prints 1: Try it online! main=print.div 3$4
-1--main=print.div 3$4 -1--  Also prints 1: Try it online! main=print.div 3$4
-1--main=print.div 3$4 -1--main=print.div 3$4
-1--


Prints 3: Try it online!

# Cubix, 5 bytes

)<@OP


Try it online: once, twice, thrice.

## Explanation

Cubix is a stack-based language whose instructions are wrapped around the outside of a cube. Important to note is that the stack is initially filled with infinite zeroes, which allows us to "pull values out of thin air" with operators rather than pushing them explicitly.

I must admit that this was found by a brute-forcer; I never would have found it on my own. In fact, @MartinEnder was the one who asked me to try brute-forcing, as he had been looking for this solution without luck. This is the only solution the brute-forcer found, and I do believe it is the one and only shortest solution in Cubix.

### Single program

Watch it run!

The original program fits on a unit cube. Here's the unfolded net:

  )
< @ O P
.


The IP (instruction pointer) starts on the leftmost face (the <) headed east. The < immediately points it west, and it wraps around to the P. P is exponentiation, and since there's nothing on the stack, the interpreter pulls out two 0s and calculates 00, which is 1 according to JavaScript. O then prints this value, and @ ends the program.

### Double program

Watch it run!

)<@OP)<@OP


The 10-byte program is too long to fit onto a unit cube, and so it is expanded to a size-2 cube:

    ) <
@ O
P ) < @ O P . .
. . . . . . . .
. .
. .


As before, the IP starts out at the top-left of the left-most face. This time, the very first instruction is P, which pushes a 1 as before. Next is ), which increments the top item, turning it into a 2. Then < turns the IP around, and it hits the ) again, transforming the 2 into a 3.

Here's where it gets interesting. P raises the second-from-top item to the power of the first item, which gives 03 = 0. Then the IP wraps around to the rightmost face and passes through two no-ops . before hitting another P. Here we see another quirk of Cubix: binary operators (such as P) don't remove their operands from the stack. So since the stack is now [3, 0], we calculate 30 = 1, which O outputs, and @ terminates the program.

### Triple program

Watch it run!

)<@OP)<@OP)<@OP


As with the double program, the triple can fit on a size-2 cube:

    ) <
@ O
P ) < @ O P ) <
@ O P . . . . .
. .
. .


This program starts out in the same way as the previous: P pushes 1, ) increments, < points the IP west, ) increments again, and P now pushes 0. The IP is then wrapped around to the < on the rightmost face, which does nothing since the IP is already pointed west.

Here is the one difference from the double program: the ) increments the 0 on top of the stack to a 1. When P performs its magic again, this time it calculates 31 = 3. O outputs and @ terminates, and we prove conclusively that the third time is indeed the charm.

• I really enjoyed your explanation. +1 – workoverflow Mar 16 '18 at 16:56

# Brain-Flak, 10 bytes

<>([]{}())


Try it online!

Try it doubled!

Try it tripled!

Explanation:

#Toggle stacks
<>

#Push
(
#Stack-height (initially 0) +
[]

#The TOS (initially 0) +
{}

#1
()
)


When we run this once, it will put (0 + 0 + 1) == 1 onto the alternate stack. Ran a second time, it puts the same onto the main stack. Run a third time however, it evaluates to (1 + 1 + 1) == 3, and pushes that to the alternate stack and implicitly prints.

## SQL, 2524 23 bytes

(-1 Byte Removed a mistyped character that was always commented out and doing nothing)
(-1 Byte Changed SELECT to PRINT as recommended by Razvan Socol)

PRINT 2/*
*2+1--*/-1
--


How it works:
In SQL, you can comment out the comment tags, like so:

/*
'Comment'--*/


vs

--/*
'Not Comment'--*/


Code on 1 line with comments excluded:
First iteration: SELECT 2-1 Output: 1
Second iteration: SELECT 2-1*2+1 Output: 1
Third iteration: SELECT 2-1*2+1*2+1 Output: 3

• PRINT instead of SELECT would save an extra byte. – Razvan Socol Mar 24 '18 at 9:07

# SOGL V0.12, 75 4 bytes

ē»«I


Try it here!

Try it doubled!

Try it tripled!

Explanation:

ē»«I
ē     push counter, then increment it.
First time running this will push 0, then 1, then 2.
TOS on each: 0  1  2
»    floor divide by 2   0  0  1
«   multiply by 2       0  0  2
I  and increment       1  1  3

• I tried to do something along the lines of ē1|, but apparently there's no command for bitwise OR... – ETHproductions Mar 13 '18 at 2:43
• @ETHproductions Yeah, I wanted to try something like that too, and the best I got was ē:2\+ :/ – dzaima Mar 13 '18 at 19:55

# 05AB1E, 6 5 bytes

.gDÈ+


Explanation

.g     # push length of stack
D    # duplicate
È   # check if even


Single: 0 + (0 % 2 == 0) -> 1
Double: 1 + (1 % 2 == 0) -> 1
Triple: 2 + (2 % 2 == 0) -> 3

• Should that be % 2 in the triple explanation? – LarsW Mar 12 '18 at 18:01
• @LarsW: Yes indeed :) – Emigna Mar 12 '18 at 19:42
• @Emigna I think "check if even" is actually 2%_ right? – Magic Octopus Urn Mar 15 '18 at 11:36
• 2 + (2 % 2 == 0) -> 2 but 2 + !(2 % 2 == 0) -> 3 (for your explanation). – Magic Octopus Urn Mar 15 '18 at 11:36
• @MagicOctopusUrn 2%_ is the same as È yes. Not sure what you mean about the explanation. 2+(2%2==0) = 2+(0==0) = 2+1 = 3. It probably would have been clearer if I had explanded the computations. – Emigna Mar 15 '18 at 11:49

# ><>, 9 bytes

\5 n;
\\1


Try it online!

Try it doubled!

Try it tripled!

I found this sort of by luck, using the philosophy that "if you make the fish's path convoluted enough, eventually something will work". The original and doubled versions print a 5, and the tripled version prints 1 then 5 to make 15 = 3×5. Here are the multiplied versions, for your perusal:

\5 n;
\\1\5 n;
\\1

\5 n;
\\1\5 n;
\\1\5 n;
\\1


# Python 2,  46 45  39 bytes

Inspired by Halvard's answer. I'm glad that my challenge inspired a new one, which I find even more interesting. Saved 6 bytes thanks to Kevin Cruijssen.

print open(__file__,"a").tell()/79*3|1#


Try it online!

Try it doubled!

Try it tripled!

## How it works (outdated)

k=open(__file__,"a").tell() # Read the source code in "append" mode and get its length.
# Assign it to a variable k.
;print k>>(k==90)#          # Print k, with the bits shifted to the right by 1 if k
# is equal to 90, or without being shifted at all overwise.
# By shifting the bits of a number to the right by 1 (>>1),
# we basically halve it.


When it is doubled, the length becomes 90, but the new code is ignored thanks to the #, so k==90 evaluates to True. Booleans are subclasses of integers in Python, so k>>True is equivalent to k>>1, which is essentially k / 2 = 45. When it is tripled, the new code is again ignored, hence the new length is 135, which doesn't get shifted because k==90 evaluates to False, so k>>(k==90) ⟶ k>>(135==90) ⟶ k>>False ⟶ k>>0 ⟶ k, and k is printed as-is.

# Python 2, 36 bytes

This was a suggestion by Aidan F. Pierce at 38 bytes, and I golfed it by 2 bytes. I’m not posting this as my main solution because I didn’t come up with it by myself.

0and""
True+=1
print True>3and 3or 1

• Thanks for the idea of using a comment - saved me 6 bytes. – AdmBorkBork Mar 12 '18 at 14:40
• print open(__file__,"a").tell()/79*3|1# perhaps? – Kevin Cruijssen Mar 12 '18 at 14:48
• @KevinCruijssen Great, thanks! – Mr. Xcoder Mar 12 '18 at 14:51
• One fewer byte, no source code reading: tio.run/##K6gsycjPM/r/… Prints with leading spaces for two and three repetitions, but that appears to be allowed. – praosylen Mar 13 '18 at 3:28
• @AidanF.Pierce Thank you so much! I golfed it a bit more and posted it as an alternate solution. – Mr. Xcoder Mar 13 '18 at 5:30

# R, 3731 28 bytes

Thanks to Giuseppe for golfing off the final 3 bytes.

length(readLines())%/%2*2+1


(with a trailing newline).

Try it once!

Try it twice!

Try it thrice!

This uses the readLines() trick from Giuseppe's answer to the 8-ball challenge, where stdin redirects to the source file. This code basically just counts up how many lines exist below the first line and outputs 1 if there are 1 or 3 lines (i.e. code is single or doubled), or 3 if there are 5 lines (i.e. code is tripled).

• oh, neat, +1! Wasn't sure how to do this in R. I think you need a newline after the s for this to work properly, BUT you should be able to golf it to 28 bytes by re-working some of the calculations. – Giuseppe Mar 12 '18 at 21:41
• @Giuseppe Thanks for pointing out the newline problem! I wasn't able to get your version to work when the code is tripled - am I missing something? – rturnbull Mar 12 '18 at 21:47
• oh weird I musta had a trailing newline, but if you do %/%2 it should work – Giuseppe Mar 12 '18 at 21:48

# Lost, 38 bytes

\\<<<<</<<<<>
2>((1+@>?!^%^
.........v


Try it online!

\\<<<<</<<<<>
2>((1+@>?!^%^
.........v\\<<<<</<<<<>
2>((1+@>?!^%^
.........v


Try it online!

\\<<<<</<<<<>
2>((1+@>?!^%^
.........v\\<<<<</<<<<>
2>((1+@>?!^%^
.........v\\<<<<</<<<<>
2>((1+@>?!^%^
.........v


Try it online!

## Explanation

Lost is a very interesting language for this challenge. The usual Lost technique is to build a "trap". A trap is a section of the program designed to catch all the ips in one place so that their stacks can be cleared and they can be controlled to go in a specific direction. This makes writing programs in Lost a lot more manageable. However since the program is duplicated we need to avoid trap duplication as well. This requires us to design a new trap that works properly but when duplicated only one of the traps works. My basic idea here is the following

v<<<<>
>%?!^^


While the stack is non-empty the ? will remove a item and cause it to jump back to the begining if that item is non-zero. The key here is that when this stacks the ^^s line up

v<<<<>
>%?!^^v<<<<>
>%?!^^v<<<<>
>%?!^^v<<<<>
>%?!^^v<<<<>
>%?!^^


Meaning that no matter how you enter you will always exit in the same place.

From here we can attempt to implement the same idea from my Klein answer.

\\<<<<<v<<<<>
2>((1+@>?!^%^


The backbone of our program is the left had side which pushes a number of 2s. Each time we add a copy of the program another 2 gets added to the backbone of the program meaning an additional 2 is pushed to the stack. Once it goes off the bottom it bounces through \\> and executes the code

((1+@


This removes the first 2 stack items, adds one to the whatever is left, and exits. Once our backbone has 3 2s we will add 1 and get 3, if we have any less than 3 items we will just discard the entire stack and return 1.

Now the only problem left is that the ! in our program can cause an infinite loop. If the ip starts on ! going upwards it will jump and land right back where it was. This means we have to add another line underneath to prevent the loop.

\\<<<<</<<<<>
2>((1+@>?!^%^
.........^


This has the slight problem of putting some slashes in between our ^s in the trap. However, rather miraculously, everything works out. Our ips bounce around properly so that it doesn't make a difference.

• – Jo King Dec 19 '18 at 4:49
• @joking unfortunately I'm stuck on mobile for the time being. Could you post it as an answer with an explanation? – Wheat Wizard Dec 19 '18 at 21:28
• Posted – Jo King Dec 19 '18 at 22:26

# Stax, 5 bytes

|dhH^


## Explanation

|dhH^
|d       Push Current stack depth d, originally 0
Doubled -> 1, Tripled -> 2
hH^    Map d to 2*(floor(d/2))+1
Implicit print


# C (gcc), 9591 85 bytes

#ifndef a
#define a-1
main(){puts(3
#include __FILE__
?"1":"3");}
#define a
#endif
a



Try it online!

• Then I suggest that you edit the correct TIO link in. – Erik the Outgolfer Mar 12 '18 at 15:58
• I sometimes can't connect to TIO, I don't know why – l4m2 Mar 12 '18 at 15:59

# Japt, 86 5 bytes

-1 byte thanks to @ETHproductions

°U-v



## Explanation:

°U-v
U     # variable U=0                # U=0
°U     # ++U                         # U=1
-    # minus:
v   #   1 if U is divisible by 2
#     else
#   0                         # U=1


This evaluates to 1-0 = 1

Doubled evaluates to 2-1 = 1

Tripled evaluates to 3-0 = 3

• Rearranging a little, I think you can do °U-v (plus newline) to save on the second U. – ETHproductions Mar 13 '18 at 2:27
• @ETHproductions Thanks! v is perfect for this challenge :-) – Oliver Mar 13 '18 at 2:52

# Pure Bash (no wc or other external utils), 27

trap echo\ $[a++&2|1] EXIT  • – GammaFunction Sep 6 '19 at 19:12 # Perl 5, 18151312 11 bytes -3 bytes thanks to nwellnhof say 1| +.7#  Once Try it online! Twice Try it online! Thrice Try it online! • n;$_=$a++|1;say (15 bytes) – nwellnhof Mar 13 '18 at 4:25 • @nwellnhof Of course!. Thanks. – Ton Hospel Mar 13 '18 at 6:31 # ><>, 10 9 8 bytes 562gn|  Try it online! Try it doubled! Try it tripled! I'm sure there's an 8 byte solution somewhere out there. The unprintable at the end has ASCII value 1, and is only fetched by the get command on the third iteration. For the first two it prints 05, and then prints 15. • The 8 byte solution is proving elusive, but here are a couple more 9 byte ones in case they inspire you: TIO, TIO – Not a tree Mar 13 '18 at 17:04 • @Notatree Got the 8 byte with an unprintable – Jo King Mar 14 '18 at 9:20 ## C (gcc), 107 bytes My first submission in C (gcc). Way too long ... i; #ifdef c #define c #ifdef b i=2; #else #define b #endif #else #define c main(){putchar(i+49);} #endif c  TIO links: single, double, triple. # Labyrinth, 1211 9 bytes :#%!@ 7  # JavaScript, 81 77 74 70 bytes Saved 4 bytes thanks to Shaggy var t,i=(i||[3,1,1]),a=i.pop() clearTimeout(t) t=setTimeout(alert,9,a) Pretty lame JS solution. Consumes the values from the [3,1,1] array from the right (pop()). Registers a timeout to display the current value in the future. If a timeout was already registered, cancel it. Relies on the dirty nature of var, which hoists variable declarations. ## Two times: var t,i=(i||[3,1,1]),a=i.pop() clearTimeout(t) t=setTimeout(alert,9,a) var t,i=(i||[3,1,1]),a=i.pop() clearTimeout(t) t=setTimeout(alert,9,a) ## Three times: var t,i=(i||[3,1,1]),a=i.pop() clearTimeout(t) t=setTimeout(alert,9,a) var t,i=(i||[3,1,1]),a=i.pop() clearTimeout(t) t=setTimeout(alert,9,a) var t,i=(i||[3,1,1]),a=i.pop() clearTimeout(t) t=setTimeout(alert,9,a) • This needs a trailing semi-colon or newline in order to work but you can save 4 bytes by passing a as the 3rd argument of setTimeout: setTimeout(alert,9,a) – Shaggy Mar 12 '18 at 15:52 • @Shaggy Thanks! It works fine even without an extra semi-colon. – Cristian Lupascu Mar 12 '18 at 21:30 # C (gcc), 53 52 bytes Note the space after #endif. n;main(){putchar(n+49);} #if __LINE__>7 n=2; #endif  Try it online! # Charcoal, 12 bytes ⎚≔⁺ι¹ιＩ⁻ι⁼ι²  Try it online! Link is to verbose code. Try it doubled! Try it tripled! ### Explanation ⎚ Clear ≔⁺ι¹ι Assign plus(i, 1) to i Ｉ Cast (and implicitly print) ⁻ ⁼ι² Subtract equals(i, 2) from ι i  • MapAssignRight(Plus, 1, i) saves you a byte, which gets you down to the same length as a port of my answer to @Mr. XCoder's challenge: ＰＩ∨›³Ｌ⊞Ｏυω³ – Neil Mar 12 '18 at 16:23 • ＰＩ⊕⊗÷Ｌ⊞Ｏυω³ is another version of my answer, but still 11 bytes... – Neil Mar 12 '18 at 16:26 • Found a 10-byter! – Neil Mar 12 '18 at 17:11 • :/ I should really fix MapAssign(Incremented, i) – ASCII-only Mar 12 '18 at 22:29 # JavaScript, 43 40 Bytes var t=t?--t:~!setTimeoutt=alert(1|~t); 2x: var t=t?--t:~!setTimeoutt=alert(1|~t);var t=t?--t:~!setTimeoutt=alert(1|~t); 3x: var t=t?--t:~!setTimeoutt=alert(1|~t);var t=t?--t:~!setTimeoutt=alert(1|~t);var t=t?--t:~!setTimeoutt=alert(1|~t); • p.s. this solution doesn't break the environment – l4m2 Mar 12 '18 at 16:12 # PowerShell, 544845 44 bytes if(99-gt(gc$PSCOMMANDPATH|wc -c)){1;exit}3#


Try it online!

Try it doubled!

Try it tripled!

Gets its own invocation path with $PSCOMMANDPATH and performs a get-content on the file. If the character count of that file is less than 99 (checked via wc -c from coreutils), then we output 1 and exit (i.e., stop execution). That accounts for the original code and the doubled code. Otherwise we output 3 and exit. The actual code that's in the doubled or tripled sections is meaningless, since either we'll exit before we get to it, or it's behind a comment #. Saved 6 bytes thanks to Mr. Xcoder Saved 3 4 bytes thanks to Pavel • @Pavel Aha, yes. I need to swap around the -lt99 to a 99-gt to get the casting to work correctly, but that is indeed one byte shorter. Thanks! – AdmBorkBork Mar 12 '18 at 16:55 ## C# (178 Bytes) Console.WriteLine(1+2*4%int.Parse(System.Configuration.ConfigurationManager.AppSettings["z"]=(int.Parse(System.Configuration.ConfigurationManager.AppSettings["z"]??"0"))+1+""));  crazy C# solution, but I am happy it's possible in one line in C# at all. :) For me the hardest part was having valid C# that would either intialize or increment the same variable, so I ended up abusing the ConfigurationManager because I needed a global static NameValueCollection and ConfigurationManager was the only one I could think of that I could update in memory. EnvironmentVariables was another option I Iooked at but it doesn't have an indexer so I am not sure how to do that in one line that can be copy pasted to produce the required output as per the spec. # Runic Enchantments, 35 bytes ^w3'\ f 1 /1@ / '54\w /yyy  Try it online! Working on this one allowed me to find an error in my parser dealing with the new delay modifier characters, although the final result ends up not being affected by it, as I ended up not needing them. Functions due to the fact that the final line does not have a trailing newline (or for that matter, trailing spaces), allowing the duplicate IPs to spawn in a different place. The top-left one ends up making a large loop around the grid while the second IP performs a Reflection operation to replace the \ on the 6th line with a . This IP then will loop forever and do nothing. The third IP also makes this same replacement at the same time, but because it's situated on the 13th line, its copy of that reflector sends it upwards and it executes the 1f'3w sequence present in the upper right corner, which replaces the 1 with a 3 on the 14th line, just before the original IP executes it, causing the tripled program to output 3 instead of 1 (values could also be 2 and 6, 3 and 9, 4 and 12, or 5 and 15 due to the availability of a-f numerical constants; 1 and 3 were chosen arbitrarily). It is then left in an endless loop performing more reflection commands that do nothing. Try it in triplicate! • 29 bytes, though I think I could get it lower if I actually understood it :P – Jo King Dec 19 '18 at 5:47 • @JoKing Not really surprised that a lot of that whitespace could come out. Did this one at work and due to running into an issue with the interpreter I was happy just to get something that worked (my original was 52 bytes and after getting the interpreter fixed, I was able to remove a good chunk). – Draco18s no longer trusts SE Dec 19 '18 at 14:16 # Lost, 27 bytes \\<<<<//<<<> 2>((1+@>((%^ v  Try it online! Try it doubled! Try it tripled! This is mostly an improvement of Post Left Garf Hunter's answer that removes all the pesky no-ops from that last line, To do this, we have to remove the !, otherwise the program always gets stuck in a loop. So we change the clearing section from >?!^%^ to >))%^' since there can only be a max of two elements on the stack anyway. Unfortunately, this means that the path from the extra copies to the original is broken, so we place an extra / in the first line to compensate. This forces the pointer to go through the clearing section for all copies of the program until it reaches the first one, where the ^ instead redirects it to the > instead. # Perl 5, 28 25 bytes -3 bytes thanks to @neil! print"\e[D$a"if(++$a!=2);  Moves the cursor backwards (does nothing on start of line) and prints the value of $a, first and third time (i.e., the third time a 1 is printed, the cursor moves, and a 3 is printed on the position of the 1).

• print"\e[D$a"if(++$a!=2); perhaps? – Neil Mar 12 '18 at 17:15