-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path048.py
More file actions
28 lines (21 loc) · 660 Bytes
/
048.py
File metadata and controls
28 lines (21 loc) · 660 Bytes
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
# https://www.freecodecamp.org/learn/daily-coding-challenge/2025-09-27
import re
def is_spam(number):
parts = number.split()
country_code = parts[0][1:]
area_code = parts[1][1:-1]
local = parts[2].split("-")
if len(country_code) > 2 or country_code[0] != "0":
return True
if int(area_code) > 900 or int(area_code) < 200:
return True
sum_local = 0
for char in local[0]:
sum_local += int(char)
if str(sum_local) in local[1]:
return True
stripped = re.sub("[-+() ]", "", number)
for i in range(10):
if f"{i}{i}{i}{i}" in stripped:
return True
return False