diff --git a/2023/challenge-18/challenge-18.ts b/2023/challenge-18/challenge-18.ts index 28e1244..0fdf2e6 100644 --- a/2023/challenge-18/challenge-18.ts +++ b/2023/challenge-18/challenge-18.ts @@ -1,108 +1,27 @@ export function drawClock(time: string) { const clock: string[][] = [[], [], [], [], [], [], []] + const full = ['*', '*', '*'] + const open = ['*', ' ', '*'] + const start = ['*', ' ', ' '] + const end = [' ', ' ', '*'] + const spaces = [' ', ' ', ' '] + const middle = [' ', '*', ' '] + const numbers: Record = { - 0: [ - ['*', '*', '*'], - ['*', ' ', '*'], - ['*', ' ', '*'], - ['*', ' ', '*'], - ['*', ' ', '*'], - ['*', ' ', '*'], - ['*', '*', '*'], - ], - 1: [ - [' ', ' ', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - ], - 2: [ - ['*', '*', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - ['*', '*', '*'], - ['*', ' ', ' '], - ['*', ' ', ' '], - ['*', '*', '*'], - ], - 3: [ - ['*', '*', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - ['*', '*', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - ['*', '*', '*'], - ], - 4: [ - ['*', ' ', '*'], - ['*', ' ', '*'], - ['*', ' ', '*'], - ['*', '*', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - ], - 5: [ - ['*', '*', '*'], - ['*', ' ', ' '], - ['*', ' ', ' '], - ['*', '*', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - ['*', '*', '*'], - ], - 6: [ - ['*', '*', '*'], - ['*', ' ', ' '], - ['*', ' ', ' '], - ['*', '*', '*'], - ['*', ' ', '*'], - ['*', ' ', '*'], - ['*', '*', '*'], - ], - 7: [ - ['*', '*', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - ], - 8: [ - ['*', '*', '*'], - ['*', ' ', '*'], - ['*', ' ', '*'], - ['*', '*', '*'], - ['*', ' ', '*'], - ['*', ' ', '*'], - ['*', '*', '*'], - ], - 9: [ - ['*', '*', '*'], - ['*', ' ', '*'], - ['*', ' ', '*'], - ['*', '*', '*'], - [' ', ' ', '*'], - [' ', ' ', '*'], - ['*', '*', '*'], - ], + 0: [full, open, open, open, open, open, full], + 1: [end, end, end, end, end, end, end], + 2: [full, end, end, full, start, start, full], + 3: [full, end, end, full, end, end, full], + 4: [open, open, open, full, end, end, end], + 5: [full, start, start, full, end, end, full], + 6: [full, start, start, full, open, open, full], + 7: [full, end, end, end, end, end, end], + 8: [full, open, open, full, open, open, full], + 9: [full, open, open, full, end, end, full], } - const colon = [ - [' ', ' ', ' '], - [' ', ' ', ' '], - [' ', '*', ' '], - [' ', ' ', ' '], - [' ', '*', ' '], - [' ', ' ', ' '], - [' ', ' ', ' '], - ] + const colon = [spaces, spaces, middle, spaces, middle, spaces, spaces] const one = numbers[time[0]] const two = numbers[time[1]]