• + 13 comments

    Hmmm.. I made a completely different algorithm than the proposed one on the Editorial.

    First, I check if there is an odd number of odds, because the way I understood it, when you give an odd a loaf, you "push the odd forward"... So it needs to reach another odd number so that both become even.

    When I realised that, all that was left, after checking there was an even number of odds (so every odd could be pushed into another one), was to get the distances between odd numbers and multiply them by 2, because on every "push" you give 2 loaves of bread.

    It's a real simple algorithm and isn't a greedy one.