しょっちゅう忘れることを書いておく。
![]() |
66 |
581 views
# coding:UTF-8
def get_row(records, row):
return records[row]
def get_col(records, col):
cols = [r[col] for r in records]
return cols
def get_col_wakariyasui(records, col):
cols = []
for record in records:
cols.append(record[col])
return cols
if __name__ == '__main__':
records = [
[0, 1, 1, 0],
[1, 0, 1, 0],
[1, 0, 1, 0],
[1, 1, 0, 0]
]
y_parities = [0, 1, 0, 0]
x_parities = [1, 1, 1, 0]
# 行の誤りを調べる
error_row = 0
for i in range(4):
row = get_row(records, i)
# TODO ここでパリティと比較する
y_parity = y_parities[i]
total = sum(row)
if total % 2 == y_parity:
print("{}行目に誤りなし".format(i))
else:
error_row = i
# 列の誤りを調べている
error_col = 0
for i in range(4):
col = get_col(records, i)
# TODO ここでパリティと比較する
x_parity = x_parities[i]
total = sum(col)
if total % 2 == x_parity:
print("{}列目に誤りなし".format(i))
else:
error_col = i
print("{}行目{}列目の値が誤っています".format(error_row, error_col))
Page 33 of 69.
すぺぺぺ
本サイトの作成者。
プログラムは趣味と勉強を兼ねて、のんびり本サイトを作っています。
フレームワークはdjango。
ChatGPTで自動プログラム作成に取り組み中。
https://www.osumoi-stdio.com/novel/