-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
184 changed files
with
17,215 additions
and
11,487 deletions.
There are no files selected for viewing
This file contains 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
Binary file not shown.
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { join, resolve } from '@std/path'; | ||
import { getTitle, profilePuzzle, runPuzzle, submitAnswer, updatePuzzle } from './aoc.ts'; | ||
|
||
const year = '2016'; | ||
|
||
const baseDirectory = resolve('../puzzles'); | ||
|
||
const getComment = async (day: string, year: string) => { | ||
const title = await getTitle(day, year); | ||
|
||
return `// @ts-nocheck previous years was written in javascript, so disable it here | ||
/** | ||
* puzzles/${year}/day${day}/solution.ts | ||
* | ||
* ~~ ${title} ~~ | ||
* this is my solution for this advent of code puzzle | ||
* | ||
* by alex prosser | ||
* 11/24/2024 | ||
*/ | ||
`; | ||
}; | ||
|
||
const part1Comment = `/** | ||
* code for part 1 of the advent of code puzzle | ||
* | ||
* @param {string} input | ||
* @returns {string | number} the result of part 1 | ||
*/ | ||
const part1 = input => {`; | ||
|
||
const part2Comment = `/** | ||
* code for part 2 of the advent of code puzzle | ||
* | ||
* @param {string} input | ||
* @returns {string | number} the result of part 2 | ||
*/ | ||
const part2 = input => {`; | ||
|
||
for (let i = 1; i <= 25; i++) { | ||
const solutionDirectory = join(baseDirectory, year, `day${i.toString().padStart(2, '0')}`); | ||
|
||
await profilePuzzle(i.toString(), year, '3'); | ||
await submitAnswer(i.toString(), year, 'both', 'true'); | ||
console.log('day', i, year); | ||
|
||
// const response = await submitAnswer(i.toString(), year, 'both', 'true'); | ||
// console.log(response.part1); | ||
// console.log(response.part2); | ||
|
||
// let script = await Deno.readTextFile(join(solutionDirectory, 'solution.js')); | ||
// script = script.replace(/async /g, ''); | ||
// script = script.replace(/const part1 = input => {/g, part1Comment); | ||
// script = script.replace(/const part2 = input => {/g, part2Comment); | ||
// const lines = script.replace(/\r/g, '').split('\n'); | ||
// const commentLines = await getComment(i.toString(), year); | ||
|
||
// commentLines.split('\n').reverse().forEach(line => lines.unshift(line)); | ||
|
||
// await Deno.writeTextFile(join(baseDirectory, year, `day${i.toString().padStart(2, '0')}`, 'solution.ts'), lines.join('\n')); | ||
// await Deno.remove(join(baseDirectory, year, `day${i.toString().padStart(2, '0')}`, 'solution.js')) | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// @ts-nocheck previous years was written in javascript, so disable it here | ||
|
||
/** | ||
* puzzles/2015/day04/solution.ts | ||
* | ||
* ~~ The Ideal Stocking Stuffer ~~ | ||
* this is my solution for this advent of code puzzle | ||
* | ||
* by alex prosser | ||
* 11/27/2023 | ||
*/ | ||
|
||
import { crypto } from '@std/crypto'; | ||
|
||
/** | ||
* returns an md5 hash for the given string. | ||
* | ||
* @param {string} content - the string to hash. | ||
* @returns {string} the md5 hash of the input string in hexadecimal format. | ||
*/ | ||
const md5 = (content) => { | ||
const encoder = new TextEncoder(); | ||
const data = encoder.encode(content); | ||
const hashBuffer = crypto.subtle.digestSync('md5', data); | ||
return Array.from(new Uint8Array(hashBuffer)) | ||
.map((byte) => byte.toString(16).padStart(2, '0')) | ||
.join(''); | ||
}; | ||
|
||
/** | ||
* code for part 1 of the advent of code puzzle | ||
* | ||
* @param {string} input | ||
* @returns {string | number} the result of part 1 | ||
*/ | ||
const part1 = input => { | ||
let i = 0; | ||
while (true) { | ||
if (md5(input + i).startsWith('00000')) return i; | ||
i++; | ||
} | ||
} | ||
|
||
/** | ||
* code for part 2 of the advent of code puzzle | ||
* | ||
* @param {string} input | ||
* @returns {string | number} the result of part 2 | ||
*/ | ||
const part2 = input => { | ||
let i = 0; | ||
while (true) { | ||
if (md5(input + i).startsWith('000000')) return i; | ||
i++; | ||
} | ||
} | ||
|
||
export { part1, part2 }; |
This file contains 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
Oops, something went wrong.