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')
@kwirk
Copy link
Author

kwirk commented Feb 20, 2023

ChatGPT input (not showing intermediate responses)

Write code to generate all possible standard UK amateur radio call signs, read in a CSV of already allocated call signs, and write out a CSV file all unallocated call signs as a result. 
Please update the code limiting the call sign generation 3 character suffixes, and only for the following prefixes: M0, M1, M3, M5, M6, M7, 20, 21, G0, G1, G2, G3, G4, G5, G6, G7, G8.
When reading in the call signs, use the standard library CSV parser, and take the call sign from the first column.
Read in the CSV of allocated call signs with "windows-1252" encoding.
Update the code, excluding all suffixes starting with Q and Z, and listed below:
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

@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