Added the first days
This commit is contained in:
parent
7ebc2cd003
commit
6ed18289c8
26 changed files with 6168 additions and 0 deletions
4
2021/01/first.b98
Normal file
4
2021/01/first.b98
Normal file
|
@ -0,0 +1,4 @@
|
|||
&:>#;&-:v@,a.$$;
|
||||
: 0
|
||||
^ -<w-\1+\
|
||||
^<
|
39
2021/01/first.go
Normal file
39
2021/01/first.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
f, err := os.Open("input")
|
||||
if err != nil {
|
||||
log.Fatalf("%+v", err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
scanner := bufio.NewScanner(f)
|
||||
scanner.Split(bufio.ScanLines)
|
||||
|
||||
scanner.Scan()
|
||||
prev, err := strconv.Atoi(scanner.Text())
|
||||
if err != nil {
|
||||
log.Fatalf("%+v", err)
|
||||
}
|
||||
result := 0
|
||||
|
||||
for scanner.Scan() {
|
||||
i, err := strconv.Atoi(scanner.Text())
|
||||
if err != nil {
|
||||
log.Fatalf("%+v", err)
|
||||
}
|
||||
if i > prev {
|
||||
result++
|
||||
}
|
||||
prev = i
|
||||
}
|
||||
fmt.Println(result)
|
||||
}
|
2000
2021/01/input
Normal file
2000
2021/01/input
Normal file
File diff suppressed because it is too large
Load diff
4
2021/01/second.b98
Normal file
4
2021/01/second.b98
Normal file
|
@ -0,0 +1,4 @@
|
|||
v > v
|
||||
>&00p&10p&20p>#;&:00gw;@,a.; v
|
||||
^ >\1+\ v
|
||||
^p02p01g02p00g01<
|
57
2021/01/second.go
Normal file
57
2021/01/second.go
Normal file
|
@ -0,0 +1,57 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
f, err := os.Open("input")
|
||||
if err != nil {
|
||||
log.Fatalf("%+v", err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
scanner := bufio.NewScanner(f)
|
||||
scanner.Split(bufio.ScanLines)
|
||||
|
||||
scanner.Scan()
|
||||
A, err := strconv.Atoi(scanner.Text())
|
||||
if err != nil {
|
||||
log.Fatalf("%+v", err)
|
||||
}
|
||||
scanner.Scan()
|
||||
B, err := strconv.Atoi(scanner.Text())
|
||||
if err != nil {
|
||||
log.Fatalf("%+v", err)
|
||||
}
|
||||
A += B
|
||||
scanner.Scan()
|
||||
C, err := strconv.Atoi(scanner.Text())
|
||||
if err != nil {
|
||||
log.Fatalf("%+v", err)
|
||||
}
|
||||
B += C
|
||||
A += C
|
||||
|
||||
result := 0
|
||||
|
||||
for scanner.Scan() {
|
||||
D, err := strconv.Atoi(scanner.Text())
|
||||
if err != nil {
|
||||
log.Fatalf("%+v", err)
|
||||
}
|
||||
C += D
|
||||
B += D
|
||||
if B > A {
|
||||
result++
|
||||
}
|
||||
A = B
|
||||
B = C
|
||||
C = D
|
||||
}
|
||||
fmt.Println(result)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue