回答編集履歴

3

fixed code

2022/10/12 06:53

投稿

ps_aux_grep
ps_aux_grep

スコア1579

test CHANGED
@@ -1,8 +1,8 @@
1
- `range()`の`rows`と`cols`が逆,もしくは`mask[x, y]`の`x,y`を逆にすると直ります.
1
+ `range()`の`rows`と`cols`が逆,もしくは`mask[x,y]`の`x,y`を逆にすると直ります.
2
2
 
3
3
  コードの意味的には,`range()`の`rows`と`cols`を逆にするのが正しそうです.
4
4
  ```Python
5
5
  for x in range(rows):
6
6
  for y in range(cols):
7
- maskc[x, y] = int(abs(x - crow) < mask and abs(y - ccol) < mask)
7
+ maskc[x, y] = abs(x - crow) < mask and abs(y - ccol) < mask
8
8
  ```

2

append code example

2022/10/12 06:49

投稿

ps_aux_grep
ps_aux_grep

スコア1579

test CHANGED
@@ -1,3 +1,8 @@
1
1
  `range()`の`rows`と`cols`が逆,もしくは`mask[x, y]`の`x,y`を逆にすると直ります.
2
2
 
3
3
  コードの意味的には,`range()`の`rows`と`cols`を逆にするのが正しそうです.
4
+ ```Python
5
+ for x in range(rows):
6
+ for y in range(cols):
7
+ maskc[x, y] = int(abs(x - crow) < mask and abs(y - ccol) < mask)
8
+ ```

1

fix context

2022/10/12 06:45

投稿

ps_aux_grep
ps_aux_grep

スコア1579

test CHANGED
@@ -1,5 +1,3 @@
1
1
  `range()`の`rows`と`cols`が逆,もしくは`mask[x, y]`の`x,y`を逆にすると直ります.
2
2
 
3
- コードの意味的には,`mask[y, x]`で扱う方が正しそうです.
3
+ コードの意味的には,`range()`の`rows`と`cols`を逆にするのが正しそうです.
4
-
5
- 直感的に`x, y`の順になるのはわかりますが,よく考えると`y, x`の順であることがわかるはずです.