4 kyu
Spinning Rings - Fidget Spinner Edition
105 of 263Voile
Description:
This is the performance version of this kata.
Imagine two rings with numbers on them. The inner ring spins clockwise and the outer ring spins anti-clockwise. We start with both rings aligned on 0 at the top, and on each move we spin each ring by 1. How many moves will it take before both rings show the same number at the top again?
The inner ring has integers from 0 to innerMax and the outer ring has integers from 0 to outerMax, where innerMax and outerMax are integers >= 1.
e.g. if innerMax is 2 and outerMax is 3 then after
1 move: inner = 2, outer = 1
2 moves: inner = 1, outer = 2
3 moves: inner = 0, outer = 3
4 moves: inner = 2, outer = 0
5 moves: inner = 1, outer = 1
Therefore it takes 5 moves for the two rings to reach the same number
Therefore spinningRings(2, 3) = 5
e.g. if innerMax is 3 and outerMax is 2 then after
1 move: inner = 3, outer = 1
2 moves: inner = 2, outer = 2
Therefore it takes 2 moves for the two rings to reach the same number
spinningRings(3, 2) = 2
Test input range:
100
tests with1 <= innerMax, outerMax <= 10000
400
tests with1 <= innerMax, outerMax <= 2^48
Performance
Similar Kata:
Stats:
Created | Sep 7, 2017 |
Published | Sep 7, 2017 |
Warriors Trained | 2998 |
Total Skips | 746 |
Total Code Submissions | 5245 |
Total Times Completed | 263 |
Python Completions | 105 |
Ruby Completions | 14 |
JavaScript Completions | 81 |
COBOL Completions | 8 |
D Completions | 6 |
Rust Completions | 14 |
Go Completions | 11 |
C++ Completions | 20 |
C# Completions | 13 |
C Completions | 51 |
Total Stars | 144 |
% of votes with a positive feedback rating | 90% of 63 |
Total "Very Satisfied" Votes | 54 |
Total "Somewhat Satisfied" Votes | 6 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 3 |
Average Assessed Rank | 4 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 5 kyu |