-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask-2-7.txt
More file actions
17 lines (16 loc) · 1.17 KB
/
Copy pathTask-2-7.txt
File metadata and controls
17 lines (16 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
The safe has a combination lock with four dials showing digits
from 0 to 9. In one move you may turn exactly one dial by one
step up or down. The dials are circular: after 9 comes 0, and
before 0 is 9. The current code A is entered, then on the next line
the target code B. Both are four-digit numbers with no leading
zeros. Find the minimum number of moves to reach the target
code from the current one. Example: from 1000 to 1009 - 1 move
(turn the last dial from 0 to 9).
У сейфа кодовый замок из четырёх дисков с цифрами от 0
до 9. За один ход можно повернуть один диск на одну
позицию вверх или вниз. Диски циклические: после 9 идёт 0,
перед 0 - 9. Вводится текущий код А, на следующей
строке - целевой В. Оба четырёхзначные, без ведущих
нулей. Найди минимальное количество ходов для получения
целевого кода из текущего. Пример: из 1000 в 1009 - 1 ход
(повернуть последний диск с 0 на 9).