This commit is contained in:
2023-11-30 22:36:04 +01:00
parent 3fa5a03fb2
commit b8bacd133b
75 changed files with 8610 additions and 0 deletions

BIN
2021/01/first Executable file

Binary file not shown.

21
2021/01/first.go Normal file
View File

@ -0,0 +1,21 @@
package main
import (
"fmt"
"os"
)
func checkErr(e error) {
if e!=nil{
panic(e)
}
}
func main(){
numbers := getNumbers("numbers")
}
func getNumbers(filename string)[]byte{
dat, err := os.ReadFile(filename)
checkErr(err)
return dat
}

8
2021/01/first.js Normal file
View File

@ -0,0 +1,8 @@
import fs from 'fs'
let input = fs.readFileSync('numbers',{encoding:"utf8"}).split('\n')
let result = 0
for (let i = 1; i < input.length; i++) {
if (Number(input[i]) >= Number(input[i - 1]))
result++
}
console.log(result)

2000
2021/01/numbers Normal file

File diff suppressed because it is too large Load Diff

11
2021/01/package.json Normal file
View File

@ -0,0 +1,11 @@
{
"name": "01",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"type":"module",
"scripts": {
"first": "node first.js",
"second": "node second.js"
}
}

11
2021/01/second.js Normal file
View File

@ -0,0 +1,11 @@
import fs from 'fs'
let input = fs.readFileSync('numbers',{encoding:"utf8"}).split('\n').map(x=>Number(x))
let result = 0
let sums = []
for (let i = 0; i < input.length; i++) {
sums.push(input[i] + input[i + 1] + input[i + 2])
if (sums[sums.length-1] > sums[sums.length - 2])
result++
}
console.log(result)