aboutsummaryrefslogtreecommitdiff
path: root/challenge-247/luca-ferrari/python/ch-1.py
blob: a80cf2c6bdd8a4b20b73b656b649d123b1586214 (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
30
31
32
33
34
35
36
37
#!python

#
# Perl Weekly Challenge 247
# Task 1
#
# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-247/>
#

import sys
from random import randrange, choice

# task implementation
def main( argv ):
    santas    =  argv.copy()
    receivers =  argv.copy()

    while len( santas ) >= 0 :
        current_santa = santas[ randrange( 0, len( santas )  ) ]
        current_receiver = receivers[ randrange( 0, len( receivers )  ) ]

        if ( current_santa == current_receiver ):
            continue

        print( current_santa, " -> ", current_receiver )
        santas.remove( current_santa )
        receivers.remove( current_receiver )

        if len( santas ) == 0:
            break


# invoke the main without the command itself
if __name__ == '__main__':
    main( sys.argv[ 1: ] )