Back to Problem Solutions forum
Modular Inverse problem accepts solution for modular equation:
B * x - A = 0 | mod M
instead of:
A * x + B = 0 | mod M
For first unittest from example:
M, A, B, x = 929, 252, 410, 413
(A * x + B) % m = 438
(B * x - A) % m = 0
For third unittest from example:
M, A, B, x = 705, 77, 443, 589
(A * x + B) % m = 676
(B * x - A) % m = 0
Oh, I see I've made a horrible mistake in formula when trying to refactor it! I'll fix it soon.
Quite curious, how you anyway got to solve this "puzzle" :D
Quite curious, how you anyway got to solve this "puzzle" :D
TDD is my way :)
I'll wait the proper checker and then try to solve it again.
GCD(494,235)=1, the second example of 144 seems buggy.
> TDD is my way :)
You are invaluable specialist! I wish my colleagues share your views! :)
> GCD(494,235)=1, the second example of 144 seems buggy.
I'm afraid they all were completely wrong. Thanks to hint by Serge I've fixed it just now (I hope).
Yes, the bug was in the checker itself and the first version of "example" was generated with it also with bugs.
Since I've fixed them both I think the first solution by Serge should work no more :)
Do you suspect the bug in checker still exists?
No, I think that it’s correct now.
I've submitteded the proper solution for ax+b=0. It works.
But in page http://www.codeabbey.com/index/task_solvers/modular-inverse i see two solutions of Nicolas.
Yes, it is just a buggy "feature" of our site - several solutions in different languages could be saved (though only one is counted). However Python
is sometimes incorrectly detected as Ruby
so the same solution in Python
could give "two" in these two languages... I know it looks silly %)
My codes always begin with the shebang (you can add this in your detector).