Swapping Digits (swappingdigits)

100 teams scored 8797 points on this task, for a maximum score of 100, an average score of 88 and a median score of 100.

Highlights

  1. Banfi, Vimercate is the institute with the most points (600).
  2. Lombardia is the region with the most points (2144).

Statement

You are given a positive integer N. In one move you are allowed to swap any two digits of N. For example, if N is 1234, then after swapping the first and the third digit N becomes 3214, and if N is 20005, after swapping the first and the fourth digit N becomes 00025 = 25. Note that you can not get 20005 from 25 (i.e., you should not assume the existence of leading zeroes). What is the minimum number of moves to make N divisible by 25? If it is not possible to make N divisible by 25 using the above operation some (possibly zero) number of times, then the answer is -1.