You're a professional hacker and your boss has just ordered you to help his favorite candidate to win the election. Your task is to alter the voting machines data to boost your candidate's results.
Voting machines store voting results as two integers : the number of votes for your candidate (v1) and the number of votes for his opponent (v2).
After weeks of research, you have found a security hole in the system and you can increase the value of v1 by an integer x, and decrease the value of v2 by the same x.
But there is a constraint, you have to keep the security hash code constant:
- security hash code :
(v1 + v2*2) modulo 7
Also, the value for x must be minimal so your changes can go unnoticed.
Your program should accept as input v1 and v2 ; it should output the optimal value for x so v1>v2.
There are some cases for which you cannot hack the results ; you don't have to handle them (this might lead to problems with your boss, but that's another story).
Test cases
100,123 --> 14
47,23 --> 0
40,80 --> 21
62,62 --> 7
1134,2145 --> 511

xmust be a multiple of7than to talk about the hash. – xnor 6 hours ago