Test Task - Python Programmer - Event Registration

This task is to be done in Python 3. You are free to do the task at your earliest convenience. You are not limited by time and we are not measuring it. Also feel free to use Google or any other source. But you should do the task all by yourself, without any external help.  

There's no need to enhance the task in any way, try to do your best to achieve the result as per the instructions provided. 

Test Task - Your Details

Name

Email


Test Task - Event Registration

Read carefully the Task Description, work on your computer, use any development tool you like and then push the code to Gitlab or Github - and put the link to your code as below the Description. 

We count on your honesty - please measure your time (how long of actual work did it take you to get the task done, not counting any breaks) and let us know in the question below.

Task Description *

Our company is organizing a webinar. We have invited all people in our Contacts and Leads. However those people are free to invite their friends. Whoever would like to attend the webinar, is asked to register through our contact form. At the end we want to make sure that all registered people will be stored in our Contacts. 


Some technical details:

  • Contacts is a simple class having attributes of Name, Email and Phone (for each contact we'd have Name and then either Email or Phone or both).

  • Leads is also a simple class - having Name, Email and Phone (any of them might be empty, including Name). Those are the people who tried to contact us one way or another, but we didn't have a chance to call them back or to verify that those are real contacts, not just spams. 

  • For the sake of simplicity, we'd not work with any database, just with lists of objects of an instantiated class - ContactsList and LeadsList

  • Every registration form is providing us with JSON that looks like this:

{
  "registrant": 
     { 
        "name": "Tom Jones", 
        "email": "tom@jones.com",
        "phone": "3211234567",
     }
}


Here are the data you should work with (Name/Email/Phone). All phones are stored as 10 digits - no brackets, spaces or dashes

CONTACTS:

Alice Brown / None / 1231112223
Bob Crown / bob@crowns.com / None
Carlos Drew / carl@drewess.com / 3453334445
Doug Emerty / None / 4564445556
Egan Fair / eg@fairness.com / 5675556667


LEADS:

None / kevin@keith.com / None
Lucy / lucy@liu.com / 3210001112
Mary Middle / mary@middle.com / 3331112223
None / None / 4442223334
None / ole@olson.com / None


REGISTRANTS (these should be read as JSON mentioned above)

Lucy Liu / lucy@liu.com / None
Doug / doug@emmy.com / 4564445556
Uma Thurman / uma@thurs.com / None


Now what you should do:

We believe that only real people will register for our webinar. So as mentioned, we want to make sure that all registrants will end up in our Contacts. If they provide us with more details than we currently have (like phone or email) - great! We should store them as well. But non-empty values in Contacts should not be updated. 


In order to match our registrants, we should follow this order: 

1) Try to match registrant's email to our Contacts list

2) If not matched, try to match registrant's phone to our Contacts list

3) Otherwise try to match our LeadsList with email (if Lead is matched, remove it from LeadsList and add to ContactsList)

4) Else match our Leads with phone (same rule as above applies)

5) If not matched, simply add it to ContactsList

That's all! Place a link to your final code here: 

How many minutes did it take you to do the task?