34
\$\begingroup\$

Based on this challenge.

In the rhythm game osu!, the difficulty modifier "Double-time" actually only increases the speed by 50%.

Your task, is to write a program that outputs a positive even integer (higher than 0), and when each byte/character (your choice which) in your source code is duplicated, it should output the number multiplied by 1.5.

For example if your source code is ABC and that outputs 6, then AABBCC should output 9.

Following the original challenge's rules:

Rules

  • You must build a full program.
  • 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) and must not throw any error (compiler warnings are not considered errors).
  • Outputting the integers with trailing / leading spaces is allowed.
  • You may not assume a newline between copies of your source.
  • This is , so the fewest bytes in each language wins!
  • Default Loopholes apply.

I imagine this will be far less trivial than the original challenge, but hopefully we'll see some creative and unique answers!

\$\endgroup\$
  • \$\begingroup\$ @Fatalize write a program that outputs a positive even integer Yes it will. Every even number can be multiplied by 1.5 to result in a whole integer \$\endgroup\$ – Skidsdev Jul 17 '17 at 8:28
  • \$\begingroup\$ It seems like a dupe to me. \$\endgroup\$ – Erik the Outgolfer Jul 17 '17 at 8:35
  • \$\begingroup\$ @EriktheOutgolfer Very similar but I'm sure this one is going to be a lot harder (unless I'm missing something obvious). \$\endgroup\$ – TheLethalCoder Jul 17 '17 at 8:37
  • 8
    \$\begingroup\$ Duplicating characters may make trivial languages unrunnable. I wonder if there is a solution in a not single-character-command-styled or expression-based language. \$\endgroup\$ – Keyu Gan Jul 17 '17 at 10:35
  • 1
    \$\begingroup\$ @TheLethalCoder Maybe the biggest obstacle is full program. It is hard to imagine a duplicated program still have a valid entry point / function. \$\endgroup\$ – Keyu Gan Jul 17 '17 at 14:52

18 Answers 18

21
\$\begingroup\$

Pylons, 7 5 4 bytes

Picked a random language on TIO used it

46vt

Explanation:

Try it Online!

46    # Stack is [4, 6]

v     # Reverse the stack [6, 4]

t     # take top of stack 4

Doubled:

4466   # Stack is [4, 4, 6, 6]

vv     # Reverse the stack twice so it's the same [4, 4, 6, 6]

tt     # take top of stack 6 and again which is 6 again

Saved 2 bytes thanks to officialaimm

Saved 1 bytes thanks to Veedrac

\$\endgroup\$
  • 1
    \$\begingroup\$ Hey, 4/6vt works as well... \$\endgroup\$ – officialaimm Jul 17 '17 at 11:25
  • 16
    \$\begingroup\$ I wholeheartedly approve of the strategy of picking a random TIO language and learning it for a challenge \$\endgroup\$ – Skidsdev Jul 17 '17 at 11:25
  • \$\begingroup\$ @officialaimm you are right, thanks. \$\endgroup\$ – LiefdeWen Jul 17 '17 at 11:28
  • 1
    \$\begingroup\$ 4/6 <- 4 divided by nothing -> 4 ; and then 6. 44//66 <- 4 divided by 4 -> 1 ; nothing divided by nothing -> nothing ; and then 6 and 6. Maybe. Well done though. \$\endgroup\$ – V. Courtois Jul 17 '17 at 12:12
  • 1
    \$\begingroup\$ Wouldn't 46vt do the same? \$\endgroup\$ – Veedrac Jul 17 '17 at 17:20
18
\$\begingroup\$

Jelly, 2 bytes

!‘

Try it online!

Explanation:

!‘ Implicit 0
!  Factorial
 ‘ Increment

Doubled version:

!!‘‘

Try it online!

Explanation:

!!‘‘ Implicit 0
!    Factorial
 !   Factorial
  ‘  Increment
   ‘ Increment
\$\endgroup\$
  • \$\begingroup\$ If you do it a third time it goes from 3 -> 4, not 3->4.5?? \$\endgroup\$ – tuskiomi Jul 17 '17 at 16:19
  • \$\begingroup\$ @tuskiomi No because it's not expected to do so. \$\endgroup\$ – Erik the Outgolfer Jul 17 '17 at 16:21
11
\$\begingroup\$

LibreOffice Calc, 8 bytes

=A2+3
19

Save it as *.csv and open it in LibreOffice Calc. You will get 22 in A1.


Double them:

==AA22++33

1199

You will get 33 in A1

\$\endgroup\$
  • \$\begingroup\$ clever language choice! \$\endgroup\$ – Giuseppe Jul 18 '17 at 2:34
10
\$\begingroup\$

MATL, 3 bytes

TnQ

Try it online! Or doubled version.

Explanation

In MATL a scalar value (number, char, logical value) is the same as a 1×1 array containing that value.

Normal version:

T    % Push true
n    % Number of elements of true: gives 1
Q    % Add 1: gives 2

Doubled version:

TT   % Push [true, true]
n    % Number of elements of [true, true]: gives 2
n    % Number of elements of 2: gives 1
Q    % Add 1: gives 2
Q    % Add 1: gives 3
\$\endgroup\$
  • 7
    \$\begingroup\$ TnQ for the answer... :D [We sometimes use tnq as a short-form for thank-you] \$\endgroup\$ – officialaimm Jul 17 '17 at 11:30
  • 7
    \$\begingroup\$ @officialaimm :) [we sometimes use that to get the first n elements from an array...] \$\endgroup\$ – Luis Mendo Jul 17 '17 at 13:39
10
\$\begingroup\$

vim, 5

i1<esc>X<C-a>

Without doubling:

i1<esc>  insert the literal text "1"
X        delete backwards - a no-op, since there's only one character
<C-a>    increment, giving 2

With doubling:

ii11<esc>   insert the literal text "i11"
<esc>       escape in normal mode does nothing
XX          since the cursor is on the last character, delete "i1"
<C-a><C-a>  increment twice, giving 3
\$\endgroup\$
10
\$\begingroup\$

Not sure if this answer is valid. Just post here in case some one may got ideas from here.

Node.js with -p flag, 7 bytes

By Alex Varga:

3/3*22

33//33**2222

Node.js with -p flag, 11 bytes

Old one:

3*2*0/1+22

33**22**00//11++2222

Output 22 and 33.

\$\endgroup\$
  • \$\begingroup\$ How is it supposed to do 33? TIO doesn't seem able to do it. It locks on 00. \$\endgroup\$ – V. Courtois Jul 17 '17 at 12:07
  • 1
    \$\begingroup\$ How about: 3/3*22 \$\endgroup\$ – Alex Varga Jul 17 '17 at 21:21
  • \$\begingroup\$ @AlexVarga so sweet. \$\endgroup\$ – tsh Jul 18 '17 at 1:17
  • \$\begingroup\$ @V.Courtois you are using strict mode \$\endgroup\$ – tsh Jul 18 '17 at 1:18
  • 1
    \$\begingroup\$ @EdmundReed need -p flag to output expression value \$\endgroup\$ – tsh Jul 18 '17 at 5:29
9
\$\begingroup\$

Python 2 REPL, 11 bytes

(3/1)*(2/1)

This simply evaluates to 3*2=6. Duplicated, it is

((33//11))**((22//11))

which evaluates to 3**2, which is 3 to the power of 2, or 9.

\$\endgroup\$
  • \$\begingroup\$ Welcome to the site. This python does not produce any output and thus is not a valid answer. However if you change your answer to be a Python REPL, this does produce output and thus is a valid answer. You will either have to delete this answer or change the language from python 2 to python 2 repl. \$\endgroup\$ – Sriotchilism O'Zaic Jul 18 '17 at 3:57
  • \$\begingroup\$ @WheatWizard Thanks, and thanks for helping! Did I do this properly? \$\endgroup\$ – Carl Schildkraut Jul 18 '17 at 21:16
8
\$\begingroup\$

APL, 7 bytes

⊃⍕⌊3×⍟2

Prints 2.

⊃⊃⍕⍕⌊⌊33××⍟⍟22

Prints 3.

Try it online!

Waaat?

Single:

3×⍟2         → 2.079441542  ⍝  3 * ln 2
⌊2.079441542 → 2            ⍝  floor
⊃⍕           → '2'          ⍝  format and take first character

Double:

⍟⍟22          → 1.128508398  ⍝  ln ln 22
×1.128508398  → 1            ⍝ signum
33×1          → 33           ⍝  33 * 1
⌊⌊33          → 33           ⍝  floor
⊃⊃⍕⍕          → '3'          ⍝  format and take first character
\$\endgroup\$
  • \$\begingroup\$ Could you please align the comments vertically? Or do we have different settings or something causing it on my end to loop like this? \$\endgroup\$ – Kevin Cruijssen Jul 17 '17 at 11:44
  • \$\begingroup\$ @KevinCruijssen I think that's your browser font, but browsers doesn't render APL as monospaced anyways. that mine prntscr.com/fwp0l0 \$\endgroup\$ – Uriel Jul 17 '17 at 11:47
  • \$\begingroup\$ Ah well, it's still readable and a great answer regardless. :) \$\endgroup\$ – Kevin Cruijssen Jul 17 '17 at 12:00
  • \$\begingroup\$ It renders as monospace for me. Probably just depends on the font (prnt.sc/fwrnz1). The comments are definitely not aligned though :P \$\endgroup\$ – therealfarfetchd Jul 17 '17 at 15:02
  • \$\begingroup\$ @therealfarfetchd thanks, I've updated the last 3 rows \$\endgroup\$ – Uriel Jul 17 '17 at 15:13
5
\$\begingroup\$

Actually, 3 bytes

1u*

Try it online!

Explanation:

1u* Errors are ignored
1   Push 1
 u  Increment
  * Multiply

Doubled version:

11uu**

Try it online!

Explanation:

11uu** Errors are ignored
1      Push 1
 1     Push 1
  u    Increment
   u   Increment
    *  Multiply
     * Multiply
\$\endgroup\$
5
\$\begingroup\$

CJam, 4 bytes

],))

Try it normally!

Try it doubled!

Explanation

Normal:

]     e# Wrap the stack in an array: []
 ,    e# Get its length: 0
  ))  e# Increment twice: 2

Double:

]         e# Wrap the stack in an array: []
 ]        e# Wrap the stack in an array: [[]]
  ,       e# Get its length: 1
   ,      e# Get the range from 0 to n-1: [0]
    )     e# Pull out its last element: 0
     )))  e# Increment 3 times: 3
\$\endgroup\$
  • \$\begingroup\$ The overloads are tricky...;) \$\endgroup\$ – Erik the Outgolfer Jul 17 '17 at 16:41
  • \$\begingroup\$ AB], also works. \$\endgroup\$ – geokavel Jul 17 '17 at 17:03
4
\$\begingroup\$

05AB1E, 2 bytes

X>

Try it online!

Explanation:

X> Only top of stack is printed
X  Push X (default 1)
 > Increment

Doubled version:

XX>>

Try it online!

Explanation:

XX>> Only top of stack is printed
X    Push X (default 1)
 X   Push X (default 1)
  >  Increment
   > Increment
\$\endgroup\$
4
\$\begingroup\$

Neim, 2 bytes

𝐓>

Try it online!

Explanation:

𝐓> Implicit 0
𝐓  Factorial
 > Increment

Doubled version:

𝐓𝐓>>

Try it online!

𝐓𝐓>> Implicit 0
𝐓    Factorial
 𝐓   Factorial
  >  Increment
   > Increment
\$\endgroup\$
  • \$\begingroup\$ 4 out of the 5 answers... you're really going for it on this one! \$\endgroup\$ – TheLethalCoder Jul 17 '17 at 9:30
  • 5
    \$\begingroup\$ @TheLethalCoder At least it's not 15 yet. ;) \$\endgroup\$ – Erik the Outgolfer Jul 17 '17 at 9:32
3
\$\begingroup\$

Pyth, 3 bytes

he1

Try it here.

Explanation:

he1
h   Increment
 e   Last digit
  1   1

Doubled version:

hhee11

Try it here.

Explanation:

hhee11
h      Increment
 h      Increment
  e      Last digit
   e      Last digit
    11     11
\$\endgroup\$
  • 1
    \$\begingroup\$ one he11 of an answer \$\endgroup\$ – Uriel Jul 17 '17 at 14:33
2
\$\begingroup\$

Cubix, 6 bytes

O.1)W@

Prints 2.

  O
. 1 ) W
  @

Pushes 1, ) increments, W jumps left to O which outputs 2, and @ finishes the program.

Doubled up, it's obviously OO..11))WW@@, which on a cube is:

    O O
    . .
1 1 ) ) W W @ @
. . . . . . . .
    . .
    . .

It pushes 1 twice, ) increments twice, W jumps left again, which puts it at the right-hand O heading north, which outputs 3, and then the next command is @ which terminates the program.

Try it online!

Doubled online!

\$\endgroup\$
2
\$\begingroup\$

Klein, 8 6 bytes

/3+@4\

Single, Double

Explanation

For the single the program follows a pretty straightforward path. The first mirror deflects it into the second which deflects it through the 4 to the end of the program.

The double is a little more complex. Here it is:

//33++@@44\\

The first two mirrors work the same, however there is a new mirror due to the doubling which deflects the ip back to the beginning, it is caught by the duplicate of the first mirror and deflected towards the end. All that is run is the 33++ which evaluates to 6.

\$\endgroup\$
2
\$\begingroup\$

TI-Basic, 3 bytes

Single:

int(√(8

The last expression is implicitly returned/printed in TI-Basic, so this prints 2

Doubled:

int(int(√(√(88

Returns/prints 3

TI-Basic is a tokenized language; int(, √(, and 8 are each one byte in memory.

\$\endgroup\$
  • \$\begingroup\$ Technically the challenge spec explicitly states when each character is doubled, but I'll allow this and update the spec \$\endgroup\$ – Skidsdev Jul 18 '17 at 15:48
2
\$\begingroup\$

Ruby REPL, 8 bytes

";3#";22

The REPL only prints the last value evaluated: 22.

Doubled:

"";;33##"";;22

This time 33 is the last value evaluated. The string is discarded once again, and a # starts a comment.

\$\endgroup\$
2
\$\begingroup\$

><>, 19 8 Bytes

32b*!{n;

Prints 22
Try it online!

Explanation:

32b   push literals onto the stack: [3,2,11]
*     multiply the top two values: [3,22]
!     skip the next instruction
{     (skipped)
n     pop and print the top value from the stack (22)
;     end execution

Doubled:

3322bb**!!{{nn;;

Prints 33
Try it online!

Explanation:

3322bb push literals onto the stack: [3,3,2,2,11,11]
**     multiply top values (twice): [3,3,2,242]
!      skip next instruction
!      (skipped)
{{     rotate the stack to the left (twice): [2,242,3,3]
nn     pop and print the top two values from the stack (33)
;      end execution

Old Version:
Normal:

11+!vn;
    n
    ;

Prints 2
Try it online!

Explanation:

1    push 1 on the stack: [1]
 1    push 1 on the stack: [1,1]
  +    add top two values of the stack: [2]
   !    skip the next instruction
    v    (skipped)
     n    print the top value of the stack (2)
      ;    end execution

Doubled:

1111++!!vvnn;;
        nn
        ;;

Prints 3
Try it online!

Explanation:

1111    push four 1's on the stack: [1,1,1,1]
    +    add top two values of the stack: [1,1,2]
     +    add top two values of the stack: [1,3]
      !    skip the next instruction
       !    (skipped)
        v    change direction of execution (down)
         n    print the top value of the stack (3)
          ;    end execution

\$\endgroup\$
  • 5
    \$\begingroup\$ I think you're supposed to duplicate the newlines too. \$\endgroup\$ – Erik the Outgolfer Jul 17 '17 at 16:37
  • \$\begingroup\$ @EriktheOutgolfer There aren't newlines anymore. \$\endgroup\$ – KSmarts Sep 28 '17 at 18:02

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.