{"id":17245591,"url":"https://github.com/bobbicodes/advent-2016","last_synced_at":"2025-07-03T08:09:02.296Z","repository":{"id":101319096,"uuid":"109871813","full_name":"bobbicodes/advent-2016","owner":"bobbicodes","description":"Advent of Code 2016","archived":false,"fork":false,"pushed_at":"2018-05-25T00:06:03.000Z","size":459,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-26T05:09:09.169Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","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/bobbicodes.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":"2017-11-07T18:00:30.000Z","updated_at":"2025-02-20T21:17:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"860b8f57-48e5-4906-b330-68bce489fefa","html_url":"https://github.com/bobbicodes/advent-2016","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bobbicodes/advent-2016","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobbicodes%2Fadvent-2016","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobbicodes%2Fadvent-2016/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobbicodes%2Fadvent-2016/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobbicodes%2Fadvent-2016/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bobbicodes","download_url":"https://codeload.github.com/bobbicodes/advent-2016/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobbicodes%2Fadvent-2016/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263287907,"owners_count":23443088,"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-10-15T06:29:55.827Z","updated_at":"2025-07-03T08:09:02.269Z","avatar_url":"https://github.com/bobbicodes.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Advent of Code 2016 problems\n\nSince they all involve parsing some kind of input data, this will be a job for ... [Instaparse](https://github.com/Engelberg/instaparse)!\n\nWith it we can use a context-free grammar to generate a tree-like structure from our data.\n\n### Day 4\n\nFor example, here's an input string for the day 4 problem. Each room is represented as a key, id and checksum:\n\n    aaaaa-bbb-z-y-x-123[abxyz]\n\nThe key is made of one or more strings of letters separated with hyphens.\nThe id is a string of numbers, and the checksum is a string of letters in brackets.\nThis is how we represent that in [EBNF notation](en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form)... In Clojure!:\n  \n    (def room-parser\n      (insta/parser\n        \"room = key id checksum\n        key = (word \u003cseparator\u003e)+\n        \u003cseparator\u003e = '-'\n        word = #'[a-zA-Z]+'\n        checksum = \u003c'['\u003e word \u003c']'\u003e\n        id = #'[0-9]+'\"))\n        \n Now we pass the input to our shiny-new parser:\n\n    (room-parser \"aaaaa-bbb-z-y-x-123[abxyz]\")\n    \nAnd we get our magical tree! Ooowee!\n  \n    =\u003e [:room [:key [:word \"aaaaa\"] [:word \"bbb\"] [:word \"z\"] [:word \"y\"] [:word \"x\"]]\n    [:id \"123\"]\n    [:checksum [:word \"abxyz\"]]]\n\nWe can even make a pretty little chart using [rhizome](github.com/ztellman/rhizome) and [graphviz](www.graphviz.org/)! Oooweee!\n\n    (insta/visualize  (room-parser \"aaaaa-bbb-z-y-x-123[abxyz]\"))\n\n![room](https://github.com/sdfwer124/interview-problems/blob/master/room.png)\n\n### Day 10\n\nLet's do another one!\nDay 10 we are programming robots.\n\nThe input data consists of instructions like this:\n\n    bot 147 gives low to bot 67 and high to bot 71\n    bot 142 gives low to bot 128 and high to bot 164\n    bot 47 gives low to bot 4 and high to bot 209\n    bot 107 gives low to bot 194 and high to bot 103\n    bot 102 gives low to bot 82 and high to bot 3\n    bot 101 gives low to bot 46 and high to bot 111\n    value 23 goes to bot 76\n    \nWe'll break it down to the first line:\n\n    (def bots \"bot 147 gives low to bot 67 and high to bot 71\")\n    \nNow we'll express the relevant data in EBNF notation: \n\n    (def bot-parser\n      (insta/parser\n        \"handoff = bot+\n         bot = word whitespace id\n         word = #'[a-zA-Z]+'\n         whitespace = #'\\\\s+'\n         id = #'[0-9]+'\"))\n         \n  Each transaction performed by the bots is represented as a \"handoff\".\n  A handoff is a messenger bot followed by one or more receiver bots.\n  \n  Let's use this parser to visualize this transaction:\n  \n    (insta/visualize (bot-parser bots))\n    \n![bots](https://github.com/sdfwer124/interview-problems/blob/master/src/advent/bots.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobbicodes%2Fadvent-2016","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbobbicodes%2Fadvent-2016","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobbicodes%2Fadvent-2016/lists"}