From bed2dd20f640ccd4eab0a8ffbd5052f3593357b5 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 13 Dec 2020 00:13:32 -0500 Subject: Solve day 13 part 1 --- 2020/day13.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 2020/day13.c (limited to '2020') diff --git a/2020/day13.c b/2020/day13.c new file mode 100644 index 0000000..f8c0665 --- /dev/null +++ b/2020/day13.c @@ -0,0 +1,26 @@ +#include +#include +#include +int main(void) { + int earliest = 0; + scanf("%d\n", &earliest); + int buses[128] = {0}; + int len = 0; + for (;;) { + int n = scanf("%d,", &buses[len]); + if (!n) n = scanf("x,"); + if (n < 0) break; + len++; + } + int min = INT_MAX; + int bus = 0; + for (int i = 0; i < len; ++i) { + if (!buses[i]) continue; + int wait = (earliest / buses[i] + 1) * buses[i] - earliest; + if (wait < min) { + min = wait; + bus = buses[i]; + } + } + printf("%d\n", bus * min); +} -- cgit 1.4.1 IRC client
summary refs log tree commit diff
Commit message (Expand)Author
2020-02-13Add -g for generating certificatesJune McEnroe
2020-02-13Explicitly close the TLS connectionJune McEnroe
2020-02-12Add sandman wrapperJune McEnroe
2020-02-12Document scripts in READMEJune McEnroe
2020-02-12Add -N flag for notificationsJune McEnroe
2020-02-12Mark and unmark on uiHide, uiShowJune McEnroe
2020-02-12Hide debug prompt if buffer starts with /June McEnroe
2020-02-12Only exit on errorneous nick during registrationJune McEnroe
2020-02-12Add 378 to list of WHOIS responsesJune McEnroe
2020-02-13Implement source address selectionmultiplexd
2020-02-12Add /listJune McEnroe
2020-02-12Simplify transpose swapJune McEnroe
2020-02-12Add C-t transposeJune McEnroe
2020-02-12Add C-v and M-vJune McEnroe
2020-02-12Allow for arguments to open/copy utilitiesJune McEnroe
2020-02-12Handle RPL_AWAYJune McEnroe
2020-02-11Support monochromatic terminalsJune McEnroe
2020-02-11Add .gz to chroot-man scriptJune McEnroe
2020-02-11Add -R restricted flagJune McEnroe
2020-02-11Add chroot targetJune McEnroe
2020-02-11Exit focus and paste modes on err exitJune McEnroe
2020-02-11Add startup GPLv3 note and URLJune McEnroe
2020-02-11Make sure -D_GNU_SOURCE ends up in CFLAGS on LinuxJune McEnroe
2020-02-11Add note about setting PKG_CONFIG_PATHJune McEnroe
2020-02-11Rename query ID on nick changeJune McEnroe
2020-02-11Call completeClear when closing a windowJune McEnroe
2020-02-11Don't insert color codes for non-mentionsJune McEnroe
2020-02-11Take first two words in colorMentionsJune McEnroe
2020-02-11Use time_t for save signatureJune McEnroe
2020-02-11Set self.nick to * initiallyJune McEnroe
2020-02-11Define ColorCap instead of hardcoding 100June McEnroe
2020-02-11Move hash to top of chat.hJune McEnroe
2020-02-11Move base64 out of chat.hJune McEnroe
2020-02-11Move XDG_SUBDIR out of chat.hJune McEnroe
2020-02-11Fix whois idle unit calculationJune McEnroe
2020-02-11Cast towupper to wchar_tJune McEnroe
2020-02-11Cast set but unused variables to voidJune McEnroe
2020-02-11Declare strlcatJune McEnroe
2020-02-11Check if VDSUSP existsJune McEnroe
2020-02-11Fix completeReplace iterationJune McEnroe
2020-02-11Use pkg(8) to configure on FreeBSDJune McEnroe
2020-02-11Remove legacy codeJune McEnroe
2020-02-11Add INSTALLING section to READMEJune McEnroe/tr>
idk it seems to work.
2020-01-28Import shows.txtJune McEnroe