5 added 489 characters in body
source | link

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

Try it online! Try it doubled! Try it tripled!

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,  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

Try it online! Try it doubled! Try it tripled!

4 deleted 258 characters in body
source | link

Python 2,  46  46 45  4539 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.

k=openprint open(__file__,"a").tell();print k>>(k==90)#/79*3|1#

Try it online!Try it online!

Try it doubled!Try it doubled!

Try it tripled!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,  46  45 bytes

Inspired by Halvard's answer. I'm glad that my challenge inspired a new one, which I find even more interesting.

k=open(__file__,"a").tell();print k>>(k==90)#

Try it online!

Try it doubled!

Try it tripled!

How it works

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,  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.

3 added 57 characters in body
source | link

Python 2,  46  45 bytes

Inspired by Halvard's answer to the other. I'm glad that my challenge inspired a new one, which I find even more interesting.  

  
k=open(__file__,"a").tell();print k>>(k==90)#

Try it online!

Try it doubled!

Try it tripled!

How it works

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,  46  45 bytes

Inspired by Halvard's answer to the other challenge.  

 
k=open(__file__,"a").tell();print k>>(k==90)#

Try it online!

Try it doubled!

Try it tripled!

Python 2,  46  45 bytes

Inspired by Halvard's answer. I'm glad that my challenge inspired a new one, which I find even more interesting.

 
k=open(__file__,"a").tell();print k>>(k==90)#

Try it online!

Try it doubled!

Try it tripled!

How it works

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.

2 added 57 characters in body
source | link
1
source | link