The Captain's Room

  • + 1 comment

    Ah, I've just now noticed the phrase "having removed the integer parsing". Ok, let's do that and see..

    UPDATE: here is the timing after removing the integer parsing:

    $ cat captain-bruce-ver3.py 
    nom = int(input())
    members = input().split()
    rooms = set()   # Contains all the rooms.
    room_more_mem = set()   # Contains only the rooms with families.
    
    for m in members:
        if m not in room_more_mem:
            target = room_more_mem if m in rooms else rooms
            target.add(m)
    print(rooms.difference(room_more_mem).pop())
    $ time python3 captain-bruce-ver3.py  < input01.txt 
    2710
    
    real	0m0.447s
    user	0m0.407s
    sys	0m0.040s
    

    Yes, indeed, your solution is faster and superior. Excellent! Thank you, Bruce --- you have taught me something new and I now stand corrected and grateful! :)