move into year directory
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { open } from 'node:fs/promises';
|
||||
|
||||
function getHash(input: string) {
|
||||
let curr = 0
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
curr += input.charCodeAt(i)
|
||||
curr *= 17
|
||||
curr %= 256
|
||||
}
|
||||
return curr
|
||||
}
|
||||
|
||||
const file = await open('./inputs/15');
|
||||
|
||||
for await (const line of file.readLines()) {
|
||||
console.log(line.split(',').map(getHash).reduce((acc, cur) => acc + cur, 0))
|
||||
}
|
||||
console.log(getHash('rn'))
|
||||
Reference in New Issue
Block a user