aboutsummaryrefslogtreecommitdiff
path: root/challenge-228/sgreen/python/ch-2.py
blob: 5422a435d1845777bb7a8ccf1c21d9d3c0f94d6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3

import sys


def main(ints):
    # Get the minimum value
    moves = 0
    min_int = min(ints)

    while len(ints):
        moves += 1
        value = ints.pop(0)

        # If this is the minimum value, calculate the new minimum value
        if value == min_int:
            if len(ints):
                min_int = min(ints)
        else:
            # Move it to the end
            ints.append(value)

    print(moves)


if __name__ == '__main__':
    # Convert input into integers
    array = [int(n) for n in sys.argv[1:]]
    main(array)