Created
January 15, 2018 23:18
-
-
Save Ino4137/daf36031170e177c3857455269419721 to your computer and use it in GitHub Desktop.
AOC day 5 part 1 UNHOLY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| macro_rules! walker { | |
| // step | |
| ($steps:expr; $node:expr; [$($listB:tt),* $prev:expr]; [$next:expr, $($listF:expr),+]) => { | |
| match $steps { | |
| $steps if $steps == 0 => { | |
| *$node + 1; | |
| ($node - 1; $node; [$listB, $prev]; [$next, $listF];) | |
| }, | |
| $steps if $steps > 0 => { | |
| ($steps - 1; $next; [$listB, $prev, $node]; [$listF]) | |
| }, | |
| $steps if $steps < 0 => { | |
| ($steps + 1; $prev; [$listB]; [$node, $next, $listF]) | |
| }, | |
| } | |
| }; | |
| // 1st step case | |
| ($steps:expr; [$node:expr, $($listB:expr),*]; [$($listF:expr),+]) => { | |
| ($steps; $node; [$listB]; [$listF]) | |
| }; | |
| // after last step | |
| ($steps:expr; $node:expr; [$($listB:expr),*]; [$($listF:expr),*]) => { | |
| ($steps) | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment