Skip to content

Instantly share code, notes, and snippets.

@woctezuma
Created December 29, 2023 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woctezuma/99142be562174fce902357c68bcd3dcf to your computer and use it in GitHub Desktop.
Save woctezuma/99142be562174fce902357c68bcd3dcf to your computer and use it in GitHub Desktop.
Find Steam games whose names fullfil a few constraints
import json
import pathlib
import re
WORD_LENGTH = 4
START_FIRST_WORD = "a"
START_LAST_WORD = "i"
WORD_LENGTH = 2
START_FIRST_WORD = "e"
START_LAST_WORD = "a"
WORD_LENGTH = 4
START_FIRST_WORD = "2"
START_LAST_WORD = "d"
def main() -> None:
# Reference: https://steamapi.xpaw.me/#ISteamApps/GetAppList
# Alternatively, use https://steamapi.xpaw.me/#IStoreService/GetAppList
with pathlib.Path("api.steampowered.com.json").open(encoding="utf8") as f:
data = [e["name"] for e in json.load(f)["applist"]["apps"]]
output = []
for s in sorted(set(data)):
# Reference: https://stackoverflow.com/a/55902074/376454
e = re.sub(r"[^A-Za-z0-9 ]+", "", s)
f = e.lower().split()
if (
len(f) == WORD_LENGTH
and f[0].startswith(START_FIRST_WORD)
and f[-1].startswith(START_LAST_WORD)
):
output.append(e)
print("\n".join(output))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment