45
\$\begingroup\$

Goal:

Given two natural numbers (integers from 0 to infinity), output a number that is not the sum of those numbers, but is a natural number.

Example solutions (TI-Basic):

  • A+B+1

  • not(A+B)

Invalid solutions:

  • A+B-1 (for inputs 0,0, it returns -1, which is not natural)

  • "ABC" (ABC is not a number)

Notes:

  • The output must always be a sum of two natural numbers (which is actually just a natural number)

  • -1, undefined, infinity, NaN and Error messages are not natural numbers. For our purposes, 0 is natural (although not all mathematicians agree).

asked Feb 13, 2017 at 1:35
\$\endgroup\$
10
  • 1
    \$\begingroup\$ Maybe we take the numbers as strings and output as a string? \$\endgroup\$ Commented Feb 13, 2017 at 3:01
  • 1
    \$\begingroup\$ Can the output have leading zeroes? \$\endgroup\$ Commented Feb 13, 2017 at 8:27
  • 1
    \$\begingroup\$ I presume overflows need to be taken into account, so the result of 2^32 -1 and 2 should not be negative, right? \$\endgroup\$ Commented Feb 13, 2017 at 12:28
  • 3
    \$\begingroup\$ Just a small remark because I like to pay attention to useless details: 0 is not a natural number. If you change the first sentence to "Given two non-negative integers ...", there won't be any useless detail left for me to comment on. :) \$\endgroup\$ Commented Feb 13, 2017 at 17:11
  • 9
    \$\begingroup\$ @peech This is not true. 0 is considered a natural number under some definitions. You cannot see it because it has been deleted but there has been an extensive conversation on this matter. \$\endgroup\$ Commented Feb 13, 2017 at 17:16

94 Answers 94

1
2 3 4
43
\$\begingroup\$

RProgN, (削除) 4 (削除ここまで) (削除) 3 (削除ここまで) 1 Byte

Crossed out 4 is still 4 ;(

E

The most simple of solutions, compares if A and B are equal. Pushes true, which RProgN sees as 1, if they are the same, or false aka 0 otherwise.

Test Cases

0+0 = 1
1+たす0 = 0
0+たす1 = 0
1+たす1 = 1

Try it online!

answered Feb 13, 2017 at 1:41
\$\endgroup\$
5
  • 28
    \$\begingroup\$ I just went down the rabbit hole with your crossed out link. I rate it <s>4</s>/4 \$\endgroup\$ Commented Feb 14, 2017 at 1:10
  • 2
    \$\begingroup\$ @RohanJhunjhunwala hold my 4, I'm going in \$\endgroup\$ Commented Feb 14, 2017 at 3:20
  • 4
    \$\begingroup\$ ̶4̶ <-- u+0336 (combining character) may be a better way to do it \$\endgroup\$ Commented Feb 14, 2017 at 3:23
  • 3
    \$\begingroup\$ PSA: codegolf.stackexchange.com/questions/48100/… Original crossed out thing \$\endgroup\$ Commented Feb 27, 2017 at 23:50
  • 4
    \$\begingroup\$ @AlbertRenshaw the old PPCG crossed-out-4-a-roo? \$\endgroup\$ Commented Mar 7, 2017 at 16:36
18
\$\begingroup\$

Python, 13 bytes

[(0,0)].count

Try it online! Takes input as a tuple.

Using an object method for the function avoids the boilerplate of a lambda.

lambda a,b:a-~b # 15 bytes

Here, the idea is to map (0,0) to 1 and everything else to 0. Since only 0+0 gives a sum of 0 among natural numbers, that always avoids matching the sum.

If one could output a Boolean here, which I find shady, a byte could be saved as

(0,0).__ge__

This checks if the input tuple is at most (0,0), which is only true for (0,0). In Python, True==1 and False==0. Even more shadily, outputting via exit code and treating that as a Python Boolen would save two bytes:

[(0,0)].pop

If string I/O is allowed and leading zeroes are OK, there's the 8-byte solution

'1'.join

This concatenates a1b, which is always bigger than a+b.

answered Feb 13, 2017 at 2:05
\$\endgroup\$
3
  • 2
    \$\begingroup\$ int.__eq__ for 10 bytes \$\endgroup\$ Commented Feb 13, 2017 at 12:48
  • 1
    \$\begingroup\$ @muddyfish Yeah, I saw suever's answer too, didn't think of using equality. It returns a bool though, which I think is iffy on a challenge that asks for a number output. \$\endgroup\$ Commented Feb 13, 2017 at 13:32
  • 3
    \$\begingroup\$ IMO if it swims like a number and quacks like a number, it's reasonable to assume it's a number. \$\endgroup\$ Commented Jun 19, 2017 at 17:47
15
\$\begingroup\$

Retina, 3 bytes

 
1

Try it online!

(The first line has a space before the newline. Stack Exchange isn't very good at showing trailing whitespace.)

Input is the numbers in decimal, separated by a space (e.g. 12 34). This program just changes the space to a 1, creating a number too large to be the sum of the input numbers (it necessarily has at least 2 more digits than either, and adding two numbers produces an output with no more than 1 digit more than the larger input).

answered Feb 13, 2017 at 2:59
\$\endgroup\$
5
  • 2
    \$\begingroup\$ 0 0 should also work. \$\endgroup\$ Commented Feb 13, 2017 at 3:59
  • 1
    \$\begingroup\$ @Dennis: I was wondering about that. 010 is considered to be an integer via basically all integer parsers. I can see a potential argument that 0 8 is invalid on the basis that 018 is considered invalid octal via some integer parsers (although it's considered to be decimal 18 by others). Note that this program is quite happy to handle leading zeroes in the input, treating them as decimal; and I've written programs that output leading zeroes for other questions without people seeing a problem. Is there a relevant meta post on the subject? \$\endgroup\$ Commented Feb 13, 2017 at 4:04
  • 2
    \$\begingroup\$ Or . 1 if you don't want to return leading zeros yourself. \$\endgroup\$ Commented Feb 13, 2017 at 14:48
  • \$\begingroup\$ @MartinEnder > but is a natural number \$\endgroup\$ Commented Feb 14, 2017 at 19:43
  • \$\begingroup\$ @wizzwizz4 I'm not following. \$\endgroup\$ Commented Feb 14, 2017 at 19:44
14
\$\begingroup\$

MATL, et al. 1 byte

=

Accepts two natural numbers as inputs and compares them. If they are equal, the output is 1 and if they not equal the output is 0. This is the same approach as @ATaco's solution.

\$\endgroup\$
8
  • 3
    \$\begingroup\$ The = solution also works in Jelly for 1 byte. I thought I'd mention it in the comments as it doesn't seem worth creating a separate answer for the trivial solution. \$\endgroup\$ Commented Feb 13, 2017 at 3:01
  • \$\begingroup\$ @ais523 Updated to include that. Thanks. \$\endgroup\$ Commented Feb 13, 2017 at 3:07
  • 2
    \$\begingroup\$ Also in Stacked. Try it online! \$\endgroup\$ Commented Feb 13, 2017 at 16:36
  • \$\begingroup\$ Can you add APL and J? \$\endgroup\$ Commented Feb 14, 2017 at 18:08
  • \$\begingroup\$ @Adám Sure thing. Do you have a TIO link that I can link to? \$\endgroup\$ Commented Feb 14, 2017 at 18:19
11
\$\begingroup\$

Javascript, 10 bytes

x=>y=>!x+y

Takes 2 numbers using currying syntax like so:

(x=>y=>!x+y)(0)(0) // 1
answered Feb 13, 2017 at 21:59
\$\endgroup\$
2
  • 4
    \$\begingroup\$ Welcome to the site! :) \$\endgroup\$ Commented Feb 13, 2017 at 22:04
  • \$\begingroup\$ Thanks =) I've been reading challenges for a while, just trying to find a good place to start. \$\endgroup\$ Commented Feb 14, 2017 at 13:52
10
\$\begingroup\$

Brain-Flak, 8 bytes

({}{}())

Try it online!

This is the most readable brain-flak answer I have ever written. :)

Explanation:

( ) # Push the sum of all the following:
 {} # The first input
 {} # The second input
 () # and one

Alternate solutions (also 8 bytes):

({}[]{}) # Sum + 1
([]{}{}) # Sum + 2

There's a bunch of other solutions that only work with positive numbers:

(<{}>{})
({}<{}>)
({{}}())
({{}()})
({{}}[])
({{}[]})
answered Feb 13, 2017 at 2:57
\$\endgroup\$
0
9
\$\begingroup\$

Vim, 3 bytes/keystrokes

<C-a>gJ

Try it online!

Note that <C-a> is actually ctrl-a, which represents byte 0x01.

I love it when vim (which isn't even a programming language) can compete with golfing languages. :) Input comes in this format:

a
b

This simply increments the first number by one (This is the <C-a> part) and then joins the string representations of the two numbers together. As far as I can tell, this should never result in the sum.

answered Feb 13, 2017 at 3:06
\$\endgroup\$
7
\$\begingroup\$

TI-Basic, 3 bytes

not(max(Ans

Alternative solutions:

10^(sum(Ans 3 bytes @DestructibleWatermelon
not(sum(Ans 3 bytes
1+sum(Ans 4 bytes
Input :X=Y 5 bytes @ATaco
Input :X+not(Y 6 bytes
Input :not(X+Y 6 bytes
Input :10^(X+Y 6 bytes
Input :X+Y+1 7 bytes
Input :not(max(X,Y 7 bytes
Ans(1)=Ans(2 8 bytes
Ans(1)+not(Ans(2 9 bytes
not(Ans(1)+Ans(2 9 bytes

It's interesting that you made the question's examples in TI-Basic, but you forgot the shorter A=B (or maybe it was up to us to find out?)

answered Feb 13, 2017 at 3:05
\$\endgroup\$
4
  • 1
    \$\begingroup\$ Nobody likes it when the OP posts a super short solution in the question, making it hard to beat. \$\endgroup\$ Commented Feb 13, 2017 at 20:20
  • \$\begingroup\$ @mbomb007 I suppose, but those were only snippets and not full programs. Adding Prompt A,B: to them brings the byte count to eight bytes each. \$\endgroup\$ Commented Feb 13, 2017 at 22:14
  • 1
    \$\begingroup\$ @Timtech Exactly. I didn't want to give good answers as examples, I just wanted examples. \$\endgroup\$ Commented Feb 15, 2017 at 11:57
  • \$\begingroup\$ @JulianLachniet I understand and appreciate that :) \$\endgroup\$ Commented Feb 15, 2017 at 15:32
7
\$\begingroup\$

Brachylog, 2 bytes

+<

Try it online!

Explanation

+ The sum of the elements in the Input...
 < ...is strictly less than the Output
 (implicitely label the output with an integer respecting this constraint)

This will always result in A+B+1, if Input = [A, B].

answered Feb 13, 2017 at 9:01
\$\endgroup\$
7
\$\begingroup\$

Jelly, 2 bytes

+‘

The + adds the two inputs together then the ' increments the answer by one

Try it online!

answered Feb 13, 2017 at 16:28
\$\endgroup\$
3
  • \$\begingroup\$ This answer makes me jelly. \$\endgroup\$ Commented May 20, 2017 at 1:56
  • \$\begingroup\$ I bet it does :P \$\endgroup\$ Commented May 20, 2017 at 19:34
  • \$\begingroup\$ Technically this is not (a+b)+1 but a+(b+1) because the dyad-monad chain fG is treated as f(a, G(b)). In this case it's the same thing but technically how it works is different :P \$\endgroup\$ Commented May 17, 2018 at 12:29
5
\$\begingroup\$

Mathematica, 5 bytes

1+##&

Outputs the sum of the two arguments plus 1. For example, 1+##&[2,5] yields 8.

(Side note: Binomial almost works, although Binomial[1,0]=1 and Binomial[4,2]=6 are counterexamples; I think they're the only counterexamples, though.)

answered Feb 13, 2017 at 2:51
\$\endgroup\$
2
  • \$\begingroup\$ Pochhammer seems to be one better than Binomial. As far as I can tell only 1,0 fails. \$\endgroup\$ Commented Feb 13, 2017 at 12:05
  • \$\begingroup\$ Ah, and KroneckerDelta works for all inputs (being the equivalent of the equality check in some of the esolangs). It's actually shorter to reimplement as Boole[#==#2]&, but I assume you were looking for a built-in that works as is. \$\endgroup\$ Commented Feb 13, 2017 at 12:08
5
\$\begingroup\$

PHP, 17 bytes

<?=1-join($argv);

Run like this:

echo '<?=1-join($argv);' | php -- 0 0
> 1

Explanation

This just concatenates the arguments. The first argument (script name) contains -. So that results in a negative number, which I negate with the minus sign. Then I add 1, just in case the first input number is a 0 (0123 = 123).

answered Feb 13, 2017 at 9:56
\$\endgroup\$
5
\$\begingroup\$

Perl 6, 4 bytes

!*+*

A lambda (formed by Whatever-currying), that adds the boolean inverse (1 or 0) of the first argument to the second argument.

Try it online!

answered Feb 13, 2017 at 13:18
\$\endgroup\$
5
\$\begingroup\$

Java (OpenJDK 9), 10 bytes

a->b->a-~b

Try it online!

answered Feb 13, 2017 at 6:23
\$\endgroup\$
5
  • 1
    \$\begingroup\$ With currying, you can spare a byte: a->b->a-~b. Also works with Java 8, any edition (so there's no need to specify the OpenJDK 9) \$\endgroup\$ Commented Feb 14, 2017 at 9:20
  • \$\begingroup\$ @OlivierGrégoire Java has started to look like JS now >_> \$\endgroup\$ Commented Feb 14, 2017 at 9:34
  • \$\begingroup\$ @KritixiLithos Well... we had a hint this would happen for years: JavaScript ;-) \$\endgroup\$ Commented Feb 14, 2017 at 10:01
  • \$\begingroup\$ @KritixiLithos The specification for Java 9 has a section on 'ECMAScript 6 Compliance'. \$\endgroup\$ Commented Feb 14, 2017 at 15:33
  • \$\begingroup\$ @OlivierGrégoire Yeah, but this submission was generates automatically, which is why the 9 was added. \$\endgroup\$ Commented Feb 14, 2017 at 15:33
4
\$\begingroup\$

Turtlèd, 12 bytes

makes very large numbers

'1?:?:[1'0l]

Try it online!

Explanation:

'1 write one on the starting grid square
 ?:?: take a number, move right that many (repeat)
 [1 ] while not on a grid square with a one on it
 '0l put a zero on that square, move left
[implicit output of grid]

It thus outputs 10**(x+y).

answered Feb 13, 2017 at 2:10
\$\endgroup\$
4
\$\begingroup\$

PHP, 19 bytes

1<?=max([0]+$argv);
answered Feb 13, 2017 at 5:59
\$\endgroup\$
4
\$\begingroup\$

05AB1E, 1 byte

Q

Works the same as the RProgN answer.

Checks if a and b are the same. If so, print 1. Otherwise, print 0

Try it online!

answered Feb 13, 2017 at 9:31
\$\endgroup\$
3
  • 3
    \$\begingroup\$ ¢ ( a.count(b) ) should also work for 1 byte. \$\endgroup\$ Commented Feb 13, 2017 at 16:54
  • \$\begingroup\$ @Riley you could post that as your own answer. \$\endgroup\$ Commented Feb 13, 2017 at 17:48
  • 2
    \$\begingroup\$ It's not different enough to needs it's own answer. I thought we could just combine both 1 byte solutions into one answer. \$\endgroup\$ Commented Feb 13, 2017 at 17:49
4
\$\begingroup\$

///, 10 bytes + input

/0/1//+//[input A]+[input B]

Obviously [input A] and [input B] are supposed to be replaced with the appropriate inputs

Try it online!

Changes 0's to 1's, then concatenates the strings.

This works because:

  • For A,B>0, join(A,B)>A+B
  • join(A,B)>join(C,D) if A>C or B>D
  • The function f(x)='change 0's to 1's in the digits of x' is always at least x

So we have join(f(A),f(B))>f(A)+f(B)>=A+B.

And if one or both of the inputs are 0, we have join(1,B)>1+B>0+B, join(A,1)>A+1>A+0 and join(1,1)=11>0+0.

Note 1: This type of input has been approved by the community
Note 2: This output doesn't give leading 0's either
Note 3: Less bytes than Python, PHP, C#, C, Powershell and more!

Erik the Outgolfer
40.8k5 gold badges46 silver badges125 bronze badges
answered Feb 26, 2017 at 5:23
\$\endgroup\$
3
\$\begingroup\$

SmileBASIC, 4 bytes

!A+B

not(A)+B
1+1=2 -> !1+1 -> 0+1=1
0+1=1 -> !0+1 -> 1+1=2

answered Feb 13, 2017 at 1:52
\$\endgroup\$
2
  • \$\begingroup\$ Out of curiosity, how does this support 2+1? \$\endgroup\$ Commented Feb 13, 2017 at 1:53
  • 2
    \$\begingroup\$ 2+1=3 -> !2+1 -> 0+1=1 \$\endgroup\$ Commented Feb 13, 2017 at 1:54
3
\$\begingroup\$

R, 13 bytes

sum(scan()+1)

Thanks to Jonathan Allan for his inputs !

answered Feb 13, 2017 at 6:48
\$\endgroup\$
6
  • \$\begingroup\$ @JonathanAllan : You're right, I changed my answer. Thanks ! \$\endgroup\$ Commented Feb 13, 2017 at 7:06
  • \$\begingroup\$ OK, pretty sure 00 is the same as 0 though, maybe sep="1"? \$\endgroup\$ Commented Feb 13, 2017 at 7:08
  • \$\begingroup\$ @JonathanAllan : damnit ! Thanks again ! \$\endgroup\$ Commented Feb 13, 2017 at 7:38
  • \$\begingroup\$ Looking at the Tips For Golfing In R it seems scan() should be fine, accepting a vector input, like this. But we can do one byte better with cat(sum(scan()+1)). Maybe there is shorter? \$\endgroup\$ Commented Feb 13, 2017 at 7:54
  • 1
    \$\begingroup\$ With the cat it is a full program, the alternative would be an unnamed function for the same byte cost function(a,b)a+b+1 \$\endgroup\$ Commented Feb 13, 2017 at 8:10
3
\$\begingroup\$

C (削除) 26 (削除ここまで) (削除) 24 (削除ここまで) 19 bytes

f(c,d){return!c+d;}

Ungolfed version:

int f(int c,int d)
{
 return !c+d; 
}

I hope I got the specification right. Can definitely be shortened!?

@Pavel Thanks for saving 2 bytes

@Neil Thanks for your input.

answered Feb 13, 2017 at 7:43
\$\endgroup\$
16
  • 1
    \$\begingroup\$ Do you need () around !c+d? \$\endgroup\$ Commented Feb 13, 2017 at 7:48
  • \$\begingroup\$ @Pavel You're right, brackets were useless, updated! \$\endgroup\$ Commented Feb 13, 2017 at 8:07
  • 2
    \$\begingroup\$ Not 100% sure but I think you can remove the space in your return, like return!c+d; \$\endgroup\$ Commented Feb 13, 2017 at 8:50
  • 1
    \$\begingroup\$ Lose the return and instead assign it with something like c+=!d \$\endgroup\$ Commented Feb 13, 2017 at 10:22
  • 1
    \$\begingroup\$ @AlbertRenshaw It's not something I'd rely on for portability but here are a couple of examples. I can't get it to work offline and it seems that it needs to be assigned to a non argument variable on TIO.. tio.run/nexus/… \$\endgroup\$ Commented Feb 14, 2017 at 6:44
3
\$\begingroup\$

MATLAB / Octave, 3 bytes

@eq

Accepts two inputs and checks for equality and yields 1 if they are equal and 0 otherwise.

Online Demo

answered Feb 13, 2017 at 3:10
\$\endgroup\$
3
  • 4
    \$\begingroup\$ Shouldn't this be @eq? That returns a function handle which can be used to evaluate to the desired function, while just eq is meaningless. \$\endgroup\$ Commented Feb 13, 2017 at 8:16
  • \$\begingroup\$ @Sanchises I've seen many answers go both ways: codegolf.stackexchange.com/questions/106149/compute-the-median/…. I'm not actually sure which is preferred. \$\endgroup\$ Commented Feb 13, 2017 at 13:30
  • \$\begingroup\$ Hmmm. I should think this is more like a snippet, while an @ turns it into a valid language construct. But maybe I'm just being pedantic. \$\endgroup\$ Commented Feb 13, 2017 at 13:58
3
\$\begingroup\$

brainfuck, 12 bytes

Simple solution that outputs A+B+1.

,>,[-<+>]<+.

Try it online

answered Feb 13, 2017 at 20:27
\$\endgroup\$
5
  • \$\begingroup\$ Alternate answer (12 bytes): ,>,[-<++>]<. \$\endgroup\$ Commented Feb 13, 2017 at 20:37
  • \$\begingroup\$ @JulianLachniet will that output A+2B? \$\endgroup\$ Commented Mar 8, 2017 at 13:37
  • \$\begingroup\$ A+2B hacked when B=0 \$\endgroup\$ Commented Dec 15, 2017 at 18:48
  • \$\begingroup\$ @mbomb007 I'm saying the ,>,[-<++>]<. solution \$\endgroup\$ Commented Dec 18, 2017 at 21:04
  • \$\begingroup\$ @JulianLachniet Yeah, that's not a valid answer because A+2B for input B=0, gives A. \$\endgroup\$ Commented Dec 18, 2017 at 22:40
3
\$\begingroup\$

dc, 5 bytes

?1n+n

Try it online!

Input: Two natural numbers separated by a space on stdin.

Output: The digit 1 immediately followed by the sum of the two numbers, which is a number larger than the sum of the two numbers.

Example:

Input: 222 333

Output: 1555

answered Feb 13, 2017 at 21:17
\$\endgroup\$
3
\$\begingroup\$

PHP, 13 bytes; (17 REPL-less)

!max($argv)+0

Examples

[0,0] -> 1
[0,1] -> 0
[1,0] -> 0

For those without REPL use

<?=!max($argv)+0;

and run using

echo '<?=!max($argv)+0;' | php -- 0 0
answered Feb 13, 2017 at 10:22
\$\endgroup\$
3
  • \$\begingroup\$ This answer is not valid because it doesn't output anything \$\endgroup\$ Commented Feb 14, 2017 at 8:57
  • \$\begingroup\$ @aross If boolean cast was problem I updated my answer \$\endgroup\$ Commented Feb 14, 2017 at 11:29
  • \$\begingroup\$ Yes, you addressed both problems. The output would be true/false, not 1/0. Also, REPL :) \$\endgroup\$ Commented Feb 14, 2017 at 11:46
3
\$\begingroup\$

Cubix, (削除) 9 (削除ここまで) 8 bytes

u-~OII/@

Explanation

Expanded, this answer looks like this:

 u -
 ~ O
I I / @ . . . .
. . . . . . . .
 . .
 . .

The order of the instructions that are executed is II~-O@

II~-O@
I # First input
 - # Minus
 I~ # NOT(second input)
 O # Output as integer
 @ # End program

Tested for all combinations of inputs where both are in the range 0-100.

Try it here.

answered Feb 13, 2017 at 15:21
\$\endgroup\$
0
3
\$\begingroup\$

APL - 4 Bytes

1++/

Takes array, sums its elements and adds one. Test:

 1++/1 2 
4
 1++/1 0
2
\$\endgroup\$
3
+50
\$\begingroup\$

Milky Way 2 bytes

b!

Checks equality.

http://meta.codegolf.stackexchange.com/a/8493/63187 allows me to assume the inputs are pushed to stack.

Thank you Zach Gates! I out golfed him in his own language :P

answered Feb 28, 2017 at 17:01
\$\endgroup\$
2
  • \$\begingroup\$ You still need to output your result (use ! or ¡). Best alternative I've come up with so far is l+¡. \$\endgroup\$ Commented Mar 2, 2017 at 15:04
  • \$\begingroup\$ @ZachGates one I had was +R+! Then found the other way \$\endgroup\$ Commented Mar 2, 2017 at 16:13
3
\$\begingroup\$

Hexagony, 7 bytes

?<.!?)@

Try it online!

Or in more readable format,

 ? <
. ! ?
 ) @

This beats the current Hexagony solution of 11 bytes.

Explanation:

If the first number is not 0, the program takes the following path:

Not 0

This reads the first number and branches right. Then it reads the second number, followed by wrapping and trying to read a third, but that doesn't exist so it reads 0. This is printed and the program terminated (note that if a>0, since b is non-negative a+b>0).

If the first number is 0, the program takes the following path to start with:

Is 0

This reads the first number and branches left. It hits the corner, taking the route from along the north-west edge because the number is 0, and reads the second number. It wraps, then increments the second number and prints.

Is still 0

It bounces against the <, printing the incremented second input again. It increments the value and takes the north-east edge again, but this time because the current edge a twice-incremented non-negative value which is definitely positive. It then tries to get a third input, but receives 0 instead.

Is still 0 some more

Finally it wraps and gets diverted by the arrow, then tries to read a fourth input and gets 0 again. It wraps and tries to read a fifth input and receives 0 for the last time. This it prints, and wraps to the @ and exits.

Note that b*(10^k+1)*10>0+b=b where k is the length of b in digits, so this works.

answered Nov 21, 2017 at 7:26
\$\endgroup\$
3
\$\begingroup\$

√ å ı \ ® Ï Ø ¿, 4 bytes

II1_
II Take 2 inputs and push to the stack
 1 Push 1 to the stack
 _ Push the sum of the stack

To output, add o to the end.

answered Apr 1, 2017 at 12:10
\$\endgroup\$
0
1
2 3 4

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.