partial bugfix: make grid consistent

This was satisfying to visually debug.

But now we can again end up with totals over 10 😅
This commit is contained in:
Kartik K. Agaram 2023-11-16 11:01:04 -08:00
parent d6b1b38d6a
commit 69b803b9f2
3 changed files with 10 additions and 5 deletions

View File

@ -1 +1 @@
Debug_animation_period = 0.3 -- seconds between animation frames
Debug_animation_period = 1 -- seconds between animation frames

View File

@ -1,7 +1,7 @@
on.keychord_press = function(chord, key)
print(chord)
if chord == 'C-n' then
new()
animate(new)
elseif chord == '`' then
if Draw == 'problem' then
Draw = 'solution'

View File

@ -7,14 +7,19 @@ generate = function()
{'', ''},
},
}
Solution = g
g.data[1][1] = math.random(1,9)
-- loiter()
local d11 = g.data[1][1]
g.row_totals[1] = math.random(d11+1,10)
g.col_totals[1] = math.random(d11+1,10)
-- loiter()
g.data[1][2] = g.row_totals[1] - d11
g.data[2][1] = g.col_totals[1]-d11
g.row_totals[2] = math.random(g.data[1][2]+1,10)
-- loiter()
g.col_totals[2] = math.random(g.data[2][1]+1,10)
g.data[2][2] = g.col_totals[2]-g.data[2][1]
Solution = g
-- loiter()
g.data[2][2] = g.col_totals[2]-g.data[1][2]
-- loiter()
g.row_totals[2] = g.data[2][1] + g.data[2][2]
end