# 在W×H的数字网格中找到最大的N位数

25

• 不考虑数字的对角线。
• 网格不环绕，即不具有周期性边界条件。

``````928
313
049
``````

4×3网格

``````7423
1531
6810
``````

3×3网格

``````000
010
000
``````

`1`对于N = 1，`10`对于N = 2和N = 3 ，将具有输出（`010`对于N = 3也有效）。

1×1网格

``````0
``````

`0`N = 1的输出。

1

PurkkaKoodari 2015年

@ Pietu1998“如果输出中的零是网格的一部分，则允许在输出中使用零。”

0

# Pyth，22 19字节

3个字节，感谢Jakube。

``````seSs.:RQ.n,L_MdCB.z
``````

``````eSs.:RQ.n,L_MdCB.z
``````

9

## CJam，39 36 35 34字节

``````qN/)i\[{zW%_}4*]ff{_,@e<ew:i}e_:e>
``````

### 说明

``````qN/             Split input by newlines, giving an array of lines
)i\             Drop N from the array and put at bottom
[        ]      Wrap in array...
{    }4*         Perform 4 times...
zW%_              Rotate grid anticlockwise and push a copy
Note that this gives an array of 5 grids [CCW1 CCW2 CCW3 CCW4 CCW4]
ff{         }   For each grid row, mapping with N as an extra parameter...
_,             Push length of row
@e<          Take min with N
ew        Split into chunks
:i      Convert to ints
e_              Flatten that array
:e>             Take cumulative max
``````

ETHproductions

3
@ETHproductions实际上是`ew`使用`f`或“带有附加参数的映射” 应用的运算符。例如，`["abcd" "efgh"] 2 few`结果为`[["ab" "bc" "cd"] ["ef" "fg" "gh"]]`
Sp3000

ETHproductions

kirbyfan64sos 2015年

-2

## 滑稽的

``````blsq ) "7423\n1531\n6810"ln)XXJ)\[jtp)\[_+J)<-_+{3.+ti}m[>]
854
blsq ) "7423\n1531\n6810"ln)XXJ)\[jtp)\[_+J)<-_+{4.+ti}m[>]
7423
``````

N和网格如何精确给出？

Alex A.

mroman
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.