如有任何疑问:Nan = Non-numeric datatype
就本挑战而言。
编写一个将矩阵/数组作为输入以及列索引列表的程序或函数。
面临的挑战是删除指定列中所有元素所在的行Nan
。该行中的其他元素是否为数字都没有关系。以下示例有望使这一点更加清晰(它是一个索引的):
Input array:
16 NaN 3 13
5 11 NaN 8
NaN 7 NaN 12
4 14 -15 1
Input column index: [1 3]
Output array:
16 NaN 3 13
5 11 NaN 8
4 14 -15 1
----
Input array:
16 NaN 3 13
5 11 NaN 8
NaN 7 NaN 12
4 14 -15 1
Input column index: 3
Output array =
16 NaN 3 13
4 14 -15 1
----
Input array:
NaN NaN NaN NaN
NaN NaN NaN NaN
NaN NaN NaN NaN
NaN NaN NaN NaN
Input column index: 1 2 4
Output array:
[]
规则和说明:
- 矩阵将始终为非空
- 数值将是有限的,但不一定是整数或正值
- 列索引向量可以为空(在这种情况下,不会删除任何行)
- 列索引的值永远不会超过矩阵尺寸
- 您可以假设列索引列表中不会重复
- 您可以选择是否要使用零索引或一索引值(请指定)
- 您可以采用任何方便的格式输入
- 排列为列表列表即可。列索引可以是单独的参数
ans =
类似的在输出中被接受- 您可以自由选择要使用的非数字数据类型
- 使用此数据类型执行算术运算,或使用诸如之类的函数将其转换为有限数量应该是不可能的
float(x)
。
- 使用此数据类型执行算术运算,或使用诸如之类的函数将其转换为有限数量应该是不可能的
这是代码高尔夫,因此以字节为单位的最短代码获胜。
J
使用vz
,并K
用Q
。z
初始化为输入,Q
为求值输入。