4.5 Count dots on any number of black and white cards as one input (using a loop)

Block-based solution

View solution

This is just one of many possible solutions:

whenclickedsettotal number of dotsto0setnumber of dotsto1askPlease enter a sequence of cards ('B' for black and 'W' for white):andwaitsetcardstoanswersetindextolengthofcardsrepeatlengthofcardsifletterindexofcards=Wthensettotal number of dotstototalnumberofdots+numberofdotssetnumber of dotstonumberofdots*2setindextoindex-1saytotalnumberofdots

Back to programming challenge