Write a programExercise 3/4Elementary20 XP

A piece on a game board

Task

A piece stands on square 0. The program reads dice throws - numbers from 1 to 6 on one line, separated by spaces. After each throw the piece moves forward by the value thrown. If it ends on square 5, 13 or 20, it goes back to square 0.

The program prints after how many throws the piece first reaches square 30 or beyond. If the throws are not enough, it prints -1.

For the throws 4 1 6 6 6 6 6 6 the program prints 7 (after the second throw the piece is on square 5, so it goes back to the start).

Examples

  • Input

    4 1 6 6 6 6 6 6

    Expected output

    7

After you submit, 7 hidden tests will also check your solution: no going back, back right after the first throw, not enough throws, few throws, ends on 29, back from square 20, extra throws do not count.

Python starts the first time you run code.

Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.

Input (stdin)

Each line = one call to input().

Output

Hints

Try it yourself first. Each hint reveals a little more - and lowers the reward a little.

Signed out, hints are free - but no XP is awarded either.

Solution

The solution unlocks after the last hint.