┌─────┬─────┐
1 23 -> │0 1 2│2 3 4│
└─────┴─────┘
┌─────┬─────┐
1 2 -> │0 1 2│2 3 4│
└─────┴─────┘
┌─────┬─────┐
1 3 -> │0 1 2│2 3 4│
└─────┴─────┘
A naïve and verbose solution in J. It is a straightforward implementtionimplementation of the task.
m=.{;~1 3 5
(+/^:_"2((,&.>/@(<:,],>:)"0)&.>m){0 m}a)m(m=.{;~1 3 5)}a=.>:?7 79ドル
A naïve and verbose solution in J. It is a straightforward implementtion of the task.
m=.{;~1 3 5
(+/^:_"2((,&.>/@(<:,],>:)"0)&.>m){0 m}a)m}a=.>:?7 79ドル
A naïve and verbose solution in J. It is a straightforward implementation of the task.
(+/^:_"2((,&.>/@(<:,],>:)"0)&.>m){0 m}a)(m=.{;~1 3 5)}a=.>:?7 79ドル
J, 67(削除) 67 (削除ここまで) 65 bytes
A naïve and verbose solution in J. It is a straightforward implementationimplementtion of the task.
s=m=.{;~1 3 5
(+/^:_"2((,&.>/@(<:,],>:)"0)&.>m=.{;~1 3 5
(+/^:_"2 s>m){0 m}a)m}a=.>:?7 79ドル
┌─────┬─────┐
1 32 -> │0 1 2│2 3 4│
└─────┴─────┘
J, 67 bytes
A naïve and verbose solution in J. It is a straightforward implementation of the task.
s=.(,&.>/@(<:,],>:)"0)&.>m=.{;~1 3 5
(+/^:_"2 s{0 m}a)m}a=.>:?7 79ドル
┌─────┬─────┐
1 3 -> │0 1 2│2 3 4│
└─────┴─────┘
J, (削除) 67 (削除ここまで) 65 bytes
A naïve and verbose solution in J. It is a straightforward implementtion of the task.
m=.{;~1 3 5
(+/^:_"2((,&.>/@(<:,],>:)"0)&.>m){0 m}a)m}a=.>:?7 79ドル
┌─────┬─────┐
1 2 -> │0 1 2│2 3 4│
└─────┴─────┘