Please tell me an efficient and easy way to calculate the values c & d.
0 <= c,d <= 25
9 = (c * 2 + d) % 26
14 = (c * 17 + d) % 26
>>352234
Numerically.
Generally, if there's fewer than a few billion permutations, there's no point in being cute.
https://repl.it/Jfth/0
>>352244
I had the same idea, but I also need to calculate the values with pen & paper. Isn't there a different approach than just testing each value?
>>352247
You're breaking out constants for no reason there.
Read http://thedailywtf.com/articles/Soft_Coding .
Maybe also read up on the "and" operator and using the "%" operator on formatting strings.
>>352247
You can subtract top from bottom to get
5 = (15c) % 26
Then find a number x so that x*15 = 1 %26. Just keep looking at multiples of 26 until you get one where number+1 is divisible by 15. We know this is only possible for multiples of 4 - 4 works actually. 26*4 + 1 = 105, which divides by 15 into 7. So then we can do
5*7 = 15c*7 %26
Mod of the lefthand side is 9. Now you can plug in c to get d.
>>352276
Seems good.
Thank you, anon.
>>352234
Numerator=Quotient*Denominator+Remainder
Since it's an integer division, I'll name the quotients "n" and "m"
9 = (c * 2 + d) % 26 <=> c * 2 + d = n*26 + 9
14 = (c * 17 + d) % 26 <=> c * 17 + d = m*26 + 14
c = 1/3 + 26*m/15 - 26*n/15
d = 25/3 - 52*m/15 + 442*n/15
c >= 0 <=> n <= m + 5/26
c <= 25 <=> n >= 1/13 (13 * m - 185)
d >= 0 <=> n >= 1/442 * (52 * m - 125)
d <= 25 <=> n <= 1/221 (26 * m + 125)
These can be solved grafically. You get many (n, m) couples that solve your equations. If you want integer c and d, the (1, 6) couple results in c = 9 and d = 17.
>>352373
Thank you for your detailed answer.