2 Commits

Author SHA1 Message Date
Kira bdbcb47075 Initial commit, hopefully everything is fine :3 2025-12-22 10:27:45 +01:00
Kirill Shakirov b05aee9825 Initial commit 2025-12-22 09:56:13 +01:00
+5 -10
View File
@@ -182,7 +182,7 @@ NEAR_COUNTRIES = {
"YE": ['OM', 'SA'], "YE": ['OM', 'SA'],
"ZA": ['BW', 'LS', 'MZ', 'NA', 'SZ', 'ZW'], "ZA": ['BW', 'LS', 'MZ', 'NA', 'SZ', 'ZW'],
"ZM": ['AO', 'BW', 'CD', 'MW', 'MZ', 'NA', 'TZ', 'ZW'], "ZM": ['AO', 'BW', 'CD', 'MW', 'MZ', 'NA', 'TZ', 'ZW'],
"ZW": ['BW', 'MZ', 'ZA', 'ZM'] "ZW": ['BW', 'MZ', 'ZA', 'ZM'],
} }
@@ -208,21 +208,16 @@ def main():
args = parser.parse_args() args = parser.parse_args()
# Strip whitespaces and uppercase input search_country = args.country
search_country = args.country.strip().upper()
recursion_depth = args.recursion recursion_depth = args.recursion
if recursion_depth > 12: if recursion_depth > 12:
sys.exit("Recursion should be less than or equal 12! You doing something stupid here.") sys.exit("Recursion should be less than or equal 12! You doing something stupid here.")
result = {search_country} result = set(NEAR_COUNTRIES[search_country])
for i in range(recursion_depth): for i in range(1, recursion_depth, 1):
n_c = list(result) n_c = list(result)
for country in n_c: for country in n_c:
result.update(NEAR_COUNTRIES.get(country,[])) result.update(NEAR_COUNTRIES[country])
# Remove search country from result
result.discard(search_country)
list_result = list(result) list_result = list(result)
list_result.sort() list_result.sort()