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1,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,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,0,0,0,0,0]] nage=[p1,p2,p3,p4] def draw_swimmer(x,y,pos): for i in range (16): for j in range (16): set_pixel (x+i,y+j,black if pos[j][i]==1 else white) def draw_pool(): for i in range (6): draw_string(str(i+1),0,19+35*i) for n in range (320): set_pixel(n,10+35*i,black) def swim(): draw_pool() pos=[300,300,300,300,300,300] rang=0 for j in range (6): draw_swimmer(300,20+35*j,p1) while max(pos)>10: i=randint(0,5) if pos[i]>10: draw_swimmer(pos[i]-1,20+35*i,nage[pos[i]%4]) pos[i]=pos[i]-1 if pos[i]==10: rang=rang+1 draw_string(str(rang),300,19+35*i)