dice_height ( + dice_width ( topleftx left toplefty top toprightx left dice_width toprighty top bottomleftx left bottomlefty top dice_height bottomrightx left dice_width bottomrighty top dice_height check if this die overlaps with previous dice overlaps false for prevdieleftprevdietop in topleftdicecornersprevdieright prevdieleft dice_width prevdiebottom prevdietop dice_height check each corner of this die to see if it is inside of the area the previous diefor cornerxcornery in ((topleftxtoplefty)(toprightxtoprighty)(bottomleftxbottomlefty)(bottomrightxbottomrighty))if (prevdieleft <cornerx prevdieright and prevdietop <cornery prevdiebottom)overlaps true if not overlapsit doesn' overlapso we can put it heretopleftdicecorners append((lefttop)break draw the dice on the canvaskeys are (xytuples of intsvalues the character at that position on the canvascanvas {loop over each diefor (dieleftdietopin enumerate(topleftdicecorners)loop over each character in the die' facedieface dicefaces[ifor dx in range(dice_width)for dy in range(dice_height)copy this character to the correct place on the canvascanvasx dieleft dx canvasy dietop dy note that in diefacea list of stringsthe and are swappedcanvas[(canvasxcanvasy)dieface[dy][dxdisplay the canvas on the screenfor cy in range(canvas_height)for cx in range(canvas_width)print(canvas get((cxcy)')end=''dice math