{"id":25195698,"url":"https://github.com/danprince/webassembly-wizardry","last_synced_at":"2025-09-03T07:40:19.326Z","repository":{"id":256817187,"uuid":"856520782","full_name":"danprince/webassembly-wizardry","owner":"danprince","description":"🪄 Tiny challenges for learning WebAssembly","archived":false,"fork":false,"pushed_at":"2025-01-01T22:56:26.000Z","size":140,"stargazers_count":68,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-17T20:44:23.234Z","etag":null,"topics":["challenges","wasm","wat","webassembly"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/danprince.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,"zenodo":null}},"created_at":"2024-09-12T18:01:44.000Z","updated_at":"2025-05-27T14:14:52.000Z","dependencies_parsed_at":"2025-05-08T05:55:47.727Z","dependency_job_id":"e44a47fd-3803-4a1b-9abe-07cdd4669843","html_url":"https://github.com/danprince/webassembly-wizardry","commit_stats":null,"previous_names":["danprince/wasm-challenges","danprince/webassembly-wizardry"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danprince/webassembly-wizardry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danprince%2Fwebassembly-wizardry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danprince%2Fwebassembly-wizardry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danprince%2Fwebassembly-wizardry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danprince%2Fwebassembly-wizardry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danprince","download_url":"https://codeload.github.com/danprince/webassembly-wizardry/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danprince%2Fwebassembly-wizardry/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273410258,"owners_count":25100450,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["challenges","wasm","wat","webassembly"],"created_at":"2025-02-10T01:19:33.971Z","updated_at":"2025-09-03T07:40:19.286Z","avatar_url":"https://github.com/danprince.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg width=\"300\" src=\"https://github.com/user-attachments/assets/0d8c7c5d-ffdc-4a2a-9c45-07d58fbd4ff1\" /\u003e\u003c/p\u003e\n\u003ch1 align=\"center\"\u003eWebAssembly Wizardry\u003c/h1\u003e\n\nTiny programming challenges designed for learning about WebAssembly by writing it by hand.\n\nEach challenge has a [`.wat`][wat] file where you'll need to implement a WebAssembly module to pass the tests.\n\nRun `node tests.mjs` to run the tests and to see the recommended order for solving the challenges.\n\nThe challenges have descriptions within their `.wat` files, but it some cases it will also be useful to look inside `tests.mjs` to better understand the different test cases.\n\nRemove the `;; SOLVE` comment when you're ready to test your solution.\n\nIf you get stuck or want to compare notes check out my `solutions` branch.\n\n_These challenges assume you have a programming background and are comfortable with some low-level concepts such as binary representations, bitwise operations, memory and pointers._\n\n## Dependencies\n\nTo run the tests and compile `.wat` to `.wasm`, you'll need the following dependencies.\n\n- [`node`](https://nodejs.org)\n- [`wabt`](https://github.com/WebAssembly/wabt)\n\n## Resources\n\nThe challenges aren't designed to teach you WAT syntax or WebAssembly instructions directly, so you'll probably need to do some reading alongside.\n\n- [Understanding WebAssembly text format](https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format)\n- [WebAssembly instruction reference](https://developer.mozilla.org/en-US/docs/WebAssembly/Reference)\n- [WebAssembly specification](https://webassembly.github.io/spec/core/)\n\nWhilst not technically a reference, I found the [WebAssembly core test suite](https://github.com/WebAssembly/spec/tree/main/test/core) incredibly helpful for some exhaustive learning about the various instructions. The files are `.wast` and they include some testing directives, but otherwise they are all valid `.wat`.\n\n## Debugging\n\nEvery challenge can import functions for logging debug values at runtime.\n\n```wat\n(module\n  ;; Add any of the following imports to your .wat module\n  (import \"debug\" \"i32\" (func $debug_i32 (param i32)))\n  (import \"debug\" \"i64\" (func $debug_i64 (param i64)))\n  (import \"debug\" \"f32\" (func $debug_f32 (param f32)))\n  (import \"debug\" \"f64\" (func $debug_f64 (param f64)))\n  (import \"debug\" \"bool\" (func $debug_bool (param i32)))\n  (import \"debug\" \"char\" (func $debug_char (param i32)))\n  (import \"debug\" \"byte\" (func $debug_byte (param i32)))\n  (import \"debug\" \"bits\" (func $debug_bits (param i32)))\n\n  ;; ...\n\n  ;; Then call it with the appropriate value type in your program.\n  (call $debug_f64 (f64.const 123.456))\n)\n```\n\n## Poker Notes\n\nThe poker exercises require you to read values from five cards, which are stored in memory as pairs of `u8` values. The first is the _rank value_ and the second is the _suit value_.\n\n| Decimal Value | Rank Value |\n| ------------- | ---------- |\n| `1`           | `A`        |\n| `2`           | `2`        |\n| `3`           | `3`        |\n| ...           | ...        |\n| `10`          | `10`       |\n| `11`          | `J`        |\n| `12`          | `Q`        |\n| `13`          | `K`        |\n\n| Decimal Value | Suit Value |\n| ------------- | ---------- |\n| `0`           | ♠ Spades   |\n| `1`           | ♣ Clubs    |\n| `2`           | ♥ Hearts   |\n| `3`           | ♦ Diamonds |\n\nSo the hand `A♠ 2♣️ 3♥ 4♦ 5♠️` would be stored in memory as:\n\n| A     | ♠     | 2     | ♣️    | 3     | ♥     | 4     | ♦     | 5     | ♠ ️   |\n| ----- | ----- | ----- | ----- | ----- | ----- | ----- | ----- | ----- | ----- |\n| `0x1` | `0x0` | `0x2` | `0x1` | `0x3` | `0x2` | `0x4` | `0x3` | `0x5` | `0x0` |\n\n## String Notes\n\nThe string challenges all work with [null-terminated](https://en.wikipedia.org/wiki/Null-terminated_string) [ASCII](https://en.wikipedia.org/wiki/ASCII) strings for simplicity, unless stated explicitly otherwise.\n\nCompared to UTF-8 and other multi-byte encodings, ASCII is generally easier to work with, because every single character can be represented with a single byte in memory.\n\nFor example, the string `\"Hello, world\"` would be stored in memory as:\n\n| `H`    | `e`    | `l`    | `l`    | `o`    | `,`    | ` `    | `w`    | `o`    | `r`    | `l`    | `d`    | END    |\n| ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ |\n| `0x48` | `0x65` | `0x6C` | `0x6C` | `0x6F` | `0x2C` | `0x20` | `0x77` | `0x6F` | `0x72` | `0x6C` | `0x64` | `0x00` |\n\nThe strings are null-terminated, which means they always end with a `NUL` byte (`0x00`).\n\n[wat]: https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanprince%2Fwebassembly-wizardry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanprince%2Fwebassembly-wizardry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanprince%2Fwebassembly-wizardry/lists"}