5.1 Detect parity error in any number of rows (after all the rows are entered)

Scratch solution

View solution

This is just one of many possible solutions:

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

Back to programming challenge