{"id":20905873,"url":"https://github.com/atom0s/synacor-challenge-2012","last_synced_at":"2025-07-20T12:34:59.532Z","repository":{"id":175259255,"uuid":"471911297","full_name":"atom0s/Synacor-Challenge-2012","owner":"atom0s","description":"My personal code and solution to the Synacor Challenge from 2012 OSCON.","archived":false,"fork":false,"pushed_at":"2022-03-21T04:35:49.000Z","size":724,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-12T21:34:36.731Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atom0s.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-20T07:41:07.000Z","updated_at":"2022-03-20T18:30:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"b645b295-4445-4db4-bb91-b89d602ac9f8","html_url":"https://github.com/atom0s/Synacor-Challenge-2012","commit_stats":null,"previous_names":["atom0s/synacor-challenge-2012"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/atom0s/Synacor-Challenge-2012","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atom0s%2FSynacor-Challenge-2012","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atom0s%2FSynacor-Challenge-2012/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atom0s%2FSynacor-Challenge-2012/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atom0s%2FSynacor-Challenge-2012/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atom0s","download_url":"https://codeload.github.com/atom0s/Synacor-Challenge-2012/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atom0s%2FSynacor-Challenge-2012/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266127236,"owners_count":23880423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T13:28:02.427Z","updated_at":"2025-07-20T12:34:59.505Z","avatar_url":"https://github.com/atom0s.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Synacor OSCON Challenge Solution (2012)\n\nThis repository contains my code and solution to solve the Synacor OSCON 2012 Challenge. \n\nIf you are interested in checking out or trying the challenge for yourself, it can be found online still here:\n\nhttps://challenge.synacor.com/\n\n## Notes\n\nFirstly, please understand this is an old challenge. I am not the first to solve it, not even close, and this was solely done because a friend suggested it to me on Discord this past week. I never saw the challenge before and since it involved implementation of a VM, it was something I was interested in checking out since it has been a topic I've been involved in recently.\n\nNext, the challenge is still online and fully functional. Because of that, it is important to note that if you do sign up and decide to try the challenge, the information in this solution will work but the flags (codes) you need will be different. The challenge generates unique flags for each player. _(The `challenge.bin` data file is unique to each player.)_ If you try to use my flags, you will get an error.\n\nLastly, I used this challenge as a means to continue with my progress of learning Python. So please excuse the messy code and probably poor / old means of which I did some things. I'm sure there are much better ways to code various things I made, but I am still fairly new to Python. \n\n## Repository Information\n\n**You can read my full solution here:** [Full Solution](SOLUTION.md)\n\nIn order to solve the challenge, the main task you are given is to implement a virtual machine that can emulate the given opcodes found within the challenge `arch-spec` file. To handle this part of the challenge, and assisting with other parts, I wrote the virtual machine and a disassembler for the binary data file in Python.\n\n  * **Virtual Machine:** [Virtual Machine Implementation](vm.py)\n  * **Disassembler:** [Disassembler Implementation](dism.py)\n\nThroughout the challenge, once the VM is functional, there are puzzles to be solved. The three puzzles all required their own implementation of code to be solved. Two of the puzzles I was able to solve in Python, however the other was too slow to implement in Python alone. Instead, I opt'd to use C++ for that one instead. _(I made a Python implementation using ghetto threading, but it's ugly and slow so not worth including.)_\n\nThe first puzzle is within the `Ruins` area of the game. My solver for that can be found here:\n\n  * **Ruins Puzzle (Coins):** [Ruins Puzzle Solver](ruins.py)\n\nThe next puzzle, which required the C++ implementation to not be ungodly slow, is for the `teleporter` item puzzle. That can be found here:\n\n  * **Teleporter Puzzle:** [Teleport Puzzle Solver](ackermann/synacor_ackermann/main.cpp)\n\nThe final puzzle, in the `Vault` area, can be solved with my solution here:\n\n  * **Vault Puzzle:** [Vault Puzzle Solver](vault.py)\n\nOther files included in the repo are:\n\n  - [arch-spec](data/arch-spec) - The challenge documentation.\n  - [challenge.bin](data/challenge.bin) - My unique `challenge.bin` binary data file.\n  - [Disassembler Dump](data/dism.txt) - A full dump of my `challenge.bin` disassembly.\n  \n## Challenge Information\n\n```\n== Synacor Challenge ==\nIn this challenge, your job is to use this architecture spec to create a\nvirtual machine capable of running the included binary.  Along the way,\nyou will find codes; submit these to the challenge website to track\nyour progress.  Good luck!\n\n\n== architecture ==\n- three storage regions\n  - memory with 15-bit address space storing 16-bit values\n  - eight registers\n  - an unbounded stack which holds individual 16-bit values\n- all numbers are unsigned integers 0..32767 (15-bit)\n- all math is modulo 32768; 32758 + 15 =\u003e 5\n\n== binary format ==\n- each number is stored as a 16-bit little-endian pair (low byte, high byte)\n- numbers 0..32767 mean a literal value\n- numbers 32768..32775 instead mean registers 0..7\n- numbers 32776..65535 are invalid\n- programs are loaded into memory starting at address 0\n- address 0 is the first 16-bit value, address 1 is the second 16-bit value, etc\n\n== execution ==\n- After an operation is executed, the next instruction to read is immediately after the last argument of the current operation.  If a jump was performed, the next operation is instead the exact destination of the jump.\n- Encountering a register as an operation argument should be taken as reading from the register or setting into the register as appropriate.\n\n== hints ==\n- Start with operations 0, 19, and 21.\n- Here's a code for the challenge website: fNCoeXxLEawt\n- The program \"9,32768,32769,4,19,32768\" occupies six memory addresses and should:\n  - Store into register 0 the sum of 4 and the value contained in register 1.\n  - Output to the terminal the character with the ascii code contained in register 0.\n\n== opcode listing ==\nhalt: 0\n  stop execution and terminate the program\nset: 1 a b\n  set register \u003ca\u003e to the value of \u003cb\u003e\npush: 2 a\n  push \u003ca\u003e onto the stack\npop: 3 a\n  remove the top element from the stack and write it into \u003ca\u003e; empty stack = error\neq: 4 a b c\n  set \u003ca\u003e to 1 if \u003cb\u003e is equal to \u003cc\u003e; set it to 0 otherwise\ngt: 5 a b c\n  set \u003ca\u003e to 1 if \u003cb\u003e is greater than \u003cc\u003e; set it to 0 otherwise\njmp: 6 a\n  jump to \u003ca\u003e\njt: 7 a b\n  if \u003ca\u003e is nonzero, jump to \u003cb\u003e\njf: 8 a b\n  if \u003ca\u003e is zero, jump to \u003cb\u003e\nadd: 9 a b c\n  assign into \u003ca\u003e the sum of \u003cb\u003e and \u003cc\u003e (modulo 32768)\nmult: 10 a b c\n  store into \u003ca\u003e the product of \u003cb\u003e and \u003cc\u003e (modulo 32768)\nmod: 11 a b c\n  store into \u003ca\u003e the remainder of \u003cb\u003e divided by \u003cc\u003e\nand: 12 a b c\n  stores into \u003ca\u003e the bitwise and of \u003cb\u003e and \u003cc\u003e\nor: 13 a b c\n  stores into \u003ca\u003e the bitwise or of \u003cb\u003e and \u003cc\u003e\nnot: 14 a b\n  stores 15-bit bitwise inverse of \u003cb\u003e in \u003ca\u003e\nrmem: 15 a b\n  read memory at address \u003cb\u003e and write it to \u003ca\u003e\nwmem: 16 a b\n  write the value from \u003cb\u003e into memory at address \u003ca\u003e\ncall: 17 a\n  write the address of the next instruction to the stack and jump to \u003ca\u003e\nret: 18\n  remove the top element from the stack and jump to it; empty stack = halt\nout: 19 a\n  write the character represented by ascii code \u003ca\u003e to the terminal\nin: 20 a\n  read a character from the terminal and write its ascii code to \u003ca\u003e; it can be assumed that once input starts, it will continue until a newline is encountered; this means that you can safely read whole lines from the keyboard and trust that they will be fully read\nnoop: 21\n  no operation\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatom0s%2Fsynacor-challenge-2012","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatom0s%2Fsynacor-challenge-2012","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatom0s%2Fsynacor-challenge-2012/lists"}