Beta

#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.

Wave Drive

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.

Algorithms
Mathematics

Similar Kata:

More By Author:

Check out these other kata created by Max_Pegankin

Stats:

CreatedApr 4, 2023
PublishedApr 4, 2023
Warriors Trained35
Total Skips3
Total Code Submissions177
Total Times Completed19
Python Completions19
Total Stars2
% of votes with a positive feedback rating64% of 11
Total "Very Satisfied" Votes6
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes3
Total Rank Assessments11
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • Max_Pegankin Avatar
Ad