7 kyu

Safecracker

154 of 182saudiGuy

Description:

Traditional safes use a three-wheel locking mechanism, with the safe combination entered using a dial on the door of the safe. The dial is marked with clockwise increments between 0 and 99. The three-number combination is entered by first dialling to the right (clockwise), then to the left (anti-clockwise), and then to the right (clockwise) again. Combination numbers are read from the top of the dial:

Given the starting (top) position of the dial and the increments used for each turn of the dial, return a tuple containing the combination of the safe.

Step-By-Step Example

(0, (3, 10, 5)) ➞ (97, 7, 2)

Starting dial position of 0 (same as the diagram above).

First turn (rightward) of 3 increments:
0 -> 99, 98, 97
First number of combination = 97

Second turn (leftward) of 10 increments:
97 -> 98, 99, 0, 1, 2, 3, 4, 5, 6, 7
Second number of combination = 7

Third turn (rightward) of 5 increments:
7 -> 6, 5, 4, 3, 2
Third number of combination = 2

The final combination is (97, 7, 2)

Other Examples

(96, (54, 48, 77)) ➞ (42, 90, 13)

(43, (51, 38, 46)) ➞ (92, 30, 84)

(4, (69, 88, 55)) ➞ (35, 23, 68)

Notes

  • Two consecutive numbers will equal
  • Values greater than 100 may be provided
Algorithms

Similar Kata:

More By Author:

Check out these other kata created by saudiGuy

Stats:

CreatedSep 13, 2023
PublishedSep 13, 2023
Warriors Trained314
Total Skips2
Total Code Submissions362
Total Times Completed182
Python Completions154
Rust Completions37
Total Stars8
% of votes with a positive feedback rating93% of 51
Total "Very Satisfied" Votes44
Total "Somewhat Satisfied" Votes7
Total "Not Satisfied" Votes0
Total Rank Assessments13
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • saudiGuy Avatar
  • Blind4Basics Avatar
  • akar-0 Avatar
Ad