{"id":20323554,"url":"https://github.com/dplocki/synacor-challenge","last_synced_at":"2026-05-10T18:08:09.703Z","repository":{"id":119391703,"uuid":"326050205","full_name":"dplocki/synacor-challenge","owner":"dplocki","description":"Solution for Synacor Challange.","archived":false,"fork":false,"pushed_at":"2021-01-14T18:25:43.000Z","size":119,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-14T14:11:41.505Z","etag":null,"topics":["challange","python","simulator","synacor","synacor-challenge","virtual-machine"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dplocki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-01-01T20:23:39.000Z","updated_at":"2023-08-19T18:22:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"8c5d92ac-1c8f-40f4-8295-986e7400a65e","html_url":"https://github.com/dplocki/synacor-challenge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dplocki%2Fsynacor-challenge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dplocki%2Fsynacor-challenge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dplocki%2Fsynacor-challenge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dplocki%2Fsynacor-challenge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dplocki","download_url":"https://codeload.github.com/dplocki/synacor-challenge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241827169,"owners_count":20026601,"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":["challange","python","simulator","synacor","synacor-challenge","virtual-machine"],"created_at":"2024-11-14T19:28:35.589Z","updated_at":"2025-11-29T18:05:12.066Z","avatar_url":"https://github.com/dplocki.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Synacor Challenge\n\n![GitHub](https://img.shields.io/github/license/dplocki/synacor-challange)\n![Lines of code](https://img.shields.io/tokei/lines/github/dplocki/synacor-challenge)\n\nSolution for [Synacor Challenge](https://challenge.synacor.com/).\n\nLanguage used: **Python**.\n\n## Tasks\n\n### Virtual machine\n\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#### Architecture\n\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\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\n- After an operation is executed, the next instruction to read is immediately after the last argument of the current operation.\n  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#### Optcodes\n\n| Name | Code | Parameters | Notes |\n|------|------|------------|-------|\n| halt | 0    |            | stop execution and terminate the program |\n| set  | 1    | a b        | set register `a` to the value of `b` |\n| push | 2    | a          | push `a` onto the stack |\n| pop  | 3    | a          | remove the top element from the stack and write it into `a`; empty stack = error |\n| eq   | 4    | a b c      | set `a` to 1 if `b` is equal to `c`; set it to 0 otherwise |\n| gt   | 5    | a b c      | set `a` to 1 if `b` is greater than `c`; set it to 0 otherwise |\n| jmp  | 6    | a          | jump to `a` |\n| jt   | 7    | a b        | if `a` is nonzero, jump to `b` |\n| jf   | 8    | a b        | if `a` is zero, jump to `b` |\n| add  | 9    | a b c      | assign into `a` the sum of `b` and `c` (modulo 32768) |\n| mult | 10   | a b c      | store into `a` the product of `b` and `c` (modulo 32768) |\n| mod  | 11   | a b c      | store into `a` the remainder of `b` divided by `c` |\n| and  | 12   | a b c      | stores into `a` the bitwise and of `b` and `c` |\n| or   | 13   | a b c      | stores into `a` the bitwise or of `b` and `c` |\n| not  | 14   | a b        | stores 15-bit bitwise inverse of `b` in `a` |\n| rmem | 15   | a b        | read memory at address `b` and write it to `a` |\n| wmem | 16   | a b        | write the value from `b` into memory at address `a` |\n| call | 17   | a          | write the address of the next instruction to the stack and jump to `a` |\n| ret  | 18   |            | remove the top element from the stack and jump to it; empty stack = halt |\n| out  | 19   | a          | write the character represented by ascii code `a` to the terminal |\n| in   | 20   | a          | read a character from the terminal and write its ascii code to `a`; 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 |\n| noop | 21   |            | no operation |\n\n### Running\n\nRun Virtual Machine by command:\n\n```bash\npython main.py\n```\n\n#### Parameters\n\n- `-l`: load dump file (excepte file name after `-l` option)\n- `-d`: display debug information during running program\n\nExample:\n\n```bash\npython main.py -l save.dump -d\n```\n\n### Decompiling\n\nRun decompile script. The script requires dump file to operate on.\n\n```bash\npython decompile.py -l save.dump\n```\n\n## Other puzzles notes\n\nAfter running the virtual machine, we can play in the text advature hidden in the given program. In the game we can find another puzzles:\n\n- [A puzzle for open the door](./puzzles/door_puzzle.ipynb)\n- [A puzzle breaking the teleporter check function](./puzzles/check_code.ipynb)\n- [A puzzle with bypassing the check function invoking](./puzzles/bypassing_the_check.md)\n- [A puzzle with opening the vault lock](./puzzles/vault_lock.ipynb)\n- [A puzzle with mirror](./puzzles/mirror_puzzle.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdplocki%2Fsynacor-challenge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdplocki%2Fsynacor-challenge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdplocki%2Fsynacor-challenge/lists"}