Double-time is not double time

36

1

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!

Skidsdev

Posted 2017-07-17T08:22:47.847

Reputation: 9 656

@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 – Skidsdev – 2017-07-17T08:28:14.160

It seems like a dupe to me. – Erik the Outgolfer – 2017-07-17T08:35:42.997

@EriktheOutgolfer Very similar but I'm sure this one is going to be a lot harder (unless I'm missing something obvious). – TheLethalCoder – 2017-07-17T08:37:16.413

@EriktheOutgolfer and it's duplicating each character, not the entire source. So ABC becomes AABBCC rather than ABCABC – Skidsdev – 2017-07-17T08:39:42.940

@Mayube Oh I get it. – Erik the Outgolfer – 2017-07-17T08:40:59.667

9Duplicating characters may make trivial languages unrunnable. I wonder if there is a solution in a not single-character-command-styled or expression-based language. – Keyu Gan – 2017-07-17T10:35:20.410

@KeyuGan More than likely not unless you can do something clever with comments. – TheLethalCoder – 2017-07-17T11:07:28.183

3@TheLethalCoder Maybe the biggest obstacle is full program. It is hard to imagine a duplicated program still have a valid entry point / function. – Keyu Gan – 2017-07-17T14:52:07.970

So it only has to be able to do so once? that's not much of a challenge, is it? – tuskiomi – 2017-07-17T16:34:40.733

Would you consider linking to the new homepage?

– Frenzy Li – 2017-07-18T09:01:50.920

@FrenzyLi done. I don't use the osu site enough to even realise there was a new homepage :P – Skidsdev – 2017-07-18T09:09:52.730

@KeyuGan There is a full-program solution in at least one non-golfing language. Here.

– GammaFunction – 2019-09-08T00:05:19.513

Answers

22

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

LiefdeWen

Posted 2017-07-17T08:22:47.847

Reputation: 3 381

1Hey, 4/6vt works as well... – officialaimm – 2017-07-17T11:25:43.533

18I wholeheartedly approve of the strategy of picking a random TIO language and learning it for a challenge – Skidsdev – 2017-07-17T11:25:59.677

@officialaimm you are right, thanks. – LiefdeWen – 2017-07-17T11:28:55.987

14/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. – V. Courtois – 2017-07-17T12:12:04.953

1Wouldn't 46vt do the same? – Veedrac – 2017-07-17T17:20:12.040

21

Jelly, 2 bytes

!‘

Try it online!

Explanation:

!‘ Implicit 0
!  Factorial
 ‘ Increment

Doubled version:

!!‘‘

Try it online!

Explanation:

!!‘‘ Implicit 0
!    Factorial
 !   Factorial
  ‘  Increment
   ‘ Increment

Erik the Outgolfer

Posted 2017-07-17T08:22:47.847

Reputation: 38 134

If you do it a third time it goes from 3 -> 4, not 3->4.5?? – tuskiomi – 2017-07-17T16:19:02.683

@tuskiomi No because it's not expected to do so. – Erik the Outgolfer – 2017-07-17T16:21:09.637

14

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

tsh

Posted 2017-07-17T08:22:47.847

Reputation: 13 072

1clever language choice! – Giuseppe – 2017-07-18T02:34:54.267

11

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

Luis Mendo

Posted 2017-07-17T08:22:47.847

Reputation: 87 464

7TnQ for the answer... :D [We sometimes use tnq as a short-form for thank-you] – officialaimm – 2017-07-17T11:30:40.653

8

@officialaimm :) [we sometimes use that to get the first n elements from an array...]

– Luis Mendo – 2017-07-17T13:39:48.197

10

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.

tsh

Posted 2017-07-17T08:22:47.847

Reputation: 13 072

How is it supposed to do 33? TIO doesn't seem able to do it. It locks on 00. – V. Courtois – 2017-07-17T12:07:53.427

1How about: 3/3*22 – Alex Varga – 2017-07-17T21:21:21.753

@AlexVarga so sweet. – tsh – 2017-07-18T01:17:45.613

@V.Courtois you are using strict mode – tsh – 2017-07-18T01:18:59.963

@tsh how do I prevent using strict mode?? I thought it used strict only if the code began with use strict; – V. Courtois – 2017-07-18T04:26:32.217

Is there a reason Node.js is specified as opposed to just JavaScript? – ESR – 2017-07-18T04:32:36.107

1@EdmundReed need -p flag to output expression value – tsh – 2017-07-18T05:29:41.120

10

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

Doorknob

Posted 2017-07-17T08:22:47.847

Reputation: 68 138

10

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.

Carl Schildkraut

Posted 2017-07-17T08:22:47.847

Reputation: 403

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. – Post Rock Garf Hunter – 2017-07-18T03:57:58.843

@WheatWizard Thanks, and thanks for helping! Did I do this properly? – Carl Schildkraut – 2017-07-18T21:16:57.970

8

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

Uriel

Posted 2017-07-17T08:22:47.847

Reputation: 11 708

Could you please align the comments vertically? Or do we have different settings or something causing it on my end to loop like this?

– Kevin Cruijssen – 2017-07-17T11:44:34.617

@KevinCruijssen I think that's your browser font, but browsers doesn't render APL as monospaced anyways. that mine http://prntscr.com/fwp0l0

– Uriel – 2017-07-17T11:47:04.223

Ah well, it's still readable and a great answer regardless. :) – Kevin Cruijssen – 2017-07-17T12:00:58.533

It renders as monospace for me. Probably just depends on the font (https://prnt.sc/fwrnz1). The comments are definitely not aligned though :P

– 2xsaiko – 2017-07-17T15:02:09.170

@therealfarfetchd thanks, I've updated the last 3 rows – Uriel – 2017-07-17T15:13:31.643

5

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

Erik the Outgolfer

Posted 2017-07-17T08:22:47.847

Reputation: 38 134

5

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

Business Cat

Posted 2017-07-17T08:22:47.847

Reputation: 8 927

The overloads are tricky...;) – Erik the Outgolfer – 2017-07-17T16:41:49.337

AB], also works. – geokavel – 2017-07-17T17:03:26.433

4

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

Erik the Outgolfer

Posted 2017-07-17T08:22:47.847

Reputation: 38 134

4

Neim, 2 bytes

>

Try it online!

Explanation:

> Implicit 0
  Factorial
 > Increment

Doubled version:

>>

Try it online!

>> Implicit 0
    Factorial
    Factorial
  >  Increment
   > Increment

Erik the Outgolfer

Posted 2017-07-17T08:22:47.847

Reputation: 38 134

4 out of the 5 answers... you're really going for it on this one! – TheLethalCoder – 2017-07-17T09:30:22.363

5@TheLethalCoder At least it's not 15 yet. ;) – Erik the Outgolfer – 2017-07-17T09:32:10.380

3

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

Erik the Outgolfer

Posted 2017-07-17T08:22:47.847

Reputation: 38 134

1one he11 of an answer – Uriel – 2017-07-17T14:33:59.857

3

R, 11 bytes

8*(!0)+1*!1

Try it online!

! is negation, and ** is exponentiation (an alias for ^). Numerics get converted to booleans: 0 to FALSE, all others to TRUE. Booleans get converted to integers: FALSE to 0, TRUE to 1, so !0==1, !1==0, !!00==0 and !!11==1.

The single version thus computes \$8\times 1 + 1\times 0=8\$, and the double version computes \$88^0+11^1=12\$.

Robin Ryder

Posted 2017-07-17T08:22:47.847

Reputation: 6 625

1I was just trying to come up with a solution relying on * and **, but you beat me to it! – Giuseppe – 2019-09-10T19:37:40.480

@Giuseppe I'm not convinced my solution is optimal (the need for brackets around !0 is annoying). There might be something shorter with - and *, but I haven't found such a solution yet... – Robin Ryder – 2019-09-10T21:22:24.360

2

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

KSmarts

Posted 2017-07-17T08:22:47.847

Reputation: 1 830

5I think you're supposed to duplicate the newlines too. – Erik the Outgolfer – 2017-07-17T16:37:55.723

@EriktheOutgolfer There aren't newlines anymore. – KSmarts – 2017-09-28T18:02:20.137

2

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!

Giuseppe

Posted 2017-07-17T08:22:47.847

Reputation: 21 077

2

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.

Post Rock Garf Hunter

Posted 2017-07-17T08:22:47.847

Reputation: 55 382

2

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.

pizzapants184

Posted 2017-07-17T08:22:47.847

Reputation: 3 174

Technically the challenge spec explicitly states when each character is doubled, but I'll allow this and update the spec – Skidsdev – 2017-07-18T15:48:17.070

2

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.

m-chrzan

Posted 2017-07-17T08:22:47.847

Reputation: 1 390

1

Zsh, 14 bytes

<:|echo 22
3
:

Try it online!

Getting a full program in a non-golfing language to print anything with source code duplicated like this is a challenge. Zsh is very useful for this, because files and heredocs are implicitly passed to cat. Let's take a look at the first line in both cases:

<:|echo 22            # Give the file : on stdin to cat. cat pipes to 'echo 22', which ignores stdin
<<::||eecchhoo  2222  # Start heredoc on following lines with EOF string '::', pass to cat.
                      # Since cat exits 0, 'eecchhoo 2222' is not executed

So long as 3 is not a program, the first program will only print 22. The second program will print 33 surrounded by extra newlines (due to the duplication).


If 3 is a function/program/alias, then this 18 byte solution will still work!

<:|echo 22\\c\
3
:

Try it online!

The last \ is line continuation, so the newline is discarded, effectively making the echo statement echo '22\c3'. The \c causes echo to stop printing after 22 (which also happens to suppress the newline).

GammaFunction

Posted 2017-07-17T08:22:47.847

Reputation: 2 838

1

Stax, 3 bytes

UJ^

Run and debug it

Run and debug the doubled one

U pushes -1. J squares. ^ increments.

recursive

Posted 2017-07-17T08:22:47.847

Reputation: 8 616

1

Perl 6, 14 bytes

'|d 3#';say 22

Try it online! Try it doubled!

This uses the conveniently named debug function dd to output the doubled program to STDERR. To separate the logic we encase the doubled program in quotes, which then cancel each other out when doubled, along with a comment character # to comment out the now invalid normal program.

Jo King

Posted 2017-07-17T08:22:47.847

Reputation: 38 234

0

MathGolf, 2 bytes

▬)

Try it online! Try it doubled

Similar to other answers in that the first instruction produces a 1 even when doubled and the second increments it. In this case, I've used reverse exponentiation (0**0 = 0**0**0 = 1) but it also could have been any of the !£≤° instruction and perhaps even more that I missed.

Jo King

Posted 2017-07-17T08:22:47.847

Reputation: 38 234

0

Japt, 2 bytes

Another "factorial+1" solution.

ÊÄ

Test it

ÊÊÄÄ

Test it

Shaggy

Posted 2017-07-17T08:22:47.847

Reputation: 24 623