Compare commits
35 Commits
262f2aae90
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ef8dad418 | |||
| c65e1b3828 | |||
| 640babea21 | |||
| f0b80ccc00 | |||
| f564347e2c | |||
| 49d4f20b18 | |||
| f511d1c0ea | |||
| 23c65a00a8 | |||
| ba2e16d000 | |||
| 724b4abcf0 | |||
| caee6ea61b | |||
| ea4d0e8580 | |||
| d54b9f9812 | |||
| b818aa089e | |||
| 2eecbe9980 | |||
| 4906e74cf3 | |||
| 51ae128a14 | |||
| e0aab0618b | |||
| 8f0915640c | |||
| 273de564c2 | |||
| 05d587e1eb | |||
| 62bef0d75a | |||
| 0760edeabc | |||
| 13f2a77803 | |||
| fac4b3aacc | |||
| 29c5ea7841 | |||
| 56ceceaa49 | |||
| bc4c273de0 | |||
| e316345265 | |||
| caf3d3b43d | |||
| 2005e169f4 | |||
| 6ca4b02c67 | |||
| 47b3230d69 | |||
| 42afd893c9 | |||
| 0c31a2da33 |
16
.gitignore
vendored
16
.gitignore
vendored
@@ -1,11 +1,11 @@
|
||||
# Ignore all executables
|
||||
### Ignore all
|
||||
*
|
||||
### Unignore all with extensions
|
||||
!*.*
|
||||
### Unignore all dirs
|
||||
!*/
|
||||
|
||||
# # Ignore all executables
|
||||
# ### Ignore all
|
||||
# *
|
||||
# ### Unignore all with extensions
|
||||
# !*.*
|
||||
# ### Unignore all dirs
|
||||
# !*/
|
||||
Main
|
||||
|
||||
# Regular gitignore
|
||||
.direnv
|
||||
|
||||
1
.pre-commit-config.yaml
Symbolic link
1
.pre-commit-config.yaml
Symbolic link
@@ -0,0 +1 @@
|
||||
/nix/store/gr5dfsr20jqrim8w0lbhicgdnpwwwhs2-pre-commit-config.json
|
||||
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@@ -1,6 +1,9 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"Bifunctor",
|
||||
"bimap",
|
||||
"Collatz",
|
||||
"Combinators",
|
||||
"concat",
|
||||
"coprime",
|
||||
"elems",
|
||||
@@ -8,6 +11,9 @@
|
||||
"factorise",
|
||||
"foldl",
|
||||
"HLINT",
|
||||
"mempty",
|
||||
"Prec",
|
||||
"succ",
|
||||
"unrecognised"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# [The Universal Calculator](https://git.ewanick.com/bill/universal-calculator)
|
||||
|
||||
Using the GHC REPL and Haskell to teach programming concepts through the guise of mathematics.
|
||||
Using the GHC REPL and Haskell to teach programming concepts through the guise of mathematics.\
|
||||
A handy assistant to help you understand and solve maths problems.
|
||||
|
||||
- GHC = [Glasgow Haskell Compiler](https://www.haskell.org/ghc/)
|
||||
|
||||
129
flake.lock
generated
129
flake.lock
generated
@@ -1,24 +1,139 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1694304580,
|
||||
"narHash": "sha256-5tIpNodDpEKT8mM/F5zCzWEAnidOg8eb1/x3SRaaBLs=",
|
||||
"lastModified": 1767039857,
|
||||
"narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4c8cf44c5b9481a4f093f1df3b8b7ba997a7c760",
|
||||
"repo": "flake-compat",
|
||||
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-23.05",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1765835352,
|
||||
"narHash": "sha256-XswHlK/Qtjasvhd1nOa1e8MgZ8GS//jBoTqWtrS1Giw=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "a34fae9c08a15ad73f295041fec82323541400a9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"git-hooks-nix": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1767281941,
|
||||
"narHash": "sha256-6MkqajPICgugsuZ92OMoQcgSHnD6sJHwk8AxvMcIgTE=",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"rev": "f0927703b7b1c8d97511c4116eb9b4ec6645a0fa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gitignore": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"git-hooks-nix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1709087332,
|
||||
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1767364772,
|
||||
"narHash": "sha256-fFUnEYMla8b7UKjijLnMe+oVFOz6HjijGGNS1l7dYaQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "16c7794d0a28b5a37904d55bcca36003b9109aaa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1765674936,
|
||||
"narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
"flake-parts": "flake-parts",
|
||||
"git-hooks-nix": "git-hooks-nix",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
}
|
||||
},
|
||||
"treefmt-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1767468822,
|
||||
"narHash": "sha256-MpffQxHxmjVKMiQd0Tg2IM/bSjjdQAM+NDcX6yxj7rE=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "d56486eb9493ad9c4777c65932618e9c2d0468fc",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
262
flake.nix
262
flake.nix
@@ -1,117 +1,181 @@
|
||||
{
|
||||
description = ''
|
||||
▄ ▄ ▄▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄
|
||||
▐░▌ ▐░▌▐░░▌ ▐░▌▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌
|
||||
▐░▌ ▐░▌▐░▌░▌ ▐░▌ ▀▀▀▀█░█▀▀▀▀ ▐░▌ ▐░▌ ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░▌
|
||||
▐░▌ ▐░▌▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌▐░▌
|
||||
▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌▐░▌
|
||||
▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌
|
||||
▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀█░█▀▀ ▀▀▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀█░▌▐░▌
|
||||
▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌▐░▌
|
||||
▐░█▄▄▄▄▄▄▄█░▌▐░▌ ▐░▐░▌ ▄▄▄▄█░█▄▄▄▄ ▐░▐░▌ ▐░█▄▄▄▄▄▄▄▄▄ ▐░▌ ▐░▌ ▄▄▄▄▄▄▄▄▄█░▌▐░▌ ▐░▌▐░█▄▄▄▄▄▄▄▄▄
|
||||
▐░░░░░░░░░░░▌▐░▌ ▐░░▌▐░░░░░░░░░░░▌ ▐░▌ ▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░░░░░░░░░░░▌
|
||||
▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀
|
||||
|
||||
▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄
|
||||
▄ ▄ ▄▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄
|
||||
▐░▌ ▐░▌▐░░▌ ▐░▌▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌
|
||||
▐░▌ ▐░▌▐░▌░▌ ▐░▌ ▀▀▀▀█░█▀▀▀▀ ▐░▌ ▐░▌ ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░▌
|
||||
▐░▌ ▐░▌▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌▐░▌
|
||||
▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌▐░▌
|
||||
▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌
|
||||
▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀█░█▀▀ ▀▀▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀█░▌▐░▌
|
||||
▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌▐░▌
|
||||
▐░█▄▄▄▄▄▄▄█░▌▐░▌ ▐░▐░▌ ▄▄▄▄█░█▄▄▄▄ ▐░▐░▌ ▐░█▄▄▄▄▄▄▄▄▄ ▐░▌ ▐░▌ ▄▄▄▄▄▄▄▄▄█░▌▐░▌ ▐░▌▐░█▄▄▄▄▄▄▄▄▄
|
||||
▐░░░░░░░░░░░▌▐░▌ ▐░░▌▐░░░░░░░░░░░▌ ▐░▌ ▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░░░░░░░░░░░▌
|
||||
▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀
|
||||
|
||||
▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄
|
||||
▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌ ▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌
|
||||
▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░▌ ▐░█▀▀▀▀▀▀▀▀▀ ▐░▌ ▐░▌▐░▌ ▐░█▀▀▀▀▀▀▀█░▌ ▀▀▀▀█░█▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀█░▌
|
||||
▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌
|
||||
▐░▌ ▐░█▄▄▄▄▄▄▄█░▌▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░█▄▄▄▄▄▄▄█░▌ ▐░▌ ▐░▌ ▐░▌▐░█▄▄▄▄▄▄▄█░▌
|
||||
▐░▌ ▐░░░░░░░░░░░▌▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░░░░░░░░░░░▌ ▐░▌ ▐░▌ ▐░▌▐░░░░░░░░░░░▌
|
||||
▐░▌ ▐░█▀▀▀▀▀▀▀█░▌▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░█▀▀▀▀▀▀▀█░▌ ▐░▌ ▐░▌ ▐░▌▐░█▀▀▀▀█░█▀▀
|
||||
▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌
|
||||
▐░█▄▄▄▄▄▄▄▄▄ ▐░▌ ▐░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░▌ ▐░▌ ▐░▌ ▐░█▄▄▄▄▄▄▄█░▌▐░▌ ▐░▌
|
||||
▐░▌ ▐░█▀▀▀▀▀▀▀█░▌▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░█▀▀▀▀▀▀▀█░▌ ▐░▌ ▐░▌ ▐░▌▐░█▀▀▀▀█░█▀▀
|
||||
▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌
|
||||
▐░█▄▄▄▄▄▄▄▄▄ ▐░▌ ▐░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░▌ ▐░▌ ▐░▌ ▐░█▄▄▄▄▄▄▄█░▌▐░▌ ▐░▌
|
||||
▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌ ▐░▌ ▐░▌ ▐░░░░░░░░░░░▌▐░▌ ▐░▌
|
||||
▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀
|
||||
▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀
|
||||
|
||||
A basic Haskell flake for solving problems and sketching out concepts.
|
||||
https://tristancacqueray.github.io/blog/beautiful-haskell
|
||||
'';
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
|
||||
git-hooks-nix.url = "github:cachix/git-hooks.nix";
|
||||
git-hooks-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }: {
|
||||
devShell.x86_64-linux =
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
|
||||
ghc' = pkgs.haskell.packages.ghc928.ghcWithHoogle (self: with self;
|
||||
[
|
||||
relude
|
||||
split
|
||||
|
||||
aeson
|
||||
random
|
||||
neat-interpolation
|
||||
|
||||
# maths
|
||||
primes
|
||||
arithmoi
|
||||
|
||||
# graphing libraries!
|
||||
Chart
|
||||
Chart-cairo
|
||||
]
|
||||
);
|
||||
|
||||
clean = pkgs.writeShellScriptBin "clean" ''
|
||||
# Delete executables
|
||||
find . -type f -executable -not -path '*/.git/*' -delete
|
||||
|
||||
# Delete all Haskell IR files
|
||||
find . -type f -name '*.hi' -delete
|
||||
find . -type f -name '*.o' -delete
|
||||
|
||||
# Delete any test graphs created
|
||||
find . -type f -name '*.png' -delete
|
||||
'';
|
||||
in
|
||||
pkgs.mkShell {
|
||||
buildInputs = with pkgs.haskellPackages; [
|
||||
ghc'
|
||||
|
||||
haskell-language-server
|
||||
ghcid
|
||||
hlint
|
||||
] ++ (with pkgs; [
|
||||
# Scripts
|
||||
clean
|
||||
|
||||
go
|
||||
gofumpt
|
||||
]);
|
||||
|
||||
shellHook = ''
|
||||
echo ".------..------..------..------..------..------..------..------..------..------."
|
||||
echo "|U.--. ||N.--. ||I.--. ||V.--. ||E.--. ||R.--. ||S.--. ||A.--. ||L.--. ||=.--. |"
|
||||
echo "| (\/) || :(): || (\/) || :(): || (\/) || :(): || :/\: || (\/) || :/\: || (\/) |"
|
||||
echo "| :\/: || ()() || :\/: || ()() || :\/: || ()() || :\/: || :\/: || (__) || :\/: |"
|
||||
echo "| '--'U|| '--'N|| '--'I|| '--'V|| '--'E|| '--'R|| '--'S|| '--'A|| '--'L|| '--'=|"
|
||||
echo "[------'[------'[------'[------'[------'[------'[------'[------'[------'[------'"
|
||||
echo ".------..------..------..------..------..------..------..------..------..------."
|
||||
echo "|C.--. ||A.--. ||L.--. ||C.--. ||U.--. ||L.--. ||A.--. ||T.--. ||O.--. ||R.--. |"
|
||||
echo "| :/\: || (\/) || :/\: || :/\: || (\/) || :/\: || (\/) || :/\: || :/\: || :(): |"
|
||||
echo "| :\/: || :\/: || (__) || :\/: || :\/: || (__) || :\/: || (__) || :\/: || ()() |"
|
||||
echo "| '--'C|| '--'A|| '--'L|| '--'C|| '--'U|| '--'L|| '--'A|| '--'T|| '--'O|| '--'R|"
|
||||
echo "[------'[------'[------'[------'[------'[------'[------'[------'[------'[------'"
|
||||
|
||||
echo " _ _ _ _ "
|
||||
echo "| | | | (_) | | ______ "
|
||||
echo "| | | | _ __ _ __ __ ___ _ __ ___ __ _ | ||______|"
|
||||
echo "| | | || '_ \ | |\ \ / / / _ \| '__|/ __| / _[ || | ______ "
|
||||
echo "| |_| || | | || | \ V / | __/| | \__ \| (_| || ||______|"
|
||||
echo " \___/ |_| |_||_| \_/ \___||_| |___/ \__,_||_| "
|
||||
echo " "
|
||||
echo " "
|
||||
echo " _____ _ _ _ "
|
||||
echo "/ __ \ | | | | | | "
|
||||
echo "| / \/ __ _ | | ___ _ _ | | __ _ | |_ ___ _ __ "
|
||||
echo "| | / _[ || | / __|| | | || | / _[ || __| / _ \ | '__| "
|
||||
echo "| \__/\| (_| || || (__ | |_| || || (_| || |_ | (_) || | "
|
||||
echo " \____/ \__,_||_| \___| \__,_||_| \__,_| \__| \___/ |_| "
|
||||
'';
|
||||
outputs = inputs @ {flake-parts, ...}:
|
||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||
imports = [
|
||||
# To import a flake module
|
||||
# 1. Add foo to inputs
|
||||
# 2. Add foo as a parameter to the outputs function
|
||||
# 3. Add here: foo.flakeModule
|
||||
inputs.git-hooks-nix.flakeModule
|
||||
inputs.treefmt-nix.flakeModule
|
||||
];
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
# "aarch64-linux"
|
||||
# "aarch64-darwin"
|
||||
# "x86_64-darwin"
|
||||
];
|
||||
flake = {
|
||||
# The usual flake attributes can be defined here, including system-
|
||||
# agnostic ones like nixosModule and system-enumerating ones, although
|
||||
# those are more easily expressed in perSystem.
|
||||
};
|
||||
};
|
||||
perSystem = {
|
||||
config,
|
||||
self',
|
||||
inputs',
|
||||
pkgs,
|
||||
system,
|
||||
...
|
||||
}: {
|
||||
# Per-system attributes can be defined here. The self' and inputs'
|
||||
# module parameters provide easy access to attributes of the same
|
||||
# system.
|
||||
|
||||
# Equivalent to inputs'.nixpkgs.legacyPackages.hello;
|
||||
# packages.default = pkgs.hello;
|
||||
|
||||
devShells.default = let
|
||||
# https://downloads.haskell.org/~ghc/9.10.3/docs/users_guide/index.html
|
||||
ghc' = pkgs.haskell.packages.ghc9103.ghcWithHoogle (
|
||||
self:
|
||||
with self; [
|
||||
relude
|
||||
split
|
||||
aeson
|
||||
random
|
||||
neat-interpolation
|
||||
|
||||
# maths
|
||||
primes
|
||||
arithmoi
|
||||
parallel
|
||||
|
||||
# graphing libraries!
|
||||
Chart
|
||||
Chart-cairo
|
||||
]
|
||||
);
|
||||
|
||||
clean = pkgs.writeShellScriptBin "clean" ''
|
||||
# Delete executables
|
||||
find . -type f -executable -not -path '*/.git/*' -delete
|
||||
|
||||
# Delete all Haskell IR files
|
||||
find . -type f -name '*.hi' -delete
|
||||
find . -type f -name '*.o' -delete
|
||||
|
||||
# Delete any test graphs created
|
||||
find . -type f -name '*.png' -delete
|
||||
'';
|
||||
in
|
||||
pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
cowsay
|
||||
|
||||
alejandra
|
||||
|
||||
ghc'
|
||||
clean
|
||||
|
||||
haskell-language-server
|
||||
ghcid
|
||||
hlint
|
||||
|
||||
kotlin
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
${config.pre-commit.installationScript}
|
||||
|
||||
echo ".------..------..------..------..------..------..------..------..------..------."
|
||||
echo "|U.--. ||N.--. ||I.--. ||V.--. ||E.--. ||R.--. ||S.--. ||A.--. ||L.--. ||=.--. |"
|
||||
echo "| (\/) || :(): || (\/) || :(): || (\/) || :(): || :/\: || (\/) || :/\: || (\/) |"
|
||||
echo "| :\/: || ()() || :\/: || ()() || :\/: || ()() || :\/: || :\/: || (__) || :\/: |"
|
||||
echo "| '--'U|| '--'N|| '--'I|| '--'V|| '--'E|| '--'R|| '--'S|| '--'A|| '--'L|| '--'=|"
|
||||
echo "[------'[------'[------'[------'[------'[------'[------'[------'[------'[------'"
|
||||
echo ".------..------..------..------..------..------..------..------..------..------."
|
||||
echo "|C.--. ||A.--. ||L.--. ||C.--. ||U.--. ||L.--. ||A.--. ||T.--. ||O.--. ||R.--. |"
|
||||
echo "| :/\: || (\/) || :/\: || :/\: || (\/) || :/\: || (\/) || :/\: || :/\: || :(): |"
|
||||
echo "| :\/: || :\/: || (__) || :\/: || :\/: || (__) || :\/: || (__) || :\/: || ()() |"
|
||||
echo "| '--'C|| '--'A|| '--'L|| '--'C|| '--'U|| '--'L|| '--'A|| '--'T|| '--'O|| '--'R|"
|
||||
echo "[------'[------'[------'[------'[------'[------'[------'[------'[------'[------'"
|
||||
|
||||
echo " _ _ _ _ "
|
||||
echo "| | | | (_) | | ______ "
|
||||
echo "| | | | _ __ _ __ __ ___ _ __ ___ __ _ | ||______|"
|
||||
echo "| | | || '_ \ | |\ \ / / / _ \| '__|/ __| / _[ || | ______ "
|
||||
echo "| |_| || | | || | \ V / | __/| | \__ \| (_| || ||______|"
|
||||
echo " \___/ |_| |_||_| \_/ \___||_| |___/ \__,_||_| "
|
||||
echo " "
|
||||
echo " "
|
||||
echo " _____ _ _ _ "
|
||||
echo "/ __ \ | | | | | | "
|
||||
echo "| / \/ __ _ | | ___ _ _ | | __ _ | |_ ___ _ __ "
|
||||
echo "| | / _[ || | / __|| | | || | / _[ || __| / _ \ | '__| "
|
||||
echo "| \__/\| (_| || || (__ | |_| || || (_| || |_ | (_) || | "
|
||||
echo " \____/ \__,_||_| \___| \__,_||_| \__,_| \__| \___/ |_| "
|
||||
'';
|
||||
};
|
||||
|
||||
pre-commit = {
|
||||
settings.hooks = {
|
||||
alejandra.enable = true;
|
||||
mdformat.enable = true;
|
||||
prettier.enable = true;
|
||||
prettier.excludes = [".*\.md" "flake.lock"];
|
||||
stylish-haskell.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
treefmt = {
|
||||
programs = {
|
||||
alejandra.enable = true;
|
||||
mdformat.enable = true;
|
||||
prettier.enable = true;
|
||||
prettier.excludes = ["*.md"];
|
||||
stylish-haskell.enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,24 +3,61 @@ The Simplest Math Problem No One Can Solve - Collatz Conjecture
|
||||
https://youtu.be/094y1Z2wpJg
|
||||
-}
|
||||
|
||||
import Control.Monad ()
|
||||
import Debug.Trace (trace)
|
||||
import Control.Parallel.Strategies
|
||||
import Data.Containers.ListUtils
|
||||
import Debug.Trace (trace)
|
||||
|
||||
main :: IO ()
|
||||
main = print $ take 100 $ map f [2^1000..]
|
||||
main = do
|
||||
let start = 2^1_000_000
|
||||
let end = 100
|
||||
-- let message = "Starting at " <> show start <> ", and computing " <> show end <> " values."
|
||||
let message = "Starting at 2^1_000_000, and computing " <> show end <> " values."
|
||||
let results = parMap rpar f [start..start+end] :: [Integer]
|
||||
putStrLn "======================================"
|
||||
putStrLn message
|
||||
print $ nubOrd results
|
||||
putStrLn "======================================"
|
||||
|
||||
{-
|
||||
Idea for next steps
|
||||
Don't compute numbers if even, we know they'll go to 1
|
||||
(https://smunix.github.io/dev.stephendiehl.com/hask/tutorial.pdf - Scientific numbers)
|
||||
|
||||
Sample a few numbers at a given order of magnitude, then increase the exponent and sample more numbers
|
||||
eg. [-10..n..+10], where n = 2^1_000, then n = 2^1_001, then n = 2^2_000, etc.
|
||||
-}
|
||||
|
||||
{-
|
||||
Starting at 2^1_000, and computing 100 values.
|
||||
- [1001,7249,7430]
|
||||
|
||||
Starting at 2^10_000, and computing 100 values.
|
||||
- [10001,72379]
|
||||
|
||||
Starting at 2^100_000, and computing 100 values.
|
||||
- [100001,717859]
|
||||
|
||||
Starting at 2^1_000_000, and computing 100 values.
|
||||
- [1000001,7212801]
|
||||
-}
|
||||
|
||||
lst :: [Integer]
|
||||
lst = take 300 [2^100_000..]
|
||||
|
||||
f :: Integer -> Integer
|
||||
f n = s 1 n
|
||||
where
|
||||
s :: Integer -> Integer -> Integer
|
||||
s i n
|
||||
| n == 1 = i
|
||||
| n == 0 = i
|
||||
| n == (-1) = i
|
||||
| n == (-5) = i
|
||||
| n == (-17) = i
|
||||
| even n = s (succ i) (n `div` 2)
|
||||
| odd n = s (succ i) (3*n + 1)
|
||||
s c n
|
||||
| n == 1 = c
|
||||
| n == 0 = c
|
||||
| n == (-1) = c
|
||||
| n == (-5) = c
|
||||
| n == (-17) = c
|
||||
| even n = s c' (n `div` 2)
|
||||
| odd n = s c' (3*n + 1)
|
||||
where c' = succ c
|
||||
|
||||
f' :: Integer -> Integer
|
||||
f' n = f'' 1 n
|
||||
@@ -53,3 +90,5 @@ cc n = cc' [] n
|
||||
| even n = cc' acc' (n `div` 2)
|
||||
| odd n = cc' acc' (3*n + 1)
|
||||
where acc' = acc <> [n]
|
||||
|
||||
x = map (length . cc) [2^1_000+10..]
|
||||
|
||||
45
src/3n+1/Main.kt
Normal file
45
src/3n+1/Main.kt
Normal file
@@ -0,0 +1,45 @@
|
||||
import java.math.BigInteger
|
||||
|
||||
// var count = 1
|
||||
val big2 = BigInteger("2")
|
||||
val big3 = BigInteger("3")
|
||||
|
||||
fun main() {
|
||||
var startingN = BigInteger("10").pow(100000)
|
||||
while(true) {
|
||||
// print("Num: $startingN, ")
|
||||
var count = f(startingN)
|
||||
println("Count: $count")
|
||||
startingN = startingN.inc()
|
||||
}
|
||||
}
|
||||
|
||||
fun f(nPrime: BigInteger): Int {
|
||||
var count = 1
|
||||
var n = nPrime
|
||||
while (!n.equals(BigInteger.ONE)) {
|
||||
val isEven = n.rem(big2).equals(BigInteger.ZERO)
|
||||
count++
|
||||
if(isEven) {
|
||||
n = n.div(big2)
|
||||
} else {
|
||||
n = n.times(big3).inc()
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
/*
|
||||
f :: Integer -> Integer
|
||||
f n = s 1 n
|
||||
where
|
||||
s :: Integer -> Integer -> Integer
|
||||
s i n
|
||||
| n == 1 = i
|
||||
| n == 0 = i
|
||||
| n == (-1) = i
|
||||
| n == (-5) = i
|
||||
| n == (-17) = i
|
||||
| even n = s (succ i) (n `div` 2)
|
||||
| odd n = s (succ i) (3*n + 1)
|
||||
*/
|
||||
81
src/3n+1/collatzChainPost.lhs
Normal file
81
src/3n+1/collatzChainPost.lhs
Normal file
@@ -0,0 +1,81 @@
|
||||
= Collatz Chains in Haskell
|
||||
|
||||
== Title header
|
||||
|
||||
This is a literate haskell blog post. You can load and run this code!
|
||||
|
||||
The Simplest Math Problem No One Can Solve - Collatz Conjecture
|
||||
<https://youtu.be/094y1Z2wpJg>
|
||||
|
||||
Why do we want to do this?
|
||||
|
||||
> collatzStep :: Integer -> Integer
|
||||
> collatzStep n
|
||||
> | even n = n `div` 2
|
||||
> | odd n = 3 * n + 1
|
||||
|
||||
With this, we can iterate over it.
|
||||
|
||||
> collatzStep' :: Integer -> Integer
|
||||
> collatzStep' n
|
||||
> | n == 1 = error "done"
|
||||
> | even n = n `div` 2
|
||||
> | odd n = 3 * n + 1
|
||||
|
||||
> result :: [Integer]
|
||||
> result = iterate collatzStep' 5
|
||||
|
||||
|
||||
collatz collect
|
||||
generate the collatz sequence and return it
|
||||
|
||||
> cc :: Integer -> [Integer]
|
||||
> cc n = cc' [] n
|
||||
> where
|
||||
> cc' :: [Integer] -> Integer -> [Integer]
|
||||
> cc' acc n
|
||||
> | n == 1 = acc <> [1]
|
||||
> | n == 0 = acc <> [0]
|
||||
> | n == (-1) = acc <> [-1]
|
||||
> | n == (-5) = acc <> [-5]
|
||||
> | n == (-17) = acc <> [-17]
|
||||
> | even n = cc' acc' (n `div` 2)
|
||||
> | odd n = cc' acc' (3*n + 1)
|
||||
> where acc' = acc <> [n]
|
||||
|
||||
> a :: [Integer]
|
||||
> a = reverse $ cc $ 2^1_000+1
|
||||
|
||||
> b :: [Integer]
|
||||
> b = reverse $ cc $ 2^1_000+2
|
||||
|
||||
> comparingChains :: [Bool]
|
||||
> comparingChains = zipWith (==) a b
|
||||
|
||||
Now if we collect the chain lengths of large numbers we see something slightly horrifying:
|
||||
|
||||
> x = map (length . cc) [2^1_000+10..]
|
||||
|
||||
This prints us the list of lengths of the chain as:
|
||||
[7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7430,7249,7249,7249,7249,7249,7249,7249,7249,7249,7430,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7430,7430,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7430,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7430,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7430,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249,7249...]
|
||||
|
||||
λ> cc 13
|
||||
[13,40,20,10,5,16,8,4,2,1]
|
||||
λ> cc 12
|
||||
[12,6,3,10,5,16,8,4,2,1]
|
||||
|
||||
Now this makes sense with small numbers.
|
||||
But I find it weird with large numbers.
|
||||
|
||||
> f :: Integer -> Integer
|
||||
> f n = s 1 n
|
||||
> where
|
||||
> s :: Integer -> Integer -> Integer
|
||||
> s i n
|
||||
> | n == 1 = i
|
||||
> | n == 0 = i
|
||||
> | n == (-1) = i
|
||||
> | n == (-5) = i
|
||||
> | n == (-17) = i
|
||||
> | even n = s (succ i) (n `div` 2)
|
||||
> | odd n = s (succ i) (3 * n + 1)
|
||||
161
src/advent_of_code/2023/1.hs
Normal file
161
src/advent_of_code/2023/1.hs
Normal file
@@ -0,0 +1,161 @@
|
||||
-- https://adventofcode.com/2023/day/1
|
||||
|
||||
import Data.Bifunctor (bimap, second)
|
||||
import Data.Maybe (fromJust, fromMaybe, isJust)
|
||||
import Data.Text (Text, pack, replace, unpack)
|
||||
import Text.ParserCombinators.ReadP (ReadP, choice, many, readP_to_S,
|
||||
string, (<++))
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
entries <- lines <$> readFile "src/advent_of_code/2023/input1"
|
||||
print "Advent of Code 2023 - Day 1"
|
||||
-- print entries
|
||||
|
||||
print ("Part 1: " <> show (solveP1 entries))
|
||||
print ("Part 2: " <> show (solveP2 entries))
|
||||
|
||||
--
|
||||
-- Part 1
|
||||
--
|
||||
|
||||
solveP1 :: [String] -> Int
|
||||
solveP1 = sum . map solveP1Line
|
||||
|
||||
solveP1Line :: String -> Int
|
||||
solveP1Line = sumPairS . bimap head last . doubleString . filter isNumP1 . tokenized tokensP1
|
||||
|
||||
tokensP1 :: ReadP String
|
||||
tokensP1 = parseNumberChars <++ parseChars
|
||||
|
||||
--
|
||||
-- Part 2
|
||||
--
|
||||
|
||||
solveP2 :: [String] -> Int
|
||||
solveP2 = sum . map solveP2Line
|
||||
|
||||
solveP2Line :: String -> Int
|
||||
solveP2Line = sumPairS . bimap head last . doubleString . map stringToNum . filter isNumP2 . tokenized tokensP2 . replaceAll overlaps
|
||||
|
||||
tokensP2 :: ReadP String
|
||||
tokensP2 = parseNumberWords <++ parseNumberChars <++ parseChars
|
||||
|
||||
--
|
||||
-- Utility functions
|
||||
--
|
||||
|
||||
-- Doing this because I want to use a bifunctor
|
||||
doubleString :: str -> (str, str)
|
||||
doubleString str = (str, str)
|
||||
|
||||
sumPairS :: (String, String) -> Int
|
||||
sumPairS (x,y) = read (x ++ y)
|
||||
|
||||
stringToNum :: String -> String
|
||||
stringToNum str = fromMaybe str (lookup str $ zip numberWords numberChars)
|
||||
|
||||
--
|
||||
-- Boilerplate equality checks
|
||||
-- Now condensed
|
||||
--
|
||||
|
||||
isNumP1 :: String -> Bool
|
||||
isNumP1 = flip elem numberChars
|
||||
|
||||
isNumP2 :: String -> Bool
|
||||
isNumP2 = flip elem (numberChars ++ numberWords)
|
||||
|
||||
--
|
||||
-- Parsing for question
|
||||
--
|
||||
|
||||
letterChars :: String
|
||||
letterChars = ['a'..'z']
|
||||
|
||||
numberChars :: [String]
|
||||
numberChars = map show [0..9]
|
||||
|
||||
numberWords :: [String]
|
||||
numberWords = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
|
||||
|
||||
parseChars :: ReadP String
|
||||
parseChars = choice $ map (\c -> string [c]) letterChars
|
||||
|
||||
parseNumberChars :: ReadP String
|
||||
parseNumberChars = choice $ map string numberChars
|
||||
|
||||
parseNumberWords :: ReadP String
|
||||
parseNumberWords = choice $ map string numberWords
|
||||
|
||||
tokenized :: ReadP a -> String -> [a]
|
||||
tokenized tokenSet = fst . last . readP_to_S (many tokenSet)
|
||||
|
||||
--
|
||||
-- Detecting overlaps
|
||||
-- - Instead of reversing to tokenize from the right, I'm using the numberWords list to create a set of possible string overlaps
|
||||
-- - later I'll detect these and replace them, to be able to parse all strings from left to right
|
||||
--
|
||||
|
||||
overlaps :: [(String, String)]
|
||||
overlaps = concatMap combineOverlaps overlapsDerived
|
||||
|
||||
-- Not used, but the full list written manually
|
||||
overlapsSpec :: [((String, String), String)]
|
||||
overlapsSpec =
|
||||
[ (("zero" , "one" ), "01")
|
||||
, (("one" , "eight"), "18")
|
||||
, (("two" , "one" ), "21")
|
||||
, (("three", "eight"), "38")
|
||||
, (("five" , "eight"), "58")
|
||||
, (("seven", "nine" ), "79")
|
||||
, (("eight", "two" ), "82")
|
||||
, (("eight", "three"), "83")
|
||||
, (("nine" , "eight"), "98")
|
||||
]
|
||||
|
||||
overlapsDerived :: [(String, [String])]
|
||||
overlapsDerived = map (second fromJust) . filter (isJust . snd) . zip numberWords $ map findOverlaps numberWords
|
||||
where
|
||||
findOverlaps :: String -> Maybe [String]
|
||||
findOverlaps str = if null overlaps then Nothing else Just overlaps
|
||||
where
|
||||
overlaps = filter (\s -> last str == head s) numberWords
|
||||
|
||||
combineOverlaps :: (String, [String]) -> [(String, String)]
|
||||
combineOverlaps (numStr, [] ) = []
|
||||
combineOverlaps (numStr, over:laps) = (numStr ++ tail over, stringToNum numStr ++ stringToNum over) : combineOverlaps (numStr, laps)
|
||||
|
||||
-- String replace using Text lol
|
||||
replace' :: String -> String -> String -> String
|
||||
replace' needle replacement haystack = unpack $ replace needle' replacement' haystack'
|
||||
where
|
||||
needle' = pack needle
|
||||
replacement' = pack replacement
|
||||
haystack' = pack haystack
|
||||
|
||||
replaceAll :: [(String, String)] -> String -> String
|
||||
replaceAll overlaps str = foldl (\haystack (needle, replacement) -> replace' needle replacement haystack) str overlaps
|
||||
|
||||
--
|
||||
-- Examples
|
||||
--
|
||||
|
||||
example1 :: [String]
|
||||
example1 =
|
||||
[ "1abc2"
|
||||
, "pqr3stu8vwx"
|
||||
, "a1b2c3d4e5f"
|
||||
, "treb7uchet"
|
||||
]
|
||||
|
||||
example2 :: [String]
|
||||
example2 =
|
||||
[ "two1nine"
|
||||
, "eightwothree"
|
||||
, "abcone2threexyz"
|
||||
, "xtwone3four"
|
||||
, "4nineeightseven2"
|
||||
, "zoneight234"
|
||||
, "7pqrstsixteen"
|
||||
]
|
||||
124
src/advent_of_code/2023/2.hs
Normal file
124
src/advent_of_code/2023/2.hs
Normal file
@@ -0,0 +1,124 @@
|
||||
-- https://adventofcode.com/2023/day/2
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
import Data.Bifunctor (Bifunctor (bimap, second))
|
||||
import Data.Char (isSpace)
|
||||
import Data.List (foldl')
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.IO as T
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
entries <- T.lines <$> T.readFile "src/advent_of_code/2023/input2"
|
||||
putStrLn "Advent of Code 2023 - Day 2"
|
||||
|
||||
putStrLn ("Part 1: " <> show (solveP1 entries))
|
||||
putStrLn ("Part 2: " <> show (solveP2 entries))
|
||||
|
||||
--
|
||||
-- Part 1
|
||||
--
|
||||
|
||||
data Colour
|
||||
= Red
|
||||
| Green
|
||||
| Blue
|
||||
deriving (Show, Read, Ord, Eq)
|
||||
|
||||
data Cube c n
|
||||
= Cube c n
|
||||
deriving (Show, Read, Ord, Eq)
|
||||
|
||||
cubeLessThanLimit :: (Cube Colour Int, Cube Colour Int, Cube Colour Int) -> Cube Colour Int -> Bool
|
||||
cubeLessThanLimit (Cube Red n, _, _) (Cube Red v) = v <= n
|
||||
cubeLessThanLimit (_, Cube Green n, _) (Cube Green v) = v <= n
|
||||
cubeLessThanLimit (_, _, Cube Blue n) (Cube Blue v) = v <= n
|
||||
|
||||
lessThanP1 :: Cube Colour Int -> Bool
|
||||
lessThanP1 = cubeLessThanLimit p1Limit
|
||||
|
||||
p1Limit :: (Cube Colour Int, Cube Colour Int, Cube Colour Int)
|
||||
p1Limit = (Cube Red 12, Cube Green 13, Cube Blue 14)
|
||||
|
||||
solveP1 :: [Text] -> Int
|
||||
solveP1 = sum . map fst . filter snd . map (second (all (== True) . concatMap (map lessThanP1)) . parseInput)
|
||||
|
||||
--
|
||||
-- Part 2
|
||||
--
|
||||
|
||||
solveP2 :: [Text] -> Int
|
||||
solveP2 = sumOfPowerCubes . allMinCubes . parsedEntries
|
||||
|
||||
parsedEntries :: [Text] -> [[[Cube Colour Int]]]
|
||||
parsedEntries = map (snd . parseInput)
|
||||
|
||||
allMinCubes :: [[[Cube Colour Int]]] -> [(Cube Colour Int, Cube Colour Int, Cube Colour Int)]
|
||||
allMinCubes = map findMinimumCubes
|
||||
where
|
||||
findMinimumCubes :: [[Cube Colour Int]] -> (Cube Colour Int, Cube Colour Int, Cube Colour Int)
|
||||
findMinimumCubes = foldl' (compareRGBCubes (>)) cubeMempty . map (foldl' minimumCubesRequired cubeMempty)
|
||||
|
||||
sumOfPowerCubes :: [(Cube Colour Int, Cube Colour Int, Cube Colour Int)] -> Int
|
||||
sumOfPowerCubes = sum . map powerCube
|
||||
where
|
||||
powerCube :: (Cube Colour Int, Cube Colour Int, Cube Colour Int) -> Int
|
||||
powerCube (r,g,b) = n
|
||||
where
|
||||
r' = cubeVal r
|
||||
g' = cubeVal g
|
||||
b' = cubeVal b
|
||||
n = r' * g' * b'
|
||||
|
||||
minimumCubesRequired
|
||||
:: (Cube Colour Int, Cube Colour Int, Cube Colour Int)
|
||||
-> Cube Colour Int
|
||||
-> (Cube Colour Int, Cube Colour Int, Cube Colour Int)
|
||||
minimumCubesRequired (r,g,b) (Cube Red n) = if n > cubeVal r then (Cube Red n,g,b ) else (r,g,b)
|
||||
minimumCubesRequired (r,g,b) (Cube Green n) = if n > cubeVal g then (r,Cube Green n,b) else (r,g,b)
|
||||
minimumCubesRequired (r,g,b) (Cube Blue n) = if n > cubeVal b then (r,g,Cube Blue n ) else (r,g,b)
|
||||
|
||||
compareRGBCubes
|
||||
:: (Int -> Int -> Bool)
|
||||
-> (Cube Colour Int, Cube Colour Int, Cube Colour Int)
|
||||
-> (Cube Colour Int, Cube Colour Int, Cube Colour Int)
|
||||
-> (Cube Colour Int, Cube Colour Int, Cube Colour Int)
|
||||
compareRGBCubes f (h,i,j) (k,l,m) = (r,g,b)
|
||||
where
|
||||
r = if cubeVal h `f` cubeVal k then h else k
|
||||
g = if cubeVal i `f` cubeVal l then i else l
|
||||
b = if cubeVal j `f` cubeVal m then j else m
|
||||
|
||||
cubeMempty :: (Cube Colour Int, Cube Colour Int, Cube Colour Int)
|
||||
cubeMempty = (Cube Red 0, Cube Green 0, Cube Blue 0)
|
||||
|
||||
cubeVal :: Cube Colour Int -> Int
|
||||
cubeVal (Cube _ n) = n
|
||||
|
||||
--
|
||||
-- Parsing
|
||||
--
|
||||
|
||||
parseInput :: Text -> (Int, [[Cube Colour Int]])
|
||||
parseInput = bimap (read . T.unpack . T.drop 5) (map (map stringToCube . T.splitOn ", ") . T.splitOn "; " . T.drop 2) . T.breakOn ": "
|
||||
|
||||
stringToCube :: Text -> Cube Colour Int
|
||||
stringToCube str = read $ "Cube " <> colour' <> " " <> n'
|
||||
where
|
||||
(n, colour) = second (T.drop 1) . T.break isSpace $ str
|
||||
colour' = T.unpack (T.toTitle colour)
|
||||
n' = T.unpack n
|
||||
|
||||
--
|
||||
-- Examples
|
||||
--
|
||||
|
||||
example :: [Text]
|
||||
example =
|
||||
[ "Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green"
|
||||
, "Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue"
|
||||
, "Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red"
|
||||
, "Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red"
|
||||
, "Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green"
|
||||
]
|
||||
108
src/advent_of_code/2023/3.hs
Normal file
108
src/advent_of_code/2023/3.hs
Normal file
@@ -0,0 +1,108 @@
|
||||
-- https://adventofcode.com/2023/day/3
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
import Data.Bifunctor
|
||||
import Data.List
|
||||
|
||||
import Data.Char
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.IO as T
|
||||
import Debug.Trace (trace)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
entries <- T.lines <$> T.readFile "src/advent_of_code/2023/input3"
|
||||
|
||||
putStrLn "Advent of Code 2023 - Day 3"
|
||||
putStrLn ("Part 1: " <> show (solveP1 entries))
|
||||
-- putStrLn ("Part 2: " <> show (solveP2 entries))
|
||||
|
||||
--
|
||||
-- Part 1
|
||||
--
|
||||
|
||||
allCoords :: Int -> [(Int, Int)]
|
||||
allCoords n = [ (x,y) | x <- [0..n-1], y <- [0..n-1]]
|
||||
|
||||
getSymbolSet :: [Text] -> String
|
||||
getSymbolSet = nub . concatMap
|
||||
(filter (\str
|
||||
-> not (isDigit str)
|
||||
&& (/= '.') str
|
||||
) . T.unpack)
|
||||
|
||||
nextCoord :: [(Int, Int)]
|
||||
nextCoord = [ (x,y) | x <- [-1,0,1], y <- [-1,0,1] ]
|
||||
|
||||
adjacentCoords :: Int -> (Int, Int) -> [(Int, Int)]
|
||||
adjacentCoords l (x,y) =
|
||||
filter (and . tupleToList . bimap gtl gtl)
|
||||
. filter (and . tupleToList . bimap gtz gtz)
|
||||
$ map (bimap (+x) (+y)) nextCoord
|
||||
where
|
||||
gtz = (>=0)
|
||||
gtl = (< l)
|
||||
tupleToList (a, b) = [a,b]
|
||||
|
||||
pointer :: [Text] -> String -> (Int, Int) -> Int
|
||||
pointer txt symbolSet (x,y) = numberAt symbolSet x $ txt !! y
|
||||
|
||||
numberAt :: String -> Int -> Text -> Int
|
||||
numberAt symbolSet n txt = if not $ check (T.head h')
|
||||
then 0
|
||||
else sumPair . bimap
|
||||
(T.takeWhileEnd check)
|
||||
(T.takeWhile check)
|
||||
$ (h,h')
|
||||
where
|
||||
isElem = flip elem symbolSet
|
||||
check a = a /= '.' && not (isElem a)
|
||||
(h,h') = T.splitAt n txt
|
||||
|
||||
sumPair :: (Text, Text) -> Int
|
||||
sumPair (a,b) = read str'
|
||||
where
|
||||
str = T.unpack $ T.concat [a,b]
|
||||
str' = if null str then "0" else str
|
||||
|
||||
-- attachCoords :: [Text] -> [((Int, Int), Char)]
|
||||
-- attachCoords = concat . zipWith (\col -> map (\(r,c) -> ((r,col),c))) [0..] . map (zip [0..] . T.unpack)
|
||||
|
||||
attachCoords :: [Text] -> [[((Int, Int), Char)]]
|
||||
attachCoords = zipWith (\col -> map (\(r,c) -> ((r,col),c))) [0..] . map (zip [0..] . T.unpack)
|
||||
|
||||
solveP1 = id
|
||||
|
||||
getAllNumbers :: [Text] -> [Int]
|
||||
getAllNumbers = map (read . T.unpack) . concatMap (filter (not . T.null) . T.split (not . isDigit))
|
||||
|
||||
test = groupBy (\((i,_),c) ((j,_),c')
|
||||
-> trace ("\n" <> show c <> show i <> ", " <> show c' <> show j <> "\n")
|
||||
i == j-1
|
||||
) $ concatMap (filter (\(_,c)-> isDigit c)) $ attachCoords example
|
||||
|
||||
--
|
||||
-- Part 2
|
||||
--
|
||||
|
||||
solveP2 = id
|
||||
|
||||
|
||||
--
|
||||
-- Examples
|
||||
--
|
||||
|
||||
example :: [Text]
|
||||
example =
|
||||
[ "467..114.."
|
||||
, "...*......"
|
||||
, "..35..633."
|
||||
, "......#..."
|
||||
, "617*......"
|
||||
, ".....+.58."
|
||||
, "..592....."
|
||||
, "......755."
|
||||
, "...$.*...."
|
||||
, ".664.598.."
|
||||
]
|
||||
69
src/advent_of_code/2023/4.hs
Normal file
69
src/advent_of_code/2023/4.hs
Normal file
@@ -0,0 +1,69 @@
|
||||
-- https://adventofcode.com/2023/day/4
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.IO as T
|
||||
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
entries <- T.lines <$> T.readFile "src/advent_of_code/2023/input4"
|
||||
|
||||
putStrLn "Advent of Code 2023 - Day 4"
|
||||
-- print entries
|
||||
|
||||
putStrLn ("Part 1: " <> show (solveP1 entries))
|
||||
-- putStrLn ("Part 2: " <> show (solveP2 entries))
|
||||
|
||||
|
||||
--
|
||||
-- Part 1
|
||||
--
|
||||
|
||||
double :: Int -> Int
|
||||
double = (* 2)
|
||||
|
||||
scoreWins :: Int -> Int
|
||||
scoreWins 0 = 0
|
||||
scoreWins n = last . take n $ iterate double 1
|
||||
|
||||
parse :: Text -> ([Int], [Int])
|
||||
parse line = (winners, numbers)
|
||||
where
|
||||
parsed =
|
||||
map (map (read . T.unpack)
|
||||
. filter (not . T.null)
|
||||
. T.splitOn " ")
|
||||
. T.splitOn "|"
|
||||
. T.drop 2
|
||||
. T.dropWhile (/= ':')
|
||||
$ line
|
||||
winners = head parsed
|
||||
numbers = last parsed
|
||||
|
||||
scoreTicket :: ([Int], [Int]) -> Int
|
||||
scoreTicket (winners, numbers) = scoreWins . length
|
||||
$ filter (`elem` winners) numbers
|
||||
|
||||
solveP1 :: [Text] -> Int
|
||||
solveP1 = sum . map (scoreTicket . parse)
|
||||
|
||||
--
|
||||
-- Part 2
|
||||
--
|
||||
|
||||
|
||||
--
|
||||
-- Examples
|
||||
--
|
||||
|
||||
example :: [Text]
|
||||
example =
|
||||
[ "Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53"
|
||||
, "Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19"
|
||||
, "Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1"
|
||||
, "Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83"
|
||||
, "Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36"
|
||||
, "Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11"
|
||||
]
|
||||
1000
src/advent_of_code/2023/input1
Normal file
1000
src/advent_of_code/2023/input1
Normal file
File diff suppressed because it is too large
Load Diff
100
src/advent_of_code/2023/input2
Normal file
100
src/advent_of_code/2023/input2
Normal file
@@ -0,0 +1,100 @@
|
||||
Game 1: 8 green; 5 green, 6 blue, 1 red; 2 green, 1 blue, 4 red; 10 green, 1 red, 2 blue; 2 blue, 3 red
|
||||
Game 2: 10 blue, 12 red; 8 red; 7 green, 5 red, 7 blue
|
||||
Game 3: 1 red, 15 blue, 3 green; 8 blue, 2 red, 4 green; 2 red, 5 green, 9 blue
|
||||
Game 4: 8 green, 4 blue, 1 red; 3 green; 4 blue, 1 red, 12 green; 5 green, 1 red, 8 blue; 3 green, 5 blue, 1 red
|
||||
Game 5: 2 green, 8 blue; 7 blue, 4 green; 7 blue; 5 blue; 5 green, 2 blue, 1 red
|
||||
Game 6: 6 blue, 3 green; 18 green, 8 blue; 9 green, 4 blue; 4 blue, 2 red, 3 green
|
||||
Game 7: 15 red, 12 blue, 15 green; 12 blue, 18 green; 9 blue, 11 red; 16 green, 6 blue, 18 red; 6 blue, 12 red; 14 red, 18 green, 12 blue
|
||||
Game 8: 6 red, 13 blue, 3 green; 18 blue; 3 green, 8 red
|
||||
Game 9: 3 blue, 4 red; 8 red, 2 blue; 4 green, 8 red, 3 blue; 6 red, 1 blue; 16 green, 2 red, 2 blue
|
||||
Game 10: 3 red, 7 blue, 2 green; 1 green, 15 red, 5 blue; 1 red, 5 blue; 3 blue, 4 green
|
||||
Game 11: 12 green, 3 blue; 3 red; 1 red, 6 blue, 9 green; 7 blue, 1 red, 13 green; 1 blue, 5 green, 4 red; 18 green, 3 red
|
||||
Game 12: 9 green, 13 blue; 3 red, 4 blue, 4 green; 10 green, 7 red, 5 blue; 9 red, 12 blue, 3 green
|
||||
Game 13: 15 red, 18 blue, 10 green; 11 red, 3 green, 4 blue; 2 green, 12 blue, 4 red
|
||||
Game 14: 12 blue, 6 red; 2 blue, 7 green, 6 red; 12 blue, 7 green; 4 blue, 1 green, 4 red; 9 green, 12 blue; 3 red, 5 green, 8 blue
|
||||
Game 15: 9 green, 1 blue; 14 green, 4 red, 1 blue; 1 blue, 6 green, 2 red; 7 red, 13 green, 2 blue; 4 red, 9 green; 2 green, 1 blue, 2 red
|
||||
Game 16: 3 blue, 2 green, 5 red; 4 green, 3 blue, 4 red; 6 red, 5 blue, 2 green; 3 red, 11 blue; 6 green, 15 blue, 4 red
|
||||
Game 17: 15 blue, 3 green, 2 red; 2 green, 2 red, 15 blue; 1 red, 1 blue, 7 green
|
||||
Game 18: 2 blue, 9 red; 12 red, 1 green, 6 blue; 5 red, 5 blue, 2 green
|
||||
Game 19: 3 red, 4 green, 8 blue; 10 red, 8 green, 1 blue; 13 blue, 7 green, 10 red; 6 red, 1 green, 11 blue; 9 green, 7 blue, 10 red; 7 blue, 7 red
|
||||
Game 20: 8 blue, 4 green, 14 red; 4 green, 16 red, 1 blue; 10 blue, 14 red, 8 green; 4 green, 13 blue, 20 red; 5 blue, 5 green, 1 red
|
||||
Game 21: 4 green, 10 blue, 5 red; 11 blue, 4 green, 1 red; 3 blue, 3 red, 2 green; 1 red, 11 blue, 6 green; 1 green, 9 blue, 5 red; 7 blue, 5 green
|
||||
Game 22: 3 green, 7 blue, 6 red; 12 red, 11 blue, 2 green; 1 blue, 1 green, 15 red; 6 blue, 1 green, 8 red; 4 blue, 1 red; 2 blue, 1 green, 5 red
|
||||
Game 23: 2 blue, 5 green, 13 red; 1 green, 5 blue, 16 red; 6 blue, 9 green, 9 red; 7 green, 3 blue
|
||||
Game 24: 2 green; 2 red, 7 blue, 17 green; 5 red, 6 blue, 13 green; 1 green, 6 blue; 2 green, 4 red, 2 blue; 4 blue, 2 green
|
||||
Game 25: 2 green, 5 blue, 9 red; 2 green, 8 red, 5 blue; 3 green, 1 red, 19 blue
|
||||
Game 26: 3 green, 2 blue, 8 red; 4 red, 2 blue; 11 red, 3 green; 9 red, 3 green, 6 blue; 10 red, 1 green, 2 blue; 4 blue, 4 green, 14 red
|
||||
Game 27: 1 green, 4 red, 7 blue; 13 red; 17 red
|
||||
Game 28: 5 red, 17 green, 15 blue; 7 blue; 7 red, 12 green, 10 blue; 5 red, 11 blue, 3 green
|
||||
Game 29: 4 blue, 9 red, 9 green; 2 green, 10 red, 2 blue; 3 red, 4 blue, 6 green; 2 green, 17 red, 1 blue; 2 red, 7 green, 1 blue
|
||||
Game 30: 16 red, 5 blue, 11 green; 5 blue, 5 green, 9 red; 7 green, 1 red, 6 blue
|
||||
Game 31: 3 green, 11 blue; 5 green; 8 green, 13 blue; 4 red, 10 blue, 8 green
|
||||
Game 32: 11 blue, 5 green, 4 red; 7 blue; 1 red, 1 green, 7 blue; 7 red, 1 blue, 4 green
|
||||
Game 33: 7 red, 3 green, 6 blue; 2 red, 16 green, 5 blue; 1 blue, 2 red, 8 green
|
||||
Game 34: 1 blue, 1 red, 1 green; 9 red, 6 green; 2 blue, 8 red, 6 green; 1 blue, 12 green, 13 red
|
||||
Game 35: 10 red, 9 green; 1 red, 4 blue, 4 green; 7 blue, 3 green, 4 red
|
||||
Game 36: 5 red, 6 green, 4 blue; 9 green, 1 red; 12 red, 12 green, 4 blue; 3 red; 18 green, 5 red, 4 blue
|
||||
Game 37: 10 green, 4 blue, 2 red; 1 red, 3 blue, 9 green; 5 blue, 4 green, 1 red; 6 green, 12 blue; 7 green, 1 red, 13 blue; 9 green, 20 blue, 2 red
|
||||
Game 38: 9 blue, 20 red, 2 green; 3 blue, 6 green, 19 red; 10 green, 8 red, 2 blue; 4 blue, 4 red, 3 green
|
||||
Game 39: 4 green, 2 blue, 4 red; 16 blue, 1 red, 2 green; 13 red, 2 green; 16 blue, 7 red, 3 green
|
||||
Game 40: 8 blue, 2 green, 2 red; 7 blue, 2 red, 1 green; 8 green, 12 blue, 2 red; 2 red, 3 blue, 8 green
|
||||
Game 41: 9 blue, 2 green; 10 blue, 3 green; 1 green, 9 blue, 3 red; 3 blue, 3 green; 12 blue, 1 red; 3 blue, 1 green, 1 red
|
||||
Game 42: 1 blue, 1 green, 8 red; 1 blue, 1 red; 2 red, 1 green
|
||||
Game 43: 5 red, 2 green, 8 blue; 11 blue, 10 green, 1 red; 11 blue, 7 red
|
||||
Game 44: 9 red, 3 green; 9 red, 1 blue, 6 green; 14 red, 5 green; 4 red, 2 green, 1 blue
|
||||
Game 45: 5 blue, 1 red, 1 green; 5 blue, 1 red; 6 blue; 10 blue, 1 green; 1 red
|
||||
Game 46: 4 green, 8 blue, 13 red; 12 green, 11 blue, 12 red; 1 green, 13 red, 1 blue; 12 red, 8 green, 12 blue
|
||||
Game 47: 1 green, 16 blue, 15 red; 1 blue; 18 red, 10 blue, 9 green; 17 blue, 16 red, 5 green; 2 red, 3 blue, 9 green
|
||||
Game 48: 2 blue, 4 green; 7 blue, 3 red, 2 green; 17 blue, 13 red; 2 red, 1 green, 9 blue; 2 red, 14 blue
|
||||
Game 49: 6 red, 2 blue, 3 green; 1 green, 4 blue, 7 red; 5 red, 8 green, 6 blue; 1 red, 9 green
|
||||
Game 50: 18 red, 4 blue; 6 blue, 3 green, 13 red; 1 green, 7 red, 6 blue
|
||||
Game 51: 10 blue, 1 green, 9 red; 3 green, 6 blue, 8 red; 4 red, 2 green, 12 blue
|
||||
Game 52: 7 blue, 1 red, 8 green; 2 red, 9 blue, 8 green; 16 blue, 7 green; 1 red, 11 green, 8 blue; 2 red, 20 blue
|
||||
Game 53: 8 green, 15 red, 4 blue; 5 green, 13 blue; 6 blue, 6 green, 15 red; 12 blue, 2 green, 2 red
|
||||
Game 54: 3 green, 5 red, 1 blue; 1 blue, 6 green, 2 red; 4 green, 3 red
|
||||
Game 55: 12 green, 8 red, 3 blue; 6 blue, 2 red, 7 green; 4 blue, 13 red, 11 green; 12 green, 9 blue, 7 red; 10 red, 6 blue, 3 green
|
||||
Game 56: 6 red, 1 green, 2 blue; 1 red, 1 green, 3 blue; 12 red, 4 blue, 4 green; 3 green, 5 blue, 1 red; 5 blue, 3 green, 2 red; 1 green, 5 red, 7 blue
|
||||
Game 57: 1 blue, 1 green, 3 red; 10 red, 6 green, 1 blue; 4 red, 4 green, 2 blue; 7 green, 2 blue, 1 red
|
||||
Game 58: 5 green, 2 blue, 4 red; 2 red, 2 blue; 5 red, 3 green; 3 blue, 5 green; 6 red, 2 green, 2 blue; 7 red, 3 blue, 5 green
|
||||
Game 59: 14 red, 9 green; 11 red, 2 blue, 5 green; 18 red, 2 blue, 4 green
|
||||
Game 60: 16 red, 9 green, 2 blue; 8 green, 17 red; 3 blue, 5 green, 14 red
|
||||
Game 61: 12 red, 17 blue, 18 green; 1 green, 1 blue; 1 blue, 4 green, 6 red
|
||||
Game 62: 2 blue, 5 green, 3 red; 1 blue, 7 green, 6 red; 8 blue, 1 red; 4 blue, 5 red, 12 green; 15 blue, 3 green, 1 red
|
||||
Game 63: 2 blue, 2 red, 1 green; 5 red, 10 blue, 4 green; 4 green, 5 blue, 8 red
|
||||
Game 64: 2 blue, 14 green; 9 green, 5 red; 7 red, 3 blue, 10 green; 14 green, 2 blue, 5 red
|
||||
Game 65: 4 green, 7 blue, 1 red; 3 red, 2 green, 7 blue; 5 blue, 2 red, 1 green; 6 blue, 2 green; 7 blue
|
||||
Game 66: 9 red, 2 green, 5 blue; 5 blue; 8 blue, 5 green, 11 red; 17 blue, 3 green, 14 red; 2 green, 9 blue; 11 red, 4 blue
|
||||
Game 67: 2 green, 7 red, 8 blue; 6 red, 4 green; 1 red, 3 green, 7 blue; 7 blue, 7 red, 4 green; 2 red, 1 green; 3 green, 6 red, 2 blue
|
||||
Game 68: 4 red, 2 blue, 5 green; 5 blue, 8 red, 2 green; 11 red, 2 green, 4 blue; 7 red, 5 blue, 3 green
|
||||
Game 69: 8 blue, 1 green, 4 red; 3 red, 11 blue, 9 green; 12 blue, 10 green; 1 red, 15 blue, 7 green
|
||||
Game 70: 13 blue, 1 green, 8 red; 15 blue, 10 red; 10 blue, 17 red; 15 red, 4 green, 6 blue; 11 red, 1 blue, 2 green; 14 red, 4 green, 4 blue
|
||||
Game 71: 1 red, 10 blue; 1 green, 12 blue, 2 red; 4 red, 4 green, 8 blue
|
||||
Game 72: 2 green, 6 red, 1 blue; 7 red, 4 green, 4 blue; 7 red, 4 blue, 7 green; 7 green, 3 blue; 10 green, 9 blue, 8 red; 5 red, 2 green, 8 blue
|
||||
Game 73: 8 blue, 2 green, 9 red; 2 green, 10 red, 6 blue; 3 blue, 6 green, 2 red
|
||||
Game 74: 2 blue, 10 green, 7 red; 4 blue, 13 red, 3 green; 11 green, 3 red, 4 blue
|
||||
Game 75: 14 green, 1 red, 7 blue; 15 blue, 11 green, 1 red; 11 green, 15 blue, 6 red
|
||||
Game 76: 7 green, 7 red, 2 blue; 4 blue, 18 red, 9 green; 12 red, 4 blue, 1 green
|
||||
Game 77: 3 blue, 1 green, 12 red; 10 green, 13 red, 7 blue; 7 green, 12 red; 6 blue, 10 red; 5 blue, 3 green, 17 red; 3 green, 5 blue, 13 red
|
||||
Game 78: 11 red, 9 blue; 2 red, 7 blue; 12 red, 7 blue, 3 green; 3 green, 8 red, 9 blue; 1 green, 5 red, 6 blue
|
||||
Game 79: 6 red, 12 blue; 5 red, 4 green, 11 blue; 13 blue, 2 green, 3 red
|
||||
Game 80: 7 red, 6 blue; 2 green, 7 red, 6 blue; 5 blue, 6 red, 2 green; 1 green, 7 red, 2 blue; 4 green, 6 blue, 7 red; 1 green, 6 red, 10 blue
|
||||
Game 81: 10 blue, 7 green, 3 red; 7 green, 3 red, 16 blue; 18 blue, 3 red, 7 green
|
||||
Game 82: 7 red, 5 blue, 9 green; 7 blue, 8 green, 11 red; 1 blue, 1 green, 10 red; 5 red, 8 blue, 7 green; 6 red, 10 green, 2 blue; 3 blue, 5 green, 10 red
|
||||
Game 83: 2 red, 2 green, 1 blue; 2 green, 2 red; 6 red, 1 green; 8 red, 1 blue, 1 green; 1 red, 1 green; 3 red
|
||||
Game 84: 9 red, 4 green; 1 red, 13 green, 2 blue; 2 green, 15 red, 2 blue
|
||||
Game 85: 2 green, 4 red; 1 blue; 2 green, 4 red, 1 blue
|
||||
Game 86: 2 green, 10 red, 3 blue; 3 red, 5 blue; 3 green, 2 blue, 8 red; 1 blue, 5 red, 2 green
|
||||
Game 87: 19 green, 9 blue, 7 red; 12 red, 15 green; 4 blue, 8 green; 6 green, 3 red, 11 blue; 16 green, 4 blue, 11 red; 10 red, 4 blue, 9 green
|
||||
Game 88: 6 red, 2 green; 10 red, 4 green, 4 blue; 1 blue, 8 red, 12 green; 7 green, 2 blue, 12 red; 1 green, 5 blue, 16 red; 10 red, 5 blue
|
||||
Game 89: 1 red, 14 blue, 1 green; 1 red, 12 blue, 8 green; 2 red, 13 blue, 11 green; 8 blue, 4 red, 16 green; 4 red, 5 blue; 6 blue, 1 red, 1 green
|
||||
Game 90: 3 blue, 9 green, 5 red; 4 green, 6 red, 1 blue; 2 blue, 12 green, 5 red; 1 green, 1 blue, 3 red; 5 red, 3 green
|
||||
Game 91: 8 green, 3 blue, 8 red; 8 green, 4 blue, 4 red; 5 red, 1 green
|
||||
Game 92: 1 green, 9 red; 1 red, 4 blue; 9 red, 2 green; 3 red, 1 blue
|
||||
Game 93: 1 red, 16 green, 5 blue; 1 red, 1 green, 4 blue; 4 blue, 6 red, 13 green
|
||||
Game 94: 9 red, 9 blue, 3 green; 5 green, 11 blue, 1 red; 3 red, 6 blue
|
||||
Game 95: 2 green, 4 blue; 8 green, 2 blue, 12 red; 10 red, 9 green; 4 red, 2 blue, 4 green; 8 blue, 7 green, 14 red; 1 blue, 4 red, 8 green
|
||||
Game 96: 12 red, 2 blue, 8 green; 6 green, 6 red; 7 blue, 8 green, 6 red; 14 red, 8 green; 2 blue, 4 green, 10 red; 6 green, 7 blue, 7 red
|
||||
Game 97: 4 green, 12 red, 2 blue; 8 blue, 3 red, 3 green; 2 blue, 2 red, 7 green; 17 blue, 1 green, 7 red; 19 blue, 1 red, 6 green; 6 green, 7 red, 9 blue
|
||||
Game 98: 13 red, 15 green, 14 blue; 6 blue, 1 green; 14 blue, 12 red, 1 green
|
||||
Game 99: 1 green, 11 red, 12 blue; 7 red, 20 blue, 1 green; 5 blue, 5 red; 6 blue, 4 red; 1 blue, 1 green; 6 red, 8 blue
|
||||
Game 100: 2 red, 9 green, 11 blue; 13 blue, 4 red, 16 green; 8 green, 13 blue; 10 green, 1 red, 12 blue
|
||||
140
src/advent_of_code/2023/input3
Normal file
140
src/advent_of_code/2023/input3
Normal file
@@ -0,0 +1,140 @@
|
||||
...317..........214.....................................751.................................630...479..205....41.993............416.........
|
||||
...*....813........%....572........%...629.154......518....*....365..................-.......*.......#.....................422...........661
|
||||
269.......*...58...........=......264.....*..........*......937.-...........235...303.........848..............195.....154*.........144.-...
|
||||
........476..@...162.855................$....288...821..............107.....-...........290......../..301.........=...........135..*........
|
||||
618.............=....*...547...........441....*........................@................*........851....+...................+..*...102.310..
|
||||
...*961....905......534..$...377...............854...341.342....485.......109....89.995..927..............................90..997......*....
|
||||
............*...................*.................../.....*......@...........%....*...*.......................+44.....913.........9.....891.
|
||||
....62......724...592....946.878...854....$.701............480......575.246....119.....54..296.906..684..................*.........*838.....
|
||||
.................+......*...............478....................469.....*..................*...........+..502..156.........821...........983.
|
||||
....................315.764..996..571...............=........................804.......&...892....958.....*......*.............61...........
|
||||
........+...697*.....+.........*...*...........@.448........................*.......322.............*....309..37.602.....775....*...........
|
||||
32.480..665.....557......+...435..449..691..327....................#....921..535..........755...43...597........................322..7......
|
||||
......*.....848.........745.............*.......679/............106.......&........404......+....*...................888..750........*......
|
||||
......93...*....=.............*297......550...........324.597............................................819.....997*......-...734$..588....
|
||||
.........363..112..754...............&..........723....................14..954.............175....773...*.............&.....................
|
||||
..................*.......#..........502......../...............606.........@..778*.......#.........*....844...713...743....-.........&.....
|
||||
............827.895.-539...469...938...../.248.....................*.49............749.............783.........$...+.........33....471......
|
||||
..............*.................../...517...&......368*710......432...*............................................841.=.................194
|
||||
.....*491....395.......&481.................../.#...................83................668..181.....698..155*...........981.200..............
|
||||
...................219.................196.473..224.....=.....733*.......=.........98*.......*.420..........671.....*......*......369.205...
|
||||
........@......696*....669.....50.....................853.593.........168....@.............802..*...388............3......792........*......
|
||||
......641............./....62..*...836#.......*169.........@...............872.................416....*.................-...................
|
||||
..........................#...377..........179.......101........+504.................*554.............947..............447.............830..
|
||||
243........*902.....#................480*...........+.....*258.........*243.......389.......&....................723.........838...991......
|
||||
........182.........33..........840......616.733.......756..........290.....................145..119..........................+......&......
|
||||
..............................................*....807...................777......+..556............@....85#................................
|
||||
.212.664..3......316..579..462..............435.......*............@....*........36...$........572................703..732........@.........
|
||||
...........=....@.....*.....*............*.......-..337......656...411.357.373.....................*21....37.........%./.....918...185.387..
|
||||
...350.................338...161.856..157.906...527...........*............+.........*336.......204............755.............*............
|
||||
....&...........683...................................801......313............831.230......374.......................383.....940.48.........
|
||||
...............*........447......635....335......%.........627........44@..........................895....................@.................
|
||||
....$....958..943.......#...935.%..........*...794......16.*..................+...........100..469........743.*.........529....=.......883..
|
||||
..308.....*........*776.......*.....*....430............*..562.......895......765.................*.........*..776..........246..921&.......
|
||||
.........200...............*..1....572................814...........$......#..........138...&....487..668..58.......485.....................
|
||||
...*845.............935...958.................................667.....%.121.......691.......245.........*..............*........131.........
|
||||
.........*............*.............=............................*.593.............*..................380........189...219.211......@.......
|
||||
.....152..783........634...........521.+.......26.............659...............328...%.............................*........$......397.*...
|
||||
......*.......124..........299..........808.....*........359................424.....%..454..........553.............49..562.....257......723
|
||||
......641.........24.............576.............975........=..............*.......974.............*...........146......*......../...@......
|
||||
940.........&....@....221........*.........149.......&...............689....418...........538...................*.....985............526....
|
||||
.............192.........*816...582...561..+..........915..981%.......*..................*......&8....+.........497..........145............
|
||||
.........144........$....................@......................425.933....846*824.$...370.342*....375...641..=........927.....*.......160..
|
||||
............$.......925...67.655....57.............=905..881....@..................585.........746.............224..........224...864...*...
|
||||
.....872................#..*...$.....*.........#............*...........979....699...................947.........................*.....788..
|
||||
............949......676..42........340.....694...144......712..296..45...*.......*..............191.@.......889-......=786.....417.........
|
||||
...........*.................846....................*..160.......*.......403.....347...914.91...=...........................................
|
||||
.371.=....904.643......816...*...647...$.858.......431..........486..........706......*....-..............961........................698....
|
||||
......398.....*....252*....591..../..224...$..341...........#................*................956............*...27..............57.....*534
|
||||
.............363...............................&.............69........163.233.580....113*367..............44...*..................*406.....
|
||||
...893..457..........91%........................................538.....$......*..............................475....864.......289..........
|
||||
..........-........................549............909..572.....-..............385.............97.....................=.....159..*...........
|
||||
...174...............................*...576.875....*.....=...................................*....506..115...............*....856....408...
|
||||
.....=.......685....58........177.965...-.....*....489......402/..&603.....................357......=..&....84.....451&.810........93...*...
|
||||
.....................*...87.........................................................447........@............*................-......*...117.
|
||||
......205.593........298..................................622....955.......34*325......*....965...................604......729....509.......
|
||||
........=..*.......+...............966.......................$.$...................206......................99....-....424..............$...
|
||||
378..........636..141.543%....34...........437-.................303.........80....*.............915...........*........*...885...........148
|
||||
............*................=......................39......-.......208.560*...906...................320.860.975....532....*.........740....
|
||||
....834...13...................426.395*962...44.......-......552...................*539.+........953.......%............647.........*.......
|
||||
..............589...............*..........................................179...71.....207........#.577......758...247..........958........
|
||||
....930.......*......&139...820.56.....%164....................536.=31......*.............................................89................
|
||||
.....#.........569............*.............882....296......&................465.......21............=.....331........998*..................
|
||||
..........847..............206....$............%.....#.464.318..=.....751*........................501..971...*..............227.......854...
|
||||
.466......*......768..../.......110......................*.......612......551......868.......727.......*......39.850..-.....*.........*.....
|
||||
.........377.561....&.718...94............246..........159...........255............%.........*...........445........472...520.......304.472
|
||||
...............*..........................@.....292.............................476......&.........135......*...223.........................
|
||||
..............288.....................944........*......775*934................+......152.............*55..806............239#..............
|
||||
...181*552...............................*....238...............499...880.476...................................417.#66.........472.........
|
||||
.....................*........%...629.853............*......@9...@......=.....443...673........271...*..........-...........98..............
|
||||
.........567*288...10.257..837......*.........862..14................21......*...................%..714...........963.........%.450....528..
|
||||
....................................862..................889.....604...*424..350...812..34........................*...646...................
|
||||
...............*....*933.....355@..................*528....=......................+.....*...&996..493.....992..840.......*..271.............
|
||||
..............984...............................678.................+571.....648......262............*......*..............*......293..197..
|
||||
..........386..............463..984......129................-588..............*..361...............408..269.652...........406........*..+...
|
||||
.........*............494....*.......847...*..#..942..825.............&......32.........................*........427...........-....339.....
|
||||
.......415.=434..439.....*..23........$..34..410.........+.......746.976.............731..../.1*.........709.......*.........197........#...
|
||||
................*......493.......760.............................................654*....398.........158....../......396.............922....
|
||||
.....845.=....955...................*.....*574....954*........@...........$.......................-....*.....796......-...426...$732........
|
||||
.......*.88.............@.........738..924............213...40....115......315...................299...108...................*.......320....
|
||||
....567...............%..13.................*14...........$.......@.....%.........../...518.......................-.810...514..952..........
|
||||
........892...275....485.......820.......367.......@.....544...........428.........54..-.............*....108..964...*..........*...........
|
||||
.......@...................861......#.........893.116.........836.982......961.............../...615.188.....*.....914.........761....765...
|
||||
...........169.962.........*......81...769...#...............................-..714.424..759.390...@.........855...........562.........*....
|
||||
....../906......../......81..968.......-..............................185..............*.%............=......................*.205.....72...
|
||||
................*............*....110........./.907....241.......708...*...383.701..869...............346..............649.771.#............
|
||||
.............531.976...670...288...........382....*.......*116.........820.-...*............764..556...........@..984....$.......638...165..
|
||||
........................-..........479.............55..........................515.....345...#................533...*.......................
|
||||
.....$....569.936.301.........914..*.......-.....=................453..............209..*..........................551.-.......479..........
|
||||
..233.....*......*.....506.........931..246....221.639....#..................@......*....784........591.................818...%.......523...
|
||||
.......233....%.........................................416...714&........448.......698......387........432............................*....
|
||||
...........718.......@......465....................430........................603.......491..*..........*...22.164...+...............179....
|
||||
...............450.462.549.=....283.185...880......................652.......................142..430.372.....*.......633...................
|
||||
.370....143....*.........*.........*......*.....962...........*.....*....................537........%...........&136........................
|
||||
.....39.......956......213...........476.143.......*.......321.60....708..........966.......#...921......+146............+...665............
|
||||
...........................941...321*.............880.499...........................*.............*.383........668.....212...*....827*428...
|
||||
..236..527...................=..........................*........../..854......................489...-........................234...........
|
||||
.....*.................................622..........289..599....207...*............&953.599=...............885............682.....914.....12
|
||||
793...754.............$497..............*............*................163....................+.........15.....*..*....338*..................
|
||||
...*.......864................348..........758.......439...................1........83....748...............325.535...................=.....
|
||||
...368....*........382*250....*.....317.......*................473*....877.+.........*..................@................%....331..513......
|
||||
.........55..239...........2...377...=......1.792...294*607........831..........*.950...&....-....#....864.....139.......512................
|
||||
....427.......*...*...#....%...........765...............................418.995.........6..492.465...........@....................*218.....
|
||||
......*......939.410.371......#...-......#.................&............*.............................496..........503..........629.........
|
||||
.....410....................215.193.................678.786.....370...71..598......329..........262.................*.......473.............
|
||||
.........979..855..432=................212.....346..*....................*........*............#...................249...=.....+...525.217..
|
||||
.........*....*...............387.....*...........*.228......./....%....245..&.....690.....429............................685.........*.....
|
||||
129....907.423........949.772......666....173..679........992.313...398......427..............*...................244.......................
|
||||
.........................*.....*............................*........................../....998..........510..825*..........................
|
||||
.....132....867........%.....42.780..............776*744...898.......664....196....360..823......899.211..=.................+...............
|
||||
.....*.......%......703................916...%...............................*....*................*....&.....689..$......591.......64*238..
|
||||
...684..160.......................445.....*...164.......602....249...........431.12.............=..758............138..........983..........
|
||||
..........@..766.92..............*......334........671..*...............&646..................797.............950.........935.........469...
|
||||
................*..................510..............*..285..........................................650.......*....807...*............#.....
|
||||
..205.669...768...88........................+59..148............682........#.................3..............376...*.......191...............
|
||||
.........&....*..%........................................183......*......61................/........657..........163............255........
|
||||
..674.......46..............392..251....507.................*.248...74..........+...775.97.....222.........%..........135...950.....*.......
|
||||
....*...........*967..533...*............*......949..245.276...#.........*.....728...................677..137.....*.....*..&........522.....
|
||||
...367.......196.......$..239..........510.748..*............/...481..722....................800........*........735..268...................
|
||||
.........442...................111...............752........567...*.........*..........696..%............790................................
|
||||
.............182....677..613............................/..........814...372.86........*......915*..............799.................*....253
|
||||
....&....739*........../....*206.........284...........584...427................727..485..........781.992.........-...............619.......
|
||||
.....603.........................907........*....607......../.............................617............*...=.......986-.............918...
|
||||
.........819..667..341...........*....#..397................................#........$..................822...20...........359.....43.......
|
||||
.......&....*...#....*.......*....88.691.........................700.675....910...227........350...&591............301.......$.......*......
|
||||
..404$..259.......557....876.218...........216.=211.7...=569........*........................=.................320..*....462...480....747...
|
||||
..........................+.............#..*........*.................=518........................274............@...276........../.........
|
||||
.......#...904......622..............923....543....969../..................571..778......#888.253..................+.....163.........-679...
|
||||
295.207.........708......................................942...496....#...*.......*.373@.......*..645...............580.......177...........
|
||||
................................982*317............304........*.......28.823....994.......370..96........@.=...*675............*.....604....
|
||||
644.138.522......%......901.................374*..*.........458.....................#135....=..........730.355........955...=.47.277*.......
|
||||
...*....*.........288..*.............+.433.........240.................317/........................609............#90.*...623...............
|
||||
.....%..675....87.......110...126.408..*......355.............................@131......110....778...*..519.834.......537.....19........502.
|
||||
..831............*460........*..........824.....*..751...467.829..........850..........*............365....*................................
|
||||
..........398..............473....-..........751.....*......*................@.446*....780...........................732....................
|
||||
.......................#.........333..................170........596...............943......66..186......@...........@.....=................
|
||||
......124....780.....58.....933........926.../.............693...*..........*828...............*........666.............=..337..............
|
||||
.......*.........197..........$.......*......67............-...335...........................122...582................197..........328......
|
||||
.....151...............................763......180....@............890../....835...578..871..........*295..#....%...........-541.$.........
|
||||
........................153.........-........@.....*...661..*833......*.775.....-...........................40....665...............701.....
|
||||
..890....252......................544........809..425..............925......................................................................
|
||||
192
src/advent_of_code/2023/input4
Normal file
192
src/advent_of_code/2023/input4
Normal file
@@ -0,0 +1,192 @@
|
||||
Card 1: 26 36 90 2 75 32 3 21 59 18 | 47 97 83 82 43 7 61 73 57 2 67 31 69 11 44 38 23 52 10 21 45 36 86 49 14
|
||||
Card 2: 45 10 54 17 15 38 59 96 25 32 | 17 12 77 87 29 70 38 96 15 54 86 64 32 10 28 59 24 45 65 81 42 25 98 14 60
|
||||
Card 3: 37 31 21 71 80 76 91 77 64 69 | 90 71 91 13 2 40 83 22 45 31 69 53 77 27 97 35 4 55 14 9 52 21 16 19 63
|
||||
Card 4: 16 82 44 42 51 11 86 14 92 47 | 44 61 81 88 15 11 76 42 17 98 48 83 14 92 99 16 82 86 56 47 10 66 13 22 51
|
||||
Card 5: 83 84 64 81 97 88 96 59 92 25 | 52 65 98 86 75 48 96 60 56 33 76 81 29 44 97 82 59 64 88 25 23 92 37 84 83
|
||||
Card 6: 50 51 91 86 25 44 75 23 5 56 | 86 17 56 16 91 75 27 94 39 80 25 71 23 26 12 31 43 45 5 18 50 44 96 51 57
|
||||
Card 7: 34 14 63 33 87 92 69 67 24 13 | 86 47 31 45 3 32 81 96 21 93 80 25 90 63 79 6 49 91 7 95 62 66 19 24 76
|
||||
Card 8: 19 67 63 77 62 92 51 49 52 1 | 35 1 94 87 11 82 12 84 49 28 39 96 92 23 34 4 56 5 63 13 77 47 14 9 78
|
||||
Card 9: 54 14 61 36 10 35 92 34 47 95 | 87 92 95 54 3 47 15 36 90 11 9 84 10 75 45 72 61 88 14 64 35 34 98 46 76
|
||||
Card 10: 27 59 55 95 4 99 8 48 97 6 | 51 50 48 91 34 4 97 86 27 99 20 95 17 6 80 43 21 60 28 10 89 59 73 55 8
|
||||
Card 11: 74 46 96 17 62 65 38 4 29 6 | 48 83 42 4 17 35 1 38 6 74 40 95 80 49 46 29 65 62 85 47 96 18 76 36 68
|
||||
Card 12: 68 12 22 46 33 57 61 86 13 62 | 62 35 20 7 16 78 60 11 9 31 46 34 73 68 77 36 61 66 65 14 26 83 98 95 69
|
||||
Card 13: 50 14 10 3 83 27 52 84 61 44 | 75 22 56 60 62 36 87 33 85 52 7 95 19 81 10 47 20 73 50 13 46 3 83 37 84
|
||||
Card 14: 51 42 40 21 29 78 10 31 54 24 | 78 67 10 17 54 99 1 87 8 66 23 56 5 63 92 50 71 47 98 3 73 16 74 42 85
|
||||
Card 15: 65 68 76 6 40 78 11 60 55 84 | 39 40 59 43 55 69 72 14 94 66 20 80 11 93 64 68 96 34 38 84 67 41 53 89 88
|
||||
Card 16: 77 95 61 17 74 46 54 3 37 81 | 3 14 41 73 12 75 31 71 24 26 92 74 64 98 89 95 93 19 15 82 91 30 66 81 40
|
||||
Card 17: 87 11 32 58 43 99 7 79 37 82 | 70 14 67 68 18 29 54 12 15 17 34 71 84 74 4 36 98 42 24 23 38 97 79 81 83
|
||||
Card 18: 2 70 93 86 50 39 15 76 64 8 | 76 42 75 67 14 39 15 64 45 10 56 12 32 2 93 52 8 68 97 36 79 98 17 37 59
|
||||
Card 19: 55 53 86 35 88 48 79 56 34 33 | 77 89 45 76 82 23 52 97 62 27 7 38 84 81 99 41 40 70 42 50 21 4 80 12 46
|
||||
Card 20: 53 21 29 48 42 89 12 34 76 14 | 56 46 69 50 88 85 74 40 66 47 79 77 61 9 67 39 22 63 6 59 54 92 14 51 96
|
||||
Card 21: 11 87 63 43 5 91 22 45 61 26 | 46 99 43 57 88 75 32 34 91 7 87 15 13 54 66 82 1 10 31 70 24 16 2 90 39
|
||||
Card 22: 31 89 65 74 38 4 99 40 19 9 | 45 28 54 77 3 42 14 55 41 71 81 84 82 69 64 97 76 48 56 13 23 66 15 30 8
|
||||
Card 23: 6 59 76 99 9 86 4 84 5 27 | 37 80 51 24 46 72 68 82 89 30 21 55 96 7 91 85 92 93 78 14 70 61 2 11 50
|
||||
Card 24: 11 37 40 53 70 95 44 3 92 49 | 60 67 54 52 34 93 87 26 74 88 4 91 78 68 17 38 97 7 43 69 64 18 73 15 80
|
||||
Card 25: 35 52 84 65 30 2 37 89 67 90 | 51 14 25 96 45 4 28 88 8 22 13 66 9 48 82 85 86 54 75 91 1 10 29 5 39
|
||||
Card 26: 88 84 2 68 47 81 8 11 46 29 | 47 84 98 20 75 63 44 64 15 7 27 53 43 26 68 73 2 91 78 29 46 11 76 8 99
|
||||
Card 27: 65 94 27 71 54 86 77 47 64 31 | 65 8 27 76 83 64 69 96 78 61 7 11 72 55 41 10 54 93 15 52 90 4 33 94 82
|
||||
Card 28: 46 89 43 92 93 60 14 34 91 69 | 60 94 46 43 82 53 91 34 92 15 28 55 6 88 57 89 14 67 4 61 36 69 2 93 12
|
||||
Card 29: 73 54 41 45 29 83 65 70 80 72 | 42 59 6 73 36 87 23 14 47 96 77 72 43 29 70 93 90 50 65 68 56 19 17 63 76
|
||||
Card 30: 73 18 66 4 96 55 52 59 93 97 | 36 50 90 22 78 96 71 60 87 26 84 74 66 68 55 54 63 73 20 97 10 12 16 76 93
|
||||
Card 31: 58 42 91 76 86 26 80 5 14 79 | 1 40 4 42 11 13 68 99 10 97 59 76 56 67 5 91 93 26 38 87 80 17 86 33 12
|
||||
Card 32: 65 29 20 80 13 60 43 18 17 95 | 55 53 72 8 22 45 90 79 81 10 77 5 26 87 52 56 43 30 54 98 93 14 62 74 51
|
||||
Card 33: 40 81 10 65 18 59 1 68 69 35 | 65 91 69 35 59 48 23 37 33 10 29 11 76 25 55 64 58 9 46 47 83 51 98 68 1
|
||||
Card 34: 9 87 17 41 81 51 50 20 5 14 | 54 19 81 60 48 90 70 43 44 62 78 3 9 6 87 51 4 47 77 30 82 76 56 13 94
|
||||
Card 35: 58 71 47 3 59 96 92 30 74 4 | 9 78 30 51 43 82 96 35 48 76 53 52 62 49 4 41 39 93 27 80 87 59 33 34 7
|
||||
Card 36: 8 45 92 39 66 36 34 69 82 63 | 67 37 24 19 85 46 47 92 74 3 17 97 61 65 83 39 77 34 15 55 75 7 20 28 54
|
||||
Card 37: 39 59 17 65 89 24 28 87 86 29 | 3 67 73 44 27 68 8 12 32 59 2 50 40 76 62 75 34 5 72 18 52 25 70 90 53
|
||||
Card 38: 7 91 1 70 12 16 57 78 89 69 | 92 28 56 94 15 44 31 35 51 82 11 52 7 74 62 3 76 93 26 6 19 72 86 30 2
|
||||
Card 39: 63 43 99 29 91 33 52 96 76 26 | 61 53 42 2 84 73 72 55 49 18 80 34 77 62 43 45 92 50 38 40 89 60 47 69 16
|
||||
Card 40: 83 91 18 21 48 6 82 85 39 17 | 38 43 7 77 59 40 73 1 49 76 66 64 84 22 53 56 15 42 94 24 2 10 99 70 63
|
||||
Card 41: 19 74 11 78 71 39 21 58 25 50 | 81 26 33 82 71 58 54 4 19 47 37 73 50 74 99 25 44 39 38 78 21 77 11 88 59
|
||||
Card 42: 22 15 3 33 62 13 67 18 24 72 | 50 4 86 74 15 38 47 42 89 9 30 87 2 20 33 17 78 45 48 81 62 51 71 35 96
|
||||
Card 43: 39 42 48 11 23 59 25 54 40 88 | 7 73 32 8 1 60 4 13 14 70 79 3 98 68 76 43 47 6 56 85 92 94 74 62 90
|
||||
Card 44: 30 16 41 34 89 13 1 53 3 59 | 64 50 55 74 67 78 89 86 63 85 26 28 34 69 59 31 44 56 37 39 20 15 17 71 93
|
||||
Card 45: 13 57 96 32 69 88 75 15 40 47 | 40 61 32 70 95 29 28 75 87 37 69 57 72 63 15 30 21 38 13 47 20 96 56 76 88
|
||||
Card 46: 71 28 77 18 39 16 25 1 95 66 | 50 30 39 62 54 25 22 16 24 32 40 41 95 11 64 38 77 14 34 90 86 48 1 4 79
|
||||
Card 47: 32 31 18 26 43 33 46 39 60 29 | 85 51 41 74 77 14 72 89 65 60 11 92 33 39 18 15 32 95 42 46 94 38 90 68 53
|
||||
Card 48: 13 47 30 5 40 66 64 51 60 83 | 13 30 84 83 43 40 46 5 98 47 91 86 4 66 23 96 10 92 51 60 93 64 36 71 53
|
||||
Card 49: 72 99 94 27 31 49 75 36 66 82 | 95 4 14 11 36 89 19 45 50 84 24 72 99 90 82 71 56 16 20 58 39 83 75 49 22
|
||||
Card 50: 25 81 56 1 64 50 80 79 87 23 | 98 19 25 22 50 24 74 29 51 1 54 39 80 28 23 87 75 56 93 89 55 71 3 65 79
|
||||
Card 51: 81 10 35 77 13 47 90 24 79 97 | 14 32 77 85 58 17 30 89 8 51 13 76 80 94 79 56 65 43 11 5 19 47 70 90 81
|
||||
Card 52: 14 34 90 39 44 26 95 17 19 20 | 80 78 93 16 67 15 68 36 98 1 35 45 10 86 65 61 47 26 82 9 69 83 81 23 48
|
||||
Card 53: 55 75 8 44 62 30 19 97 65 12 | 77 96 15 42 86 84 70 24 68 11 97 69 16 56 66 13 73 74 46 67 2 88 63 50 98
|
||||
Card 54: 2 69 28 76 77 6 86 74 32 38 | 83 96 73 79 71 8 4 46 63 49 65 16 84 75 26 50 61 37 17 39 36 47 58 14 91
|
||||
Card 55: 41 89 46 60 37 82 69 52 35 72 | 16 56 63 34 45 59 37 1 29 46 51 75 99 90 76 7 60 57 5 98 62 20 93 50 44
|
||||
Card 56: 27 11 5 14 81 18 33 36 96 69 | 67 61 6 28 77 63 74 44 60 29 54 93 94 40 83 20 97 66 52 87 2 79 32 1 70
|
||||
Card 57: 30 91 94 56 18 73 32 88 51 84 | 62 45 54 7 53 96 29 43 3 81 91 80 24 14 46 65 89 4 92 50 71 35 49 47 86
|
||||
Card 58: 47 55 32 62 21 25 69 60 14 41 | 98 87 10 84 89 4 28 96 72 35 66 31 95 91 76 3 52 45 81 24 97 8 1 27 67
|
||||
Card 59: 34 10 7 40 92 72 4 44 98 23 | 50 92 98 10 4 17 34 44 65 74 21 64 6 23 40 72 79 86 59 27 7 91 47 63 16
|
||||
Card 60: 75 7 58 65 17 14 50 8 69 20 | 96 25 69 20 75 50 7 8 64 31 14 17 24 65 93 19 40 62 53 90 34 58 74 85 51
|
||||
Card 61: 40 93 9 39 71 44 36 80 87 90 | 87 27 25 39 26 36 97 82 79 93 44 15 31 20 2 61 90 55 40 74 1 80 7 95 49
|
||||
Card 62: 78 91 53 31 29 93 98 99 46 43 | 59 53 28 70 31 37 99 1 82 46 44 60 17 61 43 29 98 93 91 8 42 6 78 32 23
|
||||
Card 63: 36 20 89 67 86 17 50 29 49 12 | 43 99 83 28 29 94 50 76 82 51 40 47 97 30 20 78 49 72 6 57 46 67 75 68 86
|
||||
Card 64: 69 24 34 10 2 14 86 38 76 5 | 70 38 34 99 64 10 75 82 58 72 5 2 83 76 9 15 42 81 86 24 59 74 18 69 14
|
||||
Card 65: 33 69 2 45 25 40 35 48 83 53 | 64 40 33 48 63 96 2 22 53 97 43 69 83 79 20 5 35 9 25 29 74 47 72 99 45
|
||||
Card 66: 93 1 92 57 71 23 85 51 13 88 | 10 27 92 6 65 28 33 67 53 58 38 13 40 69 90 97 24 50 36 85 54 91 94 30 21
|
||||
Card 67: 82 25 87 96 97 55 35 90 68 93 | 40 74 21 45 59 82 16 67 79 36 32 28 12 73 81 60 84 54 77 29 7 58 86 34 3
|
||||
Card 68: 13 22 75 87 19 67 29 51 80 17 | 91 87 16 98 52 24 43 34 19 80 23 21 99 44 27 13 60 42 17 79 67 14 1 31 3
|
||||
Card 69: 50 35 32 17 92 40 88 41 91 77 | 71 17 41 23 26 5 92 29 55 91 40 83 88 65 51 9 50 53 77 46 54 35 62 32 52
|
||||
Card 70: 56 61 5 90 8 15 6 46 10 98 | 10 55 82 56 30 72 78 13 91 95 49 6 93 27 74 85 64 62 70 8 9 54 57 45 90
|
||||
Card 71: 76 2 26 66 56 41 72 70 61 94 | 88 32 97 68 83 37 76 41 36 86 3 84 44 9 24 69 5 95 7 50 35 1 27 77 46
|
||||
Card 72: 82 38 71 98 60 55 29 73 4 1 | 83 92 69 85 64 97 35 33 20 87 81 71 57 75 66 82 29 19 63 36 23 58 60 93 72
|
||||
Card 73: 74 70 33 43 58 5 47 18 98 59 | 77 81 75 64 69 92 20 2 1 28 40 32 7 12 57 31 68 36 45 46 61 97 39 66 63
|
||||
Card 74: 85 6 64 88 46 86 4 25 12 17 | 11 49 38 40 36 46 23 62 84 48 12 60 76 75 9 10 90 35 26 37 69 89 4 17 43
|
||||
Card 75: 71 52 55 35 87 86 60 27 32 89 | 35 30 73 10 89 98 4 69 22 9 23 17 71 53 87 83 48 86 74 40 21 62 63 85 50
|
||||
Card 76: 75 66 33 41 3 25 99 98 37 91 | 35 38 12 11 46 40 20 15 94 61 47 79 10 83 24 50 51 2 48 26 63 13 72 4 88
|
||||
Card 77: 78 8 62 30 92 18 76 36 84 91 | 4 26 82 15 92 94 13 48 33 49 46 60 74 58 81 67 10 2 9 23 70 6 57 53 79
|
||||
Card 78: 56 55 32 44 13 84 95 85 20 92 | 7 17 87 86 16 60 70 65 74 12 4 18 95 8 19 54 15 6 94 84 82 58 59 28 99
|
||||
Card 79: 16 14 42 27 10 49 89 65 91 76 | 68 70 1 61 81 71 32 40 51 41 36 31 45 33 18 94 17 2 60 76 74 6 62 79 11
|
||||
Card 80: 56 78 20 15 58 30 49 75 79 66 | 12 52 96 14 80 34 61 7 40 9 17 47 97 6 2 93 39 3 76 42 43 71 33 67 54
|
||||
Card 81: 75 44 15 74 17 25 51 28 96 67 | 45 69 89 75 8 67 71 70 46 40 15 96 87 20 28 17 21 42 85 68 44 18 74 59 51
|
||||
Card 82: 74 29 44 13 94 22 40 80 36 27 | 55 51 74 40 77 36 49 87 43 13 46 62 23 38 90 30 39 57 70 1 80 22 91 32 89
|
||||
Card 83: 87 21 17 14 49 92 19 1 77 36 | 67 36 31 74 87 13 1 21 35 97 99 52 19 92 9 77 51 49 89 72 14 26 56 17 90
|
||||
Card 84: 2 60 7 46 57 31 68 83 25 5 | 42 72 20 38 88 35 73 98 92 89 41 90 65 81 96 21 50 62 87 36 43 33 8 66 55
|
||||
Card 85: 38 43 61 78 57 48 82 80 3 26 | 25 17 61 94 50 69 5 26 39 85 76 58 80 8 33 11 55 38 79 60 82 93 84 20 86
|
||||
Card 86: 17 36 14 77 98 99 33 38 34 4 | 17 97 98 30 38 65 16 43 28 85 77 36 83 88 29 18 60 26 14 33 80 78 99 34 4
|
||||
Card 87: 42 52 68 76 78 48 36 50 65 44 | 21 23 42 68 13 43 63 36 33 67 8 66 70 90 48 1 65 50 34 7 69 82 76 78 44
|
||||
Card 88: 68 67 15 30 92 38 96 63 75 44 | 59 30 83 6 48 42 35 28 46 34 92 44 49 78 43 27 47 75 15 33 62 37 3 68 60
|
||||
Card 89: 12 46 88 26 86 43 52 83 29 92 | 4 29 60 78 25 43 15 74 73 99 83 86 59 27 96 44 38 48 6 37 52 85 42 41 46
|
||||
Card 90: 95 71 59 29 13 83 90 57 7 94 | 71 19 43 13 68 84 51 29 16 31 45 94 57 92 7 90 20 55 98 36 64 83 59 10 95
|
||||
Card 91: 16 74 55 79 95 25 84 61 67 14 | 67 44 80 79 62 81 25 84 61 35 72 78 10 93 14 95 16 45 85 66 74 47 8 29 53
|
||||
Card 92: 41 74 92 35 88 76 9 79 71 53 | 51 88 44 71 81 49 36 97 35 46 33 62 18 9 85 98 79 76 53 47 41 89 92 63 94
|
||||
Card 93: 71 11 27 69 65 21 23 25 40 81 | 90 96 34 21 11 55 20 76 44 49 60 75 71 98 27 40 58 63 43 81 18 59 33 88 47
|
||||
Card 94: 4 39 9 70 63 75 14 99 29 25 | 99 77 91 19 30 94 25 26 1 80 73 32 48 10 61 4 7 31 75 39 70 36 63 51 57
|
||||
Card 95: 30 24 19 73 42 89 47 66 61 13 | 30 86 52 37 61 25 65 33 32 41 44 92 10 95 59 34 93 39 43 14 73 74 82 13 94
|
||||
Card 96: 51 3 7 37 96 54 9 83 69 95 | 95 61 28 83 69 22 31 54 51 50 25 29 89 27 4 14 49 3 53 6 59 7 21 30 79
|
||||
Card 97: 67 5 91 27 33 4 99 15 19 85 | 33 84 51 65 15 67 93 47 94 35 80 11 45 86 69 82 55 85 63 12 29 68 76 61 41
|
||||
Card 98: 60 64 34 61 95 94 36 2 11 75 | 71 60 39 12 11 51 7 88 64 54 5 90 84 50 26 22 42 36 92 53 67 28 76 58 38
|
||||
Card 99: 40 77 57 46 19 55 28 31 11 70 | 62 12 45 46 49 32 94 93 13 7 29 66 70 99 37 63 30 52 4 84 54 36 2 11 33
|
||||
Card 100: 15 18 10 32 26 89 17 78 85 64 | 14 54 15 11 75 45 91 83 88 86 60 62 92 8 29 19 58 79 59 31 93 66 55 46 13
|
||||
Card 101: 15 44 6 92 88 7 24 20 28 83 | 12 41 95 92 61 16 84 29 31 89 85 97 79 63 54 78 60 27 11 64 72 23 94 52 14
|
||||
Card 102: 87 56 58 2 25 57 85 83 95 24 | 51 42 58 71 44 62 19 43 27 45 9 13 59 28 93 99 8 31 38 65 32 54 48 97 90
|
||||
Card 103: 32 37 48 65 94 71 83 31 24 80 | 47 76 28 74 99 46 91 78 21 34 40 20 11 35 88 14 16 55 87 97 52 36 56 90 81
|
||||
Card 104: 5 35 42 73 55 13 59 81 33 9 | 50 12 81 85 35 82 62 13 73 58 93 59 9 80 68 4 18 7 86 5 33 16 55 65 42
|
||||
Card 105: 44 69 1 73 91 24 94 64 31 77 | 34 77 39 94 41 9 69 52 95 17 31 74 98 73 42 44 67 1 36 50 21 91 35 64 24
|
||||
Card 106: 49 69 38 10 46 92 35 50 15 93 | 89 69 27 24 10 46 35 32 15 81 38 67 49 58 91 29 93 92 57 70 68 82 50 86 90
|
||||
Card 107: 92 57 65 15 23 45 96 56 88 25 | 92 25 15 31 57 56 64 41 87 30 23 78 38 45 28 10 65 71 96 88 27 3 69 91 73
|
||||
Card 108: 31 1 94 61 10 45 34 11 41 66 | 2 66 38 78 57 88 19 46 35 23 36 59 34 61 10 96 41 45 81 1 94 63 28 12 76
|
||||
Card 109: 16 72 48 78 77 27 12 36 7 42 | 22 99 23 36 13 53 2 25 72 1 47 48 14 49 69 3 93 44 78 87 38 55 60 52 90
|
||||
Card 110: 6 80 47 92 32 83 37 53 4 87 | 92 6 41 4 20 91 81 83 40 70 7 87 19 73 63 37 18 47 99 53 80 32 66 45 39
|
||||
Card 111: 9 72 17 89 28 68 34 63 76 81 | 80 70 22 36 23 61 59 7 53 43 45 67 3 60 6 89 79 95 56 85 31 98 65 39 48
|
||||
Card 112: 10 23 9 78 98 3 27 6 84 60 | 16 68 84 10 22 50 87 9 5 23 27 74 21 98 3 2 60 85 73 1 26 83 6 89 78
|
||||
Card 113: 14 90 59 66 86 7 44 10 40 69 | 91 87 14 59 29 40 56 45 11 66 15 90 48 24 62 69 44 79 20 98 76 10 86 7 43
|
||||
Card 114: 31 90 75 12 34 60 39 74 24 2 | 56 52 85 40 1 14 80 60 42 84 75 18 6 90 76 25 44 74 28 34 13 12 54 48 7
|
||||
Card 115: 67 42 11 91 53 57 98 17 95 50 | 74 45 25 98 57 66 67 77 69 95 87 79 83 39 96 84 42 91 21 3 53 17 63 50 11
|
||||
Card 116: 66 36 5 11 33 51 30 67 38 3 | 50 86 36 76 33 77 30 51 11 67 38 26 43 66 39 69 17 90 21 3 16 56 62 5 73
|
||||
Card 117: 53 34 69 9 10 61 18 23 93 14 | 44 9 69 2 90 14 53 23 21 92 49 72 31 61 46 10 27 70 57 38 18 93 34 67 11
|
||||
Card 118: 83 89 94 55 65 36 20 79 53 14 | 36 65 41 8 49 29 99 83 94 5 62 78 53 20 68 66 14 89 4 74 48 81 77 52 55
|
||||
Card 119: 82 69 85 60 9 13 16 3 18 44 | 82 55 85 3 5 80 43 11 13 86 16 31 56 70 17 46 79 69 60 44 95 81 45 49 93
|
||||
Card 120: 35 53 9 78 73 55 20 64 13 62 | 9 20 3 84 35 71 22 86 8 64 58 82 88 51 54 13 38 68 5 77 81 56 21 74 55
|
||||
Card 121: 61 34 85 77 66 87 91 49 15 36 | 59 49 46 70 10 94 93 87 36 3 44 66 24 61 95 83 91 75 89 60 81 57 41 85 74
|
||||
Card 122: 22 90 71 49 34 4 56 74 42 3 | 21 52 19 53 79 34 56 71 95 5 91 14 4 40 78 96 61 42 57 47 73 50 10 74 87
|
||||
Card 123: 87 49 40 25 31 4 20 48 1 76 | 12 6 43 69 48 2 9 24 95 65 47 57 4 91 94 39 16 62 68 8 23 42 38 59 78
|
||||
Card 124: 63 38 94 44 69 76 33 89 47 32 | 8 19 96 98 68 24 54 31 28 67 57 73 45 70 64 22 65 50 34 80 6 4 10 78 90
|
||||
Card 125: 4 48 65 10 93 80 26 23 90 12 | 64 32 40 87 58 3 13 18 86 60 66 71 74 9 61 43 50 99 88 52 95 46 37 22 67
|
||||
Card 126: 90 71 53 57 5 24 6 3 52 8 | 96 33 13 70 44 27 87 89 81 63 65 8 66 47 31 92 40 53 7 88 99 19 64 38 79
|
||||
Card 127: 89 68 48 98 32 22 73 79 53 93 | 75 30 35 15 96 64 19 4 14 66 88 85 33 11 43 82 25 1 61 91 94 45 6 78 77
|
||||
Card 128: 15 39 76 95 5 70 9 23 4 65 | 64 58 90 54 46 42 68 29 11 38 20 92 87 44 98 83 99 27 67 22 13 6 14 43 55
|
||||
Card 129: 45 83 47 63 64 38 15 95 6 48 | 49 91 6 20 64 56 52 28 55 5 15 54 61 11 71 95 53 57 8 75 27 98 92 13 81
|
||||
Card 130: 37 14 56 22 7 1 9 76 83 91 | 56 53 1 36 74 37 9 73 70 91 22 77 83 44 68 97 54 39 76 7 65 55 14 34 38
|
||||
Card 131: 23 92 82 24 86 78 31 98 68 48 | 83 29 28 54 65 47 92 67 94 48 89 49 24 4 59 40 41 82 86 64 38 98 78 66 68
|
||||
Card 132: 9 63 36 66 29 97 90 20 81 46 | 10 40 43 82 4 9 37 87 3 27 28 54 65 5 50 80 8 31 73 26 88 96 74 23 57
|
||||
Card 133: 17 48 12 31 13 44 57 45 40 88 | 56 80 55 26 8 16 22 70 13 45 78 7 4 40 10 71 34 32 59 35 69 82 47 88 46
|
||||
Card 134: 91 87 65 7 49 67 17 60 9 78 | 50 35 40 25 74 62 29 80 21 93 92 52 39 81 51 8 47 65 4 89 83 6 88 87 43
|
||||
Card 135: 35 87 16 9 34 80 15 81 83 61 | 46 40 8 93 89 67 86 35 71 9 76 95 49 26 22 28 87 90 64 34 79 27 32 59 23
|
||||
Card 136: 23 1 83 65 67 46 40 97 71 55 | 86 8 79 95 2 59 20 60 31 11 42 97 62 12 67 80 19 55 81 33 13 87 57 9 23
|
||||
Card 137: 23 99 91 8 79 45 29 3 42 27 | 85 45 65 82 36 76 29 48 8 78 54 79 57 34 70 52 3 96 19 86 12 91 51 59 66
|
||||
Card 138: 47 48 85 73 89 61 98 39 36 2 | 83 50 1 63 71 30 76 11 93 82 60 4 78 56 66 25 75 33 51 57 28 24 67 74 58
|
||||
Card 139: 40 41 96 36 71 97 74 78 9 83 | 41 73 51 70 76 22 23 63 56 58 26 91 47 37 88 80 18 67 95 33 11 60 34 7 94
|
||||
Card 140: 98 32 46 64 18 95 27 65 74 41 | 89 20 42 40 58 84 48 76 67 12 73 44 23 92 90 70 81 71 85 11 83 59 78 22 9
|
||||
Card 141: 34 18 67 74 52 35 31 27 14 54 | 92 44 48 73 14 51 98 54 88 5 70 65 80 66 84 56 7 40 39 71 94 86 26 25 11
|
||||
Card 142: 57 53 93 13 4 96 83 23 74 90 | 82 43 42 40 38 87 81 58 44 71 59 50 7 9 30 98 66 80 85 29 1 84 20 26 72
|
||||
Card 143: 47 3 32 53 72 82 44 64 85 24 | 2 71 98 94 62 23 87 68 93 86 70 96 19 84 74 15 95 42 29 90 6 54 67 30 61
|
||||
Card 144: 74 46 9 94 60 86 56 40 34 57 | 66 55 16 95 5 25 75 90 47 76 54 93 61 23 37 89 64 48 42 30 18 31 3 97 27
|
||||
Card 145: 57 25 17 78 1 63 31 3 65 23 | 39 95 13 65 3 27 17 85 56 47 10 8 63 51 23 25 40 22 54 78 81 62 90 4 50
|
||||
Card 146: 54 71 5 68 25 76 33 31 32 64 | 99 75 87 61 32 91 47 71 11 51 43 36 33 83 3 63 35 42 16 31 81 28 86 22 90
|
||||
Card 147: 22 98 86 67 26 72 31 52 93 20 | 87 42 20 49 43 35 27 52 56 86 40 22 29 59 76 26 9 93 30 58 67 31 72 33 98
|
||||
Card 148: 47 81 86 1 87 63 16 58 98 26 | 34 15 7 39 47 86 21 14 81 49 87 43 91 24 73 63 18 98 37 29 77 53 67 26 19
|
||||
Card 149: 24 21 62 66 80 31 50 23 13 54 | 47 6 13 90 54 49 66 74 62 34 4 95 23 55 50 45 18 59 61 21 26 75 39 80 24
|
||||
Card 150: 14 97 9 69 44 64 63 22 8 89 | 71 65 32 59 28 43 97 48 6 70 45 75 63 99 60 39 20 78 95 47 55 1 74 58 13
|
||||
Card 151: 93 73 94 83 23 50 68 40 18 13 | 76 70 83 7 4 23 82 29 78 40 93 77 66 94 92 68 18 2 15 49 17 39 37 35 64
|
||||
Card 152: 73 6 44 81 1 39 61 34 7 23 | 32 81 85 42 23 40 97 74 55 46 39 2 79 86 91 3 37 33 76 58 77 88 75 12 53
|
||||
Card 153: 15 19 22 66 3 50 77 97 21 62 | 66 59 27 78 6 28 54 13 32 70 23 51 48 50 17 43 42 21 22 34 16 64 3 37 74
|
||||
Card 154: 10 17 93 15 92 4 22 2 44 88 | 60 69 90 85 19 13 88 11 84 39 68 33 14 27 95 2 53 87 66 82 74 36 41 42 46
|
||||
Card 155: 74 88 14 39 78 54 60 75 11 65 | 64 14 66 16 18 81 20 36 3 82 8 62 34 87 43 53 80 96 59 39 78 5 40 13 21
|
||||
Card 156: 25 5 87 20 51 57 61 39 16 83 | 37 63 60 79 83 52 81 99 92 26 70 76 56 8 73 98 5 48 1 46 16 86 28 12 78
|
||||
Card 157: 45 7 33 97 91 59 10 77 2 82 | 98 10 1 28 4 37 69 92 99 58 40 42 34 38 26 81 3 18 84 45 31 20 55 36 44
|
||||
Card 158: 98 33 35 10 56 43 60 68 25 62 | 61 89 80 40 2 26 3 13 57 10 96 71 86 27 78 87 59 37 45 75 79 46 49 36 66
|
||||
Card 159: 12 31 72 74 90 88 58 73 25 9 | 51 71 23 44 5 34 82 33 55 49 68 39 20 93 13 97 81 14 2 91 76 75 50 95 7
|
||||
Card 160: 38 23 46 5 85 22 26 81 91 93 | 85 38 22 58 19 3 89 35 84 46 18 53 95 91 47 93 99 33 81 68 57 49 80 71 23
|
||||
Card 161: 57 14 48 68 72 81 93 61 43 40 | 6 5 47 59 11 81 13 38 52 26 91 22 57 55 35 19 61 2 29 93 14 74 53 45 60
|
||||
Card 162: 20 52 9 61 26 94 11 84 28 37 | 39 9 88 48 73 14 24 29 28 37 31 27 95 79 98 26 45 11 96 68 47 58 35 62 52
|
||||
Card 163: 11 42 60 15 27 43 13 17 72 98 | 12 74 81 37 95 20 86 42 72 79 66 89 62 63 38 73 65 82 8 28 50 70 78 15 94
|
||||
Card 164: 88 38 30 3 48 17 19 68 73 2 | 13 71 34 83 40 38 59 12 73 2 91 52 60 19 87 84 1 82 65 3 8 99 80 79 70
|
||||
Card 165: 22 62 51 13 76 17 26 41 46 34 | 93 50 94 18 84 39 48 75 59 3 44 67 37 32 55 82 79 14 7 86 61 27 31 74 42
|
||||
Card 166: 27 80 73 77 72 18 83 97 53 3 | 6 74 34 22 75 60 99 17 47 12 29 64 48 67 15 14 63 13 19 49 5 89 42 9 11
|
||||
Card 167: 14 31 99 33 53 52 98 95 49 73 | 95 92 60 18 19 39 90 31 10 58 7 6 59 51 73 22 45 49 4 21 67 76 78 56 20
|
||||
Card 168: 11 78 93 57 58 47 40 22 23 85 | 6 27 66 43 57 2 90 49 25 60 99 19 36 22 47 80 1 32 21 87 98 58 93 9 76
|
||||
Card 169: 99 40 75 47 22 83 41 50 18 51 | 94 74 86 14 12 5 78 61 89 17 8 83 30 90 51 87 53 43 41 27 13 92 26 49 76
|
||||
Card 170: 23 16 36 32 91 52 73 53 18 83 | 90 76 24 97 95 62 39 70 3 52 63 30 19 75 96 82 9 71 81 64 22 84 99 35 21
|
||||
Card 171: 38 27 53 94 16 71 18 6 83 17 | 76 3 78 23 31 19 50 22 57 97 39 35 56 51 83 94 55 85 1 5 12 43 86 58 46
|
||||
Card 172: 45 79 25 86 56 50 20 18 97 52 | 40 85 90 28 97 43 4 3 22 76 21 61 16 62 95 29 83 44 15 12 56 34 53 36 93
|
||||
Card 173: 1 79 49 77 62 33 84 76 7 50 | 29 6 42 56 67 47 94 25 97 48 86 43 3 18 51 21 93 16 95 14 15 82 71 87 75
|
||||
Card 174: 83 64 11 39 24 97 35 54 27 60 | 22 16 31 92 42 94 72 62 58 5 69 8 28 33 89 47 23 52 90 57 68 80 9 96 7
|
||||
Card 175: 87 10 42 65 40 51 31 45 48 89 | 75 37 60 71 76 92 10 29 14 63 81 34 94 88 32 91 6 82 79 90 53 89 68 49 26
|
||||
Card 176: 96 83 15 50 17 16 81 85 11 35 | 31 17 8 30 33 47 11 15 41 73 99 40 70 48 91 26 96 60 39 95 52 59 45 23 50
|
||||
Card 177: 64 51 20 97 68 69 57 58 34 12 | 54 82 32 79 89 70 47 52 16 36 83 10 49 8 18 94 73 77 48 42 19 98 55 75 80
|
||||
Card 178: 36 1 53 62 73 77 52 59 51 3 | 59 35 68 1 45 77 4 79 83 16 36 63 99 53 52 3 73 51 13 89 84 32 64 33 62
|
||||
Card 179: 30 70 61 7 29 52 97 81 65 59 | 48 5 42 71 88 89 93 64 37 28 26 25 90 94 92 21 50 6 19 33 68 66 78 1 15
|
||||
Card 180: 66 3 33 16 57 41 91 83 48 68 | 58 68 33 80 42 13 69 78 16 83 18 41 34 35 79 48 66 62 86 90 2 6 96 57 91
|
||||
Card 181: 86 94 43 29 75 78 42 95 13 10 | 42 88 43 13 60 52 47 86 87 59 95 72 8 23 82 2 69 61 14 71 94 90 30 85 51
|
||||
Card 182: 73 90 84 14 52 15 98 43 3 23 | 84 8 11 64 83 62 77 18 53 81 19 47 1 79 99 41 40 74 93 89 20 72 49 26 38
|
||||
Card 183: 24 78 51 40 92 66 77 39 97 68 | 38 70 63 5 19 21 95 73 64 14 55 80 23 22 77 65 74 97 37 26 82 83 9 52 60
|
||||
Card 184: 98 12 62 53 69 27 84 64 91 94 | 19 9 90 98 43 26 7 12 68 16 10 45 20 23 4 63 3 38 77 6 27 8 91 70 60
|
||||
Card 185: 32 37 2 76 75 62 39 33 12 13 | 11 29 49 77 50 97 65 87 25 91 10 21 15 82 95 99 80 71 54 42 48 78 72 63 34
|
||||
Card 186: 55 49 21 41 83 40 29 51 54 57 | 20 88 52 62 85 90 25 45 54 58 72 91 98 14 13 28 74 92 31 8 42 3 26 11 59
|
||||
Card 187: 95 43 56 46 98 96 55 31 28 50 | 23 5 13 35 95 37 1 89 76 45 68 73 52 15 26 3 38 36 99 51 80 8 63 77 28
|
||||
Card 188: 84 71 30 79 6 13 57 3 63 55 | 46 45 43 26 48 47 37 35 88 13 59 9 95 86 49 98 64 62 54 44 22 92 25 3 15
|
||||
Card 189: 56 94 93 30 27 53 85 58 4 91 | 86 70 1 96 60 92 66 33 9 50 78 41 67 55 7 28 89 31 14 19 76 42 71 82 63
|
||||
Card 190: 17 27 42 70 11 38 47 58 92 88 | 73 15 86 13 25 64 58 4 61 95 36 41 94 17 72 90 22 6 56 98 35 45 60 19 33
|
||||
Card 191: 19 96 44 57 88 39 7 67 85 89 | 49 31 15 98 77 14 43 59 85 2 79 71 69 81 95 93 33 66 25 87 65 13 62 46 91
|
||||
Card 192: 29 77 54 66 79 7 88 72 99 35 | 50 94 48 18 60 56 74 59 97 5 87 8 70 93 81 27 14 57 25 22 71 63 83 44 15
|
||||
37
src/advent_of_code/2024/1.hs
Normal file
37
src/advent_of_code/2024/1.hs
Normal file
@@ -0,0 +1,37 @@
|
||||
-- https://adventofcode.com/2024/day/1
|
||||
|
||||
import Data.List (elemIndices, sort)
|
||||
import GHC.IO (unsafePerformIO)
|
||||
|
||||
input :: FilePath
|
||||
input = "src/advent_of_code/2024/1.input"
|
||||
|
||||
-- entries :: ([Int], [Int])
|
||||
-- entries = unzip $ map parse' $ unsafePerformIO $ lines <$> readFile input
|
||||
entries = unsafePerformIO $ lines <$> readFile input
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
entries <- lines <$> readFile input
|
||||
print "Advent of Code 2024 - Day 1"
|
||||
|
||||
print $ "Part 1: " <> show (solveP1 $ unzip $ map parse' entries)
|
||||
print $ "Part 2: " <> show (solveP2 $ unzip $ map parse' entries)
|
||||
|
||||
parse' :: String -> (Int, Int)
|
||||
parse' str = (read l, read r)
|
||||
where
|
||||
[l, r] = words str
|
||||
|
||||
solveP1 :: ([Int], [Int]) -> Int
|
||||
solveP1 (as, bs) = sum $ map abs $ zipWith subtract as' bs'
|
||||
where
|
||||
as' = sort as
|
||||
bs' = sort bs
|
||||
|
||||
solveP2 :: ([Int], [Int]) -> Int
|
||||
solveP2 (as, bs) = sum $ zipWith (*) as (map (f bs) as)
|
||||
where
|
||||
f :: [Int] -> Int -> Int
|
||||
f bs a = length $ elemIndices a bs
|
||||
|
||||
1000
src/advent_of_code/2024/1.input
Normal file
1000
src/advent_of_code/2024/1.input
Normal file
File diff suppressed because it is too large
Load Diff
6
src/advent_of_code/2024/1f.input
Normal file
6
src/advent_of_code/2024/1f.input
Normal file
@@ -0,0 +1,6 @@
|
||||
3 4
|
||||
4 3
|
||||
2 5
|
||||
1 3
|
||||
3 9
|
||||
3 3
|
||||
51
src/advent_of_code/2024/2.hs
Normal file
51
src/advent_of_code/2024/2.hs
Normal file
@@ -0,0 +1,51 @@
|
||||
-- https://adventofcode.com/2024/day/2
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
import Data.List (all, drop, elem, filter, length, map, or, sort,
|
||||
sortOn, tail, take, zipWith)
|
||||
import Data.Ord (Down (Down), Ord ((<=), (>=)))
|
||||
import Data.Text (Text, lines, pack, splitOn, unpack)
|
||||
import Data.Text.IO (readFile)
|
||||
import GHC.IO (unsafePerformIO)
|
||||
import Prelude hiding (lines, readFile)
|
||||
|
||||
entries :: [[Int]]
|
||||
entries = parse . unsafePerformIO $ lines <$> readFile "src/advent_of_code/2024/2.input"
|
||||
|
||||
entries' :: [[Int]]
|
||||
entries' = parse . unsafePerformIO $ lines <$> readFile "src/advent_of_code/2024/2f.input"
|
||||
|
||||
parse :: [Text] -> [[Int]]
|
||||
parse = map (map (read . unpack) . splitOn " ")
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
entries <- parse . lines <$> readFile "src/advent_of_code/2024/2.input"
|
||||
print "Advent of Code 2024 - Day 2"
|
||||
|
||||
print $ "Part 1: " <> show (solveP1 entries)
|
||||
print $ "Part 2: " <> show (solveP2 entries)
|
||||
|
||||
solveP1 :: [[Int]] -> Int
|
||||
solveP1 = length . filter (== True) . map safeReportP1
|
||||
|
||||
solveP2 :: [[Int]] -> Int
|
||||
solveP2 = length . filter (== True) . map safeReportP2
|
||||
|
||||
safeReportP1 :: [Int] -> Bool
|
||||
safeReportP1 report = isSorted report && adjacentLevelCheck report
|
||||
|
||||
isSorted :: [Int] -> Bool
|
||||
isSorted report = report `elem` [sort report, sortOn Down report]
|
||||
|
||||
adjacentLevelCheck :: [Int] -> Bool
|
||||
adjacentLevelCheck report =
|
||||
all (((== True) . (\n-> n>=1 && n<=3)) . abs)
|
||||
(zipWith subtract report (tail report))
|
||||
|
||||
safeReportP2 :: [Int] -> Bool
|
||||
safeReportP2 report = any safeReportP1 (removeOneBadReport report)
|
||||
|
||||
removeOneBadReport :: [Int] -> [[Int]]
|
||||
removeOneBadReport lst = map (\i -> take i lst <> drop (succ i) lst) [0..length lst-1]
|
||||
1000
src/advent_of_code/2024/2.input
Normal file
1000
src/advent_of_code/2024/2.input
Normal file
File diff suppressed because it is too large
Load Diff
6
src/advent_of_code/2024/2f.input
Normal file
6
src/advent_of_code/2024/2f.input
Normal file
@@ -0,0 +1,6 @@
|
||||
7 6 4 2 1
|
||||
1 2 7 8 9
|
||||
9 7 6 2 1
|
||||
1 3 2 4 5
|
||||
8 6 4 4 1
|
||||
1 3 6 7 9
|
||||
37
src/hackerRank/algorithms-magicSquare.hs
Normal file
37
src/hackerRank/algorithms-magicSquare.hs
Normal file
@@ -0,0 +1,37 @@
|
||||
-- https://www.hackerrank.com/challenges/magic-square-forming/problem
|
||||
|
||||
module Main where
|
||||
import Data.List (transpose)
|
||||
|
||||
main :: IO ()
|
||||
main = print "test"
|
||||
|
||||
s :: [[Integer]]
|
||||
s =
|
||||
[ [5, 3, 4]
|
||||
, [1, 5, 8]
|
||||
, [6, 4, 2]
|
||||
]
|
||||
|
||||
-- isMagicSquare n s =
|
||||
-- all (sum rows == n) &&
|
||||
-- all (sum cols == n) &&
|
||||
-- all (sum diag == n)
|
||||
-- where
|
||||
-- rows =
|
||||
|
||||
get s (x,y) = s !! x !! y
|
||||
|
||||
allCoords n = [ (x,y) | x <- [0..n-1], y <- [0..n-1] ]
|
||||
|
||||
diagCoords n = [ (x,y) | x <- [0..n-1], y <- [0 ..n-1], x == y ] ++
|
||||
[ (x,y) | x <- [0..n-1], y <- [n-1, n-2.. 0], x + y == n-1 ]
|
||||
|
||||
rowSums :: [[Integer]] -> [Integer]
|
||||
rowSums = map sum
|
||||
|
||||
colSums :: [[Integer]] -> [Integer]
|
||||
colSums = map sum . transpose
|
||||
|
||||
diagSums :: [[Integer]] -> [Integer]
|
||||
diagSums n = map (\(x,y) -> get n (x,y)) (diagCoords 3)
|
||||
@@ -1,10 +1,31 @@
|
||||
/*
|
||||
Keys and Rooms
|
||||
|
||||
Instructions:
|
||||
There are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key.
|
||||
|
||||
When you visit a room, you may find a set of distinct keys in it. Each key has a number on it, denoting which room it unlocks, and you can take all of them with you to unlock the other rooms.
|
||||
|
||||
Given an array rooms where rooms[i] is the set of keys that you can obtain if you visited room i, return true if you can visit all the rooms, or false otherwise.
|
||||
|
||||
Constraints:
|
||||
n == rooms.length
|
||||
2 <= n <= 1000
|
||||
0 <= rooms[i].length <= 1000
|
||||
1 <= sum(rooms[i].length) <= 3000
|
||||
0 <= rooms[i][j] < n
|
||||
All the values of rooms[i] are unique.
|
||||
*/
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
res := canVisitAllRooms([][]int{{1, 3}, {3, 0, 1}, {2}, {0}})
|
||||
fmt.Printf("%+v\n", res)
|
||||
res := canVisitAllRooms([][]int{{1}, {2}, {3}, {}})
|
||||
fmt.Printf("Example 1 works: %+v\n\n", res)
|
||||
|
||||
res = canVisitAllRooms([][]int{{1, 3}, {3, 0, 1}, {2}, {0}})
|
||||
fmt.Printf("Example 2 works: %+v\n", res)
|
||||
}
|
||||
|
||||
func canVisitAllRooms(rooms [][]int) bool {
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
{-
|
||||
Keys and Rooms
|
||||
|
||||
Instructions:
|
||||
There are n rooms labelled from 0 to n - 1 and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key.
|
||||
|
||||
When you visit a room, you may find a set of distinct keys in it. Each key has a number on it, denoting which room it unlocks, and you can take all of them with you to unlock the other rooms.
|
||||
|
||||
Given an array rooms where rooms[i] is the set of keys that you can obtain if you visited room i, return true if you can visit all the rooms, or false otherwise.
|
||||
|
||||
Constraints:
|
||||
n == rooms.length
|
||||
2 <= n <= 1000
|
||||
0 <= rooms[i].length <= 1000
|
||||
1 <= sum(rooms[i].length) <= 3000
|
||||
0 <= rooms[i][j] < n
|
||||
All the values of rooms[i] are unique.
|
||||
-}
|
||||
module Main where
|
||||
|
||||
import Data.List (genericIndex, genericLength)
|
||||
|
||||
input1Rooms :: [[Integer]]
|
||||
input1Rooms = [[1],[2],[3],[]]
|
||||
|
||||
input2Rooms :: [[Integer]]
|
||||
input2Rooms = [[1,3],[3,0,1],[2],[0]]
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
print $ "Example 1 is: " <> show (canVisitAll input1Rooms)
|
||||
print $ "Example 2 is: " <> show (canVisitAll input2Rooms)
|
||||
|
||||
canVisitAll :: [[Integer]] -> Bool
|
||||
canVisitAll rooms = [0..l] == dfs rooms 0 []
|
||||
where
|
||||
l = l' rooms - 1
|
||||
|
||||
dfs :: [[Integer]] -> Integer -> [Integer] -> [Integer]
|
||||
dfs graph current visited =
|
||||
foldl (\visited next ->
|
||||
if next `elem` visited
|
||||
then visited
|
||||
else dfs graph next visited)
|
||||
(visited ++ [current])
|
||||
(graph !!! current)
|
||||
|
||||
l' :: [a] -> Integer
|
||||
l' = genericLength
|
||||
|
||||
(!!!) :: [a] -> Integer -> a
|
||||
(!!!) = genericIndex
|
||||
|
||||
@@ -5,30 +5,21 @@ The sum of these multiples is 23.
|
||||
|
||||
Find the sum of all the multiples of 3 or 5 below 1000.
|
||||
-}
|
||||
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
|
||||
{-# HLINT ignore "Use sum" #-}
|
||||
|
||||
module Main where
|
||||
|
||||
import Data.List (union)
|
||||
|
||||
main :: IO ()
|
||||
main = print ans
|
||||
|
||||
ans :: Integer
|
||||
ans = sum $ allNumbersUnder 1000
|
||||
ans = sum (_3s <> _5s)
|
||||
|
||||
sum' :: Num a => [a] -> a
|
||||
sum' = foldl (+) 0
|
||||
_3s :: [Integer]
|
||||
_3s = [3,6..999]
|
||||
|
||||
isMultipleOf :: Integral a => a -> a -> Bool
|
||||
isMultipleOf n x = x `rem` n == 0
|
||||
_5s :: [Integer]
|
||||
_5s = [5,10..999]
|
||||
|
||||
all3sUnder :: Integral a => a -> [a]
|
||||
all3sUnder n = filter (isMultipleOf 3) [1..n-1]
|
||||
all5sUnder :: Integral a => a -> [a]
|
||||
all5sUnder n = filter (isMultipleOf 5) [1..n-1]
|
||||
|
||||
allXsUnderN :: Integral a => a -> a -> [a]
|
||||
allXsUnderN x n = filter (isMultipleOf x) [1..n-1]
|
||||
|
||||
allNumbersUnder :: Integral a => a -> [a]
|
||||
allNumbersUnder l = allXsUnderN 3 l <> allXsUnderN 5 l
|
||||
solution :: Integer
|
||||
solution = sum $ union _3s _5s
|
||||
|
||||
24
src/projectEuler/question1.js
Normal file
24
src/projectEuler/question1.js
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
https://projecteuler.net/problem=1
|
||||
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
|
||||
The sum of these multiples is 23.
|
||||
|
||||
Find the sum of all the multiples of 3 or 5 below 1000.
|
||||
*/
|
||||
|
||||
var isMultipleOf = (m) => (n) => n % m === 0;
|
||||
var is3_ = isMultipleOf(3);
|
||||
var is5_ = isMultipleOf(5);
|
||||
|
||||
var is3 = (n) => n % 3 === 0;
|
||||
var is5 = (n) => n % 5 === 0;
|
||||
|
||||
var limit = 1000;
|
||||
let result = 0;
|
||||
for (let i = 0; i < limit; i++) {
|
||||
if (is3(i) || is5(i)) {
|
||||
result += i;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Answer is ${result}`);
|
||||
64
src/projectEuler/question19.hs
Normal file
64
src/projectEuler/question19.hs
Normal file
@@ -0,0 +1,64 @@
|
||||
{-
|
||||
https://projecteuler.net/problem=19
|
||||
|
||||
You are given the following information, but you may prefer to do some research for yourself.
|
||||
|
||||
- 1 Jan 1900 was a Monday.
|
||||
- Thirty days has September, April, June and November.
|
||||
- All the rest have thirty-one,
|
||||
- Saving February alone,
|
||||
- Which has twenty-eight, rain or shine.
|
||||
- And on leap years, twenty-nine.
|
||||
|
||||
A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400.
|
||||
|
||||
How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?
|
||||
-}
|
||||
|
||||
daysInMonth :: [Int]
|
||||
daysInMonth =
|
||||
[ 31 -- Jan
|
||||
, 28 -- Feb
|
||||
, 31 -- Mar
|
||||
, 30 -- Apr
|
||||
, 31 -- May
|
||||
, 30 -- Jun
|
||||
, 31 -- Jul
|
||||
, 31 -- Aug
|
||||
, 30 -- Sep
|
||||
, 31 -- Oct
|
||||
, 30 -- Nov
|
||||
, 31 -- Dec
|
||||
]
|
||||
|
||||
isLeapYear :: Int -> Bool
|
||||
isLeapYear yyyy
|
||||
| yyyy `isDivBy` 400 = True
|
||||
| yyyy `isDivBy` 100 = False
|
||||
| otherwise = yyyy `isDivBy` 4
|
||||
where
|
||||
isDivBy yyyy n = yyyy `rem` n == 0
|
||||
|
||||
daysOfWeek :: [Int]
|
||||
daysOfWeek = cycle
|
||||
[ 1 -- Sun
|
||||
, 0 -- Mon
|
||||
, 0 -- Tue
|
||||
, 0 -- Wed
|
||||
, 0 -- Thu
|
||||
, 0 -- Fri
|
||||
, 0 -- Sat
|
||||
]
|
||||
|
||||
daysInYear :: Int -> Int
|
||||
daysInYear yyyy =
|
||||
if isLeapYear yyyy
|
||||
then 366
|
||||
else 365
|
||||
|
||||
years :: [Int]
|
||||
years = [1901..2000]
|
||||
|
||||
ans :: Int
|
||||
ans = sum $ drop 2 $ take (sum $ map daysInYear years) daysOfWeek
|
||||
-- 5217
|
||||
28
src/python/2.py
Normal file
28
src/python/2.py
Normal file
@@ -0,0 +1,28 @@
|
||||
fibs2 = [1, 2, 3, 5, 8, 13]
|
||||
|
||||
i = 1
|
||||
j = 2
|
||||
b = 0
|
||||
n = 4000000
|
||||
fibs = []
|
||||
fibs.append(i)
|
||||
fibs.append(j)
|
||||
|
||||
while b < n:
|
||||
b = i + j
|
||||
if b < n:
|
||||
fibs.append(b)
|
||||
else:
|
||||
fibs
|
||||
i = j
|
||||
j = b
|
||||
|
||||
count = 0
|
||||
for fib in fibs:
|
||||
if (fib % 2) == 0:
|
||||
count += fib
|
||||
else:
|
||||
count += 0
|
||||
|
||||
print(count)
|
||||
|
||||
Reference in New Issue
Block a user