这是一个相对简单的二维数组挑战。
想象一下一个有625英尺长士兵的战场。您指挥奇数部队,但不幸的是,偶数部队的力量使您不堪重负。值得庆幸的是,您的士兵拥有秘密力量:如果每个奇兵和周围同伴的力量可以被秘密力量数字整除,那么他们将发动最终的进攻并取得胜利!您必须尊重每位胜利的士兵。
规则
给定一个25 x 25的整数数组,其中每个元素都包含其x和y位置加1的乘积,返回满足以下条件的每个“胜利”奇数元素的坐标:
元素值及其相邻奇数元素(上,下,左和右)的总和可被输入(秘密幂数)整除。它必须在所有四个侧面上与其相邻且不能在边缘上。
提交可以是需要单个输入的功能或完整程序。输出可以是任何顺序。
我们的25 x 25阵列(战场)如下所示:
1, 1, 1, 1,...
1, 2, 3, 4,...
1, 3, 5, 7,...
1, 4, 7, 10,...
etc.
例
这是一个3 x 3的示例:
43, 57, 71
46, 61, 76
49, 65, 81
为了确定某个元素(居中的61)是否获胜,我们将其值与相邻的奇数元素相加。
61 + 57 + 65 = 183
如果总计可被输入整除,则打印元素的x和y位置。如果我们的输入为3,则因为183可被3整除,所以将打印“ 1、1”。
输出量
如果输入(秘密力量数字)为37,则返回的要素(要赞扬的胜利士兵)必须是:
2, 18
3, 12
4, 9
5, 22
6, 6
8, 23
9, 4
10, 11
11, 10
12, 3
18, 2
22, 5
23, 8
如果输入为191,则返回的元素必须为:
10, 19
19, 10
输入3:
1, 2
1, 4
1, 6
1, 8
1, 10
1, 12
1, 14
1, 16
1, 18
1, 20
1, 22
2, 1
2, 3
2, 4
2, 5
2, 7
2, 9
2, 10
2, 11
2, 13
2, 15
2, 16
2, 17
2, 19
2, 21
2, 22
2, 23
3, 2
3, 4
3, 6
3, 8
3, 10
3, 12
3, 14
3, 16
3, 18
3, 20
3, 22
4, 1
4, 2
4, 3
4, 5
4, 7
4, 8
4, 9
4, 11
4, 13
4, 14
4, 15
4, 17
4, 19
4, 20
4, 21
4, 23
5, 2
5, 4
5, 6
5, 8
5, 10
5, 12
5, 14
5, 16
5, 18
5, 20
5, 22
6, 1
6, 3
6, 5
6, 7
6, 9
6, 11
6, 13
6, 15
6, 17
6, 19
6, 21
6, 23
7, 2
7, 4
7, 6
7, 8
7, 10
7, 12
7, 14
7, 16
7, 18
7, 20
7, 22
8, 1
8, 3
8, 4
8, 5
8, 7
8, 9
8, 10
8, 11
8, 13
8, 15
8, 16
8, 17
8, 19
8, 21
8, 22
8, 23
9, 2
9, 4
9, 6
9, 8
9, 10
9, 12
9, 14
9, 16
9, 18
9, 20
9, 22
10, 1
10, 2
10, 3
10, 5
10, 7
10, 8
10, 9
10, 11
10, 13
10, 14
10, 15
10, 17
10, 19
10, 20
10, 21
10, 23
11, 2
11, 4
11, 6
11, 8
11, 10
11, 12
11, 14
11, 16
11, 18
11, 20
11, 22
12, 1
12, 3
12, 5
12, 7
12, 9
12, 11
12, 13
12, 15
12, 17
12, 19
12, 21
12, 23
13, 2
13, 4
13, 6
13, 8
13, 10
13, 12
13, 14
13, 16
13, 18
13, 20
13, 22
14, 1
14, 3
14, 4
14, 5
14, 7
14, 9
14, 10
14, 11
14, 13
14, 15
14, 16
14, 17
14, 19
14, 21
14, 22
14, 23
15, 2
15, 4
15, 6
15, 8
15, 10
15, 12
15, 14
15, 16
15, 18
15, 20
15, 22
16, 1
16, 2
16, 3
16, 5
16, 7
16, 8
16, 9
16, 11
16, 13
16, 14
16, 15
16, 17
16, 19
16, 20
16, 21
16, 23
17, 2
17, 4
17, 6
17, 8
17, 10
17, 12
17, 14
17, 16
17, 18
17, 20
17, 22
18, 1
18, 3
18, 5
18, 7
18, 9
18, 11
18, 13
18, 15
18, 17
18, 19
18, 21
18, 23
19, 2
19, 4
19, 6
19, 8
19, 10
19, 12
19, 14
19, 16
19, 18
19, 20
19, 22
20, 1
20, 3
20, 4
20, 5
20, 7
20, 9
20, 10
20, 11
20, 13
20, 15
20, 16
20, 17
20, 19
20, 21
20, 22
20, 23
21, 2
21, 4
21, 6
21, 8
21, 10
21, 12
21, 14
21, 16
21, 18
21, 20
21, 22
22, 1
22, 2
22, 3
22, 5
22, 7
22, 8
22, 9
22, 11
22, 13
22, 14
22, 15
22, 17
22, 19
22, 20
22, 21
22, 23
23, 2
23, 4
23, 6
23, 8
23, 10
23, 12
23, 14
23, 16
23, 18
23, 20
23, 22
输入5:
1, 4
1, 14
2, 2
2, 4
2, 6
2, 7
2, 8
2, 10
2, 12
2, 14
2, 16
2, 17
2, 18
2, 20
2, 22
3, 8
3, 18
4, 1
4, 2
4, 4
4, 6
4, 8
4, 10
4, 11
4, 12
4, 14
4, 16
4, 18
4, 20
4, 21
4, 22
6, 2
6, 4
6, 6
6, 8
6, 9
6, 10
6, 12
6, 14
6, 16
6, 18
6, 19
6, 20
6, 22
7, 2
7, 12
7, 22
8, 2
8, 3
8, 4
8, 6
8, 8
8, 10
8, 12
8, 13
8, 14
8, 16
8, 18
8, 20
8, 22
8, 23
9, 6
9, 16
10, 2
10, 4
10, 6
10, 8
10, 10
10, 12
10, 14
10, 16
10, 18
10, 20
10, 22
11, 4
11, 14
12, 2
12, 4
12, 6
12, 7
12, 8
12, 10
12, 12
12, 14
12, 16
12, 17
12, 18
12, 20
12, 22
13, 8
13, 18
14, 1
14, 2
14, 4
14, 6
14, 8
14, 10
14, 11
14, 12
14, 14
14, 16
14, 18
14, 20
14, 21
14, 22
16, 2
16, 4
16, 6
16, 8
16, 9
16, 10
16, 12
16, 14
16, 16
16, 18
16, 19
16, 20
16, 22
17, 2
17, 12
17, 22
18, 2
18, 3
18, 4
18, 6
18, 8
18, 10
18, 12
18, 13
18, 14
18, 16
18, 18
18, 20
18, 22
18, 23
19, 6
19, 16
20, 2
20, 4
20, 6
20, 8
20, 10
20, 12
20, 14
20, 16
20, 18
20, 20
20, 22
21, 4
21, 14
22, 2
22, 4
22, 6
22, 7
22, 8
22, 10
22, 12
22, 14
22, 16
22, 17
22, 18
22, 20
22, 22
23, 8
23, 18
这是 代码高尔夫球,不使用标准漏洞的最低字节数代码就是赢家。
由于这是我的首次提交,因此非常感谢任何建议。谢谢!