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'],
"ZA": ['BW', 'LS', 'MZ', 'NA', 'SZ', '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()
# Strip whitespaces and uppercase input
search_country = args.country.strip().upper()
search_country = args.country
recursion_depth = args.recursion
if recursion_depth > 12:
sys.exit("Recursion should be less than or equal 12! You doing something stupid here.")
result = {search_country}
for i in range(recursion_depth):
result = set(NEAR_COUNTRIES[search_country])
for i in range(1, recursion_depth, 1):
n_c = list(result)
for country in n_c:
result.update(NEAR_COUNTRIES.get(country,[]))
# Remove search country from result
result.discard(search_country)
result.update(NEAR_COUNTRIES[country])
list_result = list(result)
list_result.sort()