My math problem generator fails after 4,5 tries and stops with my button colored orange

here are my blocks. you can see that the app is configurable (see dictionary at start). i only have 2 operations (addition, subtraction) right now but the app generates a math problem according to the rules.
for example for addition, it will generate 2 addends (none over 50) but with the additional (but redundant) check that the sum shouldn't be greater than 100.

the app workds giving me random addition or subtracton each time but at the 4th or 5th (or 6th?) problem it stops and my submit button turns to orange! i have to reset to restart. it's the same behavior when i try it on my android via companion connection.

i suspect it's a memory leak but i have no idea how those things occur!
any help is appreciated.

here'a picture of the blocks.

and here's the aia
mathprob_gen.aia (6.8 KB)

I blame those WHILE loops.

Somehow you are forcing them to loop forever, expecting the impossible.

Either add some validation to prevent that, or refactor your code to replace those WHILE loops with another SELECT RANDOM NUMBER IN RANGE block, working backwards from your first randomly selected operand and your target limit.

you hit it right on the spot. there were possibilites of an infinite loop so i recoded the program to remove that chance. it's working now. thanks!
here's the new the new aia
mathprob_gen.aia (6.9 KB)

and the new blocks

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.