90 likes | 263 Views
nested loop to initiate Bingo board. START. k = 0;. for i =1:5. 0. 1. 0. for j =1:15. 1. k = k + 1;. board( j,i )= k;. called( j,i )= 0;. END. pick a “ball” from the Bingo board. START. pick = 0;. 0. while pick == 0. 1. pick_col = ceil(rand ()*5);.
E N D
nested loop to initiate Bingo board START k = 0; for i=1:5 0 1 0 for j=1:15 1 k = k + 1; board(j,i)=k; called(j,i)=0; END
pick a “ball” from the Bingo board START pick = 0; 0 while pick == 0 1 pick_col = ceil(rand()*5); pick_row = ceil(rand()*15); number = board(pick_row, pick_col); if called(pick_row,pick_col) == 0 0 1 called(pick_row,pick_col)=number; pick = 1; END count = count + 1;
check user response Y or N START response = 1; while response 0 1 check=input('Y/N\n','s'); 1 if check==Y|N 0 invalid input response = 0; END
Nerd Bingo Card Generator DATA START READ 0 for k=1:n 1 ZEROS FILL PRINT END
aiche.txt START members = textread() read member names n = size(members) READ names = strvcat(members) END
fill card with zeros START ZEROS 0 for i=1:5 1 i=i+1 for j=1:5 0 1 j=j+1 card(j,i)=0 END card = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
fill card with numbers FILL START bingo = 0; 0 for i=1:5 1 i=i+1 PRINT bingo = bingo + 15 for j=1:5 0 1 j=j+1 NMSU AIChE Student Chapter Official Nerd Bingo Card B I N G O 5 21 43 52 65 3 23 41 46 74 14 18 37 50 68 12 25 32 59 69 7 16 33 58 70 Polly Darton -------- cut here -------- PICK END
place a number in position (i,j) without repetition START number = 1; PICK while number 0 1 number = bingo + ceil(rand()*15); if sum(card(:)==number)==0 0 1 card(i,j) = number; number = 0; END