44
3
iOS 11 has a bug that makes the result of 1+2+3 to be 24. This is related to the animation speed, but anyway:
The task is to make 1 + 2 + 3 == 24
. But only that. So you should provide a function that correctly sums most sequences but returns 24
when the arguments are 1
, 2
and 3
in any order.
Example inputs:
1 2 => 3
3 4 => 7
1 2 3 4 5 6 7 8 9 => 45
3 2 1 => 24
2 1 3 => 24
1 1 => 2
1 2 3 => 24
40 2 => 42
1 2 2 4 => 9
1 2 3 4 1 2 3 => 16
1 => 1
1 23 => 24
0 1 2 => 3
3 2 3 => 8
Input can be in any format as long as your code accepts any number of arguments.
- Support for negative numbers isn't required (all non negative numbers are required to work, that includes 0)
- We assume correct input
Differences from another similar question: "What do you get when you multiply 6 by 9? (42)":
- In this case your function is required to accept any number of arguments. The old question specifies exactly 2.
- In this case order doesn't matter, while the old question specified that order
6 9
is required and9 6
should be evaluated correctly.
23
Also, iOS 11 doesn't work like that. It should be like this instead. (code explanation)
– user202729 – 2017-10-24T09:39:51.4603@user202729 The question is probably inspired by iOS 11. I don't think the OP is asking you to replicate it entirely. – Okx – 2017-10-24T09:42:58.527
2@Okx exactly. This is for fun, not to implement it 1 to 1. Of course this could be changed to the user202729 proposal, but if he want he can create new challenge with such task. – Hauleth – 2017-10-24T09:45:36.567
3Are the inputs integer? – xnor – 2017-10-24T15:46:51.860
9
One reason this is a beautiful challenge is because of the property linked to wherein this combination of numbers is very special. The other reason this is a beautiful challenge is that it pokes fun at Apple for prioritizing (their idea of) UX over functionality.
– NH. – 2017-10-24T22:05:08.170Possibly related: Solving twenty-four puzzles
– Greg Bacon – 2017-11-06T17:09:56.363