Skip to main content
deleted 235 characters in body
Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, 27 2325 bytes

2-1+!1-length(readLines())

Try it online!Try it online!

Inspired by rturnbull's answer to Third time the charm, but the simplicity of the check makes it shorter.

Try it doubledDoubled | Tripled | Quadrupled

Why this works:

readLines() will actually reads the source file itself rather than stdin. Hence, adding lines just increments the tripledlength() of the vector returned by readLines(). Therefore, we compute !(1-length()) to obtain 1 whenever length()==1 and quadrupled0 when length()!=1, adding one to have the desired effect.

R, 27 23 bytes

2-!length(readLines())

Try it online!

Inspired by rturnbull's answer to Third time the charm, but the simplicity of the check makes it shorter.

Try it doubled, tripled, and quadrupled.

R, 27 25 bytes

1+!1-length(readLines())

Try it online!

Inspired by rturnbull's answer to Third time the charm, but the simplicity of the check makes it shorter.

Doubled | Tripled | Quadrupled

Why this works:

readLines() will actually reads the source file itself rather than stdin. Hence, adding lines just increments the length() of the vector returned by readLines(). Therefore, we compute !(1-length()) to obtain 1 whenever length()==1 and 0 when length()!=1, adding one to have the desired effect.

added 2 characters in body
Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, 2727 23 bytes

1+(2-!length(readLines())==1)

Try it online!Try it online!

Inspired by rturnbull's answer to a related questionThird time the charm, but the simplicity of the check makes it a byte shorter.

Try it doubledTry it doubled, tripledtripled, and quadrupledquadrupled.

R, 27 bytes

1+(length(readLines())==1)

Try it online!

Inspired by rturnbull's answer to a related question, but the simplicity of the check makes it a byte shorter.

Try it doubled, tripled, and quadrupled

R, 27 23 bytes

2-!length(readLines())

Try it online!

Inspired by rturnbull's answer to Third time the charm, but the simplicity of the check makes it shorter.

Try it doubled, tripled, and quadrupled.

Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, 27 bytes

1+(length(readLines())==1)

Try it online!

Inspired by rturnbull's answer to a related question, but the simplicity of the check makes it a byte shorter.

Try it doubled, tripled, and quadrupled