Alice's Verbal Kho-Kho — Digit Passing Game

M · mediumP · Verified PYQ

Alice gives a digit to F[1]. Each friend passes the digit to the next without speaking. A confused friend passes digit+1 (wraps: 9->0). Others pass correctly. Given starting digit S, N friends, and final digit F, find how many confusions occurred.

Input
3
5
7
Output
2
confusions = (final - start + 10) % 10. This works due to modular arithmetic.
Start=5, 3 friends, final=7. Confusions = (7-5+10)%10 = 2.
← 9 May 2024 Shift 1 — Remove Duplicates from ArrayAP/GP Series: Find Nth Term →
Report an issue with this question