Skip to main content
5 of 6
switched two letters because I'm an idiot who types to quickly without reviewing what I wrote
DJMcMayhem
  • 59.6k
  • 17
  • 196
  • 348

Look, up in the sky! It's a super duper array!

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.

DJMcMayhem
  • 59.6k
  • 17
  • 196
  • 348