Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- to avoid as much attention as possible when you're moving around the viking ship you've created a ingenious system
- to walk whereever you're supposed to walk
- if you're at row N and N is an even number, you go straight to row N/2. if N is an odd number you go to row 3N+1
- and you continue this until you've reached your target row.
- There's a limited number of rows in the ship. if your system is leading you to non-existing rows, you just have to return to your spot and return that it's not possible to reach your destination
- input:
- a line with three whole numbers N(number of total rows), M(start row) and K(destination).
- output: a whole number wich represents the number of moves you have to make to get to the destination.
- if there's no solution, return "-1"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement