![]() Proc matchPart2(msg: string, rules: TableRef, matchRule: int, msgIdx: var int): bool = # method and the rest of indices with this methodĬheck_rule(string, first) & # if more than one index is given, tries to match a prefix with the sibling # if only one index is given, goes back to the sibling method The check is done using two mutually recursive methods: # tries to match parts of the string to the corresponding indices If the rule is not in cache, it is split at each point and each of the two parts is checked against the possible combinations. If the rule is in cache, the code just checks whether the string is part of the cached values. Then the cache is frozen, and strings are checked. ![]() The solution preheats a cache of words for each rule ( Hash]), up to one or more given targets (by default 0, for the second embedded example and the actual problem input up to 42 and 31). And part two is achieved just by pushing the modified rules and heating the cache to just under boiling temperature. It only uses Set from stdlib and *no regular expression*. Thank you very much, and enjoy your month of code! Paper bags for /u/topaz2078 to breathe into so he doesn't hyperventilate onto another plane of (non-)existence.Server maintenance (hosting, bandwidth, etc.).Any instances of currency will go to, in no particular order: If you really want to show your appreciation, donations are always appreciated. If you'd like to support Advent of Code, please share it with all your friends, even the ones that are just learning to code! AoC is a fun, non-threatening way to work at your own pace to figure out how to apply problem-solving first, then work within a language's constraints. Except AoC.Ĭode should be fun, because otherwise it's just a job. Previous years: 2021 | 2020 | 2019 | 2018 | 2017 | 2016 | 2015 Quick Search by Flair Because you're lazy and we like making things easy for you. If your post is even tangentially related to a daily puzzle, use our Rules + More Info in our community wiki BEFORE YOU POST Advent of Code is an annual Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.
0 Comments
Leave a Reply. |