Magnetic alignment (magneti)

66 teams scored 5400 points on this task, for a maximum score of 100, an average score of 82 and a median score of 100.

Highlights

  1. Liceo Scientifico Severi, Frosinone is the institute with the most points (500).
  2. Emilia-Romagna is the region with the most points (1810).

Statement

Despite his age, Gabriele loves playing with magnets. One of his favourite constructions is the so-called "snake of magnets", which is a long line of magnets. Obviously, magnets can stay one next to the other only when the positive terminal of one magnet matches with the negative terminal of the next magnet, and vice versa. For instance, the following sequences of magnets are valid snakes of magnets: (+-)(+-)(+-)(+-)(+-)and(-+)(-+)(-+), while the following ones are not: (+-)(-+)(-+)(-+)and(-+)(+-)(-+). Given a generic (not necessarily stable) sequence of magnets, Gabriele wonders which is the minimum number of magnets that must be rotated in order to get a snake of magnets.