# Detect parity error in 6 rows (after each row is entered)

Challenge Level: Growing experience

Learning outcomes

Students will be able to:

## Requirement:

Write a program that asks the user to enter 6 rows of black and white cards (6 cards in each row) and checks if there is a parity error in any of the rows after entering each row.

## Testing examples:

Your program should display the outputs shown in this table for the given inputs provided:

Input Output
WWWWWW Row 1 is ok!
BBWWBB Row 2 is ok!
BBBWWW There is a parity error in row 3!
BBBBBB Row 4 is ok!
WBBWBB Row 5 is ok!
WBWBWB There is a parity error in row 6!

## Languages

Scratch

#### What it should look like

Click on the green flag, enter the inputs provided in the “testing examples” to see the expected output of your program.

Recommended blocks
when green flag clicked

ask (join [Please enter 6 black or white cards for row ] (row number)) and wait
repeat (6)
end

repeat (6)
end

if <(letter (index) of (row)) = [B]> then
end

if <((black cards total) mod (2)) = [0]> then
else
end
say (join (join [Row ] (row number)) [ is OK!]) for (2) secs

say (join [There is a parity error in row ] (row number)) for (2) secs
set [row v] to []

set [black cards total v] to [0]

set [row number v] to [1]

change [row number v] by (1)

set [black cards total v] to [0]

change [index v] by (1)

change [black cards total v] by (1)

set [index v] to [1]
• You can access a letter at the specified position in a string by using the letter (1) of [world] block under “Operators”. For example: letter (1) of [world] //w
• You can find how many letters a string has by using the length of [world] block unders “Operators”.
• To find out if a number is even or odd, use the () mod () block (under "Operators") to find the remainder after dividing that number by two. If the remainder is zero the number is even. For example: (37) mod (10) //7