Skip to content

Commit

Permalink
feat(2023): update solution for challenge #17
Browse files Browse the repository at this point in the history
  • Loading branch information
iswilljr committed Dec 18, 2023
1 parent 4ea86f4 commit 21402e7
Showing 1 changed file with 18 additions and 99 deletions.
117 changes: 18 additions & 99 deletions 2023/challenge-18/challenge-18.ts
Original file line number Diff line number Diff line change
@@ -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<string, string[][]> = {
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]]
Expand Down

0 comments on commit 21402e7

Please sign in to comment.