39

# 定义

``````3 > 2
6 > 3 + 2 (5)
13 > 6 + 3 + 2 (11)
``````

`{2, 3, 5, 11}`不是一个超级阵列，因为

``````3 > 2
5 == 3 + 2
11 > 5 + 3 + 2
``````

``````3 > 2
7 > 3 * 2 (6)
43 > 7 * 3 * 2 (42)
1856 > 43 * 7 * 3 * 2 (1806)
``````

# 挑战

9

lirtosiast '16

1

Darrel Hoffman

1
@DJMcMayhem哎呀，我不知怎么`2 * 1`等于`3`在我的头上。

4

1

2016年

20

# 果冻，47个45 44 42 字节

``````+\,×\<ḊZṖP“sd”x;€“uper ”;/“It's a ”,“¥ṫɲ»j
``````

### 这个怎么运作

``````+\,×\<Ḋ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.
``````

1

@LuisMendo现在不行。当前的压缩方法是实验性的，我将尽快对其进行更改。快速概览：使用代码页中的索引，将压缩的字符串从双射基数250转换为整数。每个步骤都可以解码为可打印的ASCII字符或词典中的单词，可能会更改大小写和/或空格。

9

# 的JavaScript（ES6），111个 110字节

``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!```

## 说明

``````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!`
``````

## 测试

ETHproductions

@ETHproductions `s`需要以这种方式完成，因为需要将其设置为`false`if `n>s`，但是`d*false`具有相同的效果，这样一个人才能工作。谢谢！
user81655 '16

5

# Java 183 182字节

``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!":"";}``

• 通过返回值进行输出。
• 空的String `""`是一个伪造的值。

1

jrich

@UndefinedFunction是的，良好的抓
ECS

4

# MATL，66字节

``````Ys5L)G6L)XK<?' super']GYp5L)K<?' duper']N?N\$h'It''s a'wh' array!'h
``````

### 说明

``````Ys             % implicit input. Cumulative sum
5L)            % remove last element
G6L)           % push input. Remove first element
XK             % copy to clipboard K
<?             % if all elements are smaller
' super'     % push string
]              % end
GYp            % push input. Cumulative product
5L)            % remove last element
K              % push input except first element
<?             % if all elements are smaller
' duper'     % push string
]              % end
N?             % if stack not empty
N\$h          % concatenate all elements (will be one or two strings)
'It''s a'    % string
wh           % prepend
' array!'    % string
h            % concatenate. Implicit end. Implicit display
``````

3

## C ++ 14、178，...， 161157字节

``````auto f(int*a,int n){int s,p,d=1,e=1,r;for(s=p=*a;--n;s+=r,p*=r)r=*++a,e=r>s?e:0,d=r>p?d:0;return e|d?"It's a "s+(e?"super ":"")+(d?"duper ":"")+"array!":"";}
``````

``````#include <iostream>
#include <string>
#include <vector>

using namespace std::literals::string_literals;

auto f(int* a, int n)
{
int s,p,d=1,e=1,r;

for(s=p=*a; --n; s+=r, p*=r)
r=*++a, e=r>s?e:0, d=r>p?d:0;

return e|d ? "It's a "s + (e?"super ":"") + (d?"duper ":"") + "array!" : "";
}

int main()
{
std::vector<std::vector<int>> test_cases = {{2,3,6,13},
{2,3,5,11},
{2,3,7,43,1856},
{1,2,3}
};

for(auto& test_case : test_cases)
{
std::cout << f(test_case.data(), test_case.size()) << '\n';
}
}
``````

``````It's a super array!

It's a super duper array!
It's a duper array!
``````

2

@Dennis实际上，这是一个编译错误（我使用的是C ++ 14 std :: string文字，而不是原始字符数组），两者都不是。无论如何，我现在正在更新我的答案以打印一个空字符串，因为这是其他解决方案中使用的方法。

1

CompuChip

1
@AlexanderRevo不喜欢`for(s=p=*a;--n;s+=r,p*=r)r=*++a`工作吗？将允许您`i`完全放弃
CompuChip

1

CompuChip

2

## C，150字节

``````#define M(N,O)N(int*d,int c){return*d?*d>c?N(d+1,c O*d):0:1;}
M(S,+)M(D,*)Z(int*d){printf("It's a %s%s array!\n",S(d,0)?"super":"",D(d,0)?"duper":"");}
``````

``````#include <stdio.h>

int main() {
int test_data[4][6] = {
{2, 3, 7, 43, 1856, 0}, // superduper
{2, 3, 5, 11, 0}, // not super
{2, 3, 6, 13, 0}, // super
{1, 2, 3, 0} // duper not super
};

for (int i = 0; i < 4; ++i) {
Z(test_data[i]);
}
}
``````

``````#define M(N,O)N(int*d,int c){return*d?*d>c?N(d+1,c O*d):0:1;}
M(S,+)M(D,*)Z(int*d){return S(d,0)*2^D(d,0);}
``````

1

# Pyth- 54 52字节

``````jd++"It's a"fT*V+R"uper""sd"m*F>VtQd,sMK._Q*MK"array
``````

1
`c2"superduper"`可以打高尔夫球`+R"uper""sd"`
isaacg '16

@isaacg真的很聪明
Maltysen '16

3

ETHproductions '16

4
@TrangOul `lang-pyth`不存在。

2

1

# Python 3、127

``````def f(a):
s=p=a[0];e=d=1
for x in a[1:]:e&=x>s;d&=x>p;s+=x;p*=x
return"It's a %s array!"%('super'*e+' '*e*d+'duper'*d)*(e|d)
``````

``````assert f([2, 3, 6, 13]) == "It's a super array!"
assert f([2, 3, 5, 11]) == ''
assert f([2, 3, 7, 43, 1856]) == "It's a super duper array!"
assert f([1, 2, 3]) == "It's a duper array!"
print('All passed')
``````

1

AWK-140字节

``````awk 'BEGIN{d[1]=" super";e[1]=" duper";RS=" ";p=1;a=1;b=1}{a=a&&\$1>s;b=b&&\$1>p;s+=\$1;p*=\$1}END{printf "It'\''s a%s%s array!\n",d[a],e[b]}'
``````

mbomb007 '16

2
@Dennis并不是我在挑剔，但挑战是“如果数组既不是超级也不是duper，则可以打印虚假的值。” ，而在其他情况下则必须使用。我想说的是，只要输出可以明显区别于其他情况并且是正确的，那就应该没问题。我想在这方面加上OP。
Stefano Sanfilippo

1

# PHP，144 ... 113112字节

``````\$x=super;\$d=duper;foreach(\$a as\$v){\$v>\$s||\$x="";\$v>\$p||\$d="";\$s+=\$v;\$p=\$p*\$v?:\$v;}echo\$x.\$d?"It.s a \$x \$d \$a!":0;
``````

``````// Initiate `\$s` to prevent isset calls. Leaving this out yields PHP
// notices, but doesn't functionally change the code.
\$s = 0;

// Set product to 1, so when multiplying with the first value, `\$p` will
// equal `\$v`.
\$p = 1;

// Not existing constants `super` and `duper` yield PHP notices
// but are interpreted as strings.
\$x = super;
\$d = duper;

// Iterate over input (register_globals).
foreach (\$a as \$v) {
// Check if current value "breaks" [sd]uper-ness: `value` not greater
// than current sum or product. If so, unset the string.
\$v > \$s || \$x = "";
\$v > \$p || \$d = "";

// Update sum.
\$s += \$v;
// Update product.
\$p *= \$v;
}

// Check if super or duper strings are set, if so, wrap output in the
// appropriate string. Otherwise, output falsy value `0`.
echo \$x . \$d ? "It's a \$x \$d \$a!" : 0;
``````

``````php -r '\$x=super;\$d=duper;for(\$p=1;\$v=\$argv[++\$i];\$p*=\$v){\$v>\$s||\$x="";\$v>\$p||\$d="";\$s+=\$v;}echo\$x.\$d?"It.s a \$x \$d array!":0;' 2 3 7 43 1856 2>/dev/null;echo
``````
• 通过不在乎输出中的额外空间节省了另外3个字节
• 通过打印节省3个字节`\$a`（数组到字符串的转换yield `Array`
• 通过初始化`\$p`为1 节省了一个字节，因此增加产品成本更低。

2016年

2
@aross，你去。还有一些专门关于PHP的内容，但从未引起过多关注。通常，STDIN和命令行参数是公平的游戏。您还可以将代码作为函数提交。
Martin Ender

2016年

1

# R，115字节

``function(x)cat("It's a",c("super","duper")[sapply(c(cumsum,cumprod),function(f)all(rev(x[-1]>f(x))[-1]))],"array!")``

0

## Scala，172字节

``````def f(a:Seq[Int])={var q=" super"
var w=" duper"
a.drop(1).foldLeft((x,x)){case ((s,p),a)=>{if(s>=a)q=""
if(p>=a)w=""
(a+s,a*p)}}
println(s"It's a \$q\$w array")}
``````

``````def f(input:Seq[Int])={
var super=" super"
var duper=" duper"
case ((sum,product),val)=>
{
if(sum>=val)super=""
if(product>=val)duper=""
(val+sum,val*product)
}
}
println(s"It's a \$super\$duper array")
}
``````

0

``````s o t=snd.foldl(\(s,b)x->(o s x,b&&x>s))(t,1>0)
f x="It's a "++(if s(+)0x then"super "else"")++(if s(*)1x then"duper "else"")++"array!"
``````

`f`是必需的功能。请注意，空总和为0，空乘积为1，这就是为什么`[0]`既不是super也不是duper的原因。

`s`通过接受任意运算符`o`和任意中性元素捕获测试超级或双重的通用结构`t`。该`foldr`跟踪元组的`(s,b)`地方`s`是链与运营商都看到了元素的结果`o``b`说，是否对看着到目前为止一切元素，这个元素比以前计算总和/产品更大。

``````s :: (Integer -> Integer -> Integer) -> Integer -> [Integer] -> Bool
s o t = snd . (foldl (\(s,b) x -> (s `o` x, b && x>s)) (t, True))

f :: [Integer] -> [Char]
f x = "It's a " ++ (if s (+) 0 x then "super " else "")
++ (if s (*) 1 x then "duper " else "") ++ "array!"
``````

0

# 05AB1E，53 51 字节

``````"It's"'a„dsIη©εRćsO›}Pè.•dwā•UX¦«®εRćsP›}PiX}„¦È!ðý
``````

``````"It's"             # Push string "It's"
'a                 # Push string "a"
„ds                # Push string "ds"
Iη              # Get the prefixes of the input-list
©             # Store it in the register (without popping)
ε     }      # Map each sub-list to:
R           #  Reverse the list
ć          #  Take the head extracted
sO        #  Swap and take the sum
›       #  Check if the head is larger than the sum of the rest
P     # Then check this is truthy for all sub-lists, resulting in 0 or 1
è    # And use this to index into the "ds" string
.•dwā•             # Push string "duper"
U            # Store it in variable `X` (with popping unfortunately)
X¦          # Push `X` and remove the first character
«         # Then merge it with the "d" or "s"
®εRćsP›}P          # Do the same as explained above, but with the product instead of sum
i }       # If this resulted in 1:
X        #  Push variable `X` ("duper")
„¦È!               # Push string "array!"
ðý                 # Join all strings on the stack by spaces (and output implicitly)
``````

0

# 果冻，37个字节

``````Ä,×\<ḊZṖPµ“¤ḋÐ“¡e⁽»x'“¡Ƈɠİ[lɦ“Ñŀṙ»jẋẸ
``````