Skip to content

Instantly share code, notes, and snippets.

@Ino4137
Created January 15, 2018 23:18
Show Gist options
  • Select an option

  • Save Ino4137/daf36031170e177c3857455269419721 to your computer and use it in GitHub Desktop.

Select an option

Save Ino4137/daf36031170e177c3857455269419721 to your computer and use it in GitHub Desktop.
AOC day 5 part 1 UNHOLY
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