From e94a2eb70482a255ba9fcd7fc42e099a777d4c5f Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 4 Dec 2016 18:50:15 -0500 Subject: Use math to rotate in day 4 --- src/bin/day04.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/bin/day04.rs b/src/bin/day04.rs index c6a9709..8e724c2 100644 --- a/src/bin/day04.rs +++ b/src/bin/day04.rs @@ -64,15 +64,12 @@ impl Room { } fn rotate(c: char, n: u32) -> char { - let mut c = c; - for _ in 0..n { - c = match c { - 'a' ... 'y' => (c as u8 + 1) as char, - 'z' => 'a', - _ => panic!("cannot rotate {}", c), - } + let c = c as u8 + (n % 26) as u8; + if c > b'z' { + (c - 26) as char + } else { + c as char } - c } fn solve1(input: &str) -> u32 { -- cgit 1.4.1 t> IRC logger
summary refs log tree commit diff
path: root/scoop.c (unfollow)
Commit message (Collapse)Author
2019-12-31Add scoop output format optionJune McEnroe
2019-12-31Refactor scoop formatters and group colored outputJune McEnroe
2019-12-31Add strftime format string optionJune McEnroe
2019-12-31Refactor binding in scoopJune McEnroe
2019-12-31Add option to group events by contextJune McEnroe
2019-12-31Add missing includeJune McEnroe
2019-12-31Use standout mode for highlightingJune McEnroe
2019-12-31Rewrite scoop(1) argument descriptionsJune McEnroe
2019-12-31Color both nicks in a changeJune McEnroe
2019-12-31Implement nick-colored outputJune McEnroe
2019-12-31Only enable highlighting on terminal outputJune McEnroe
2019-12-31Set up pager pipeJune McEnroe
2019-12-30Normalize date inputJune McEnroe
Mostly this just allows the use of 'now'.
2019-12-30Add initial rough version of scoopJune McEnroe
2019-12-30Join with USING wherever possibleJune McEnroe
2019-12-30Add -D flag to prospective scoop manualJune McEnroe
2019-12-30Order results by ID in outer query in litterboxJune McEnroe
2019-12-30Use X macro for Type enumJune McEnroe
2019-12-30Remove scoop -ABCJune McEnroe
I can almost get these to work with an inner and outer SQL query, but when contexts starts overlapping it becomes a disaster, so I'm leavin it out at least for now.
2019-12-30Add limit option for litterbox's search query interfaceJune McEnroe