This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const input = await Deno.readTextFile("input.txt"); | |
| const directions = [ | |
| [0, 1], | |
| [0, -1], | |
| [1, 0], | |
| [1, 1], | |
| [1, -1], | |
| [-1, 0], | |
| [-1, -1], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const input = await Deno.readTextFile("input.txt"); | |
| function matchMuls(str: string): string[] { | |
| return str.match(/mul\(\d+,\d+\)/g) || []; | |
| } | |
| function calculateMulSum(arr: string[]): number { | |
| return arr.reduce((acc, str) => { | |
| const [a, b] = str.slice(4, -1).split(",").map(Number); | |
| return acc + a * b; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const input = await Deno.readTextFile("input.txt"); | |
| const data = input.split("\n"); | |
| let left: number[] = []; | |
| let right: number[] = []; | |
| for (const pair of data) { | |
| const [a, b] = pair.split(" "); | |
| left.push(+a); | |
| right.push(+b); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const input = await Deno.readTextFile("input.txt"); | |
| const data = input.split("\n"); | |
| const isSafe = (levels: number[]): boolean => { | |
| const diffs = levels.slice(1).map((num, idx) => num - levels[idx]); | |
| // Stupid off by one error >:( | |
| if (diffs.length === 0) { | |
| return false; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fetcher = async (path, options = {}) => { | |
| const response = await fetch(path, options); | |
| if (!response.ok) { | |
| throw new Error(`HTTP error! status: ${response.status}`); | |
| } | |
| const data = await response.json(); | |
| return data; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // A job queue that takes an anonymous functions and executes them in parallel | |
| let maxConcurrent = 3; | |
| let queue = []; | |
| let activeCount = 0; | |
| // Add task to queue and execute | |
| async function exec(task) { | |
| queue.push(task); | |
| await next(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // A job queue that takes an anonymous functions and executes them in parallel | |
| class JobQueue { | |
| constructor(maxConcurrent = 3) { | |
| this.maxConcurrent = maxConcurrent; | |
| this.queue = []; | |
| this.activeCount = 0; | |
| } | |
| // Add task to queue and | |
| exec(task) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "errors" | |
| "fmt" | |
| "strconv" | |
| ) | |
| func rleEncode(input string) (string, error) { | |
| if len(input) == 0 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package server | |
| import ( | |
| "context" | |
| "encoding/hex" | |
| "fmt" | |
| "github.com/go-redis/redis/v8" | |
| "net/http" | |
| "strconv" | |
| "sync" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <title>all your base is ket to ball</title> | |
| <style> | |
| * { | |
| box-sizing: border-box; | |
| margin: 0; |