Look, up in the sky! It's a super duper array!
Jelly, 47 45 4̷4̷ 42 bytes
+\,×\<ḊZṖP“sd”x;€“uper ”;/“It's a ”,“¥ṫɲ»j
This prints an empty string (falsy) for arrays that are neither super nor duper. Try it online!
How it works
+\,×\<ḊZṖP“sd”x;€“uper ” Main link (first half). Argument: A (array)
+\ Compute all partial sums of A.
×\ Compute all partial products of A.
, Pair the results to the left and to the right.
<Ḋ Perform vectorized comparison with A[1:].
This yields a 2D array of Booleans.
Z Zip; pair the Booleans corresponding to each integer.
Ṗ Remove the last pair.
(Nothing is compared with the last sum/product.)
P Take the product of each column.
“sd”x Perform vectorized character repetition.
This yields ['s', d'], ['s'], ['d'], or [].
;€“uper ” Append the string "uper " to each character.
;/“It's a ”,“¥ṫɲ»j Main link (second half).
;/ Reduce the resulting array of strings by concatenation.
This will fail for an empty array, exiting immediately.
“It's a ”,“¥ṫɲ» Push ['It's a ', 'array!'].
j Join that array, separating by the super duper string.
JavaScript (ES6), 111 110 bytes
Saved a byte thanks to @ETHproductions!
a=>a.map((n,i)=>i&&(s=s&&n>s&&s+n,d*=d&&n>d&&n),s=d=a[0])|s|d&&`It's a ${s?"super ":""}${d?"duper ":""}array!`
Explanation
Takes an array of numbers, returns a string or the number 0
for false.
a=>
a.map((n,i)=> // for each number n at index i
i&&( // skip the first number (because s and d are initialised to it)
s=s&&n>s&&s+n, // if it is still super and n > s, s += n, else s = false
d*=d&&n>d&&n // if it is still duper and n > d, d *= n, else d = false
),
s= // s = sum of previous numbers if super, else false
d= // d = product of previous numbers if duper, else false
a[0] // initialise s and d to the first number
)
|s|d // if it is neither super or duper, output 0
// Output the appropriate string
&&`It's a ${s?"super ":""}${d?"duper ":""}array!`
Test
var solution = a=>a.map((n,i)=>i&&(s=s&&n>s&&s+n,d*=d&&n>d&&n),s=d=a[0])|s|d&&`It's a ${s?"super ":""}${d?"duper ":""}array!`
Numbers (space-separated) = <input type="text" id="input" value="2 3 7 43 1856" />
<button onclick="result.textContent=solution(input.value.split(' ').map(n=>+n))">Go</button>
<pre id="result"></pre>
Java, 183 182 Bytes
String w(int[]a){boolean s=1<2,d=s;int m=a[0],p=m,k=a.length,i=0,e;if(k>0)for(;++i<k;s&=e>m,d&=e>p,m+=e,p*=e)e=a[i];return d|s?"It's a "+(s?"super ":"")+(d?"duper ":"")+"array!":"";}
I made the following assumptions:
- The output is via return value.
- The empty String
""
is a falsy value.
If any of these are wrong, please tell me.
Anyway, I can't shake the feeling that I might have gone overboard with the amount of variables.
Edit: managed to save a byte, thanks to @UndefinedFunction