Menu
CoddyTech

Smart Contact Manager

Part of the Logic & Flow section of Coddy's GDScript journey. Lesson 76 of 78.

challenge icon

Challenge

Medium

Clean up a list of contacts. The program reads a whole number n, then n lines. Each line is a contact: a name, an email and a phone number, separated by commas (every line has exactly two commas).

Go through the contacts in order:

  1. Write the email in lowercase, and keep only the digits of the phone number: (555) 123-4567 becomes 5551234567
  2. Skip the contact if the email is not valid: a valid email contains @ and ., and no space
  3. Skip the contact if the phone number does not have exactly 10 digits
  4. Skip the contact if a contact you kept before has the same email or the same phone number (after cleaning)

Print each contact you keep on its own line: the name, | , the email, | and the phone digits. Last, print Contacts kept: , how many you kept, of and n.

For these inputs:

3
John Doe,JOHN@email.com,123-456-7890
Jane Doe,jane@email.com,123.456.7890
Bob Smith,invalid.email,12345

the output is:

John Doe | john@email.com | 1234567890
Contacts kept: 1 of 3

Jane is skipped because her phone number has the same digits as John's, and Bob because his email has no @ and his phone number is too short.

Try it yourself

extends Node

func _ready():
	var n := int(OS.read_string_from_stdin())
	# Read n contacts, clean them and print the ones you keep
	pass

All lessons in Logic & Flow

Practice on your own: Online GDScript compiler