1.2 Count the black squares (one line of input)

Scratch solution

View solution

This is just one of many possible solutions:

when green flag clicked
set [black cards total v] to [0]
set [index v] to [1]
ask [Please enter a sequence of black and white squares (B for black and W for white):] and wait
set [cards v] to (answer)
repeat (length of (cards))
  if <(letter (index) of (cards)) = [B]> then
    change [black cards total v] by (1)
  change [index v] by (1)
say (black cards total)

Back to programming challenge