3 ms·
3 = 123+4+5-6*7^89 First verifiable instance of error? Did a little fishing for overflow candidates with the following regex: [1-9]{3,}\^[1-9]{3,} ...caug
by metaphor 10y ago
3 = 123+4+5-6*7^89
First verifiable instance of error?
Did a little fishing for overflow candidates with the following regex:
[1-9]{3,}\^[1-9]{3,}
...caught 58 results between 266 and 10940:
266 = 123^456-78-9
...
10940 = 12345^6789
My kung fu isn't Python so I don't know how types are handled. That eval() function sure smells suicidal for anything remotely serious though.
- witty_username 10y agoNo, Python doesn't have integer overflow. "^" is the XOR operator. GP's code has that bug. > That eval() function sure smells suicidal for anything remotely serious though. Yes, ast.literal_eval() should be used.
- adtac 10y agoUgh, fixed it. Using * * is not really an option now because it takes insane amounts of time to compute something like `123456789`. And this is just a tiny script - `eval` shouldn't really be an issue. And yes, I know it's evil, generally. But if you think about it, Python itself is just one big eval loop :P