| title | Advent of Code 2023 Day 2 |
|---|---|
| author | Kory Becker |
| date | `r Sys.Date()` |
| output | html_document |
knitr::opts_chunk$set(echo = TRUE)
| class DynamicArray { | |
| /** | |
| * @constructor | |
| * @param {number} capacity | |
| */ | |
| constructor(capacity) { | |
| this.data = new Array(capacity); | |
| this.num_elements = 0; | |
| } |
| // Solved by calculating difference between each point diagonally and straight remainder. | |
| const minTimeToVisitAllPoints = (points: number[][]): number => { | |
| let moves = 0; | |
| for (let i=1; i<points.length; i++) { | |
| const dist_x = Math.abs(points[i-1][0] - points[i][0]); | |
| const dist_y = Math.abs(points[i-1][1] - points[i][1]); | |
| const dist_diag = Math.min(dist_x, dist_y); | |
| const dist_straight = Math.abs(dist_y - dist_x); |
| // Add two binary strings directly by using a carry bit. | |
| const addBinary = (a:string, b:string): string => { | |
| let result: string = ''; | |
| let i=0; | |
| let carry = 0; | |
| while (i < a.length || i < b.length) { | |
| let a_bit = '0'; | |
| let b_bit = '0'; | |
| let bit = 0; |
| using System; | |
| using System.IO; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using System.Net.Mime; | |
| using System.Dynamic; | |
| using System.Linq.Expressions; | |
| namespace Managers | |
| { |
| title | Advent of Code 2023 Day 2 |
|---|---|
| author | Kory Becker |
| date | `r Sys.Date()` |
| output | html_document |
knitr::opts_chunk$set(echo = TRUE)
| title | Advent of Code 2023 Day 1 |
|---|---|
| author | Kory Becker |
| date | `r Sys.Date()` |
| output | html_document |
knitr::opts_chunk$set(echo = TRUE)
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| <script src="https://code.jquery.com/jquery.min.js"></script> | |
| <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> | |
| <script crossorigin src="https://unpkg.com/react@17/umd/react.production.min.js"></script> |
| const busyStudent = (startTime, endTime, queryTime) => { | |
| let count = 0; | |
| // Iterate through the length of startTime. | |
| for (i in startTime) { | |
| // Increment count for each matching pair where startTime >= queryTime <= endTime. | |
| count += queryTime >= startTime[i] && queryTime <= endTime[i] ? 1 : 0; | |
| } | |
| return count; |
| const removeDigit = (number, digit) => { | |
| let max = 0; | |
| index = number.indexOf(digit); | |
| while (index != -1) { | |
| left = number.substring(0, index); | |
| right = number.substring(index+1); | |
| value = left + right; | |
| const n = BigInt(value); |
| class Solution: | |
| def maxTurbulenceSize(self, arr: List[int]) -> int: | |
| # O(n) | |
| max_length = 1 | |
| is_greater = None | |
| cur_length = 1 | |
| for i in range(len(arr) - 1): | |
| # Compare the current and next array values. | |
| s0 = arr[i] |