From 70bc1d6d8386bb807d5e6b6aea504d04b7df2ece Mon Sep 17 00:00:00 2001 From: Jesse Smick Date: Sun, 10 Nov 2024 22:35:15 -0700 Subject: [PATCH 1/2] Add Dialog to solution --- src/components/Dialog.tsx | 30 ++ src/components/Modal.tsx | 67 +++ src/components/Navbar.tsx | 21 +- src/components/solutions/1.tsx | 873 ++++++++++++++++++--------------- src/content/days/1.md | 3 + src/content/days/2.md | 14 + 6 files changed, 596 insertions(+), 412 deletions(-) create mode 100644 src/components/Dialog.tsx create mode 100644 src/components/Modal.tsx diff --git a/src/components/Dialog.tsx b/src/components/Dialog.tsx new file mode 100644 index 0000000..40eb441 --- /dev/null +++ b/src/components/Dialog.tsx @@ -0,0 +1,30 @@ +import { Modal, type ModalProps } from "./Modal"; + +export interface DialogProps extends ModalProps {} + +/** + * Open a dialog popup that can be dimissed by clicking outside of it. + * + * This is opened programatically and the content is centered on the screen. + */ +export function Dialog({ + open = false, + onToggle = () => {}, + children, + className = "", +}: DialogProps) { + return ( + // For some reason TypeScript complains if these are possibly undefined, so set defaults above + + {(args) => ( +
+
+
+ {typeof children === "function" ? children(args) : children} +
+
+
+ )} +
+ ); +} diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx new file mode 100644 index 0000000..40d68af --- /dev/null +++ b/src/components/Modal.tsx @@ -0,0 +1,67 @@ +import { useEffect, useRef, type ReactNode } from "react"; +import { twMerge } from "tailwind-merge"; + +export interface ModalProps { + open?: boolean; + onToggle?: (open: boolean) => void; + button?: ReactNode | (({ isOpen }: { isOpen: boolean }) => ReactNode); + children: + | ReactNode + | (({ + isOpen, + close, + }: { + isOpen: boolean; + close: () => void; + }) => ReactNode); + className?: string; +} + +/** + * Open a modal popup that can be dimissed by clicking outside of it. + * + * This has a button that opens the modal and anything can be displayed inside. + */ +export function Modal({ + open, + onToggle, + button, + children, + className, +}: ModalProps) { + const details = useRef(null); + const isOpen = details.current?.open === true; + function close() { + if (details.current) { + details.current.open = false; + } + } + + useEffect(() => { + function onToggleEvent() { + onToggle?.(details.current!.open); + } + details.current?.addEventListener("toggle", onToggleEvent); + + return () => { + details.current?.removeEventListener("toggle", onToggleEvent); + }; + }, [onToggle]); + + return ( +
+ + {typeof button === "function" ? button({ isOpen }) : button} + + {/* fullscreen background element that you can click to close when it's open */} +
+
+ + {typeof children === "function" ? children({ isOpen, close }) : children} +
+ ); +} diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 4f785b8..9d2881e 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -1,6 +1,7 @@ import { MdCalendarMonth, MdEventBusy } from "react-icons/md"; import { Calendar } from "./Calendar"; import { Link } from "./Link"; +import { Modal } from "./Modal"; const { BASE_URL } = import.meta.env; @@ -19,19 +20,19 @@ export function Navbar({ day }: NavbarProps) { Logo WCF -
- - - - - {/* fullscreen background element that you can click to close when it's open */} -
-
- + + + + + } + > -
+ ); diff --git a/src/components/solutions/1.tsx b/src/components/solutions/1.tsx index 1e600b7..f0d0eb2 100644 --- a/src/components/solutions/1.tsx +++ b/src/components/solutions/1.tsx @@ -1,22 +1,63 @@ import { useState } from "react"; import { Button } from "../Button"; +import { Dialog } from "../Dialog"; +import { MdOutlineDangerous, MdOutlineVerified } from "react-icons/md"; export default function () { + const [showModal, setShowModal] = useState<"correct" | "incorrect" | null>( + null + ); + function AnswerInput({ fileName, solution, }: { fileName: string; - solution: string; + solution: Record; }) { const [input, setInput] = useState(""); function checkSolution() { - if (input === solution) { - alert("Correct!"); - } else { - alert("Try again..."); + let correct = true; + + const counts: Record = {}; + // parse input into lines and accumulate counts + for (let line of input.trim().split("\n")) { + line = line.trim(); + if (!line) { + // allow empty lines + continue; + } + + const parts = line.match(/^(\d+)\s*:\s*(\d+)$/); + if (!parts) { + correct = false; + break; + } + + const country = parseInt(parts[1]!, 10); + const count = parseInt(parts[2]!, 10); + counts[country] = count; } + + if (correct) { + // is parsing succeeded, check the values + for (const [country, code] of Object.entries(solution)) { + if (counts[country] !== code) { + correct = false; + break; + } + + delete counts[country]; + } + + // check if any remaining keys in the user input + if (correct && Object.keys(counts).length !== 0) { + correct = false; + } + } + + setShowModal(correct ? "correct" : "incorrect"); } return ( @@ -24,10 +65,11 @@ export default function () { + + +

Check Your Answers

@@ -46,7 +112,7 @@ export default function () { ))} @@ -55,405 +121,408 @@ export default function () { const solutions: { fileName: string; - answerText: string; + counts: Record; }[] = [ { fileName: "letters.txt", - answerText: `1: 16 - 2: 9 - 3: 12 - 4: 14 - 5: 14 - 6: 20 - 7: 17 - 8: 20 - 9: 14 - 10: 22 - 11: 23 - 12: 16 - 13: 11 - 14: 14 - 15: 14 - 16: 12 - 17: 15 - 18: 13 - 19: 16 - 20: 13 - 21: 9 - 22: 22 - 23: 15 - 24: 18 - 25: 11 - 26: 16 - 27: 19 - 28: 10 - 29: 16 - 30: 12 - 31: 14 - 32: 12 - 33: 25 - 34: 11 - 35: 11 - 36: 9 - 37: 16 - 38: 15 - 39: 16 - 40: 19 - 41: 16 - 42: 22 - 43: 19 - 44: 15 - 45: 11 - 46: 19 - 47: 19 - 48: 11 - 49: 13 - 50: 12 - 51: 22 - 52: 15 - 53: 10 - 54: 21 - 55: 21 - 56: 16 - 57: 15 - 58: 15 - 59: 18 - 60: 12 - 61: 18 - 62: 10 - 63: 10 - 64: 15 - 65: 16 - 66: 17 - 67: 19 - 68: 17 - 69: 9 - 70: 14 - 71: 12 - 72: 12 - 73: 15 - 74: 9 - 75: 18 - 76: 14 - 77: 20 - 78: 11 - 79: 13 - 80: 19 - 81: 15 - 82: 17 - 83: 14 - 84: 22 - 85: 15 - 86: 12 - 87: 15 - 88: 11 - 89: 20 - 90: 10 - 91: 15 - 92: 17 - 93: 16 - 94: 14 - 95: 22 - 96: 14 - 97: 20 - 98: 12 - 99: 17 - 100: 11 - 101: 8 - 102: 14 - 103: 21 - 104: 9 - 105: 13 - 106: 16 - 107: 15 - 108: 13 - 109: 20 - 110: 11 - 111: 13 - 112: 19 - 113: 15 - 114: 15 - 115: 18 - 116: 24 - 117: 13 - 118: 21 - 119: 16 - 120: 13 - 121: 14 - 122: 14 - 123: 18 - 124: 11 - 125: 16 - 126: 17 - 127: 16 - 128: 16 - 129: 19 - 130: 18 - 131: 15 - 132: 12 - 133: 17 - 134: 9 - 135: 13 - 136: 19 - 137: 10 - 138: 18 - 139: 10 - 140: 17 - 141: 11 - 142: 24 - 143: 12 - 144: 19 - 145: 11 - 146: 23 - 147: 23 - 148: 21 - 149: 17 - 150: 14 - 151: 12 - 152: 13 - 153: 17 - 154: 15 - 155: 11 - 156: 9 - 157: 18 - 158: 16 - 159: 11 - 160: 14 - 161: 23 - 162: 17 - 163: 20 - 164: 10 - 165: 15 - 166: 12 - 167: 17 - 168: 12 - 169: 13 - 170: 16 - 171: 15 - 172: 19 - 173: 13 - 174: 23 - 175: 18 - 176: 22 - 177: 18 - 178: 17 - 179: 10 - 180: 17 - 181: 18 - 182: 15 - 183: 12 - 184: 17 - 185: 20 - 186: 15 - 187: 17 - 188: 6 - 189: 16 - 190: 18 - 191: 16 - 192: 16 - 193: 13 - 194: 14 - 195: 11 - 196: 12`, + counts: { + 1: 16, + 2: 9, + 3: 12, + 4: 14, + 5: 14, + 6: 20, + 7: 17, + 8: 20, + 9: 14, + 10: 22, + 11: 23, + 12: 16, + 13: 11, + 14: 14, + 15: 14, + 16: 12, + 17: 15, + 18: 13, + 19: 16, + 20: 13, + 21: 9, + 22: 22, + 23: 15, + 24: 18, + 25: 11, + 26: 16, + 27: 19, + 28: 10, + 29: 16, + 30: 12, + 31: 14, + 32: 12, + 33: 25, + 34: 11, + 35: 11, + 36: 9, + 37: 16, + 38: 15, + 39: 16, + 40: 19, + 41: 16, + 42: 22, + 43: 19, + 44: 15, + 45: 11, + 46: 19, + 47: 19, + 48: 11, + 49: 13, + 50: 12, + 51: 22, + 52: 15, + 53: 10, + 54: 21, + 55: 21, + 56: 16, + 57: 15, + 58: 15, + 59: 18, + 60: 12, + 61: 18, + 62: 10, + 63: 10, + 64: 15, + 65: 16, + 66: 17, + 67: 19, + 68: 17, + 69: 9, + 70: 14, + 71: 12, + 72: 12, + 73: 15, + 74: 9, + 75: 18, + 76: 14, + 77: 20, + 78: 11, + 79: 13, + 80: 19, + 81: 15, + 82: 17, + 83: 14, + 84: 22, + 85: 15, + 86: 12, + 87: 15, + 88: 11, + 89: 20, + 90: 10, + 91: 15, + 92: 17, + 93: 16, + 94: 14, + 95: 22, + 96: 14, + 97: 20, + 98: 12, + 99: 17, + 100: 11, + 101: 8, + 102: 14, + 103: 21, + 104: 9, + 105: 13, + 106: 16, + 107: 15, + 108: 13, + 109: 20, + 110: 11, + 111: 13, + 112: 19, + 113: 15, + 114: 15, + 115: 18, + 116: 24, + 117: 13, + 118: 21, + 119: 16, + 120: 13, + 121: 14, + 122: 14, + 123: 18, + 124: 11, + 125: 16, + 126: 17, + 127: 16, + 128: 16, + 129: 19, + 130: 18, + 131: 15, + 132: 12, + 133: 17, + 134: 9, + 135: 13, + 136: 19, + 137: 10, + 138: 18, + 139: 10, + 140: 17, + 141: 11, + 142: 24, + 143: 12, + 144: 19, + 145: 11, + 146: 23, + 147: 23, + 148: 21, + 149: 17, + 150: 14, + 151: 12, + 152: 13, + 153: 17, + 154: 15, + 155: 11, + 156: 9, + 157: 18, + 158: 16, + 159: 11, + 160: 14, + 161: 23, + 162: 17, + 163: 20, + 164: 10, + 165: 15, + 166: 12, + 167: 17, + 168: 12, + 169: 13, + 170: 16, + 171: 15, + 172: 19, + 173: 13, + 174: 23, + 175: 18, + 176: 22, + 177: 18, + 178: 17, + 179: 10, + 180: 17, + 181: 18, + 182: 15, + 183: 12, + 184: 17, + 185: 20, + 186: 15, + 187: 17, + 188: 6, + 189: 16, + 190: 18, + 191: 16, + 192: 16, + 193: 13, + 194: 14, + 195: 11, + 196: 12, + }, }, { fileName: "letters_challenge.txt", - answerText: `1: 51189 - 2: 51131 - 3: 50970 - 4: 51047 - 5: 50891 - 6: 50987 - 7: 50732 - 8: 50832 - 9: 50984 - 10: 50832 - 11: 50927 - 12: 51355 - 13: 51127 - 14: 50774 - 15: 51287 - 16: 50695 - 17: 51057 - 18: 50829 - 19: 50941 - 20: 50758 - 21: 51258 - 22: 50774 - 23: 50969 - 24: 51326 - 25: 50926 - 26: 51454 - 27: 50831 - 28: 50653 - 29: 51116 - 30: 50899 - 31: 51078 - 32: 51424 - 33: 50716 - 34: 51022 - 35: 51032 - 36: 50899 - 37: 50942 - 38: 50785 - 39: 51069 - 40: 50897 - 41: 51161 - 42: 50905 - 43: 50682 - 44: 50830 - 45: 51008 - 46: 51112 - 47: 51288 - 48: 50937 - 49: 50981 - 50: 50960 - 51: 50866 - 52: 51109 - 53: 51183 - 54: 51235 - 55: 50834 - 56: 50679 - 57: 51190 - 58: 51106 - 59: 50909 - 60: 50895 - 61: 50868 - 62: 50948 - 63: 51109 - 64: 51356 - 65: 51136 - 66: 50996 - 67: 51088 - 68: 50754 - 69: 51157 - 70: 51098 - 71: 51163 - 72: 50650 - 73: 51056 - 74: 50770 - 75: 51644 - 76: 51035 - 77: 51405 - 78: 51175 - 79: 51318 - 80: 50715 - 81: 50887 - 82: 51017 - 83: 51015 - 84: 51053 - 85: 50963 - 86: 51117 - 87: 51163 - 88: 51250 - 89: 51330 - 90: 50645 - 91: 51464 - 92: 50781 - 93: 50843 - 94: 51050 - 95: 50936 - 96: 51183 - 97: 50891 - 98: 50923 - 99: 51310 - 100: 50893 - 101: 51111 - 102: 51289 - 103: 51194 - 104: 51464 - 105: 51123 - 106: 50772 - 107: 51112 - 108: 50749 - 109: 50917 - 110: 50993 - 111: 51171 - 112: 50949 - 113: 50747 - 114: 51313 - 115: 51321 - 116: 50907 - 117: 51005 - 118: 51134 - 119: 50609 - 120: 51578 - 121: 50846 - 122: 50792 - 123: 51235 - 124: 50936 - 125: 51521 - 126: 50890 - 127: 51517 - 128: 51230 - 129: 50540 - 130: 51235 - 131: 51028 - 132: 51375 - 133: 50852 - 134: 50975 - 135: 51232 - 136: 50950 - 137: 50926 - 138: 51387 - 139: 51110 - 140: 51004 - 141: 51015 - 142: 50706 - 143: 50663 - 144: 51016 - 145: 51416 - 146: 50687 - 147: 50640 - 148: 51078 - 149: 51027 - 150: 50776 - 151: 50966 - 152: 51146 - 153: 51216 - 154: 51283 - 155: 51188 - 156: 51071 - 157: 51075 - 158: 50928 - 159: 50914 - 160: 51505 - 161: 50812 - 162: 50925 - 163: 50614 - 164: 51471 - 165: 50997 - 166: 50757 - 167: 51048 - 168: 50844 - 169: 50942 - 170: 51214 - 171: 50969 - 172: 50820 - 173: 50737 - 174: 50678 - 175: 50864 - 176: 51060 - 177: 51216 - 178: 51057 - 179: 51152 - 180: 51102 - 181: 51002 - 182: 50843 - 183: 51383 - 184: 51044 - 185: 50925 - 186: 51234 - 187: 50796 - 188: 51089 - 189: 51148 - 190: 50777 - 191: 50693 - 192: 50952 - 193: 50808 - 194: 51169 - 195: 51000 - 196: 51063 - `, + counts: { + 1: 51189, + 2: 51131, + 3: 50970, + 4: 51047, + 5: 50891, + 6: 50987, + 7: 50732, + 8: 50832, + 9: 50984, + 10: 50832, + 11: 50927, + 12: 51355, + 13: 51127, + 14: 50774, + 15: 51287, + 16: 50695, + 17: 51057, + 18: 50829, + 19: 50941, + 20: 50758, + 21: 51258, + 22: 50774, + 23: 50969, + 24: 51326, + 25: 50926, + 26: 51454, + 27: 50831, + 28: 50653, + 29: 51116, + 30: 50899, + 31: 51078, + 32: 51424, + 33: 50716, + 34: 51022, + 35: 51032, + 36: 50899, + 37: 50942, + 38: 50785, + 39: 51069, + 40: 50897, + 41: 51161, + 42: 50905, + 43: 50682, + 44: 50830, + 45: 51008, + 46: 51112, + 47: 51288, + 48: 50937, + 49: 50981, + 50: 50960, + 51: 50866, + 52: 51109, + 53: 51183, + 54: 51235, + 55: 50834, + 56: 50679, + 57: 51190, + 58: 51106, + 59: 50909, + 60: 50895, + 61: 50868, + 62: 50948, + 63: 51109, + 64: 51356, + 65: 51136, + 66: 50996, + 67: 51088, + 68: 50754, + 69: 51157, + 70: 51098, + 71: 51163, + 72: 50650, + 73: 51056, + 74: 50770, + 75: 51644, + 76: 51035, + 77: 51405, + 78: 51175, + 79: 51318, + 80: 50715, + 81: 50887, + 82: 51017, + 83: 51015, + 84: 51053, + 85: 50963, + 86: 51117, + 87: 51163, + 88: 51250, + 89: 51330, + 90: 50645, + 91: 51464, + 92: 50781, + 93: 50843, + 94: 51050, + 95: 50936, + 96: 51183, + 97: 50891, + 98: 50923, + 99: 51310, + 100: 50893, + 101: 51111, + 102: 51289, + 103: 51194, + 104: 51464, + 105: 51123, + 106: 50772, + 107: 51112, + 108: 50749, + 109: 50917, + 110: 50993, + 111: 51171, + 112: 50949, + 113: 50747, + 114: 51313, + 115: 51321, + 116: 50907, + 117: 51005, + 118: 51134, + 119: 50609, + 120: 51578, + 121: 50846, + 122: 50792, + 123: 51235, + 124: 50936, + 125: 51521, + 126: 50890, + 127: 51517, + 128: 51230, + 129: 50540, + 130: 51235, + 131: 51028, + 132: 51375, + 133: 50852, + 134: 50975, + 135: 51232, + 136: 50950, + 137: 50926, + 138: 51387, + 139: 51110, + 140: 51004, + 141: 51015, + 142: 50706, + 143: 50663, + 144: 51016, + 145: 51416, + 146: 50687, + 147: 50640, + 148: 51078, + 149: 51027, + 150: 50776, + 151: 50966, + 152: 51146, + 153: 51216, + 154: 51283, + 155: 51188, + 156: 51071, + 157: 51075, + 158: 50928, + 159: 50914, + 160: 51505, + 161: 50812, + 162: 50925, + 163: 50614, + 164: 51471, + 165: 50997, + 166: 50757, + 167: 51048, + 168: 50844, + 169: 50942, + 170: 51214, + 171: 50969, + 172: 50820, + 173: 50737, + 174: 50678, + 175: 50864, + 176: 51060, + 177: 51216, + 178: 51057, + 179: 51152, + 180: 51102, + 181: 51002, + 182: 50843, + 183: 51383, + 184: 51044, + 185: 50925, + 186: 51234, + 187: 50796, + 188: 51089, + 189: 51148, + 190: 50777, + 191: 50693, + 192: 50952, + 193: 50808, + 194: 51169, + 195: 51000, + 196: 51063, + }, }, ]; diff --git a/src/content/days/1.md b/src/content/days/1.md index d59fd85..458a56a 100644 --- a/src/content/days/1.md +++ b/src/content/days/1.md @@ -1,5 +1,8 @@ --- title: "That's a Lot of Letters" + +# contributions: +# - @dalurness original author --- Do you have any idea how many letters Santa gets each year before Christmas? Millions of people around the world send letters to Santa every year letting him know what they would like for Christmas. However, the logistics of not only reading those letters, but estimating labor, ordering materials, storing products, and loading up presents at the appropriate time in an efficient order requires a lot of planning. diff --git a/src/content/days/2.md b/src/content/days/2.md index 729b1c4..2d3c168 100644 --- a/src/content/days/2.md +++ b/src/content/days/2.md @@ -1,5 +1,8 @@ --- title: "Counting Santa's Letters" + +# contributions: +# - @mkeedlinger original author --- To help keep things efficient at the North Pole, Santa uses a text intercom system to pass messages. But right now that system is bugging out! It isn't correctly decoding messages! @@ -13,3 +16,14 @@ To help keep things efficient at the North Pole, Santa uses a text intercom syst - Any other characters are left as is (the system Santa uses was made by elves, they hate latin characters so they encoded them) There are two files: [*"small_message_encoded.txt"*](./small_message_encoded.txt), which you can test on, and [*"large_message_encoded.txt"*](./large_message_encoded.txt), which you should also decode and then share if you can hear "it" to prove you completed the challenge. + +**Example**: +Input: +``` +\33\04\11\11\14, \48\14\17\11\03! +``` + +Output: +``` +Hello, World! +``` From aa8ceb18529265431138ab84811e47910f829311 Mon Sep 17 00:00:00 2001 From: Jesse Smick Date: Sun, 10 Nov 2024 23:17:41 -0700 Subject: [PATCH 2/2] Update styles --- src/components/solutions/1.tsx | 4 +--- src/content/days/1.md | 4 ++-- src/content/days/2.md | 2 +- src/content/days/3.md | 18 +++++++++++------- src/content/days/4.md | 2 +- src/content/days/5.md | 2 +- src/layouts/Day.astro | 2 +- src/layouts/Layout.astro | 4 +--- src/layouts/LayoutNavbar.astro | 14 +++++++++++++- src/layouts/Question.astro | 4 ++-- src/pages/day/[day]/solution/[username].astro | 2 +- 11 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/components/solutions/1.tsx b/src/components/solutions/1.tsx index f0d0eb2..0e546d5 100644 --- a/src/components/solutions/1.tsx +++ b/src/components/solutions/1.tsx @@ -105,9 +105,7 @@ export default function () { -

- Check Your Answers -

+

Check Your Answers

{solutions.map((s) => ( Part 1 +## Part 1 On a particular day at the North Pole, the elves are running an assembly line packaging presents. Each present is assigned a code upon completion that contains a sequence of instructions for how to assemble it. However, there seems to be a problem with the printer, and now, many presents have invalid sequences! -For each present, its assembly code consists of a string with the following commands: **"A"** for **"Add part"**, **"R"****** for **"Remove part"**, **"C"** for **"Check assembly"**, and **"P"** for **"Package present"**. +For each present, its assembly code consists of a string with the following commands: +- `A` for "Add part" +- `R` for "Remove part" +- `C` for "Check assembly" +- `P` for "Package present" -Now, an assembly code is considered valid if there is a sequence of **"A"** and **"R"** commands leading to a correctly assembled present, followed by one single **"C"**, and ending in **"P"**. If there are multiple **"C"** commands, then the code is invalid, as the elves should only check the assembly once. Also, there cannot be an **"R"** without a corresponding **"A"** before it (as the elves can't remove a part they haven't added). +An assembly code is considered valid if there is a sequence of `A` and `R` commands leading to a correctly assembled present, followed by a single `C`, and ending in `P`. If there are multiple `C` or `P` commands, then the code is invalid, as the elves should only check and package it once. Also, there cannot be an `R` without a corresponding `A` before it (as the elves can't remove a part they haven't added). -For example, the assembly code **"AACP"** is valid (add two parts, check, and then package), while **"RCP"** (removal without corresponding addition) or **"ACCP"** (two checks) is not. +For example, the assembly code `AACP` is valid (add two parts, check, and then package), while `RCP` (removal without corresponding addition) and `ACCP` (two checks) is not. -**Problem**: Your task is to write a function that receives a list from [*"assembly_codes.txt"*](./assembly_codes.txt) and returns the number of valid codes. +**Problem**: Your task is to write a function that receives a list from [*assembly_codes.txt*](./assembly_codes.txt) and returns the number of valid codes. **Example input**: ``` @@ -34,8 +38,8 @@ ARCP The elves want to get to the bottom of this and to start they need to know how many assembly codes are still valid. **Count how many are complete and ready to be packaged**. -## Part 2 +## Part 2 -After a while, and thanks to you for getting how many presents have a correct code, the elves figure out what is wrong with the printer. The assembly commands are getting mixed up when printing. The **"A"** and **"C"** commands sometimes get swapped and the **"R"** and the **"P"** commands can get swapped. So codes that have a **"C"** command anywhere else but as the second to last command are actually **"A"** commands, and codes that have a **"P"** command anywhere else but at the end are actually a **"R"** code. +After a while, and thanks to you for getting how many presents have a correct code, the elves figure out what is wrong with the printer. The assembly commands are getting mixed up when printing. The `A` and `C` commands sometimes get swapped and the `R` and the `P` commands can get swapped. So codes that have a `C` command anywhere else but as the second to last command are actually `A` commands, and codes that have a `P` command anywhere else but at the end are actually a `R` code. The elves want to know how many parts were added and removed in total. After fixing the assembly codes count all the parts added and removed and report that back to the elves. diff --git a/src/content/days/4.md b/src/content/days/4.md index 87365ee..cfda40d 100644 --- a/src/content/days/4.md +++ b/src/content/days/4.md @@ -8,6 +8,6 @@ Holly has queried all of the presents (in order) that are going to be coming dow When the elves finish a present, if they finish in between minutes **they always wait for the next minute** on the clock to actually get up to get the next project. **It takes the elves one minute to get up and grab the next project off of the conveyer belt**, and if more that one elf is getting up to get a present at the same time, they grab the next presents in order (Snap, Crackle, Pop, and then Steve). -**Problem**: Please figure out how many minutes this batch in [*"presents.txt"*](./presents.txt) is going to take! +**Problem**: Please figure out how many minutes this batch in [*presents.txt*](./presents.txt) is going to take! **Note**: Yes it's sad, but elves don't get breaks. Ever. No need to calculate in breaks or sleep time! diff --git a/src/content/days/5.md b/src/content/days/5.md index 65471dc..a75054c 100644 --- a/src/content/days/5.md +++ b/src/content/days/5.md @@ -65,4 +65,4 @@ Should output: 3 ``` -**Problem**: Render the files [*"0.txt"*](./0.txt), [*"1.txt"*](./1.txt), [*"2.txt"*](./2.txt), [*"3.txt"*](./3.txt), [*"4.txt"*](./4.txt), [*"5.txt"*](./5.txt). **0.txt** is small and may be a good starting point. +**Problem**: Render the files [*0.txt*](./0.txt), [*1.txt*](./1.txt), [*2.txt*](./2.txt), [*3.txt*](./3.txt), [*4.txt*](./4.txt), [*5.txt*](./5.txt). **0.txt** is small and may be a good starting point. diff --git a/src/layouts/Day.astro b/src/layouts/Day.astro index c02aa8a..8cdc883 100644 --- a/src/layouts/Day.astro +++ b/src/layouts/Day.astro @@ -23,7 +23,7 @@ const { day, title, resultComponent, solutionList } = Astro.props; ) } -

Solutions

+

Solutions

    { solutionList.map((s) => ( diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 6061354..d4a6376 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -34,9 +34,7 @@ const { title } = Astro.props;