39
4
Inspired by this question from our rivals friends over at Code Review.
Definitions
A super array is an array where each new element in the array is larger than the sum of all the previous elements. {2, 3, 6, 13}
is a super array because
3 > 2
6 > 3 + 2 (5)
13 > 6 + 3 + 2 (11)
{2, 3, 5, 11}
is not a super array, because
3 > 2
5 == 3 + 2
11 > 5 + 3 + 2
A duper array is an array where each new element in the array is larger than the product of all the previous elements. {2, 3, 7, 43, 1856}
is a super array, but it is also a duper array since
3 > 2
7 > 3 * 2 (6)
43 > 7 * 3 * 2 (42)
1856 > 43 * 7 * 3 * 2 (1806)
The challenge
Write a function or program that takes an array as input in your languages native list format, and determines how super the array is. You can also optionally take an array length input (for languages like C/C++). Also, you can assume that all of the numbers in the list will be integers greater than 0.
If it's a super array, you must print It's a super array!
If it is a super duper array, you must print It's a super duper array!
It's also possible for an array to be duper-non-super. For example {1, 2, 3}
In this case, you should print It's a duper array!
If the array is neither super nor duper, you can print a falsy value.
As usual, this is code golf, so standard loopholes apply, and the shortest answer in bytes wins.
9
I don't like the cumbersome I/O format, but it may be too late to change now.
– lirtosiast – 2016-01-19T02:27:20.7171I'm sure you meant "duper-non-super" for the
{1, 2, 3}
array? – Darrel Hoffman – 2016-01-19T15:43:36.523@DarrelHoffman facepalm yup, editing now. – James – 2016-01-19T15:46:49.363
1@DJMcMayhem oops, I somehow got
2 * 1
to equal3
in my head. – Alexander Revo – 2016-01-19T20:39:55.8004
This came up in a comment: Your spec says *If the array is neither super nor duper, you can print a falsy value.* Does this mean we must print a falsy value?
– Dennis – 2016-01-20T14:55:50.0131Would it matter is there's 2 spaces between a word somewhere? I could still save more if
super[space][space]array
is allowed. – aross – 2016-01-22T11:20:34.907