#1 Step Motor Fun: Wave drive
Description:
Introduction
In this Kata, we will play with the Wave drive method of moving the motor. Let's play with a step motor like this:Stepper motor There are four motor coils, A, B, C, and D. You have to alternate them to move the motor. To implement the Wave drive, you must consequently activate the four coils. Each switching of coils results in a 3.6° motor shaft rotation. The direction of rotation is defined by upstreaming or downstream of the coils. Therefore A->B->C->D->A->... is the positive direction, and A->D->C->B->A->... is negative.
Task
You will be given an array of strings with desired positions in degrees that the motor shaft must stop. To register the position, we will use a `_` symbol. The start position of the shaft is always 0° (A coil is energized). Your task is to return a sequence of coils that must be energized accordingly.
Example
Input: ["3.6", "10.8", "-7.2", "0.0"]
Output: "B_CD_CBADC_DA_"
Explanation: Starting from 0°, switching to coil `B` will rotate the motor shaft 3.6°, the symbol `_` to register the position, `CD` two 3.6° steps -> 10.8°, `_` register position, `CBADC` moving downstream alphabet and rotating the shaft backward six steps -3.6° each, `_` register position.
Note
Typically a standard motor has a tolerance of +/- 5% non accumulative error regarding the location of any given step. This means that any step on a 100 step per revolution motor will be within a 0.36° error range.
If the motor cannot stop in the desired position with precision 0.36°, raise a ValueError with text like "Position 4.0° can't be reached." Replace 4.0 with the value you cannot reach.
Similar Kata:
Stats:
Created | Apr 4, 2023 |
Published | Apr 4, 2023 |
Warriors Trained | 35 |
Total Skips | 3 |
Total Code Submissions | 177 |
Total Times Completed | 19 |
Python Completions | 19 |
Total Stars | 2 |
% of votes with a positive feedback rating | 64% of 11 |
Total "Very Satisfied" Votes | 6 |
Total "Somewhat Satisfied" Votes | 2 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 11 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 6 kyu |