A motion designer plays two looping animations back to back. The pair looks seamless when their total length is a multiple of the beat length k. The loop lengths are in durations.
Write syncedPairs(durations, k) that returns how many pairs of indexes i < j have (durations[i] + durations[j]) % k === 0.
Input: durations = [45,15,75,30,90], k = 60 Output: 3
45 + 15 = 60, 45 + 75 = 120, and 30 + 90 = 120 are multiples of 60.
Input: durations = [60,60,60], k = 60 Output: 3
Every pair adds to 120, a multiple of 60.
0 <= durations.length <= 10^51 <= durations[i] <= 10^91 <= k <= 10^5Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #30 Animation Loops That Sync. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.