Skip to content

Instantly share code, notes, and snippets.

@kwirk
Created February 20, 2023 23:02
Show Gist options
  • Save kwirk/a381165e13f7c13fdc3768e9e1c2cc06 to your computer and use it in GitHub Desktop.
Save kwirk/a381165e13f7c13fdc3768e9e1c2cc06 to your computer and use it in GitHub Desktop.
callsigns.py
import csv
import string
import itertools
# Define valid prefixes and suffixes
valid_prefixes = ['M0', 'M1', 'M3', 'M5', 'M6', 'M7', '20', '21', 'G0', 'G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8']
valid_suffixes = [''.join(s) for s in itertools.product(string.ascii_uppercase, repeat=3) if s[0] not in {'Q', 'Z'} and ''.join(s) not in {'ADS', 'AID', 'ASS', 'AUT', 'BIG', 'BIT', 'BOG', 'BOL', 'BOM', 'BUM', 'CFM', 'CNT', 'COC', 'COK', 'COL', 'COW', 'CUM', 'DIC', 'DIE', 'DIK', 'DOR', 'DSC', 'ETA', 'FAG', 'FIC', 'FOC', 'FOF', 'FOO', 'FUC', 'FUK', 'FUX', 'GIT', 'GOD', 'HCQ', 'HIV', 'HOA', 'HON', 'HOR', 'IIR', 'IRA', 'IUD', 'JDX', 'JEW', 'JJJ', 'KKK', 'KOC', 'KOK', 'KTS', 'LIC', 'LIM', 'LOO', 'LPC', 'MIN', 'MOO', 'MSG', 'MSI', 'NIG', 'NIJ', 'NIL', 'NIP', 'NOB', 'OOG', 'PBL', 'PIG', 'PIM', 'PIN', 'PIS', 'POK', 'PON', 'POO', 'POR', 'POT', 'POX', 'PSE', 'RAF', 'RCC', 'REF', 'RID', 'RIM', 'ROD', 'ROG', 'RON', 'RPT', 'RSE', 'SAR', 'SEX', 'SIC', 'SIG', 'SLT', 'SOD', 'SOI', 'SOS', 'SOW', 'SVC', 'SYS', 'TFC', 'TIT', 'TOO', 'TOS', 'TTT', 'TXT', 'VDB', 'VIL', 'VIZ', 'WIP', 'WNG', 'WNK', 'WOG', 'WOP', 'WOR', 'XSC', 'XXX', 'YID'}]
# Generate all possible call signs
all_callsigns = []
for prefix in valid_prefixes:
for suffix in valid_suffixes:
call = prefix + suffix
all_callsigns.append(call)
# Read in allocated call signs from CSV file
allocated_callsigns = set()
with open('allocated_callsigns.csv', 'r', encoding='windows-1252') as f:
reader = csv.reader(f)
for row in reader:
call_sign = row[0].strip()
allocated_callsigns.add(call_sign)
# Find unallocated call signs
unallocated_callsigns = sorted(set(all_callsigns) - allocated_callsigns)
# Write out unallocated call signs to CSV file
with open('unallocated_callsigns.csv', 'w') as f:
for call in unallocated_callsigns:
f.write(call + '\n')
@matburnham
Copy link

Forked this at https://gist.github.com/matburnham/b29790039e158ee9de3cb6e65c8ec20c to generate number of syllables and number of morse elements (or at least what ChatGPT thinks of those, I'm not sure it's got it perfect).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment