# 6.1 Detect parity error in rows and columns (any length)

## Scratch solution

View solution

This is just one of many possible solutions:

when green flag clicked
set [row number v] to 
set [error in row v] to 
set [error in column v] to 
delete (all v) of [cards v]
ask [How many rows would you like to enter?] and wait
set [number of rows v] to (answer)
repeat (number of rows)
ask (join (join (join [Enter ] (number of rows)) [ cards for row ]) (row number)) and wait
set [black cards total v] to 
set [index v] to 
repeat (length of (row))
if <(letter (index) of (row)) = [B]> then
change [black cards total v] by (1)
end
change [index v] by (1)
end
if <((black cards total) mod (2)) = > then
set [error in row v] to (row number)
end
change [row number v] by (1)
end
set [index v] to 
repeat (number of rows)
set [black cards total v] to 
set [row index v] to 
repeat (number of rows)
if <(letter (index) of (item (row index) of [cards v] :: list)) = [B]> then
change [black cards total v] by (1)
end
change [row index v] by (1)
end
if <((black cards total) mod (2)) = > then
set [error in column v] to (index)
end
change [index v] by (1)
end
say (join (join (join [There is a parity error in row ] (error in row)) [ and column ]) (error in column))

## Extra Challenge

For the extra challenge you need to check if the number of cards in each row (number of columns) is equal the total number of rows (i.e. if you have 6 rows each row must contain 6 cards).