Showing preview only (646K chars total). Download the full file or copy to clipboard to get everything.
Repository: DestructHub/ProjectEuler
Branch: master
Commit: efba582f976c
Files: 534
Total size: 535.9 KB
Directory structure:
gitextract_2dk6ce_6/
├── .gitignore
├── .travis.yml
├── Dockerfile
├── LICENSE
├── Problem001/
│ ├── .hash
│ ├── Brain/
│ │ └── solution_1.brain
│ ├── C/
│ │ ├── Makefile
│ │ ├── solution_1.c
│ │ └── solution_2.c
│ ├── C++/
│ │ ├── Makefile
│ │ └── solution_1.cpp
│ ├── Clojure/
│ │ └── solution_1.clj
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── D/
│ │ └── solution_1.d
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Erlang/
│ │ └── solution_1.erl
│ ├── Go/
│ │ └── solution_1.go
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Java/
│ │ └── solution_1.java
│ ├── JavaScript/
│ │ ├── solution_1.js
│ │ └── solution_2.js
│ ├── Kotlin/
│ │ └── solution_1.kt
│ ├── Lua/
│ │ └── solution_1.lua
│ ├── OCaml/
│ │ └── solution_1.ml
│ ├── Objective-C/
│ │ └── solution_1.m
│ ├── PHP/
│ │ ├── solution_1.php
│ │ └── solution_2.php
│ ├── Python/
│ │ ├── solution_1.py
│ │ └── solution_2.py
│ ├── R/
│ │ └── solution_1.R
│ ├── README.md
│ ├── Racket/
│ │ └── solution_1.rkt
│ ├── Ruby/
│ │ └── solution_1.rb
│ ├── Rust/
│ │ └── solution_1.rs
│ ├── Scheme/
│ │ ├── solution_1.scm
│ │ └── solution_2.scm
│ ├── Shell/
│ │ └── solution_1.sh
│ └── Swift/
│ └── solution_1.swift
├── Problem002/
│ ├── .hash
│ ├── C/
│ │ ├── Makefile
│ │ └── solution_1.c
│ ├── C++/
│ │ ├── Makefile
│ │ └── solution_1.cpp
│ ├── Clojure/
│ │ ├── solution_1.clj
│ │ └── solution_2.clj
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── D/
│ │ └── solution_1.d
│ ├── Elixir/
│ │ └── solution_1.ex
│ ├── Go/
│ │ └── solution_1.go
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── JavaScript/
│ │ └── solution_1.js
│ ├── Lua/
│ │ └── solution_1.lua
│ ├── OCaml/
│ │ └── solution_1.ml
│ ├── PHP/
│ │ └── solution_1.php
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ ├── Ruby/
│ │ └── solution_1.rb
│ └── Scheme/
│ └── solution_1.scm
├── Problem003/
│ ├── .hash
│ ├── C++/
│ │ └── solution_1.cpp
│ ├── Clojure/
│ │ └── solution_1.clj
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Go/
│ │ └── solution_1.go
│ ├── Haskell/
│ │ ├── solution_1.hs
│ │ └── solution_2.hs
│ ├── JavaScript/
│ │ └── solution_1.js
│ ├── PHP/
│ │ └── solution_1.php
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ ├── Scheme/
│ │ └── solution_1.scm
│ └── Shell/
│ └── solution_1.sh
├── Problem004/
│ ├── .hash
│ ├── C/
│ │ └── solution_1.c
│ ├── Clojure/
│ │ └── solution_1.clj
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Go/
│ │ └── solution_1.go
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── JavaScript/
│ │ └── solution_1.js
│ ├── Lua/
│ │ └── solution_1.lua
│ ├── OCaml/
│ │ └── solution_1.ml
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── Ruby/
│ └── solution_01.rb
├── Problem005/
│ ├── .hash
│ ├── C/
│ │ └── solution_1.c
│ ├── C++/
│ │ └── solution_1.cpp
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Elixir/
│ │ ├── solution_1.exs
│ │ ├── solution_2.exs
│ │ └── solution_slow_1.exs
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── JavaScript/
│ │ └── solution_1.js
│ ├── Lua/
│ │ └── solution_1.lua
│ ├── OCaml/
│ │ └── solution_1.ml
│ ├── Python/
│ │ ├── solution_2.py
│ │ ├── solution_3.py
│ │ └── solution_slow_1.py
│ ├── README.md
│ ├── Scheme/
│ │ └── solution_1.scm
│ └── go/
│ └── solution_1.go
├── Problem006/
│ ├── .hash
│ ├── C++/
│ │ ├── Makefile
│ │ └── solution_1.cpp
│ ├── Clojure/
│ │ └── solution_1.clj
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── LaTeX/
│ │ └── solution_1.tex
│ ├── OCaml/
│ │ └── solution_1.ml
│ ├── Python/
│ │ ├── solution_1.py
│ │ └── solution_2.py
│ ├── README.md
│ ├── Ruby/
│ │ └── solution_1.rb
│ ├── Scheme/
│ │ └── solution_1.scm
│ └── go/
│ └── solution_1.go
├── Problem007/
│ ├── .hash
│ ├── C++/
│ │ ├── Makefile
│ │ └── solution_1.cpp
│ ├── Clojure/
│ │ ├── solution_1.clj
│ │ └── solution_2.clj
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Elixir/
│ │ ├── solution_2.exs
│ │ └── solution_slow_1.exs
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Lua/
│ │ └── solution_1.lua
│ ├── Python/
│ │ ├── primes.py
│ │ └── solution_1.py
│ ├── README.md
│ └── Scheme/
│ └── solution_1.scm
├── Problem008/
│ ├── .hash
│ ├── Clojure/
│ │ └── solution_slow_1.clj
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem009/
│ ├── .hash
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Python/
│ │ ├── solution_1.py
│ │ └── solution_2.py
│ ├── README.md
│ └── Ruby/
│ └── solution_1.rb
├── Problem010/
│ ├── .hash
│ ├── C++/
│ │ ├── Makefile
│ │ └── solution_1.cpp
│ ├── Clojure/
│ │ └── solution_1.clj
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Haskell/
│ │ ├── solution_slow_1.hs
│ │ └── solution_slow_2.hs
│ ├── Python/
│ │ ├── primes.py
│ │ └── solution_1.py
│ └── README.md
├── Problem011/
│ ├── .hash
│ ├── C++/
│ │ └── solution_1.cpp
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem012/
│ ├── .hash
│ ├── C++/
│ │ └── solution_1.cpp
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── JavaScript/
│ │ └── solution_1.js
│ ├── Python/
│ │ ├── solution_1.py
│ │ ├── solution_2.py
│ │ └── solution_3.py
│ └── README.md
├── Problem013/
│ ├── .hash
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Lua/
│ │ └── solution_1.lua
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── Ruby/
│ └── solution_1.rb
├── Problem014/
│ ├── .hash
│ ├── Clojure/
│ │ └── solution_1.clj
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Haskell/
│ │ └── solution_slow_1.hs
│ ├── Python/
│ │ └── solution_slow_1.py
│ └── README.md
├── Problem015/
│ ├── .hash
│ ├── C/
│ │ └── solution_1.c
│ ├── Clojure/
│ │ └── solution_1.clj
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Haskell/
│ │ ├── solution_1.hs
│ │ └── solution_2.hs
│ ├── Lua/
│ │ └── solution_1.lua
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── Ruby/
│ └── solution_1.rb
├── Problem016/
│ ├── .hash
│ ├── Clojure/
│ │ └── solution_1.clj
│ ├── CommonLisp/
│ │ ├── solution_1.lisp
│ │ └── solution_2.lisp
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Lua/
│ │ └── solution_1.lua
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── Ruby/
│ └── solution_1.rb
├── Problem017/
│ ├── .hash
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Python/
│ │ ├── p17_dic.json
│ │ └── solution_1.py
│ └── README.md
├── Problem018/
│ ├── .hash
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem019/
│ ├── .hash
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem020/
│ ├── .hash
│ ├── Clojure/
│ │ ├── solution_1.clj
│ │ └── solution_2.clj
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── JavaScript/
│ │ └── solution_1.js
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── Ruby/
│ └── solution_1.rb
├── Problem021/
│ ├── .hash
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Haskell/
│ │ └── solution_slow_1.hs
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem022/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── p022_names.txt
├── Problem023/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem024/
│ ├── .hash
│ ├── C++/
│ │ └── solution_1.cpp
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Python/
│ │ ├── solution_1.py
│ │ └── solution_2.py
│ ├── README.md
│ └── Ruby/
│ └── solution_1.rb
├── Problem025/
│ ├── .hash
│ ├── Clojure/
│ │ └── solution_1.clj
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem026/
│ ├── .hash
│ ├── C++/
│ │ ├── Makefile
│ │ └── solution_1.cpp
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem027/
│ ├── .hash
│ ├── C/
│ │ ├── Makefile
│ │ └── solution_1.c
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Go/
│ │ └── solution_1.go
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem028/
│ ├── .hash
│ ├── C/
│ │ └── solution_1.c
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem029/
│ ├── .hash
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem030/
│ ├── .hash
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── Ruby/
│ └── solution_1.rb
├── Problem031/
│ ├── .hash
│ ├── C/
│ │ ├── Makefile
│ │ └── solution_1.c
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Haskell/
│ │ └── solution_slow_1.hs
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem032/
│ ├── .hash
│ ├── Clojure/
│ │ └── solution_1.clj
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Lua/
│ │ └── solution_1.lua
│ └── README.md
├── Problem033/
│ ├── .hash
│ ├── Python/
│ │ ├── solution_1.py
│ │ └── solution_2.py
│ └── README.md
├── Problem034/
│ ├── .hash
│ ├── C/
│ │ └── solution_1.c
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Python/
│ │ ├── solution_2.py
│ │ └── solution_slow_1.py
│ ├── README.md
│ └── Ruby/
│ └── solution_1.rb
├── Problem035/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem036/
│ ├── .hash
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Go/
│ │ └── solution_1.go
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── Ruby/
│ └── solution_1.rb
├── Problem037/
│ ├── .hash
│ ├── C++/
│ │ └── solution_1.cpp
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem038/
│ ├── .hash
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── Swift/
│ └── solution_1.swift
├── Problem039/
│ ├── .hash
│ ├── C/
│ │ ├── Makefile
│ │ └── solution_1.c
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Elixir/
│ │ └── solution_1.exs
│ └── README.md
├── Problem040/
│ ├── .hash
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Python/
│ │ ├── solution_1.py
│ │ └── solution_2.py
│ └── README.md
├── Problem041/
│ ├── .hash
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Python/
│ │ └── solution_slow_1.py
│ ├── README.md
│ └── Swift/
│ └── solution_1.swift
├── Problem042/
│ ├── .hash
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Python/
│ │ ├── solution_1.py
│ │ └── solution_2.py
│ ├── README.md
│ └── p042_words.txt
├── Problem043/
│ ├── .hash
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Python/
│ │ └── solution_slow_1.py
│ ├── README.md
│ └── Swift/
│ └── solution_1.swift
├── Problem044/
│ ├── .hash
│ ├── Python/
│ │ ├── solution_1.py
│ │ └── solution_2.py
│ └── README.md
├── Problem045/
│ ├── .hash
│ ├── C/
│ │ ├── Makefile
│ │ └── solution_1.c
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Go/
│ │ └── solution_1.go
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ ├── Ruby/
│ │ └── solution_1.rb
│ └── Swift/
│ └── solution_1.swift
├── Problem046/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── Ruby/
│ └── solution_1.rb
├── Problem047/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── Swift/
│ └── solution_1.swift
├── Problem048/
│ ├── .hash
│ ├── C/
│ │ ├── Makefile
│ │ └── solution_1.c
│ ├── Clojure/
│ │ └── solution_1.clj
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Go/
│ │ └── solution_1.go
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── Ruby/
│ └── solution_1.rb
├── Problem049/
│ ├── .hash
│ ├── Python/
│ │ ├── solution_1.py
│ │ └── solution_2.py
│ └── README.md
├── Problem050/
│ ├── .hash
│ ├── Python/
│ │ └── solution_slow_1.py
│ └── README.md
├── Problem052/
│ ├── .hash
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── Ruby/
│ └── solution_1.rb
├── Problem053/
│ ├── .hash
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Python/
│ │ ├── solution_1.py
│ │ └── solution_2.py
│ └── README.md
├── Problem054/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── p054_poker.txt
├── Problem055/
│ ├── .hash
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem056/
│ ├── .hash
│ ├── Clojure/
│ │ └── solution_1.clj
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── Ruby/
│ └── solution_1.rb
├── Problem057/
│ ├── .hash
│ ├── Haskell/
│ │ └── solution_slow_1.hs
│ └── README.md
├── Problem058/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem059/
│ ├── .hash
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── README.md
│ └── p059_cipher.txt
├── Problem062/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem063/
│ ├── .hash
│ ├── C/
│ │ ├── Makefile
│ │ └── solution_1.c
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Go/
│ │ └── solution_1.go
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Python/
│ │ ├── solution_1.py
│ │ └── solution_2.py
│ └── README.md
├── Problem067/
│ ├── .hash
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── p067_triangle.txt
├── Problem069/
│ ├── .hash
│ ├── Python/
│ │ ├── solution_1.py
│ │ └── solution_2.py
│ └── README.md
├── Problem070/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem071/
│ ├── .hash
│ ├── README.md
│ └── Scheme/
│ └── solution_1.scm
├── Problem076/
│ ├── .hash
│ ├── Elixir/
│ │ └── solution_1.exs
│ └── README.md
├── Problem080/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem081/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── p081_matrix.txt
├── Problem085/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem087/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem089/
│ ├── .hash
│ ├── Elixir/
│ │ └── solution_1.exs
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── p089_romans.txt
├── Problem092/
│ ├── .hash
│ ├── Python/
│ │ ├── solution_slow_1.py
│ │ └── solution_slow_2.py
│ └── README.md
├── Problem097/
│ ├── .hash
│ ├── CommonLisp/
│ │ └── solution_1.lisp
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── Ruby/
│ └── solution_slow_1.rb
├── Problem099/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── p099_base_exp.txt
├── Problem102/
│ ├── .hash
│ ├── Haskell/
│ │ └── solution_1.hs
│ ├── README.md
│ └── p102_triangles.txt
├── Problem104/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem112/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem145/
│ ├── .hash
│ ├── Python/
│ │ └── solution_slow_1.py
│ └── README.md
├── Problem206/
│ ├── .hash
│ ├── Haskell/
│ │ └── solution_1.hs
│ └── README.md
├── Problem301/
│ ├── .hash
│ ├── Python/
│ │ └── solution_1.py
│ ├── README.md
│ └── Scheme/
│ ├── solution_1.scm
│ └── solution_2_slow.scm
├── Problem357/
│ ├── .hash
│ ├── Python/
│ │ └── solution_slow_1.py
│ └── README.md
├── Problem439/
│ ├── .hash
│ ├── Python/
│ │ └── solution_slow_1.py
│ └── README.md
├── Problem473/
│ ├── .hash
│ ├── Python/
│ │ ├── solution_slow_1.py
│ │ └── solution_slow_2.py
│ └── README.md
├── Problem500/
│ ├── .hash
│ ├── Bash/
│ │ └── solution_1.sh
│ ├── Python/
│ │ └── solution_1.py
│ └── README.md
├── Problem501/
│ ├── Python/
│ │ └── solution_slow_1.py
│ └── README.md
├── README.md
├── RULES.md
├── SOLVERS.md
├── STATUS.md
├── add
├── docker-compose.yml
├── requirements.txt
├── stats.exs
├── stats.py
└── test
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
## C and Cpp garbage ignore ##
# Object files
*.o
*.ko
*.obj
*.elf
*.slo
*.lo
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
*.lai
# Fortran module files
*.mod
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
# tmp files
*.*~
## Vim ignore ##
# Temp files
*.swp
## Python garbage ignore ##
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
## Haskell ignore ##
dist
cabal-dev
*.o
*.hi
*.chi
*.chs.h
*.dyn_o
*.dyn_hi
.hpc
.hsenv
.cabal-sandbox/
cabal.sandbox.config
*.prof
*.aux
*.hp
## Alchemist (Elixir) ignore ##
*.beam
## Custom ##
# Compiled Lua sources
luac.out
# luarocks build files
*.src.rock
*.zip
*.tar.gz
# My draft folder (ryukinix)
draft
# My emacs org-mode file (leorog)
todo.org
# Virtualenv
venv
================================================
FILE: .travis.yml
================================================
sudo: required
services:
- docker
script:
- sudo chmod +x ./test
- docker-compose run -e "TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST" -e "TRAVIS_BRANCH=$TRAVIS_BRANCH" diff-sync
================================================
FILE: Dockerfile
================================================
FROM ubuntu:trusty
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get install -y
RUN apt-get install -y software-properties-common \
python-software-properties \
python3-pip \
wget
ADD requirements.txt .
RUN apt-get install cython -y
RUN pip3 install -r requirements.txt
# set locale
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# language deps
RUN wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
RUN dpkg -i erlang-solutions_1.0_all.deb
RUN add-apt-repository ppa:eugenesan/ppa -y
RUN apt-get update
RUN apt-get install elixir -y
RUN apt-get install php5 -y
RUN apt-get install golang -y
RUN apt-get install clojure1.4 -y
RUN apt-get install ghc -y
RUN apt-get install g++ gcc -y
RUN apt-get install lua5.2 -y
RUN apt-get install ruby-full -y
RUN apt-get install sbcl -y
RUN apt-get install gawk -y
RUN apt-get install git -y
RUN apt-get install racket -y
RUN apt-get install ocaml -y
WORKDIR /code
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2015 A group of problem solvers!
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: Problem001/.hash
================================================
e1edf9d1967ca96767dcc2b2d6df69f4
================================================
FILE: Problem001/Brain/solution_1.brain
================================================
++++++++++>+* make the number 999 at cell 1
[ run while the number is greater than 0 at cell 1
>+*>+*>+*>+*>+* copy number to cell 2 3 4 5 and 6
<<% go back to cell 4 and mod it with itself because x mod x equal 0
<<% go back to cell 2 and mod it with itself
+++>% make number 3 at cell 2 and mod it with x at cell 3
? if x mod 3 is not equal 0
>+++++>%
?
> go to cell 6 if not 0
: if cell 5 equal zero add it at cell 7
>[>+<-]
;
: if x mod 3 equal 0
?
>>> go to cell 6
:
>>>[>+<-] if cell 3 equal zero add it at cell 7
;
;
[-]<[-]<[-]<[-]<[-]<- clean and go back to cell 1 and subtract one
]
================================================
FILE: Problem001/C/Makefile
================================================
CXX = gcc
LFLAGS = -lm -Wall -o
TARGET = solution_1
TARGET2 = solution_2
EXTENSION_TARGET = c
EXTENSION_OUT = out
all: t1 t2
t1:
$(CXX) $(LFLAGS) $(TARGET).$(EXTENSION_OUT) $(TARGET).$(EXTENSION_TARGET)
t2:
$(CXX) $(LFLAGS) $(TARGET2).$(EXTENSION_OUT) $(TARGET2).$(EXTENSION_TARGET)
clean:
rm -v *.$(EXTENSION_OUT)
run:
./$(TARGET).$(EXTENSION_OUT)
================================================
FILE: Problem001/C/solution_1.c
================================================
/*
* =====================================================================================
*
* Copyleft 2015 Manoel Vilela
*
*
* Filename: solution_1.c
*
* Description: Solution for Problem001 of projecteuler
*
* Author: Manoel Vilela
* Contact: manoel_vilela@engineer.com
* Organization: UFPA
*
* =====================================================================================
**/
/*
Multiples of 3 and 5
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.
*/
#include <stdio.h>
#include <stdlib.h>
#define MAX 1000
/*===================================================
*
* Author: That's it's a very old solution
* when i've beginning with programming in C.
*
* ==================================================
**/
// ?
int sumlista(int* lista, int lenght){
int sum = 0;
for(int i = 0; i < lenght; i++){
sum += lista[i];;
}
return sum;
}
// why so much pointers for this?
void increase(int **data, int *lenght){
int size = *lenght + sizeof(int);
*data = (int*) realloc(*data, size * sizeof(int));
*lenght += 1;
}
//it's really stupid
int exist(int *lista, int lenght, int num){
int exist = 0;
for(int i = 0; i <= lenght; i++)
if (lista[i] == num)
exist = 1;
return exist;
}
// i really doubt my skill for simplify after see my past
int main(void){
int *lista, lenght = 0;
int multiples[3] = {3, 5, 0};
lista = (int*) malloc(sizeof(int));
for(int i = 0; i < MAX; i++){
for (int j = 0; multiples[j] != 0; j++){
int mult = multiples[j];
if (i % mult == 0){
if (!exist(lista, lenght, i)){
lista[lenght] = i;
increase(&lista, &lenght);
}
}
}
}
int sum = sumlista(lista, lenght);
//at least works... right?
printf("%d\n", sum);
free(lista);
return 0;
}
================================================
FILE: Problem001/C/solution_2.c
================================================
/*
* Implementation of solution 1 using Principle of inclusion-exclusion
* The proof is done on the related pull request.
* by Luiz Peres
* Obs.: I'm using a lot of variables in order to make it easy to understand
*/
#include <stdio.h>
#define LAST_N 999
int main()
{
int div3 = LAST_N / 3;
int div5 = LAST_N / 5;
int div3Union5 = LAST_N / (3*5);
int sumMult3 = 3 * div3 * (div3 + 1) / 2;
int sumMult5 = 5 * div5 * (div5 + 1) / 2;
int sumMult3Union5 = 3 * 5 * div3Union5 * (div3Union5 + 1) / 2;
int inc_exc = sumMult3 + sumMult5 - sumMult3Union5;
printf("%d\n", inc_exc);
return 0;
}
================================================
FILE: Problem001/C++/Makefile
================================================
CXX = g++
LFLAGS = -lm -Wall -o
TARGET = solution_1
EXTENSION_TARGET = cpp
EXTENSION_OUT = out
all:
$(CXX) $(LFLAGS) $(TARGET).$(EXTENSION_OUT) $(TARGET).$(EXTENSION_TARGET)
clean:
rm -v *.$(EXTENSION_OUT)
run:
./$(TARGET).$(EXTENSION_OUT)
================================================
FILE: Problem001/C++/solution_1.cpp
================================================
/*
* Find the sum of all multiples of 3 and 5 below 1000
*/
#include <iostream>
#include <cstdlib>
int main(int argc, char* argv[])
{
// upper default limit.
const char *limit = "1000";
if (argv[1]) {
limit = argv[1];
}
// iterator variable.
int i = 0;
// resultant sum of all multiples of 3 and 5.
int sum = 0;
// transform an array of characters into an integer.
int number_to = atoi(limit);
while (i < number_to) {
if ((i % 3 == 0) && (i % 15 != 0)) {
sum += i;
}
if ((i % 5 == 0)) {
sum += i;
}
i++;
}
std::cout << sum << std::endl;
return 0;
}
================================================
FILE: Problem001/Clojure/solution_1.clj
================================================
;; My first code in Clojure
;; Manoel Vilela
;; solution of problem001
(defn solution [x]
(reduce + (filter (fn [n] (or (= (mod n 5) 0) (= (mod n 3) 0))) (range 1 x)))
)
(println (solution 1000))
================================================
FILE: Problem001/CommonLisp/solution_1.lisp
================================================
;; Common Lisp version
;; Manoel Vilela
(defun div (x d)
(= (mod x d) 0))
(defun special-sum (n)
(reduce '+ (loop for x from 1 to n when (or (div x 5) (div x 3)) collect x)))
(format t "~d" (special-sum 999))
================================================
FILE: Problem001/D/solution_1.d
================================================
import std.stdio : writeln;
void main()
{
int total;
foreach (n; 1..1000) {
if (n % 3 == 0 || n % 5 == 0)
total+=n;
}
writeln(total);
}
================================================
FILE: Problem001/Elixir/solution_1.exs
================================================
# Author: G4BB3R
1..999 |> Enum.to_list
|> Enum.filter(&(rem(&1, 3) == 0 or rem(&1, 5) == 0))
|> Enum.sum
|> IO.puts
================================================
FILE: Problem001/Erlang/solution_1.erl
================================================
%Autor: machad0
-module(solution_1).
-export([euler001/0]).
euler001() ->
lists:sum([Num || Num <- lists:seq(0, 999), (Num rem 3 =:= 0) or (Num rem 4 =:= 0)]).
================================================
FILE: Problem001/Go/solution_1.go
================================================
// Copyright 2016 the <project> Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import "fmt"
func main() {
sum := 0
for i := 1; i < 1000; i++ {
if i%3 == 0 || i%5 == 0 {
sum += i
}
}
fmt.Println(sum)
}
================================================
FILE: Problem001/Haskell/solution_1.hs
================================================
{-
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.
-}
main :: IO ()
main = print $ sum [x | x <- [1..999], mod x 3 == 0 || mod x 5 == 0]
================================================
FILE: Problem001/Java/solution_1.java
================================================
public class Main
{
public static void main(String[] args)
{
int total = 0;
for(int i = 1; i < 1000; i ++)
{
if(i % 3 == 0 || i % 5 == 0){
total += i;
}
}
System.out.println(total);
}
}
================================================
FILE: Problem001/JavaScript/solution_1.js
================================================
'use strict'
const sumAllMultiples = limit => {
let sum = 0
for(let i = 0; i < limit; i++) {
if(i % 3 == 0 || i % 5 == 0) {
sum += i;
}
}
return sum;
}
console.log(sumAllMultiples(1000));
================================================
FILE: Problem001/JavaScript/solution_2.js
================================================
'use strict'
const sumAllMultiples = limit => Array(limit).fill().map((_, i) => i).filter(number => number % 3 == 0 || number % 5 == 0).reduce((total, number) => total + number)
console.log(sumAllMultiples(1000))
================================================
FILE: Problem001/Kotlin/solution_1.kt
================================================
fun main(args: Array<String>) {
val seq = (1..999)
.asSequence()
.filter { it % 3 == 0 || it % 5 == 0 }
.sum()
println(seq)
}
================================================
FILE: Problem001/Lua/solution_1.lua
================================================
-- Author: G4BB3R
local resultado = 0
for i = 1, 999 do
if i % 5 == 0 or i % 3 == 0 then
resultado = resultado + i
end
end
print(resultado)
================================================
FILE: Problem001/OCaml/solution_1.ml
================================================
let check x =
if x mod 3 = 0 || x mod 5 = 0 then
1
else
0
let rec solve current top count =
if current = top then count
else
if check current = 1 then
solve (current + 1) top (count + current)
else
solve (current + 1) top (count);;
let solution =
solve 0 1000 0;;
print_int (solution);;
print_newline ()
================================================
FILE: Problem001/Objective-C/solution_1.m
================================================
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSInteger sum = 0;
NSInteger i;
for (i = 0; i < 1000; i++)
if (i % 5 == 0 || i % 3 == 0)
sum += i;
NSLog (@"%lu", sum);
[pool drain];
return 0;
}
================================================
FILE: Problem001/PHP/solution_1.php
================================================
<?php
$sum = 0;
foreach(range(1, 999) as $i)
{
if ($i % 5 == 0 || $i % 3 == 0)
$sum += $i;
}
echo $sum;
?>
================================================
FILE: Problem001/PHP/solution_2.php
================================================
<?php
echo array_reduce(range(1, 999), function($carry, $x){
return $carry += (!($x % 3 && $x % 5)) * $x; //Morgan's laws
});
?>
================================================
FILE: Problem001/Python/solution_1.py
================================================
print(sum([x for x in range(1000) if (x % 3 == 0) or (x % 5 == 0)]))
================================================
FILE: Problem001/Python/solution_2.py
================================================
count = 0
for i in range(1000):
if (i % 3 == 0) or (i % 5 == 0):
count += i
print(count)
================================================
FILE: Problem001/R/solution_1.R
================================================
vector <- 1:1000
sum(vector[vector%%3==0 | vector%%5==0])
================================================
FILE: Problem001/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=1)
================================================
FILE: Problem001/Racket/solution_1.rkt
================================================
(define (mult3-5 x)
(or (= (remainder x 3) 0)
(= (remainder x 5) 0)))
(define (main)
(let ((answer (apply + (filter mult3-5 (range 0 1000)))))
(display answer)
(newline)))
(main)
================================================
FILE: Problem001/Ruby/solution_1.rb
================================================
# Author: tkovs
def solve
(0..999).select{|n| n % 3 == 0 || n % 5 == 0}.inject(:+)
end
puts(solve)
================================================
FILE: Problem001/Rust/solution_1.rs
================================================
fn sum_all_multiples(limit: i32) -> i32 {
let mut sum = 0;
for i in 0..limit {
if i % 3 == 0 || i % 5 == 0 {
sum += i;
}
}
return sum;
}
fn main() {
println!("{:?}", sum_all_multiples(1000));
}
================================================
FILE: Problem001/Scheme/solution_1.scm
================================================
(define (range a b)
(if (>= a b)
'()
(cons a (range (+ a 1) b))))
(define (filter f l)
(cond ((null? l) '())
((f (car l)) (cons (car l) (filter f (cdr l))))
(#t (filter f (cdr l)))))
(define (mult3-5 x)
(or (= (remainder x 3) 0)
(= (remainder x 5) 0)))
(define (sum l)
(apply + l))
(define (main)
(let ((answer (sum (filter mult3-5 (range 0 1000)))))
(display answer)
(newline)))
(main)
================================================
FILE: Problem001/Scheme/solution_2.scm
================================================
(define triangular
(lambda (n)
(/ (* (+ n 1) n) 2)))
(define sum-multiples-less-than
(lambda (n k)
(* k (triangular (floor (/ (- n 1) k))))))
(define sum-multiples-of-3-or-5-less-than
(lambda (n)
(- (+ (sum-multiples-less-than n 3)
(sum-multiples-less-than n 5))
(sum-multiples-less-than n 15))))
(define solve
(let ((input 1000))
(sum-multiples-of-3-or-5-less-than input)))
(display solve)
(newline)
================================================
FILE: Problem001/Shell/solution_1.sh
================================================
#!/bin/bash
for i in {0..999}; do if !(($i%3)) || !(($i%5)); then multiples[$i]=$i; fi; done
for j in ${multiples[@]}; do let total+=$j; done; echo $total
================================================
FILE: Problem001/Swift/solution_1.swift
================================================
var sum = 0
for i in 1..<1000
{
if i % 5 == 0 || i % 3 == 0
{
sum += i
}
}
print(sum)
================================================
FILE: Problem002/.hash
================================================
4194eb91842c8e7e6df099ca73c38f28
================================================
FILE: Problem002/C/Makefile
================================================
GCC = gcc
LFLAGS = -lm -Wall -o
TARGET = solution_1
all:
$(GCC) $(LFLAGS) $(TARGET).out $(TARGET).c
clean:
rm -v *.out
run:
./$(TARGET).out
================================================
FILE: Problem002/C/solution_1.c
================================================
/*
Each new term in the Fibonacci sequence is generated by adding the previous two terms.
By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
*/
#include <stdio.h>
#include <stdlib.h>
#define INT sizeof(int)
typedef struct fib {
int *sequence;
int length;
} _fib;
int even(int);
_fib fibonacci(int);
int main(void) {
_fib numbers;
int i, sum_even;
numbers = fibonacci(4000000);
sum_even = 0;
for (i = 0; i < numbers.length; i++) {
if (even(numbers.sequence[i]))
sum_even += numbers.sequence[i];
}
printf ("%d\n", sum_even);
return 0;
}
int even(int value) {
return !(value & 1);
}
_fib fibonacci(int limit) {
_fib numbers;
int a, b;
numbers.sequence = NULL;
numbers.length = 0;
a = 0;
b = 1;
while ((a+b) < limit) {
numbers.sequence = (int *) realloc (numbers.sequence, ++numbers.length * INT);
numbers.sequence[numbers.length-1] = a+b;
a = b;
b = numbers.sequence[numbers.length-1];
}
return numbers;
}
================================================
FILE: Problem002/C++/Makefile
================================================
CXX = g++
LFLAGS = -lm -Wall -std=c++11 -o
TARGET = solution_1
EXTENSION_TARGET = cpp
EXTENSION_OUT = out
all:
$(CXX) $(LFLAGS) $(TARGET).$(EXTENSION_OUT) $(TARGET).$(EXTENSION_TARGET)
clean:
rm -v *.$(EXTENSION_OUT)
run:
./$(TARGET).$(EXTENSION_OUT)
================================================
FILE: Problem002/C++/solution_1.cpp
================================================
/**
* Find the sum of all even fibonacci numbers whose values are under 4E6.
*/
#include <iostream>
#include <cstdlib>
int main(int argc, char *argv[])
{
const char *argv_number = "4000000";
if (argv[1]) {
argv_number = argv[1];
}
// sum of all even fibonacci numbers.
int sum = 0;
int i = 0;
int limit_number = atoi(argv_number);
int last_fib = 1;
int fib_number = 2;
int fib_tmp = 0;
while (fib_number < limit_number) {
if (fib_number % 2 == 0) {
sum += fib_number;
}
fib_tmp = fib_number;
fib_number += last_fib;
last_fib = fib_tmp;
i++;
}
std::cout << sum << std::endl;
return 0;
}
================================================
FILE: Problem002/Clojure/solution_1.clj
================================================
;; Author: G4BB3R
(def fib (cons 0 (cons 1 (lazy-seq (map + fib (rest fib))))))
(def resultado
(reduce + 0 (filter #(== 0 (rem %1 2)) (take-while (fn [a] (<= a 4000000)) fib))))
(println resultado)
================================================
FILE: Problem002/Clojure/solution_2.clj
================================================
(def fib
(->> [0 1]
(iterate (fn [[x y]] [y (+' x y)]))
(map first)))
(defn solution []
(->> fib
(take-while #(< % 4000000))
(filter even?)
(reduce +')
(println)))
(solution)
================================================
FILE: Problem002/CommonLisp/solution_1.lisp
================================================
;; Common Lisp Script
;; Manoel Vilela
(defun fib (n)
(labels ((tail-fib (n a b)
(if (= n 0)
a
(tail-fib (1- n)
b
(+ a b)))))
(tail-fib n 0 1)))
(defun solution ()
(format t "~a~%" (loop for x from 0
for fib-x = (fib x)
while (< fib-x 4000000)
when (evenp fib-x) sum fib-x)))
(solution)
================================================
FILE: Problem002/D/solution_1.d
================================================
import std.stdio : writeln;
import std.algorithm : filter, sum;
enum int LIMIT = 50;
ulong[] _fibonacci()
{
ulong[] fib;
fib.reserve(LIMIT);
fib ~= 1;
fib ~= 2;
foreach (n; 2 .. LIMIT)
fib ~= fib[n-2] + fib[n-1];
return fib;
}
void main()
{
ulong[] fibonacci = _fibonacci;
ulong answer = sum(fibonacci.filter!(a => a % 2 == 0 && a < 4000000));
writeln(answer);
}
================================================
FILE: Problem002/Elixir/solution_1.ex
================================================
Stream.unfold({0, 1}, fn {a, b} -> {a, {b, a + b}} end)
|> Stream.filter(&(rem(&1, 2) == 0))
|> Enum.reduce_while(0, fn (i, acc) -> if (i < 4_000_000), do: {:cont, acc + i}, else: {:halt, acc} end)
|> IO.puts
================================================
FILE: Problem002/Go/solution_1.go
================================================
package main
import "fmt"
func p2(n int) int {
sum, a, b, c := 0, 1, 1, 2 // c = a + b
for c < n {
if n % 2 == 0 {
sum += c
}
a = b + c
b = c + a
c = a + b
}
return sum
}
func main(){
fmt.Println(p2(4000000))
}
================================================
FILE: Problem002/Haskell/solution_1.hs
================================================
{-
Each new term in the Fibonacci sequence is generated by adding the previous two terms.
By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
-}
fibs :: [Integer]
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
main :: IO ()
main = print . sum . filter even $ takeWhile (< 4000000) fibs
================================================
FILE: Problem002/JavaScript/solution_1.js
================================================
'use strict'
LIMIT = 4000000
even = (b) => b % 2 != 0
function sequence_generator(n, filter){
a=1;
b=1;
array = [a, b];
while (true){
c = a;
a = b;
b = c + b;
if (b > n) {
break;
}
if (filter(b)){
array.push(b);
}
}
return array;
}
var solution = sequence_generator(LIMIT, even).reduce((a, b) => a + b, 0);
console.log(solution)
================================================
FILE: Problem002/Lua/solution_1.lua
================================================
-- Author: G4BB3R
-- Fibonacci function with memoization
local fib_cache = {}
local function fib (n)
if fib_cache[n] then
return fib_cache[n]
elseif n <= 1 then
return n
end
local result = fib (n - 1) + fib (n - 2)
fib_cache[n] = result
return result
end
local resultado = 0
for i = 1, 1000 do
local fib_value = fib(i)
if fib_value > 4000000 then
break
elseif fib_value % 2 == 0 then
resultado = resultado + fib_value
end
end
print(resultado)
================================================
FILE: Problem002/OCaml/solution_1.ml
================================================
let rec solve a b top sum =
if a > top then
sum
else if b mod 2 = 0 then
solve b (a + b) top (sum + b)
else
solve b (a + b) top sum
let solution =
solve 0 1 4000000 0;;
print_int (solution);;
================================================
FILE: Problem002/PHP/solution_1.php
================================================
<?php
$fibonacci = array(1, 2);
array_walk($fibonacci, function($x) use (&$fibonacci){
if($x * 2.6180 <= 4000000) // lim Φ²n, n -> ∞
array_push( $fibonacci, array_sum(array_slice($fibonacci, -2, 2)));
});
echo array_reduce($fibonacci, function($carry, $x) use (&$fibonacci){
return $carry += ($x%2 == 0) * $x;
});
?>
================================================
FILE: Problem002/Python/solution_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
#
# Python Script
#
# Copyleft © Manoel Vilela
#
#
def fib_generator(n):
a, b = 1, 1
while b <= n:
a, b = b, a + b
yield a
def solution(n):
return sum(i for i in fib_generator(n) if not i % 2)
if __name__ == '__main__':
print(solution(4000000))
================================================
FILE: Problem002/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=2)
================================================
FILE: Problem002/Ruby/solution_1.rb
================================================
# Author: tkovs
def fib(n)
a, b = 0, 1
sequence = [a] # initialize
while (b < n)
sequence.push(b)
a, b = b, a + b
end
return(sequence)
end
def solve
fib(4000000).select{|n| n.even?}.inject(:+)
end
puts(solve)
================================================
FILE: Problem002/Scheme/solution_1.scm
================================================
;;
;; The even Fibonacci numbers satisfy the recurrence
;;
;; A(n+2) = 4*A(n+1) + A(n) if n>0
;; A(1) = 2, A(2) = 8
;;
(define next-term
(lambda (a1 a2)
(+ a1 (* 4 a2))))
(define sum-terms-smaller-than
(lambda (acc1 acc2 max sum)
(cond
((> acc1 max) sum)
(else (sum-terms-smaller-than acc2 (next-term acc1 acc2) max (+ acc1 sum))))))
(define solve
(let ((input 4000000))
(sum-terms-smaller-than 2 8 input 0)))
(display solve)
(newline)
================================================
FILE: Problem003/.hash
================================================
94c4dd41f9dddce696557d3717d98d82
================================================
FILE: Problem003/C++/solution_1.cpp
================================================
#include<bits/stdc++.h>
using namespace std;
long long int largestPrime(long long int num){
int j=2;
while(num%j != 0) j+=1;
if(num%2 == 0){
if(num==2) return 2;
else return largestPrime(num/2);
}
else if(num/j == 1) return num;
else return largestPrime(num/j);
}
int main(){
long long int x=600851475143;
cout<<((long long int)largestPrime(x))<<endl;
}
================================================
FILE: Problem003/Clojure/solution_1.clj
================================================
(defn is-prime
[n]
(if (or (= n 1) (= n 4))
false
(loop [candidates (range 2 (+ 1 (Math/sqrt n)))]
(cond
(empty? candidates) true
(= 0 (rem n (first candidates))) false
:else (recur (next candidates))))))
(defn next-prime
[n]
(loop [candidate n]
(if (is-prime candidate)
candidate
(recur (+ candidate 1)))))
(defn prime-seq
([] (prime-seq 2))
([n] (cons n (lazy-seq (prime-seq (next-prime (+' 1 n )))))))
(defn solution
[n]
(loop [remaining n prime 1 factors '()]
(def p (last (take prime (prime-seq))))
(def x (/ remaining p))
(cond
(= 1 x) (cons p factors)
(ratio? x) (recur remaining (+' prime 1) factors)
:else (recur x 1 (cons p factors)))))
(println (str (first (solution 600851475143))))
================================================
FILE: Problem003/CommonLisp/solution_1.lisp
================================================
;; Common Lisp Script
;; Manoel Vilela
(defun factors (n)
"Return a list of '(prime factor) for n
(factors 100) => ((2 2) (5 2))
"
(loop for x from 2
while (> n 1)
when (= 0 (mod n x))
collect (loop for c from 0
while (= 0 (mod n x))
do (setq n (/ n x))
finally (return (list x c)))))
(defun solution ()
(caar (last (factors 600851475143))))
(format t "~a~%"(solution))
================================================
FILE: Problem003/Elixir/solution_1.exs
================================================
defmodule Prime do
def solve(num), do: solve(num, 2)
defp solve(num, acc) when num <= acc, do: num |> IO.puts()
defp solve(num, acc) when num > acc and rem(num, acc) == 0 do
num |> div(acc) |> solve(acc + 1)
end
defp solve(num, acc) when num > acc and rem(num, acc) != 0 do
num |> solve(acc + 1)
end
end
600851475143 |> Prime.solve()
================================================
FILE: Problem003/Go/solution_1.go
================================================
package main
import (
"fmt"
"math"
)
const NUM = 600851475143
var GrDiv = 1
func main() {
for i := 3; float64(i) < math.Sqrt(float64(NUM)); i += 2 {
if NUM%i == 0 && isPrime(uint64(i)) {
GrDiv = i
}
}
fmt.Println(GrDiv)
}
func isPrime(n uint64) bool {
if n < 2 {
return false
} else if n == 2 {
return true
} else if n%2 == 0 {
return false
}
for i := 3; float64(i) <= math.Sqrt(float64(n)); i = i + 2 {
if n%uint64(i) == 0 {
return false
}
}
return true
}
================================================
FILE: Problem003/Haskell/solution_1.hs
================================================
prime_acc :: Integer -> Integer -> Integer
prime_acc value acc
| acc < value = if mod value acc == 0 then
prime_acc (div value acc) (acc + 1)
else
prime_acc value (acc + 1)
| otherwise = acc
prime :: Integer -> Integer
prime x = prime_acc x 2
main :: IO ()
main = print $ prime 600851475143
================================================
FILE: Problem003/Haskell/solution_2.hs
================================================
prime value acc
| acc >= value = acc
| mod value acc == 0 = prime (div value acc) (acc + 1)
| otherwise = prime value (acc + 1)
main :: IO ()
main = print $ prime 600851475143 2
================================================
FILE: Problem003/JavaScript/solution_1.js
================================================
'use strict'
const prime = num => {
if(num == 1) {
return 1;
}
let i;
for(i = 2; i < num; i++) {
if(num % i == 0) {
num /= i;
}
}
return i;
}
console.log(prime(600851475143));
================================================
FILE: Problem003/PHP/solution_1.php
================================================
<?php
function prime($num)
{
for ($i = 2; $i < $num; $i++) {
if ($num % $i == 0) {
$num /= $i;
}
}
return $i;
}
echo prime(600851475143);
================================================
FILE: Problem003/Python/solution_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
#
# Python Script
#
# Copyleft © Manoel Vilela
#
#
from sys import version_info
if version_info >= (3, 0):
xrange = range
"""
Largest prime factor
Problem 3
Published on Friday, 2nd November 2001, 06:00 pm; Solved by 264184
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
"""
def prime_gen(n):
for i in xrange(2, n):
prime = True
if i % 2 == 0 and i != 2:
continue
sqrtp = int(i ** 1 / 2)
for j in xrange(2, sqrtp):
if j % 2 == 0:
continue
if i % j == 0:
prime = False
break
if prime:
yield i
num = 600851475143
for i in prime_gen(num):
if num % i == 0:
num /= i
if num <= 1:
print(i)
break
================================================
FILE: Problem003/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=3)
================================================
FILE: Problem003/Scheme/solution_1.scm
================================================
(define divmod
(lambda (n d)
(let ((q (floor (/ n d)))
(r (remainder n d)))
(cons q r))))
(define factor
(lambda (n)
(factor-iter 2 n '())))
(define factor-iter
(lambda (p n L)
(let ((dm (divmod n p)))
(cond
((= n 1) L)
((> p (car dm)) (factor-iter p 1 (append L (list n))))
((= 0 (cdr dm)) (factor-iter p (car dm) (append L (list p))))
(else (factor-iter (next p) n L))))))
(define next
(lambda (p)
(cond
((= p 2) 3)
((= p 3) 5)
((= (remainder p 6) 1) (+ p 4))
((= (remainder p 6) 5) (+ p 2)))))
(define biggest-prime-factor
(lambda (n)
(car (reverse (factor n)))))
(define solve
(let ((input 600851475143))
(biggest-prime-factor input)))
(display solve)
(newline)
================================================
FILE: Problem003/Shell/solution_1.sh
================================================
#!/bin/bash
prime () {
num=$1
counter=2
while [ $counter -lt $num ]; do
if !(($num % $counter)); then num=$(($num/$counter)); fi
let counter=counter+1
done
echo $num
}
prime 600851475143
================================================
FILE: Problem004/.hash
================================================
d4cfc27d16ea72a96b83d9bdef6ce2ec
================================================
FILE: Problem004/C/solution_1.c
================================================
#include <stdio.h>
#include <stdlib.h>
int main()
{
unsigned long int m=0,n=0, palindrome=0,h;
int i=0,j=0;
for(i=100;i<=999;++i)
{
for(j=100;j<=999;++j)
{
int a=0;
m=0;n=0;
m=i*j;
n=m;
h=0;
while(m!=0)
{
a=m%10;
m=m/10;
h=h*10 +a;
}
if(h==n && h>=palindrome)
palindrome=h;
}
}
printf("%d",palindrome);
return 0;
}
================================================
FILE: Problem004/Clojure/solution_1.clj
================================================
(defn solution
[]
(->>
(for [x (range 100 1000) y (range 100 1000)
:let [p (* x y)]
:when (= (reverse (str p)) (seq (str p)))] p)
(apply max)))
(println (solution))
================================================
FILE: Problem004/CommonLisp/solution_1.lisp
================================================
;; Common Lisp Script
;; Manoel Vilela
(defun reverse-digits (n)
(labels ((next (n v)
(if (zerop n)
v
(multiple-value-bind (q r)
(truncate n 10)
(next q (+ (* v 10) r))))))
(next n 0)))
(defun palindromep (n)
(= n (reverse-digits n)))
(defun solution()
(let ((nums (loop for x from 100 to 999
appending (loop for y from 100 to 999
collect (* x y)))))
(loop for x in (sort nums #'>)
when (palindromep x) return x)))
(format t "~a~%"(solution))
================================================
FILE: Problem004/Elixir/solution_1.exs
================================================
isPalindrome = fn num -> num
|> Integer.to_string
|> String.reverse
|> String.to_integer
|> (fn x -> x == num end).()
end
for x <- 1..999,
y <- 1..999,
isPalindrome.(x * y) do
x * y
end
|> Enum.max
|> IO.puts
================================================
FILE: Problem004/Go/solution_1.go
================================================
package main
import (
"fmt"
"strconv"
"strings"
)
func main() {
var MAX = 10000
for i := 100; i < 1000; i++ {
for j := 100; j < 1000; j++ {
if i*j < MAX {
continue
}
a := strconv.Itoa(i * j)
b := reverse(a)
if strings.Compare(a, b) == 0 {
MAX = i * j
}
}
}
fmt.Println(MAX)
}
func reverse(s string) (result string) {
for _, v := range s {
result = string(v) + result
}
return
}
================================================
FILE: Problem004/Haskell/solution_1.hs
================================================
-- Author: G4BB3R
isPalindrome :: Int -> Bool
isPalindrome x = show x == (reverse . show $ x)
largestPalindrome :: Int
largestPalindrome = maximum [x * y | x <- [1..999], y <- [1..999], isPalindrome $ x * y]
main :: IO ()
main = print largestPalindrome
================================================
FILE: Problem004/JavaScript/solution_1.js
================================================
'use strict'
function is_palindrome(s){
return s === s.split('').reverse().join('')
}
function find_max_palindrom(){
max = 0
for (i=100; i<999; i+=1){
for (j=100; j<999; j+=1){
if (is_palindrome(i*j + '') && i*j > max) {
max = i*j;
}
}
}
return max;
}
console.log(find_max_palindrom())
================================================
FILE: Problem004/Lua/solution_1.lua
================================================
-- Author: G4BB3R
local function isPalindrome (x)
return tonumber(string.reverse(x)) == x
end
local largest = 0
for a = 1, 999 do
for b = 1, 999 do
if a * b > largest and isPalindrome(a * b) then
largest = a * b
end
end
end
print(largest)
================================================
FILE: Problem004/OCaml/solution_1.ml
================================================
let rec ispalind s =
if String.length s <= 1 then true
else if s.[0] = s.[String.length s - 1] then ispalind (String.sub s 1 (String.length s - 2))
else false;;
let solve =
let mx= ref 0 in
for i = 100 to 999 do
for j = 100 to 999 do
if ispalind (string_of_int(i * j)) && (i * j) > !mx then mx := (i * j)
done
done;
!mx
let rec solve i j prod=
if i = 100 then
prod
else if j = 100 then
solve (i - 1) 999 prod
else
if ispalind (string_of_int(i * j)) && (i * j) > prod then solve i (j-1) (i * j)
else solve i (j-1) prod
let solution =
solve 999 999 0;;
print_int (solution);;
================================================
FILE: Problem004/Python/solution_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
#
# Python Script
#
# Copyleft © Manoel Vilela
#
#
from sys import version_info
if version_info >= (3, 0):
xrange = range
"""
Largest palindrome product
Problem 4
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99.
Find the largest palindrome made from the product of two 3-digit numbers.
"""
palindrome = 0
for i in xrange(1000):
for j in xrange(999, 1, -1):
string = str(i*j)
if string == string[::-1]:
if palindrome < i * j:
palindrome = i * j
break
print(palindrome)
================================================
FILE: Problem004/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=4)
================================================
FILE: Problem004/Ruby/solution_01.rb
================================================
# Author: tkovs
def palindrome(n)
return (n.to_s.eql?(n.to_s.reverse))
end
def solve
list = (1..999).flat_map{|x| (1..999).map {|y| x * y}}
return list.select{|x| palindrome(x).eql?(true)}.max
end
puts(solve)
================================================
FILE: Problem005/.hash
================================================
bc0d0a22a7a46212135ed0ba77d22f3a
================================================
FILE: Problem005/C/solution_1.c
================================================
#include <stdio.h>
// Author: tkovs
// Used lua solution that uses python solution XD
int main(void) {
int k, i = 1, j;
for (k = 1; k <= 20; k++) {
if (i % k > 0) {
for (j = 1; j <= 20; j++) {
if ((i * j) % k == 0) {
i = i * j;
break;
}
}
}
}
printf ("%d", i);
return 0;
}
================================================
FILE: Problem005/C++/solution_1.cpp
================================================
#include <iostream>
int main(int argc, char **argv)
{
int number = 2520;
// naive solution
while (true) {
for (int i = 2; i <= 20; i++) {
if (number % i != 0) {
break;
}
else if (i == 20 && number % i == 0) {
std::cout << number << std::endl;
return 0;
}
}
number++;
}
return 0;
}
================================================
FILE: Problem005/CommonLisp/solution_1.lisp
================================================
;; Common Lisp Script
;; Manoel Vilela
(format t "~a~%" (reduce #'lcm (loop for x from 1 to 20 collect x)))
================================================
FILE: Problem005/Elixir/solution_1.exs
================================================
defmodule Solution do
def solve(n) do
dvs = 2..n |> Enum.to_list
find_recur(n, dvs, n)
end
defp find_recur(n, dvs, inc_rate) do
if Enum.all?(dvs, &(0 == rem(n, &1))) do
n
else
find_recur(n + inc_rate, dvs, inc_rate)
end
end
end
Solution.solve(20) |> IO.puts
================================================
FILE: Problem005/Elixir/solution_2.exs
================================================
# Author: lubien
defmodule Euler5 do
def solve(n) do
1..n |> Enum.reduce(&lcm/2)
end
def lcm(x, y), do: div(x * y, gcd(x, y))
def gcd(x, 0), do: x
def gcd(x, y) do
gcd(y, rem(x, y))
end
end
Euler5.solve(20)
|> IO.puts
================================================
FILE: Problem005/Elixir/solution_slow_1.exs
================================================
# Author: G4BB3R
1..999999999999 |> Enum.find(fn x -> Enum.all? 11..20, &(rem(x, &1) == 0) end)
|> IO.puts
================================================
FILE: Problem005/Haskell/solution_1.hs
================================================
-- Author: G4BB3R
import Data.List (find)
import Data.Maybe (fromJust)
smallest :: Int
smallest = fromJust $ find (\x -> all (\y -> rem x y == 0) [11..20]) [20, 40..]
main = print smallest
================================================
FILE: Problem005/JavaScript/solution_1.js
================================================
"use strict";
function smallest_multiple() {
let i = 1;
for (let k = 1; k < 21; k++) {
if (i % k > 0) {
for (let j = 1; j < 21; j++) {
if ((i * j) % k == 0) {
i *= j;
break;
}
}
}
}
return i;
}
console.log(smallest_multiple());
================================================
FILE: Problem005/Lua/solution_1.lua
================================================
-- Author: G4BB3R
-- Used python solution XD
local i = 1
for k = 1, 20 do
if i % k > 0 then
for j = 1, 20 do
if (i * j) % k == 0 then
i = i * j
break
end
end
end
end
print(i)
================================================
FILE: Problem005/OCaml/solution_1.ml
================================================
let rec range i j = if i > j then [] else i :: (range (i+1) j)
let is_prime n =
let is_divisor d p =
if p mod d = 0 then 1 else 0
in
let targets = range 2 (int_of_float(sqrt(float_of_int(n))))
in
let rec test_targets k targets =
match targets with
| [] -> 1
| x::trg -> if is_divisor x k = 1 then 0 else test_targets k trg
in
test_targets n targets
let rec mxpow i top prod =
if prod > top then
(prod / i)
else
mxpow i top (prod * i)
let rec solve n i prod =
if i = n then
prod
else
if (is_prime i) = 1 then solve n (i + 1) (prod * (mxpow i n 1))
else solve n (i + 1) prod
let solution =
solve 20 2 1;;
print_int (solution);;
print_newline ();;
================================================
FILE: Problem005/Python/solution_2.py
================================================
#Some milliseconds slower than solution 1
def div20(num):
return all([num%x==0 for x in range(20, 10, -1)])
num = 2520
while True:
if div20(num):
print(num)
break
num+=2520
================================================
FILE: Problem005/Python/solution_3.py
================================================
# someone in the internet do that
i = 1
for k in (range(1, 21)):
if i % k > 0:
for j in range(1, 21):
if (i * j) % k == 0:
i *= j
break
print(i)
================================================
FILE: Problem005/Python/solution_slow_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
#
# Python Script
#
# Copyleft © Manoel Vilela
#
#
"""
Smallest multiple
Problem 5
2520 is the smallest number that can be divided by
each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly
divisible by all of the numbers from 1 to 20?
"""
# my ugly solution D: #brute-force:
divisors = [x for x in range(1, 21)]
x = 1
while True:
smallest = True
for i in divisors:
if x % i != 0:
smallest = False
break
if smallest:
print(x)
break
x += 1
================================================
FILE: Problem005/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=5)
================================================
FILE: Problem005/Scheme/solution_1.scm
================================================
;;
(define makelist
(lambda (f min max L)
(cond
((> min max) L)
(else (makelist f (+ min 1) max (append L (list (f min))))))))
(define aggregate
(lambda (f n L)
(cond
((null? L) n)
(else (aggregate f (f n (car L)) (cdr L))))))
(define gcd
(lambda (m n)
(cond
((= n 0) m)
((= n 1) 1)
((< m n) (gcd n m))
(else (gcd n (remainder m n))))))
(define lcm
(lambda (m n)
(cond
((= n 1) m)
((= n 0) 0)
(else (/ (* m n) (gcd m n))))))
(define solve
(let ((input 20))
(aggregate lcm 1 (makelist (lambda (x) x) 2 input '()))))
(display solve)
(newline)
================================================
FILE: Problem005/go/solution_1.go
================================================
package main
import "fmt"
func smallest_multiple(number int) int {
for result := 2; ; result++ {
found := true
for i := 2; i <= number; i++ {
if result%i != 0 {
found = false
break
}
}
if found {
return result
}
}
}
func main() {
fmt.Println(smallest_multiple(20))
}
================================================
FILE: Problem006/.hash
================================================
867380888952c39a131fe1d832246ecc
================================================
FILE: Problem006/C++/Makefile
================================================
CXX = g++
LFLAGS = -lm -Wall -std=c++0x -o
TARGET = solution_01
EXTENSION_TARGET = cpp
EXTENSION_OUT = out
all:
$(CXX) $(LFLAGS) $(TARGET).$(EXTENSION_OUT) $(TARGET).$(EXTENSION_TARGET)
clean:
rm -v *.$(EXTENSION_OUT)
run:
./$(TARGET).$(EXTENSION_OUT)
================================================
FILE: Problem006/C++/solution_1.cpp
================================================
/*
* Find the difference between the square of the sum and the sum of the squares
* of the first one hundred numbers.
*
* Square sum:
*
* (1+2+3+...+98+99+100)^2 = 5050^2 (Thanks Gauss)
*
* Sum square:
*
* 1^2+2^2+3^2+...+98^2+99^2+100^2
*/
#include <iostream>
#include <cmath>
long int sum_of_squares();
int main(int argc, char **argv)
{
// From math: Sum of n natural numbers is: [n*(n+1)]/2;
long int square_sum = pow(((100*(100+1))/2), 2);
std::cout << square_sum - sum_of_squares() << std::endl;
return 0;
}
/*
* Naive sum of the squares.
*/
long int sum_of_squares()
{
long int acc = 0;
for (int i = 1; i <= 100; i++) {
acc += pow(i, 2);
}
return acc;
}
================================================
FILE: Problem006/Clojure/solution_1.clj
================================================
;Author: tkovs
(defn solve []
(let [sum_square (reduce +' (map (fn [x] (* x x)) (range 1 101)))
square_sum (* (reduce +' (range 1 101)) (reduce +' (range 1 101)))]
(- square_sum sum_square)))
(println(solve))
================================================
FILE: Problem006/CommonLisp/solution_1.lisp
================================================
;; Common Lisp Script
;; Manoel Vilela
(defun square (x)
(* x x))
;; (1 2 3) => 1² + 2² + 3² => 14
(defun square-sum (list)
(reduce #'+ (mapcar #'square
list)))
;; (1 2 3) => (1 + 2 + 3)² => 6² => 36
(defun sum-square (list)
(square (reduce #'+ list)))
(defun solution(n)
(let ((numbers (loop for x from 1 to n collect x)))
(- (sum-square numbers)
(square-sum numbers))))
(format t "~a~%" (solution 100))
================================================
FILE: Problem006/Elixir/solution_1.exs
================================================
# Author: G4BB3R
x = 1..100 |> Enum.sum
|> :math.pow(2)
y = 1..100 |> Enum.to_list
|> Enum.map(&:math.pow(&1, 2))
|> Enum.sum
IO.puts round(x - y)
================================================
FILE: Problem006/Haskell/solution_1.hs
================================================
{-
The sum of the squares of the first ten natural numbers is,
12 + 22 + ... + 102 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)2 = 552 = 3025
Hence the difference between the sum of the squares of the first ten natural
numbers and the square of the sum is 3025 − 385 = 2640.
Find the difference between the sum of the squares of the first one hundred
natural numbers and the square of the sum.
-}
main :: IO ()
main = print $ ((sum [1..100]) ^ 2) - (sum $ map (\x -> x * x) [1..100])
================================================
FILE: Problem006/LaTeX/solution_1.tex
================================================
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath, amssymb, amsthm}
\usepackage{mathtools}
\usepackage{tabulary}
\usepackage{multirow}
\usepackage{polyglossia}
\title{Project Euler - Problem 6}
\date{}
\author{DestructHub}
\begin{document}
\maketitle
\section {Statement}
The sum of the squares of the first ten natural numbers is
$$ 1^2 + 2^2 + \ldots + 10^2 = 385 $$
The square of the sum of the first ten natural numbers is,
$$ (1 + 2 + \ldots + 10)^2 = 55^2 = 3025 $$
Hence the difference between the sum of the squares of the first ten natural
numbers and the square of the sum is $$ 3025 - 385 = 2640$$.
Find the difference between the sum of the squares of the first one hundred
natural numbers and the square of the sum.
\section{Solution}
We can use two simple formulae:
\begin{align*}
1+2+\ldots+n &= \frac{n(n+1)}{2}\\
1^2+2^2+\ldots+n^2 &= \frac{n(n+1)(2n+1)}{6}
\end{align*}
(They can be easily proved by Induction.)
Now it is a matter of simple calculations:
$$\left(\frac{n(n+1)}{2})^2\right) - \frac{n(n+1)(2n+1)}{6} = 5050^2-338350 = 25164150$$
\end{document}
%%% Compile with lualatex
%%% Local Variables:
%%% mode: latex
%%% coding: utf-8-unix
%%% fill-column: 80
%%% End:
================================================
FILE: Problem006/OCaml/solution_1.ml
================================================
let rec pow n x =
if n=0 then 1. else x *. pow (n-1) x;;
let f x = pow 2 (float_of_int ((x * (x + 1)) / 2))
let ff x = (x * (x + 1) * ((2 * x) + 1)) / 6
let solve n = -(ff n) + (int_of_float (f n))
let __kappa__ = solve 100;;
print_int(__kappa__);;
print_newline ();;
================================================
FILE: Problem006/Python/solution_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
#
# Python Script
#
# Copyleft © Manoel Vilela
#
#
from functools import reduce
from sys import version_info
if version_info >= (3, 0):
xrange = range
"""
Sum square difference
Problem 6
The sum of the squares of the first ten natural numbers is,
12 + 22 + ... + 102 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)2 = 552 = 3025
Hence the difference between the sum of the squares
of the first ten natural numbers and the square of the
sum is 3025 − 385 = 2640.
Find the difference between the sum of the squares of
the first one hundred natural numbers and the square of the sum
"""
print(reduce(lambda x, y: x + y, xrange(1, 101)) ** 2 - reduce(lambda x, y: x + y ** 2, xrange(1, 101)))
================================================
FILE: Problem006/Python/solution_2.py
================================================
#!/usr/bin/env python
# coding=utf-8
# remove unnecessary range in square of sum (solution inspired by Manoel Vilela)
from functools import reduce
from sys import version_info
if version_info >= (3, 0):
xrange = range
print(reduce(lambda x, y: x + y, xrange(1, 101)) ** 2 - ((100*101)/2))
================================================
FILE: Problem006/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=6)
================================================
FILE: Problem006/Ruby/solution_1.rb
================================================
#Author: tkovs
def solve
sum_square = (1..100).map{|x| x * x}.inject(:+)
square_sum = (1..100).inject(:+) * (1..100).inject(:+)
return(square_sum - sum_square)
end
puts(solve)
================================================
FILE: Problem006/Scheme/solution_1.scm
================================================
(define square-of-sum
(lambda (n)
(/ (* n n (+ n 1) (+ n 1)) 4)))
(define sum-of-squares
(lambda (n)
(/ (* n (+ n 1) (+ (* 2 n) 1)) 6)))
(define solve
(let ((input 100))
(- (square-of-sum input) (sum-of-squares input))))
(display solve)
(newline)
================================================
FILE: Problem006/go/solution_1.go
================================================
package main
import "fmt"
func sumOfSquare(max int) int {
result := 1
for i := 2; i <= max; i++ {
result += i * i
}
return result
}
func squareOfSum(max int) int {
number := (max * (max + 1)) / 2
return number * number
}
func main() {
number := 100
fmt.Println(squareOfSum(number) - sumOfSquare(number))
}
================================================
FILE: Problem007/.hash
================================================
8c32ab09ec0210af60d392e9b2009560
================================================
FILE: Problem007/C++/Makefile
================================================
CXX = g++
LFLAGS = -lm -Wall -std=c++0x -o
TARGET = solution_01
EXTENSION_TARGET = cpp
EXTENSION_OUT = out
all:
$(CXX) $(LFLAGS) $(TARGET).$(EXTENSION_OUT) $(TARGET).$(EXTENSION_TARGET)
clean:
rm -v *.$(EXTENSION_OUT)
run:
./$(TARGET).$(EXTENSION_OUT)
================================================
FILE: Problem007/C++/solution_1.cpp
================================================
/*
* Finds the 10001 prime number.
*/
#include <iostream>
#include <cstdlib>
bool is_prime(int n);
int main(int argc, char **argv)
{
int n = 0;
int prime_count = 1;
int limit = 10001;
if (argc > 1) {
limit = std::atoi(argv[1]);
}
while (prime_count <= limit) {
if (is_prime(n)) {
++prime_count;
}
n++;
}
std::cout << n-1 << std::endl;
return 0;
}
bool is_prime(int n)
{
if (n < 2) {
return false;
}
else if (n == 2 || n == 3) {
return true;
}
else if (n % 2 == 0) {
return false;
}
else {
for (int i = 2; i*i <= n; i++) {
if (n % i == 0) {
return false;
}
}
}
return true;
}
================================================
FILE: Problem007/Clojure/solution_1.clj
================================================
(defn is-prime
[n]
(if (or (= n 1) (= n 4))
false
(loop [candidates (range 2 (+ 1 (Math/sqrt n)))]
(cond
(empty? candidates) true
(= 0 (rem n (first candidates))) false
:else (recur (next candidates))))))
(defn next-prime
[n]
(loop [candidate n]
(if (is-prime candidate)
candidate
(recur (+ candidate 1)))))
(defn prime-seq
([] (prime-seq 2))
([n] (cons n (lazy-seq (prime-seq (next-prime (+' 1 n )))))))
(println (str (last (take 10001 (prime-seq)))))
================================================
FILE: Problem007/Clojure/solution_2.clj
================================================
(defn prime? [n]
(= 1 (->> (range 1 (inc (Math/sqrt n)))
(map (partial rem n))
(filter (partial = 0))
(count))))
(defn next-prime
[n]
(loop [candidate n]
(if (prime? candidate)
candidate
(recur (+ candidate 1)))))
(defn prime-seq
([] (prime-seq 2))
([n] (cons n (lazy-seq (prime-seq (next-prime (+' 1 n )))))))
(println (str (last (take 10001 (prime-seq)))))
================================================
FILE: Problem007/CommonLisp/solution_1.lisp
================================================
;; Common Lisp Script
;; Manoel Vilela
(defun primep (n)
(let ((divisors (loop for x from 2 to (floor (1+ (sqrt n)))
collect x)))
(loop for d in divisors
never (and (= (mod n d) 0)
(not (= n d))))))
(defun solution (n)
(loop for x from 2
count (primep x) into primes
while (< primes n)
finally (return x)))
(format t "~a~%" (solution 10001))
================================================
FILE: Problem007/Elixir/solution_2.exs
================================================
defmodule Solution do
def nth_prime(n) do
prime_sequence()
|> Stream.take(n)
|> Enum.to_list
|> List.last
end
def prime_sequence do
Stream.unfold(2, fn(x) ->
if(x |> prime?) do
{x, x+1}
else
{nil, x+1}
end
end)
|> Stream.reject(&is_nil/1)
end
def prime?(x) when x == 2, do: true
def prime?(x) when x in [1, 4], do: false
def prime?(x) do
2..round(:math.sqrt(x))
|> Enum.reduce_while(true, fn(e, _) ->
if(0 == rem(x, e)) do
{:halt, false}
else
{:cont, true}
end
end)
end
end
Solution.nth_prime(10_001) |> IO.puts
================================================
FILE: Problem007/Elixir/solution_slow_1.exs
================================================
# Author: G4BB3R
defmodule Problem007 do
def isPrime(1), do: false
def isPrime(2), do: true
def isPrime(3), do: true
def isPrime(n), do: (2..(n - 1)) |> Enum.find(fn x -> rem(n, x) == 0 end) |> (fn found -> found == nil end).()
def prime10001 , do: prime10001(1, 0)
defp prime10001(x, 10001), do: x + 1
defp prime10001(x, prime), do: prime10001(x + 1, prime + (if isPrime x do 1 else 0 end))
end
#Enum.map 1..100, &(IO.puts (Integer.to_string(&1) <> ": " <> (if Problem007.isPrime &1 do "SIM" else "NAO" end)))
IO.puts Problem007.prime10001
================================================
FILE: Problem007/Haskell/solution_1.hs
================================================
-- Author: G4BB3R
import Data.List (find)
import Data.Maybe (isNothing)
isPrime :: Int -> Bool
isPrime x
| x == 1 = False
| x <= 3 = True
| otherwise = isNothing $ find ((== 0) . rem x) [2..x - 1]
prime10001 :: Int
prime10001 = prime' 2 0 where
prime' x prime = if prime == 1001 then x + 1 else prime' (x + 1) (prime + (if isPrime x then 1 else 0))
main :: IO ()
main = print prime10001
================================================
FILE: Problem007/Lua/solution_1.lua
================================================
-- Author: G4BB3R
local function isPrime (n)
if n < 2 then
return false
elseif n == 2 or n == 3 then
return true
else
for i = 2, n - 1 do
if n % i == 0 then
return false
end
end
return true
end
end
local n = 0
local prime = nil
for i = 1, 9999999999 do
if isPrime(i) then
n = n + 1
end
if n == 10001 then
prime = i
break
end
end
print(prime)
================================================
FILE: Problem007/Python/primes.py
================================================
#!/usr/bin/env python
# coding=utf-8
#
# Python Script
#
# Copyleft © Manoel Vilela
#
#
from sys import version_info
if version_info > (3, 0):
xrange = range
def primeGen(n):
for i in xrange(2, n):
prime = True
if i % 2 == 0 and i != 2:
continue
sqrtp = int(i ** 1 / 2)
for j in xrange(2, sqrtp):
if j % 2 == 0:
continue
if i % j == 0:
prime = False
break
if prime:
yield i
def primeGenEff(n):
pp = 2
yield pp
pp += 1
tp = [pp]
ss = [2]
while pp < n:
pp += ss[0]
test = True
sqrtpp = pp ** 1/2
for a in tp:
if a > sqrtpp:
break
if pp % a == 0:
test = False
break
if test:
tp.append(pp)
yield pp
def sieve5(n):
"""Return a list of the primes below n."""
prime = [True] * n
result = [2]
append = result.append
sqrt_n = (int(n ** .5) + 1) | 1 # ensure it's odd
for p in range(3, sqrt_n, 2):
if prime[p]:
append(p)
prime[p*p::2*p] = [False] * ((n - p*p - 1) // (2*p) + 1)
for p in range(sqrt_n, n, 2):
if prime[p]:
append(p)
return result
================================================
FILE: Problem007/Python/solution_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
#
# Python Script
#
# Copyleft © Manoel Vilela
#
#
"""
10001st prime
Problem 7
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10 001st prime number?
"""
from primes import primeGenEff
for p, i in enumerate(primeGenEff(1000000000000)):
if p == 10001:
print(i)
break
================================================
FILE: Problem007/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=7)
================================================
FILE: Problem007/Scheme/solution_1.scm
================================================
(require srfi/9) ;; Records
;; begin record :listcount
(define-record-type :listcount
(listcount lst cnt)
listcount?
(lst lst set-lst!)
(cnt cnt set-cnt!))
(define listcount-car
(lambda (lc)
(car (lst lc))))
(define listcount-cdr
(lambda (lc)
(let ((new-lc-lst (cdr (lst lc)))
(new-lc-cnt (- (cnt lc) 1)))
(listcount new-lc-lst new-lc-cnt))))
(define listcount-null?
(lambda (lc)
(= (cnt lc) 0)))
(define listcount-init
(listcount '() 0))
(define append-into-listcount
(lambda (n lc)
(let ((new-lc-lst (append (lst lc) (list n)))
(new-lc-cnt (+ 1 (cnt lc))))
(listcount new-lc-lst new-lc-cnt))))
;; end record :listcount
(define square
(lambda (n) (* n n)))
(define listcount-has-useful-divisor?
(lambda (n lc)
(cond
((listcount-null? lc) #f)
((< n (square (listcount-car lc))) #f)
((= (remainder n (listcount-car lc)) 0) #t)
(else (listcount-has-useful-divisor? n (listcount-cdr lc))))))
;; begin record :sieve
(define-record-type :sieve
(sieve last-unchecked primes)
sieve?
(last-unchecked last-unchecked set-last-unchecked!)
(primes primes set-primes!)) ;; primes is a listcount
(define sieve-init
(sieve 5
(listcount '(2 3) 2)))
;; end record :sieve
(define next-sieve
(lambda (S)
(let* ((n (last-unchecked S))
(old-primes (primes S))
(test-lc (listcount-cdr old-primes)))
(if (listcount-has-useful-divisor? n test-lc)
(sieve (+ n 2) old-primes)
(sieve (+ n 2) (append-into-listcount n old-primes))))))
(define next-sieve-prime
(lambda (S)
(let ((next-S (next-sieve S)))
(cond
((= (cnt (primes S)) (cnt (primes next-S)))
(next-sieve-prime next-S))
(else next-S)))))
(define collect-primes-acc
(lambda (S-acc limit)
(cond
((not (> limit (cnt (primes S-acc)))) S-acc)
(else (collect-primes-acc (next-sieve-prime S-acc) limit)))))
(define collect-primes
(lambda (n)
(collect-primes-acc sieve-init n)))
(define solve
(let ((input 10001))
(- (last-unchecked (collect-primes input)) 2)))
(display solve)
(newline)
================================================
FILE: Problem008/.hash
================================================
0f53ea7949d32ef24f9186207600403c
================================================
FILE: Problem008/Clojure/solution_slow_1.clj
================================================
(def bignumber "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450")
(defn solution
[]
(->> (partition 13 1 bignumber)
(remove #(some (partial = \0) %))
(map (partial map #(Character/digit % 10)))
(pmap (partial reduce *'))
(apply max)))
(println (solution))
================================================
FILE: Problem008/CommonLisp/solution_1.lisp
================================================
;; Common Lisp Script
;; Manoel Vilela
(defparameter *big-num* "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450")
(defparameter *partitions* 13)
(defun partitions (s n)
(loop for x from 0 to (- (length s) n)
collect (subseq s x (+ x n))))
(defun str->list-of-digits (s)
(loop for x in (partitions s 1) collect (parse-integer x)))
(defun eval-digits (s)
(reduce #'* (str->list-of-digits s)))
(defun solution (str n-partitions)
(loop for s in (partitions str n-partitions)
maximize (eval-digits s)))
(format t "~a~%" (solution *big-num* *partitions*))
================================================
FILE: Problem008/Elixir/solution_1.exs
================================================
# Author: lubien
data = "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450"
|> String.graphemes
|> Enum.map(&String.to_integer/1)
for i <- 0..(length(data) - 12) do
Enum.slice(data, i..(i + 12))
|> Enum.reduce(1, &(&1 * &2))
end
|> Enum.max
|> IO.puts
================================================
FILE: Problem008/Haskell/solution_1.hs
================================================
list :: String
list = "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450"
pt :: Int
pt = 13 -- ué
split_list :: String -> [String]
split_list list
| length list > pt = [(take pt list)] ++ split_list (tail list)
| otherwise = [list]
product_list :: String -> Integer
product_list = product . map (read . (: []))
main :: IO ()
main = do
print . maximum . map product_list . split_list $ list
================================================
FILE: Problem008/Python/solution_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
#
# Python Script
#
# Copyleft © Manoel Vilela
#
#
from functools import reduce
"""
Largest product in a series
Problem 8
The four adjacent digits in the 1000-digit number
that have the greatest product are 9 × 9 × 8 × 9 = 5832.
Find the thirteen adjacent digits in the 1000-digit number that have the greatest product.
What is the value of this product?
"""
data = '''\
73167176531330624919225119674426574742355349194934\
96983520312774506326239578318016984801869478851843\
85861560789112949495459501737958331952853208805511\
12540698747158523863050715693290963295227443043557\
66896648950445244523161731856403098711121722383113\
62229893423380308135336276614282806444486645238749\
30358907296290491560440772390713810515859307960866\
70172427121883998797908792274921901699720888093776\
65727333001053367881220235421809751254540594752243\
52584907711670556013604839586446706324415722155397\
53697817977846174064955149290862569321978468622482\
83972241375657056057490261407972968652414535100474\
82166370484403199890008895243450658541227588666881\
16427171479924442928230863465674813919123162824586\
17866458359124566529476545682848912883142607690042\
24219022671055626321111109370544217506941658960408\
07198403850962455444362981230987879927244284909188\
84580156166097919133875499200524063689912560717606\
05886116467109405077541002256983155200055935729725\
71636269561882670428252483600823257530420752963450\
'''
#method 1
# greatest = int()
# for i in range(len(data) - 13):
# product = reduce(lambda x, y: x*y, [int(x) for x in data[i:i + 13]])
# if product > greatest:
# greatest = product
# print greatest
# method 2
def product(num): return reduce(lambda x, y: x * y, [int(digit) for digit in num])
print(max([product(data[i:i + 13]) for i in range(len(data) - 13)]))
================================================
FILE: Problem008/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=8)
================================================
FILE: Problem009/.hash
================================================
24eaa9820350012ff678de47cb85b639
================================================
FILE: Problem009/CommonLisp/solution_1.lisp
================================================
;; Common Lisp Script
;; Manoel Vilela
(defun pythagorean (a b c)
(= (+ (* a a)
(* b b))
(* c c)))
(defun solution()
(loop for a from 1 to 998 do
(loop for b from a to 998 do
(loop for c from b to 998
when (and (= 1000 (+ a b c))
(pythagorean a b c))
do (return-from solution (* a b c))))))
(format t "~a~%" (solution))
================================================
FILE: Problem009/Elixir/solution_1.exs
================================================
# Author: lubien
for a <- 1..444,
b <- 1..444,
c <- [1000 - b - a],
a * a + b * b == c * c
do a * b * c end
|> List.first
|> IO.puts
================================================
FILE: Problem009/Haskell/solution_1.hs
================================================
-- Author: G4BB3R
-- Help: tkovs
triangulo = head [(a, b, c) | a <- [1..444], b <- [a..444], c <- [1000 - b - a], a ^ 2 + b ^ 2 == c ^ 2]
main = print $ let (a, b, c) = triangulo in a * b * c
================================================
FILE: Problem009/Python/solution_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
# Python Script
#
# Copyleft © Manoel Vilela
#
#
from __future__ import print_function
"""
Special Pythagorean triplet
Problem 9
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a² + b² = c²
For example, 3² + 4² = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
"""
def decompSum(n):
from itertools import combinations
m = (x for x in range(1, n // 2))
div = [3, 4, 5]
comb = combinations((x for x in m if any(d for d in div if not x % d)), 3)
for a, b, c in comb:
if a + b + c == n and a != b != c:
yield sorted((a, b, c))
def pythagorean(a, b, c):
return (a ** 2 + b ** 2) == c ** 2
def problem9(n):
for a, b, c in decompSum(n):
if pythagorean(a, b, c):
return a * b * c
print(problem9(1000))
================================================
FILE: Problem009/Python/solution_2.py
================================================
#code created by NamanNimmo Gera
#11:32am, April 30, 2019.
for i in range(1,1000):
for j in range(i+1,1000):
k = 1000 - i - j
if i ** 2 + j ** 2 == k ** 2: break
if i**2 + j**2 == k**2: break
print(i*j*k)
================================================
FILE: Problem009/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=9)
================================================
FILE: Problem009/Ruby/solution_1.rb
================================================
#Author: tkovs
def solve
x = (1..444)
x.each{|a| x.each{|b| [1000 - b - a].each{|c| return (a * b * c) if (a*a + b*b == c*c)}}}
end
puts(solve)
================================================
FILE: Problem010/.hash
================================================
d915b2a9ac8749a6b837404815f1ae25
================================================
FILE: Problem010/C++/Makefile
================================================
CXX = g++
LFLAGS = -lm -Wall -o
TARGET = solution_1
EXTENSION_TARGET = cpp
EXTENSION_OUT = out
all:
$(CXX) $(LFLAGS) $(TARGET).$(EXTENSION_OUT) $(TARGET).$(EXTENSION_TARGET)
clean:
rm -v *.$(EXTENSION_OUT)
run:
./$(TARGET).$(EXTENSION_OUT)
================================================
FILE: Problem010/C++/solution_1.cpp
================================================
/**
* C++ algorithm to get the sum of all prime numbers between a range of 2 and the number desired.
*/
#include <iostream>
#include <cstdlib>
bool is_prime(unsigned int number);
int main(int argc, char* argv[])
{
const char *num = "2000000";
if (argv[1]) {
num = argv[1];
}
// iteration variables.
int i = 1;
// the number to reach.
int number_to = std::atoi(num);
long long int sum = 0;
while (i < number_to) {
if (is_prime(i)) {
sum += i;
}
i++;
}
std::cout << sum << std::endl;
return 0;
}
bool is_prime(unsigned int number)
{
if (number <= 1) {
return false;
}
unsigned int i;
for (i = 2; i * i <= number; i++) {
if (number % i == 0) {
return false;
}
}
// naive solution
/*for (i = 2; i < 10; i++) {
if (number % i == 0)
return false;
}*/
return true;
}
================================================
FILE: Problem010/Clojure/solution_1.clj
================================================
(defn prime? [n]
(.isProbablePrime (BigInteger/valueOf n) 10))
(defn next-prime
[n]
(loop [candidate n]
(if (prime? candidate)
candidate
(recur (+ candidate 1)))))
(defn prime-seq
([] (prime-seq 2))
([n] (cons n (lazy-seq (prime-seq (next-prime (+' 1 n )))))))
(->> (prime-seq)
(take-while (partial > 2000000))
(reduce +)
(println))
================================================
FILE: Problem010/CommonLisp/solution_1.lisp
================================================
;; Common Lisp Script
;; Manoel Vilela
(defun primep (n)
(loop for d from 2 to (floor (1+ (sqrt n)))
never (and (= (mod n d) 0)
(not (= n d)))))
(defun solution (limit)
(+ 2 (loop for x from 3 by 2
for prime? = (primep x)
count prime? into primes
while (< x limit)
when prime? sum x)))
(format t "~a~%" (solution 2000000))
================================================
FILE: Problem010/Haskell/solution_slow_1.hs
================================================
-- Author: G4BB3R
-- Performance: 7643.2s (How to improve ?)
primes :: [Int]
primes = sieve [2..]
where sieve :: [Int] -> [Int] ;
sieve (p:xs) = p : sieve [x | x <- xs, x `rem` p /= 0] ;
sieve [] = []
main :: IO ()
main = print $ sum $ takeWhile (< 2000000) primes
================================================
FILE: Problem010/Haskell/solution_slow_2.hs
================================================
-- Author: G4BB3R
-- Performance: 38.8s (Improved: 196x faster)
primes = 2 : ([3..] `minus` composites)
where composites = union [multiples p | p <- primes]
multiples n = map (n*) [n..]
(x:xs) `minus` (y:ys) | x < y = x : (xs `minus` (y : ys))
| x == y = xs `minus` ys
| x > y = (x : xs) `minus` ys
union = foldr merge []
where
merge (x : xs) ys = x : merge' xs ys
merge' (x : xs) (y : ys) | x < y = x : merge' xs (y : ys)
| x == y = x : merge' xs ys
| x > y = y : merge' (x : xs) ys
main :: IO ()
main = print $ sum $ takeWhile (< 2000000) primes
================================================
FILE: Problem010/Python/primes.py
================================================
def prime_gen(n):
for i in xrange(2, n):
prime = True
if i % 2 == 0 and i != 2:
continue
sqrtp = int(i ** 1 / 2)
for j in xrange(2, sqrtp):
if j % 2 == 0:
continue
if i % j == 0:
prime = False
break
if prime:
yield i
def prime_gen_eff(n):
pp = 2
yield pp
pp += 1
tp = [pp]
ss = [2]
while pp < n:
pp += ss[0]
test = True
sqrtpp = pp ** 1/2
for a in tp:
if a > sqrtpp:
break
if pp % a == 0:
test= False
break
if test:
tp.append(pp)
yield pp
def primes_list(lim):
from math import sqrt
""" Get an upper limit from the user to determine the generator's termination point. """
sqrtlim=sqrt(float(lim))
""" Get the square root of the upper limit. This will be the upper limit of the test prime array
for primes used to verify the primacy of any potential primes up to (lim). Primes greater than
(sqrtlim) will be placed in an array for extended primes, (xp), not needed for the verification
test. The use of an extended primes array is technically unnecessary, but helps to clarify that we
have minimized the size of the test prime array. """
pp=2
""" Initialize the variable for the potential prime, setting it to begin with the first prime
number, (2). """
ss=[pp]
""" Initialize the array for the skip set, setting it at a single member, being (pp=2). Although
the value of the quantity of members in the skip set is never needed in the program, it may be
useful to understand that future skip sets will contain more than one member, the quantity of which
can be calculated, and is the quantity of members of the previous skip set multiplied by one less
than the value of the prime which the new skip set will exclude multiples of. Example - the skip
set which eliminates multiples of primes up through 3 will have (3-1)*1=2 members, since the
previous skip set had 1 member. The skip set which eliminates multiples of primes up through 5 will
have (5-1)*2=8 members, since the previous skip set had 2 members, etc. """
ep=[pp]
""" Initialize the array for primes which the skip set eliminate multiples of, setting the first
member as (pp=2) since the first skip set will eliminate multiples of 2 as potential primes. """
pp+=1
""" Advance to the first potential prime, which is 3. """
rss=[ss[0]]
""" Initialize an array for the ranges of each skip set, setting the first member to be the range
of the first skip set, which is (ss[0]=2). Future skip sets will have ranges which can be
calculated, and are the sum of the members of the skip set. Another method of calculating the range
will also be shown below. """
tp=[pp]
""" Initialize an array for primes which are needed to verify potential primes against, setting the
first member as (pp=3), since we do not yet have a skip set that excludes multiples of 3. Also note
that 3 is a verified prime, without testing, since there are no primes less than the square root of
3. """
i=0
""" Initialize a variable for keeping track of which skip set range is current. """
rss.append(rss[i]*tp[0])
""" Add a member to the array of skip set ranges, the value being the value of the previous skip
set range, (rss[0]=2), multiplied by the value of the largest prime which the new skip set will
exclude multiples of, (tp[0]=3), so 2*3=6. This value is needed to define when to begin
constructing the next skip set. """
xp=[]
""" Initialize an array for extended primes which are larger than the square root of the user
defined limit (lim) and not needed to verify potential primes against, leaving it empty for now.
Again, the use of an extended primes array is technically unnecessary, but helps to clarify that we
have minimized the size of the test prime array. """
pp+=ss[0]
""" Advance to the next potential prime, which is the previous potential prime, (pp=3), plus the
value of the next member of the skip set, which has only one member at this time and whose value is
(ss[0]=2), so 3+2=5. """
npp=pp
""" Initialize a variable for the next potential prime, setting its value as (pp=5). """
tp.append(npp)
""" Add a member to the array of test primes, the member being the most recently identified prime,
(npp=5). Note that 5 is a verified prime without testing, since there are no TEST primes less than
the square root of 5. """
while npp<int(lim):
""" Loop until the user defined upper limit is reached. """
i+=1
""" Increment the skip set range identifier. """
while npp<rss[i]+1:
""" Loop until the next skip set range is surpassed, since data through that range is
needed before constructing the next skip set. """
for n in ss:
""" Loop through the current skip set array, assigning the variable (n) the value
of the next member of the skip set. """
npp=pp+n
""" Assign the next potential prime the value of the potential prime plus
the value of the current member of the skip set. """
if npp>int(lim): break
""" If the next potential prime is greater than the user defined limit,
then end the 'for n' loop. """
if npp<=rss[i]+1: pp=npp
""" If the next potential prime is still within the range of the next skip
set, then assign the potential prime variable the value of the next
potential prime. Otherwise, the potential prime variable is not changed
and the current value remains the starting point for constructing the next
skip set. """
sqrtnpp=sqrt(npp)
""" Get the square root of the next potential prime, which will be the
limit for the verification process. """
test=True
""" Set the verification flag to True. """
for q in tp:
""" Loop through the array of the primes necessary for verification of the
next potential prime. """
if sqrtnpp<q: break
elif npp % q == 0:
""" If the test prime IS a factor of the next potential prime. """
test=False
""" Then set the verification flag to False since the next
potential prime is not a prime number. """
break
""" And end testing through the 'for q' loop. """
""" Otherwise, continue testing through the 'for q' loop. """
if test:
""" If the next potential prime has been verified as a prime number. """
if npp<=sqrtlim: tp.append(npp)
else: xp.append(npp)
""" Otherwise, add it to the array of primes not needed to verify
potential primes against. """
""" Then continue through the 'for n' loop. """
if npp>int(lim): break
""" If the next potential prime is greater than the user defined limit, then end
the 'while npp<rss[i]+1' loop. """
""" Otherwise, continue the 'while npp<rss[i]+1' loop. """
if npp>int(lim): break
""" If the next potential prime is greater than the user defined limit, then end the 'while
npp<int(lim)' loop. """
""" At this point, the range of the next skip set has been reached, so we may begin
constructing a new skip set which will exclude multiples of primes up through the value of
the first member of the test prime set, (tp[0]), from being selected as potential
primes. """
lrpp=pp
""" Initialize a variable for the last relevant potential prime and set its value to the
value of the potential prime. """
nss=[]
""" Initialize an array for the next skip set, leaving it empty for now. """
while pp<(rss[i]+1)*2-1:
""" Loop until the construction of the new skip set has gone through the range of the new
skip set. """
for n in ss:
""" Loop through the current skip set array. """
npp=pp+n
""" Assign the next potential prime the value of the potential prime plus
the value of the current member of the skip set. """
if npp>int(lim): break
""" If the next potential prime is greater than the user defined limit,
then end the 'for n' loop. """
sqrtnpp=sqrt(npp)
""" Get the square root of the next potential prime, which will be the
limit for the verification process. """
test=True
""" Set the verification flag to True. """
for q in tp:
""" Loop through the array of the primes necessary for verification of the
next potential prime. """
""" If the test prime is greater than the square root of the next
potential prime, then end testing through the 'for q' loop. """
if sqrtnpp<q: break
elif npp%q==0:
""" If the test prime IS a factor of the next potential prime. """
test=False
""" Then set the verification flag to False since the next
potential prime is not a prime number. """
break
""" And end testing through the 'for q' loop. """
""" Otherwise, continue testing through the 'for q' loop. """
if test:
""" If the next potential prime has been verified as a prime number. """
if npp<=sqrtlim: tp.append(npp)
else: xp.append(npp)
""" And if the next potential prime is less than or equal to the
square root of the user defined limit, then add it to the array of
primes which potential primes must be tested against. """
""" Otherwise, add it to the array of primes not needed to verify
potential primes against. """
if npp%tp[0]!=0:
""" If the next potential prime was NOT factorable by the first member of
the test array, then it is relevant to the construction of the new skip set
and a member must be included in the new skip set for a potential prime to
be selected. Note that this is the case regardless of whether the next
potential prime was verified as a prime, or not. """
nss.append(npp-lrpp)
""" Add a member to the next skip set, the value of which is the
difference between the last relevant potential prime and the next
potential prime. """
lrpp=npp
""" Assign the variable for the last relevant potential prime the
value of the next potential prime. """
pp=npp
""" Assign the variable for the potential prime the value of the next
potential prime. """
""" Then continue through the 'for n' loop. """
if npp>int(lim): break
""" If the next potential prime is greater than the user defined limit, then end
the 'while npp<(rss[i]+1)*2-1' loop. """
""" Otherwise, continue the 'while npp<(rss[i]+1)*2-1' loop. """
if npp>int(lim): break
""" If the next potential prime is greater than the user defined limit, then end the 'while
npp<int(lim)' loop. """
ss=nss
""" Assign the skip set array the value of the new skip set array. """
ep.append(tp[0])
""" Add a new member to the excluded primes array, since the newly constructed skip set
will exclude all multiples of primes through the first member of the test prime array. """
del tp[0]
""" Delete the first member from the test prime array since future potential primes will
not have to be tested against this prime. """
rss.append(rss[i]*tp[0])
""" Add a member to the skip set range array with the value of the range of the next skip
set. """
npp=lrpp
""" Assign the next potential prime the value of the last relevant potential prime. """
""" Then continue through the 'while npp<int(lim)' loop. """
""" At this point the user defined upper limit has been reached and the generator has completed
finding all of the prime numbers up to the user defined limit. """
ep.reverse()
""" Flip the array of excluded primes. """
[tp.insert(0,a) for a in ep]
""" Add each member of the flipped array into the beginning of the test primes array. """
tp.reverse()
""" Flip the array of test primes. """
[xp.insert(0,a) for a in tp]
""" Add each member of the flipped array into the beginning of the extended primes array. """
return xp
""" Send the completed array of all primes up to the user defined limit back to the function call. """
def sieve5(n):
"""Return a list of the primes below n."""
"""from http://codereview.stackexchange.com/questions/42420/sieve-of-eratosthenes-python"""
prime = [True] * n
result = [2]
append = result.append
sqrt_n = (int(n ** .5) + 1) | 1 # ensure it's odd
for p in range(3, sqrt_n, 2):
if prime[p]:
append(p)
prime[p*p::2*p] = [False] * ((n - p*p - 1) // (2*p) + 1)
for p in range(sqrt_n, n, 2):
if prime[p]:
append(p)
return result
================================================
FILE: Problem010/Python/solution_1.py
================================================
#!/usr/bin/env python2
# coding=utf-8
"""
Summation of primes
Problem 10
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
"""
from primes import primes_list
from functools import reduce
print(reduce(lambda x, y: x + y, primes_list(2000000)))
================================================
FILE: Problem010/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=10)
================================================
FILE: Problem011/.hash
================================================
678f5d2e1eaa42f04fa53411b4f441ac
================================================
FILE: Problem011/C++/solution_1.cpp
================================================
#include <iostream>
using namespace std;
int main()
{
int i,j,max=0,pro;
int a[20][20]={
{8,2,22,97,38,15,0,40,0,75,4,5,7,78,52,12,50,77,91,8},
{49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,4,56,62,0},
{81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,3,49,13,36,65},
{52,70,95,23,4,60,11,42,69,24,68,56,1,32,56,71,37,2,36,91},
{22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80},
{24,47,32,60,99,3,45,2,44,75,33,53,78,36,84,20,35,17,12,50},
{32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70},
{67,26,20,68,2,62,12,20,95,63,94,39,63,8,40,91,66,49,94,21},
{24,55,58,5,66,73,99,26,97,17,78,78,96,83,14,88,34,89,63,72},
{21,36,23,9,75,0,76,44,20,45,35,14,0,61,33,97,34,31,33,95},
{78,17,53,28,22,75,31,67,15,94,3,80,4,62,16,14,9,53,56,92},
{16,39,5,42,96,35,31,47,55,58,88,24,0,17,54,24,36,29,85,57},
{86,56,0,48,35,71,89,7,5,44,44,37,44,60,21,58,51,54,17,58},
{19,80,81,68,5,94,47,69,28,73,92,13,86,52,17,77,4,89,55,40},
{4,52,8,83,97,35,99,16,7,97,57,32,16,26,26,79,33,27,98,66},
{88,36,68,87,57,62,20,72,3,46,33,67,46,55,12,32,63,93,53,69},
{4,42,16,73,38,25,39,11,24,94,72,18,8,46,29,32,40,62,76,36},
{20,69,36,41,72,30,23,88,34,62,99,69,82,67,59,85,74,4,36,16},
{20,73,35,29,78,31,90,1,74,31,49,71,48,86,81,16,23,57,5,54},
{1,70,54,71,83,51,54,69,16,92,33,48,61,43,52,1,89,19,67,48}};
for(i=0;i<17;++i)
{
for(j=0;j<20;++j)
{
pro=a[i][j]*a[i+1][j]*a[i+2][j]*a[i+3][j];
if(max<pro){
max=pro;
}
}
}
for(i=0;i<20;++i)
{
for(j=0;j<17;++j)
{
pro=a[i][j]*a[i][j+1]*a[i][j+2]*a[i][j+3];
if(max<pro){
max=pro;
}
}
}
for(i=0;i<17;++i)
{
for(j=0;j<17;++j)
{
pro=a[i][j]*a[i+1][j+1]*a[i+2][j+2]*a[i+3][j+3];
if(max<pro){
max=pro;
}
}
}
for(i=19;i>3;--i)
{
for(j=0;j<17;++j)
{
pro=a[i][j]*a[i-1][j+1]*a[i-2][j+2]*a[i-3][j+3];
if(max<pro){
max=pro;
}
}
}
cout<<max;
return 0;
}
================================================
FILE: Problem011/Elixir/solution_1.exs
================================================
master_grid_array = "08,02,22,97,38,15,00,40,00,75,04,05,07,78,52,12,50,77,91,08,
49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,04,56,62,00,
81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,03,49,13,36,65,
52,70,95,23,04,60,11,42,69,24,68,56,01,32,56,71,37,02,36,91,
22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80,
24,47,32,60,99,03,45,02,44,75,33,53,78,36,84,20,35,17,12,50,
32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70,
67,26,20,68,02,62,12,20,95,63,94,39,63,08,40,91,66,49,94,21,
24,55,58,05,66,73,99,26,97,17,78,78,96,83,14,88,34,89,63,72,
21,36,23,09,75,00,76,44,20,45,35,14,00,61,33,97,34,31,33,95,
78,17,53,28,22,75,31,67,15,94,03,80,04,62,16,14,09,53,56,92,
16,39,05,42,96,35,31,47,55,58,88,24,00,17,54,24,36,29,85,57,
86,56,00,48,35,71,89,07,05,44,44,37,44,60,21,58,51,54,17,58,
19,80,81,68,05,94,47,69,28,73,92,13,86,52,17,77,04,89,55,40,
04,52,08,83,97,35,99,16,07,97,57,32,16,26,26,79,33,27,98,66,
88,36,68,87,57,62,20,72,03,46,33,67,46,55,12,32,63,93,53,69,
04,42,16,73,38,25,39,11,24,94,72,18,08,46,29,32,40,62,76,36,
20,69,36,41,72,30,23,88,34,62,99,69,82,67,59,85,74,04,36,16,
20,73,35,29,78,31,90,01,74,31,49,71,48,86,81,16,23,57,05,54,
01,70,54,71,83,51,54,69,16,92,33,48,61,43,52,01,89,19,67,48"
defmodule GridProduct do
def search_grid(grid) do
horiz_to_right = grid
|> String.split("\n",trim: true)
|> Enum.map(fn x -> map_list_to_i(String.split(x,",",trim: true)) end)
down_right_diag = rev_transpose(0..19,horiz_to_right)
combinations(horiz_to_right,down_right_diag,0,0,0)
end
def combinations(_,_,outer,_,final) when outer > 19, do: final
def combinations(horiz,diag,outer,inner,final) when inner <= 19 do
final = find_val(horiz,diag,inner,outer,final)
combinations(horiz,diag,outer,inner+1,final)
end
def combinations(horiz,diag,outer,inner,final) when outer <= 19 do
final = find_val(horiz,diag,inner,outer,final)
combinations(horiz,diag,outer+1,0,final)
end
def find_val(horiz,diag,inner,outer,final) do
val_h = find_product_h(horiz,inner,outer)
val_d = find_product_d(diag,inner,outer)
cond do
val_h > final && val_h > val_d ->
val_h
val_d > final && val_d > val_h ->
val_d
val_d < final && val_h < final ->
final
end
end
def find_product_h(grid,col,row) do
grid
|> coord_vals([[row,col],[row,col+1],[row,col+2],[row,col+3]])
|> Enum.reduce(1, fn a,b -> a * b end)
end
def find_product_d(grid,col,row) do
grid
|> coord_vals([[row,col],[row+1,col+1],[row+2,col+2],[row+3,col+3]])
|> Enum.reduce(1, fn a,b -> a * b end)
end
def coord_vals(l,i) do
i |> Stream.map(fn t_i -> coord_val(l, Enum.at(t_i,0), Enum.at(t_i,1)) end)
end
def coord_val(a,b,c) do
a |> Enum.at(b,[]) |> Enum.at(c,0)
end
def map_list_to_i(a) do
Enum.map(a, fn b -> String.to_integer(b) end)
end
def rev_transpose(a,b) do
Enum.map(a, fn x -> Enum.reverse(Enum.map(b, fn y -> Enum.at(y,x) end)) end)
end
end
IO.puts GridProduct.search_grid(master_grid_array)
================================================
FILE: Problem011/Haskell/solution_1.hs
================================================
list = [08,02,22,97,38,15,00,40,00,75,04,05,07,78,52,12,50,77,91,08,
49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,04,56,62,00,
81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,03,49,13,36,65,
52,70,95,23,04,60,11,42,69,24,68,56,01,32,56,71,37,02,36,91,
22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80,
24,47,32,60,99,03,45,02,44,75,33,53,78,36,84,20,35,17,12,50,
32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70,
67,26,20,68,02,62,12,20,95,63,94,39,63,08,40,91,66,49,94,21,
24,55,58,05,66,73,99,26,97,17,78,78,96,83,14,88,34,89,63,72,
21,36,23,09,75,00,76,44,20,45,35,14,00,61,33,97,34,31,33,95,
78,17,53,28,22,75,31,67,15,94,03,80,04,62,16,14,09,53,56,92,
16,39,05,42,96,35,31,47,55,58,88,24,00,17,54,24,36,29,85,57,
86,56,00,48,35,71,89,07,05,44,44,37,44,60,21,58,51,54,17,58,
19,80,81,68,05,94,47,69,28,73,92,13,86,52,17,77,04,89,55,40,
04,52,08,83,97,35,99,16,07,97,57,32,16,26,26,79,33,27,98,66,
88,36,68,87,57,62,20,72,03,46,33,67,46,55,12,32,63,93,53,69,
04,42,16,73,38,25,39,11,24,94,72,18,08,46,29,32,40,62,76,36,
20,69,36,41,72,30,23,88,34,62,99,69,82,67,59,85,74,04,36,16,
20,73,35,29,78,31,90,01,74,31,49,71,48,86,81,16,23,57,05,54,
01,70,54,71,83,51,54,69,16,92,33,48,61,43,52,01,89,19,67,48] :: [Int]
type Coord = (Int, Int)
type Way = [Coord]
type Table = [[Int]]
-- slice a simple list to a list of sublists
slice :: Int -> [Int] -> Table
slice size [] = []
slice size xs = [take size xs] ++ slice size (drop size xs)
-- left-up right-down
lurd :: Int -> Int -> [Way]
lurd limit len = [[(x,y), (x+1,y+1), (x+2,y+2), (x+3,y+3)] | x <- [0..limit - len], y <- [0..limit - len]]
-- left-down right-up
ldru :: Int -> Int -> [Way]
ldru limit len = [[(x,y), (x+1,y-1), (x+2,y-2), (x+3,y-3)] | x <- [0..limit-len], y <- [len..limit-1]]
-- left right
lr :: Int -> Int -> [Way]
lr limit len = [[(x,y), (x,y+1), (x,y+2), (x,y+3)] | x <- [0..limit-1], y <- [0..limit-len]]
-- up down
ud :: Int -> Int -> [Way]
ud limit len = [[(x,y), (x+1,y), (x+2,y), (x+3,y)] | x <- [0..limit-len], y <- [0..limit-1]]
-- receives a list of coords and return the matching value in the table
get_values :: Way -> Table -> [Int]
get_values _ [] = []
get_values [] _ = []
get_values ((x,y):xs) table = ((table !! x) !! y) : get_values xs table
main :: IO ()
main = do
let table = slice 20 list
let coords = (lurd 20 4) ++ (ldru 20 4) ++ (lr 20 4) ++ (ud 20 4)
let values = [get_values way table | way <- coords]
let result = maximum . map product
print . result $ values
================================================
FILE: Problem011/Python/solution_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
# Python Script
#
# Copyleft © Manoel Vilela
#
#
import sys
if sys.version_info >= (3, 0):
from functools import reduce
grid = """08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21
24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72
21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95
78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92
16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57
86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58
19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40
04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66
88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69
04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36
20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16
20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54
01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48"""
def arrowsSearch(matrix, n):
x_len, y_len = len(matrix[0]), len(matrix)
points = []
for y in range(x_len):
for x in range(y_len):
# arrows in diagonals:
# (down-up - left-right)
if abs(x - x_len) >= n and abs(y - y_len) >= n:
points.append([(x + d, y + d) for d in range(0, n)])
# (up-down - left-right)
# y > x because i want just the left-right diagonals
if abs((x - y) - (x_len - y_len)) + 1 >= n and y > x:
points.append([(d, y - (d - x)) for d in range(x, x + n)])
# arrows in vertical and horizontal:
# left-right
if abs(x - x_len) >= n:
points.append([(new_x, y) for new_x in range(x, x + n)])
# down-up
if abs(y - y_len) >= n:
points.append([(x, new_y) for new_y in range(y, y + n)])
return points
def solution(grid, arrow_length):
grid = [x for x in map(lambda line: [int(num) for num in line],
[y.split() for y in [x for x in grid.split('\n')]])]
arrows = arrowsSearch(grid, arrow_length)
answer = max(map(lambda arrow:
reduce(lambda a, b: a * b, [grid[y][x] for x, y in arrow]), arrows))
return answer
print(solution(grid, 4))
================================================
FILE: Problem011/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=11)
================================================
FILE: Problem012/.hash
================================================
8091de7d285989bbfa9a2f9f3bdcc7c0
================================================
FILE: Problem012/C++/solution_1.cpp
================================================
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000000
#define LL long long int
LL countDivisors(LL n)
{
LL cnt = 0;
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
if (n / i == i) cnt++;
else cnt+=2;
}
}
return cnt;
}
int main()
{
LL i;
for(i=1;i<MAX;i++)
{
LL a = (i*(i+1))/2;
LL k = countDivisors(a);
if(k>500)
{
printf("%lld\n",a);
break;
}
}
return 0;
}
================================================
FILE: Problem012/Elixir/solution_1.exs
================================================
# Author: lubien
defmodule Euler12 do
def solve do
Stream.iterate(1, &(&1 + 1))
|> Stream.scan(&(&1 + &2))
|> Stream.drop_while(fn i -> count_divisors(i) < 500 end)
|> Enum.take(1)
|> hd
end
def count_divisors(n) do
sqrt = :math.sqrt(n)
count = 1..(round(sqrt))
|> Stream.filter(fn i -> rem(n, i) == 0 end)
|> Enum.count
if sqrt * sqrt == n do
count * 2
else
count * 2 - 1
end
end
end
Euler12.solve
|> IO.puts
================================================
FILE: Problem012/Haskell/solution_1.hs
================================================
triangleList :: [Int]
--triangleList = map ((\xs -> (sum xs, xs)) . enumFromTo 1) [1..]
triangleList = map (\n -> n * (n + 1) `div` 2) [1..]
main :: IO ()
main = print $ triangleList !! 501
-- Nao ta dando certo, que houve ? :(
================================================
FILE: Problem012/JavaScript/solution_1.js
================================================
"use strict"
function checkPrime(input, list) {
for (let i = 0; i < list.length && list[i] < input ** 0.5; i++)
if (!(input % list[i])) return 0;
return 1;
}
function getNumOfDivisor(input) {
let prime_list = [2,3];
let numDivisors = 1, counter = 1, k = 1;
if (!(input % 2)) {
input /= 2;
while(!(input%2)) ++counter && (input /= 2);
numDivisors *= ++counter;
}
if (!(input % 3)) {
(counter = 1) && (input /= 3);
while(!(input % 3)) ++counter && (input /= 3);
numDivisors *= ++counter;
}
while (6 * k - 1 <= input) {
if (checkPrime(6 * k - 1, prime_list)) {
prime_list.push(6 * k - 1);
if (!(input % (6 * k - 1))) {
(counter = 1) && (input /= (6 * k -1));
while (!(input % (6 * k - 1))) ++counter && (input /= (6 * k -1));
numDivisors *= ++counter;
}
}
if ((6 * k + 1) <= input && checkPrime(6 * k + 1, prime_list)) {
prime_list.push(6 * k + 1);
if (!(input % (6 * k + 1))) {
(counter = 1) && (input /= (6 * k + 1));
while (!(input % (6 * k + 1))) ++counter && (input /= (6 * k + 1));
numDivisors *= ++counter;
}
}
k++;
}
return numDivisors;
}
function getTriangleNumber() {
let n = 45, numDivisors = 0;
while (numDivisors <= 500) {
(numDivisors = getNumOfDivisor(n * (n + 1)/2)) && ++n;
}
return ((n-1) * n / 2);
}
console.log(getTriangleNumber());
================================================
FILE: Problem012/Python/solution_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
# Python Script
#
# Copyleft © Manoel Vilela
#
#
# Highly divisible triangular number
# Problem 12
# The sequence of triangle numbers is generated by adding the natural numbers.
# So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28.
# The first ten terms would be:
# 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
# Let us list the factors of the first seven triangle numbers:
# 1: 1
# 3: 1,3
# 6: 1,2,3,6
# 10: 1,2,5,10
# 15: 1,3,5,15
# 21: 1,3,7,21
# 28: 1,2,4,7,14,28
# We can see that 28 is the first triangle number to have over five divisors.
# What is the value of the first triangle number
# to have over five hundred divisors?
from itertools import combinations, count
from functools import reduce
def trianglenums():
for n in count(start=1, step=1):
yield n * (n + 1) // 2
def factoring(n):
divs = [1]
i = 2
while n > 1:
while not n % i:
n /= i
divs.append(i)
i += 1
return divs
def divisors(n):
divs = factoring(n)
primes = divs[1:]
for j in range(1, len(primes)):
for comb in combinations(primes, j + 1):
newdiv = reduce(lambda x, y: x*y, comb)
if newdiv <= n and newdiv not in divs:
divs.append(newdiv)
return len(divs)
# external thing whose I found on thread of that problem
# resuming all (one line! D:) FDP! (divisors + factoring function).
# The perfomance it's the same
def factors(n):
return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n ** 0.5) + 1) if not n % i)))
for i in trianglenums():
if divisors(i) > 500:
print(i)
break
================================================
FILE: Problem012/Python/solution_2.py
================================================
# Good Solution found on forum thread in the projecteuler
from functools import reduce
def divisors(x):
'''
exponents(28) --> 6 because 28 = 2**2 * 7*1:
total number of divisors of 28: (2+1)*(1+1) = 6
'''
expList = []
count = 0
divisor = 2
while divisor <= x:
while x % divisor == 0:
x = x/divisor
count += 1
if count != 0:
expList.append(count+1)
divisor += 1
count = 0
return reduce(lambda x, y: x * y, expList, 1)
# Find the first triangle number to have over n divisors
def diviTri(n):
'''
Triangle numbers = sum of all previous the natural numbers
Ex: The 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28
The first triangular number to have over 5 divisors is 28,
whose divisors are 1, 2, 4, 7, 14, 28
'''
natural = 1
triangular = 0
while True:
triangular += natural
natural += 1
if divisors(triangular) > n:
break
# print "First triangular number to have over", n, "divisors:", triangular
return triangular
print(diviTri(500))
================================================
FILE: Problem012/Python/solution_3.py
================================================
#!/usr/bin/env python
# coding=utf-8
# Python Script
#
# Copyleft © Manoel Vilela
#
#
# Highly divisible triangular number
# Problem 12
# The sequence of triangle numbers is generated by adding the natural numbers.
# So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28.
# The first ten terms would be:
# 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
# Let us list the factors of the first seven triangle numbers:
# 1: 1
# 3: 1,3
# 6: 1,2,3,6
# 10: 1,2,5,10
# 15: 1,3,5,15
# 21: 1,3,7,21
# 28: 1,2,4,7,14,28
# We can see that 28 is the first triangle number to have over five divisors.
# What is the value of the first triangle number
# to have over five hundred divisors?
from functools import reduce
from itertools import count
def trianglenums():
for n in count(start=1, step=1):
yield n * (n + 1) // 2
def divisors(n):
exps = []
i = 2
while n > 1:
count = 0
while n % i == 0:
n /= i
count += 1
if count != 0:
exps.append(count + 1)
i += 1
return reduce(lambda x, y: x * y, exps, 1)
for i in trianglenums():
if divisors(i) > 500:
print(i)
quit()
================================================
FILE: Problem012/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=12)
================================================
FILE: Problem013/.hash
================================================
361113f19fd302adc31268f8283a4f2d
================================================
FILE: Problem013/Elixir/solution_1.exs
================================================
# Author: G4BB3R
[37107287533902102798797998220837590246510135740250,
46376937677490009712648124896970078050417018260538,
74324986199524741059474233309513058123726617309629,
91942213363574161572522430563301811072406154908250,
23067588207539346171171980310421047513778063246676,
89261670696623633820136378418383684178734361726757,
28112879812849979408065481931592621691275889832738,
44274228917432520321923589422876796487670272189318,
47451445736001306439091167216856844588711603153276,
70386486105843025439939619828917593665686757934951,
62176457141856560629502157223196586755079324193331,
64906352462741904929101432445813822663347944758178,
92575867718337217661963751590579239728245598838407,
58203565325359399008402633568948830189458628227828,
80181199384826282014278194139940567587151170094390,
35398664372827112653829987240784473053190104293586,
86515506006295864861532075273371959191420517255829,
71693888707715466499115593487603532921714970056938,
54370070576826684624621495650076471787294438377604,
53282654108756828443191190634694037855217779295145,
36123272525000296071075082563815656710885258350721,
45876576172410976447339110607218265236877223636045,
17423706905851860660448207621209813287860733969412,
81142660418086830619328460811191061556940512689692,
51934325451728388641918047049293215058642563049483,
62467221648435076201727918039944693004732956340691,
15732444386908125794514089057706229429197107928209,
55037687525678773091862540744969844508330393682126,
18336384825330154686196124348767681297534375946515,
80386287592878490201521685554828717201219257766954,
78182833757993103614740356856449095527097864797581,
16726320100436897842553539920931837441497806860984,
48403098129077791799088218795327364475675590848030,
87086987551392711854517078544161852424320693150332,
59959406895756536782107074926966537676326235447210,
69793950679652694742597709739166693763042633987085,
41052684708299085211399427365734116182760315001271,
65378607361501080857009149939512557028198746004375,
35829035317434717326932123578154982629742552737307,
94953759765105305946966067683156574377167401875275,
88902802571733229619176668713819931811048770190271,
25267680276078003013678680992525463401061632866526,
36270218540497705585629946580636237993140746255962,
24074486908231174977792365466257246923322810917141,
91430288197103288597806669760892938638285025333403,
34413065578016127815921815005561868836468420090470,
23053081172816430487623791969842487255036638784583,
11487696932154902810424020138335124462181441773470,
63783299490636259666498587618221225225512486764533,
67720186971698544312419572409913959008952310058822,
95548255300263520781532296796249481641953868218774,
76085327132285723110424803456124867697064507995236,
37774242535411291684276865538926205024910326572967,
23701913275725675285653248258265463092207058596522,
29798860272258331913126375147341994889534765745501,
18495701454879288984856827726077713721403798879715,
38298203783031473527721580348144513491373226651381,
34829543829199918180278916522431027392251122869539,
40957953066405232632538044100059654939159879593635,
29746152185502371307642255121183693803580388584903,
41698116222072977186158236678424689157993532961922,
62467957194401269043877107275048102390895523597457,
23189706772547915061505504953922979530901129967519,
86188088225875314529584099251203829009407770775672,
11306739708304724483816533873502340845647058077308,
82959174767140363198008187129011875491310547126581,
97623331044818386269515456334926366572897563400500,
42846280183517070527831839425882145521227251250327,
55121603546981200581762165212827652751691296897789,
32238195734329339946437501907836945765883352399886,
75506164965184775180738168837861091527357929701337,
62177842752192623401942399639168044983993173312731,
32924185707147349566916674687634660915035914677504,
99518671430235219628894890102423325116913619626622,
73267460800591547471830798392868535206946944540724,
76841822524674417161514036427982273348055556214818,
97142617910342598647204516893989422179826088076852,
87783646182799346313767754307809363333018982642090,
10848802521674670883215120185883543223812876952786,
71329612474782464538636993009049310363619763878039,
62184073572399794223406235393808339651327408011116,
66627891981488087797941876876144230030984490851411,
60661826293682836764744779239180335110989069790714,
85786944089552990653640447425576083659976645795096,
66024396409905389607120198219976047599490197230297,
64913982680032973156037120041377903785566085089252,
16730939319872750275468906903707539413042652315011,
94809377245048795150954100921645863754710598436791,
78639167021187492431995700641917969777599028300699,
15368713711936614952811305876380278410754449733078,
40789923115535562561142322423255033685442488917353,
44889911501440648020369068063960672322193204149535,
41503128880339536053299340368006977710650566631954,
81234880673210146739058568557934581403627822703280,
82616570773948327592232845941706525094512325230608,
22918802058777319719839450180888072429661980811197,
77158542502016545090413245809786882778948721859617,
72107838435069186155435662884062257473692284509516,
20849603980134001723930671666823555245252804609722,
53503534226472524250874054075591789781264330331690]
|> Enum.sum
|> inspect
|> String.slice(0, 10)
|> IO.puts
================================================
FILE: Problem013/Haskell/solution_1.hs
================================================
main :: IO ()
main = putStr $ take 10 $ show $ sum numbers
numbers = [37107287533902102798797998220837590246510135740250,
46376937677490009712648124896970078050417018260538,
74324986199524741059474233309513058123726617309629,
91942213363574161572522430563301811072406154908250,
23067588207539346171171980310421047513778063246676,
89261670696623633820136378418383684178734361726757,
28112879812849979408065481931592621691275889832738,
44274228917432520321923589422876796487670272189318,
47451445736001306439091167216856844588711603153276,
70386486105843025439939619828917593665686757934951,
62176457141856560629502157223196586755079324193331,
64906352462741904929101432445813822663347944758178,
92575867718337217661963751590579239728245598838407,
58203565325359399008402633568948830189458628227828,
80181199384826282014278194139940567587151170094390,
35398664372827112653829987240784473053190104293586,
86515506006295864861532075273371959191420517255829,
71693888707715466499115593487603532921714970056938,
54370070576826684624621495650076471787294438377604,
53282654108756828443191190634694037855217779295145,
36123272525000296071075082563815656710885258350721,
45876576172410976447339110607218265236877223636045,
17423706905851860660448207621209813287860733969412,
81142660418086830619328460811191061556940512689692,
51934325451728388641918047049293215058642563049483,
62467221648435076201727918039944693004732956340691,
15732444386908125794514089057706229429197107928209,
55037687525678773091862540744969844508330393682126,
18336384825330154686196124348767681297534375946515,
80386287592878490201521685554828717201219257766954,
78182833757993103614740356856449095527097864797581,
16726320100436897842553539920931837441497806860984,
48403098129077791799088218795327364475675590848030,
87086987551392711854517078544161852424320693150332,
59959406895756536782107074926966537676326235447210,
69793950679652694742597709739166693763042633987085,
41052684708299085211399427365734116182760315001271,
65378607361501080857009149939512557028198746004375,
35829035317434717326932123578154982629742552737307,
94953759765105305946966067683156574377167401875275,
88902802571733229619176668713819931811048770190271,
25267680276078003013678680992525463401061632866526,
36270218540497705585629946580636237993140746255962,
24074486908231174977792365466257246923322810917141,
91430288197103288597806669760892938638285025333403,
34413065578016127815921815005561868836468420090470,
23053081172816430487623791969842487255036638784583,
11487696932154902810424020138335124462181441773470,
63783299490636259666498587618221225225512486764533,
67720186971698544312419572409913959008952310058822,
95548255300263520781532296796249481641953868218774,
76085327132285723110424803456124867697064507995236,
37774242535411291684276865538926205024910326572967,
23701913275725675285653248258265463092207058596522,
29798860272258331913126375147341994889534765745501,
18495701454879288984856827726077713721403798879715,
38298203783031473527721580348144513491373226651381,
34829543829199918180278916522431027392251122869539,
40957953066405232632538044100059654939159879593635,
29746152185502371307642255121183693803580388584903,
41698116222072977186158236678424689157993532961922,
62467957194401269043877107275048102390895523597457,
23189706772547915061505504953922979530901129967519,
86188088225875314529584099251203829009407770775672,
11306739708304724483816533873502340845647058077308,
82959174767140363198008187129011875491310547126581,
97623331044818386269515456334926366572897563400500,
42846280183517070527831839425882145521227251250327,
55121603546981200581762165212827652751691296897789,
32238195734329339946437501907836945765883352399886,
75506164965184775180738168837861091527357929701337,
62177842752192623401942399639168044983993173312731,
32924185707147349566916674687634660915035914677504,
99518671430235219628894890102423325116913619626622,
73267460800591547471830798392868535206946944540724,
76841822524674417161514036427982273348055556214818,
97142617910342598647204516893989422179826088076852,
87783646182799346313767754307809363333018982642090,
10848802521674670883215120185883543223812876952786,
71329612474782464538636993009049310363619763878039,
62184073572399794223406235393808339651327408011116,
66627891981488087797941876876144230030984490851411,
60661826293682836764744779239180335110989069790714,
85786944089552990653640447425576083659976645795096,
66024396409905389607120198219976047599490197230297,
64913982680032973156037120041377903785566085089252,
16730939319872750275468906903707539413042652315011,
94809377245048795150954100921645863754710598436791,
78639167021187492431995700641917969777599028300699,
15368713711936614952811305876380278410754449733078,
40789923115535562561142322423255033685442488917353,
44889911501440648020369068063960672322193204149535,
41503128880339536053299340368006977710650566631954,
81234880673210146739058568557934581403627822703280,
82616570773948327592232845941706525094512325230608,
22918802058777319719839450180888072429661980811197,
77158542502016545090413245809786882778948721859617,
72107838435069186155435662884062257473692284509516,
20849603980134001723930671666823555245252804609722,
53503534226472524250874054075591789781264330331690]
================================================
FILE: Problem013/Lua/solution_1.lua
================================================
-- Author: G4BB3R
numbers = {37107287533902102798797998220837590246510135740250,
46376937677490009712648124896970078050417018260538,
74324986199524741059474233309513058123726617309629,
91942213363574161572522430563301811072406154908250,
23067588207539346171171980310421047513778063246676,
89261670696623633820136378418383684178734361726757,
28112879812849979408065481931592621691275889832738,
44274228917432520321923589422876796487670272189318,
47451445736001306439091167216856844588711603153276,
70386486105843025439939619828917593665686757934951,
62176457141856560629502157223196586755079324193331,
64906352462741904929101432445813822663347944758178,
92575867718337217661963751590579239728245598838407,
58203565325359399008402633568948830189458628227828,
80181199384826282014278194139940567587151170094390,
35398664372827112653829987240784473053190104293586,
86515506006295864861532075273371959191420517255829,
71693888707715466499115593487603532921714970056938,
54370070576826684624621495650076471787294438377604,
53282654108756828443191190634694037855217779295145,
36123272525000296071075082563815656710885258350721,
45876576172410976447339110607218265236877223636045,
17423706905851860660448207621209813287860733969412,
81142660418086830619328460811191061556940512689692,
51934325451728388641918047049293215058642563049483,
62467221648435076201727918039944693004732956340691,
15732444386908125794514089057706229429197107928209,
55037687525678773091862540744969844508330393682126,
18336384825330154686196124348767681297534375946515,
80386287592878490201521685554828717201219257766954,
78182833757993103614740356856449095527097864797581,
16726320100436897842553539920931837441497806860984,
48403098129077791799088218795327364475675590848030,
87086987551392711854517078544161852424320693150332,
59959406895756536782107074926966537676326235447210,
69793950679652694742597709739166693763042633987085,
41052684708299085211399427365734116182760315001271,
65378607361501080857009149939512557028198746004375,
35829035317434717326932123578154982629742552737307,
94953759765105305946966067683156574377167401875275,
88902802571733229619176668713819931811048770190271,
25267680276078003013678680992525463401061632866526,
36270218540497705585629946580636237993140746255962,
24074486908231174977792365466257246923322810917141,
91430288197103288597806669760892938638285025333403,
34413065578016127815921815005561868836468420090470,
23053081172816430487623791969842487255036638784583,
11487696932154902810424020138335124462181441773470,
63783299490636259666498587618221225225512486764533,
67720186971698544312419572409913959008952310058822,
95548255300263520781532296796249481641953868218774,
76085327132285723110424803456124867697064507995236,
37774242535411291684276865538926205024910326572967,
23701913275725675285653248258265463092207058596522,
29798860272258331913126375147341994889534765745501,
18495701454879288984856827726077713721403798879715,
38298203783031473527721580348144513491373226651381,
34829543829199918180278916522431027392251122869539,
40957953066405232632538044100059654939159879593635,
29746152185502371307642255121183693803580388584903,
41698116222072977186158236678424689157993532961922,
62467957194401269043877107275048102390895523597457,
23189706772547915061505504953922979530901129967519,
86188088225875314529584099251203829009407770775672,
11306739708304724483816533873502340845647058077308,
82959174767140363198008187129011875491310547126581,
97623331044818386269515456334926366572897563400500,
42846280183517070527831839425882145521227251250327,
55121603546981200581762165212827652751691296897789,
32238195734329339946437501907836945765883352399886,
75506164965184775180738168837861091527357929701337,
62177842752192623401942399639168044983993173312731,
32924185707147349566916674687634660915035914677504,
99518671430235219628894890102423325116913619626622,
73267460800591547471830798392868535206946944540724,
76841822524674417161514036427982273348055556214818,
97142617910342598647204516893989422179826088076852,
87783646182799346313767754307809363333018982642090,
10848802521674670883215120185883543223812876952786,
71329612474782464538636993009049310363619763878039,
62184073572399794223406235393808339651327408011116,
66627891981488087797941876876144230030984490851411,
60661826293682836764744779239180335110989069790714,
85786944089552990653640447425576083659976645795096,
66024396409905389607120198219976047599490197230297,
64913982680032973156037120041377903785566085089252,
16730939319872750275468906903707539413042652315011,
94809377245048795150954100921645863754710598436791,
78639167021187492431995700641917969777599028300699,
15368713711936614952811305876380278410754449733078,
40789923115535562561142322423255033685442488917353,
44889911501440648020369068063960672322193204149535,
41503128880339536053299340368006977710650566631954,
81234880673210146739058568557934581403627822703280,
82616570773948327592232845941706525094512325230608,
22918802058777319719839450180888072429661980811197,
77158542502016545090413245809786882778948721859617,
72107838435069186155435662884062257473692284509516,
20849603980134001723930671666823555245252804609722,
53503534226472524250874054075591789781264330331690}
local soma = 0
for _, v in pairs(numbers) do
soma = soma + v
end
local resultado = string.sub(string.format("%18.0f", soma), 1, 10)
print(resultado)
================================================
FILE: Problem013/Python/solution_1.py
================================================
# Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.
data = '''37107287533902102798797998220837590246510135740250
46376937677490009712648124896970078050417018260538
74324986199524741059474233309513058123726617309629
91942213363574161572522430563301811072406154908250
23067588207539346171171980310421047513778063246676
89261670696623633820136378418383684178734361726757
28112879812849979408065481931592621691275889832738
44274228917432520321923589422876796487670272189318
47451445736001306439091167216856844588711603153276
70386486105843025439939619828917593665686757934951
62176457141856560629502157223196586755079324193331
64906352462741904929101432445813822663347944758178
92575867718337217661963751590579239728245598838407
58203565325359399008402633568948830189458628227828
80181199384826282014278194139940567587151170094390
35398664372827112653829987240784473053190104293586
86515506006295864861532075273371959191420517255829
71693888707715466499115593487603532921714970056938
54370070576826684624621495650076471787294438377604
53282654108756828443191190634694037855217779295145
36123272525000296071075082563815656710885258350721
45876576172410976447339110607218265236877223636045
17423706905851860660448207621209813287860733969412
81142660418086830619328460811191061556940512689692
51934325451728388641918047049293215058642563049483
62467221648435076201727918039944693004732956340691
15732444386908125794514089057706229429197107928209
55037687525678773091862540744969844508330393682126
18336384825330154686196124348767681297534375946515
80386287592878490201521685554828717201219257766954
78182833757993103614740356856449095527097864797581
16726320100436897842553539920931837441497806860984
48403098129077791799088218795327364475675590848030
87086987551392711854517078544161852424320693150332
59959406895756536782107074926966537676326235447210
69793950679652694742597709739166693763042633987085
41052684708299085211399427365734116182760315001271
65378607361501080857009149939512557028198746004375
35829035317434717326932123578154982629742552737307
94953759765105305946966067683156574377167401875275
88902802571733229619176668713819931811048770190271
25267680276078003013678680992525463401061632866526
36270218540497705585629946580636237993140746255962
24074486908231174977792365466257246923322810917141
91430288197103288597806669760892938638285025333403
34413065578016127815921815005561868836468420090470
23053081172816430487623791969842487255036638784583
11487696932154902810424020138335124462181441773470
63783299490636259666498587618221225225512486764533
67720186971698544312419572409913959008952310058822
95548255300263520781532296796249481641953868218774
76085327132285723110424803456124867697064507995236
37774242535411291684276865538926205024910326572967
23701913275725675285653248258265463092207058596522
29798860272258331913126375147341994889534765745501
18495701454879288984856827726077713721403798879715
38298203783031473527721580348144513491373226651381
34829543829199918180278916522431027392251122869539
40957953066405232632538044100059654939159879593635
29746152185502371307642255121183693803580388584903
41698116222072977186158236678424689157993532961922
62467957194401269043877107275048102390895523597457
23189706772547915061505504953922979530901129967519
86188088225875314529584099251203829009407770775672
11306739708304724483816533873502340845647058077308
82959174767140363198008187129011875491310547126581
97623331044818386269515456334926366572897563400500
42846280183517070527831839425882145521227251250327
55121603546981200581762165212827652751691296897789
32238195734329339946437501907836945765883352399886
75506164965184775180738168837861091527357929701337
62177842752192623401942399639168044983993173312731
32924185707147349566916674687634660915035914677504
99518671430235219628894890102423325116913619626622
73267460800591547471830798392868535206946944540724
76841822524674417161514036427982273348055556214818
97142617910342598647204516893989422179826088076852
87783646182799346313767754307809363333018982642090
10848802521674670883215120185883543223812876952786
71329612474782464538636993009049310363619763878039
62184073572399794223406235393808339651327408011116
66627891981488087797941876876144230030984490851411
60661826293682836764744779239180335110989069790714
85786944089552990653640447425576083659976645795096
66024396409905389607120198219976047599490197230297
64913982680032973156037120041377903785566085089252
16730939319872750275468906903707539413042652315011
94809377245048795150954100921645863754710598436791
78639167021187492431995700641917969777599028300699
15368713711936614952811305876380278410754449733078
40789923115535562561142322423255033685442488917353
44889911501440648020369068063960672322193204149535
41503128880339536053299340368006977710650566631954
81234880673210146739058568557934581403627822703280
82616570773948327592232845941706525094512325230608
22918802058777319719839450180888072429661980811197
77158542502016545090413245809786882778948721859617
72107838435069186155435662884062257473692284509516
20849603980134001723930671666823555245252804609722
53503534226472524250874054075591789781264330331690'''
print(str(sum([int(num) for num in [x for x in data.split()]]))[0:10])
================================================
FILE: Problem013/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=13)
================================================
FILE: Problem013/Ruby/solution_1.rb
================================================
#Author: tkovs
$numbers = [37107287533902102798797998220837590246510135740250,
46376937677490009712648124896970078050417018260538,
74324986199524741059474233309513058123726617309629,
91942213363574161572522430563301811072406154908250,
23067588207539346171171980310421047513778063246676,
89261670696623633820136378418383684178734361726757,
28112879812849979408065481931592621691275889832738,
44274228917432520321923589422876796487670272189318,
47451445736001306439091167216856844588711603153276,
70386486105843025439939619828917593665686757934951,
62176457141856560629502157223196586755079324193331,
64906352462741904929101432445813822663347944758178,
92575867718337217661963751590579239728245598838407,
58203565325359399008402633568948830189458628227828,
80181199384826282014278194139940567587151170094390,
35398664372827112653829987240784473053190104293586,
86515506006295864861532075273371959191420517255829,
71693888707715466499115593487603532921714970056938,
54370070576826684624621495650076471787294438377604,
53282654108756828443191190634694037855217779295145,
36123272525000296071075082563815656710885258350721,
45876576172410976447339110607218265236877223636045,
17423706905851860660448207621209813287860733969412,
81142660418086830619328460811191061556940512689692,
51934325451728388641918047049293215058642563049483,
62467221648435076201727918039944693004732956340691,
15732444386908125794514089057706229429197107928209,
55037687525678773091862540744969844508330393682126,
18336384825330154686196124348767681297534375946515,
80386287592878490201521685554828717201219257766954,
78182833757993103614740356856449095527097864797581,
16726320100436897842553539920931837441497806860984,
48403098129077791799088218795327364475675590848030,
87086987551392711854517078544161852424320693150332,
59959406895756536782107074926966537676326235447210,
69793950679652694742597709739166693763042633987085,
41052684708299085211399427365734116182760315001271,
65378607361501080857009149939512557028198746004375,
35829035317434717326932123578154982629742552737307,
94953759765105305946966067683156574377167401875275,
88902802571733229619176668713819931811048770190271,
25267680276078003013678680992525463401061632866526,
36270218540497705585629946580636237993140746255962,
24074486908231174977792365466257246923322810917141,
91430288197103288597806669760892938638285025333403,
34413065578016127815921815005561868836468420090470,
23053081172816430487623791969842487255036638784583,
11487696932154902810424020138335124462181441773470,
63783299490636259666498587618221225225512486764533,
67720186971698544312419572409913959008952310058822,
95548255300263520781532296796249481641953868218774,
76085327132285723110424803456124867697064507995236,
37774242535411291684276865538926205024910326572967,
23701913275725675285653248258265463092207058596522,
29798860272258331913126375147341994889534765745501,
18495701454879288984856827726077713721403798879715,
38298203783031473527721580348144513491373226651381,
34829543829199918180278916522431027392251122869539,
40957953066405232632538044100059654939159879593635,
29746152185502371307642255121183693803580388584903,
41698116222072977186158236678424689157993532961922,
62467957194401269043877107275048102390895523597457,
23189706772547915061505504953922979530901129967519,
86188088225875314529584099251203829009407770775672,
11306739708304724483816533873502340845647058077308,
82959174767140363198008187129011875491310547126581,
97623331044818386269515456334926366572897563400500,
42846280183517070527831839425882145521227251250327,
55121603546981200581762165212827652751691296897789,
32238195734329339946437501907836945765883352399886,
75506164965184775180738168837861091527357929701337,
62177842752192623401942399639168044983993173312731,
32924185707147349566916674687634660915035914677504,
99518671430235219628894890102423325116913619626622,
73267460800591547471830798392868535206946944540724,
76841822524674417161514036427982273348055556214818,
97142617910342598647204516893989422179826088076852,
87783646182799346313767754307809363333018982642090,
10848802521674670883215120185883543223812876952786,
71329612474782464538636993009049310363619763878039,
62184073572399794223406235393808339651327408011116,
66627891981488087797941876876144230030984490851411,
60661826293682836764744779239180335110989069790714,
85786944089552990653640447425576083659976645795096,
66024396409905389607120198219976047599490197230297,
64913982680032973156037120041377903785566085089252,
16730939319872750275468906903707539413042652315011,
94809377245048795150954100921645863754710598436791,
78639167021187492431995700641917969777599028300699,
15368713711936614952811305876380278410754449733078,
40789923115535562561142322423255033685442488917353,
44889911501440648020369068063960672322193204149535,
41503128880339536053299340368006977710650566631954,
81234880673210146739058568557934581403627822703280,
82616570773948327592232845941706525094512325230608,
22918802058777319719839450180888072429661980811197,
77158542502016545090413245809786882778948721859617,
72107838435069186155435662884062257473692284509516,
20849603980134001723930671666823555245252804609722,
53503534226472524250874054075591789781264330331690]
def solve
return($numbers.inject(:+).to_s[0..9])
end
puts(solve)
================================================
FILE: Problem014/.hash
================================================
5052c3765262bb2c6be537abd60b305e
================================================
FILE: Problem014/Clojure/solution_1.clj
================================================
;; wrong solution.
(def bignumbers '(37107287533902102798797998220837590246510135740250
46376937677490009712648124896970078050417018260538
74324986199524741059474233309513058123726617309629
91942213363574161572522430563301811072406154908250
23067588207539346171171980310421047513778063246676
89261670696623633820136378418383684178734361726757
28112879812849979408065481931592621691275889832738
44274228917432520321923589422876796487670272189318
47451445736001306439091167216856844588711603153276
70386486105843025439939619828917593665686757934951
62176457141856560629502157223196586755079324193331
64906352462741904929101432445813822663347944758178
92575867718337217661963751590579239728245598838407
58203565325359399008402633568948830189458628227828
80181199384826282014278194139940567587151170094390
35398664372827112653829987240784473053190104293586
86515506006295864861532075273371959191420517255829
71693888707715466499115593487603532921714970056938
54370070576826684624621495650076471787294438377604
53282654108756828443191190634694037855217779295145
36123272525000296071075082563815656710885258350721
45876576172410976447339110607218265236877223636045
17423706905851860660448207621209813287860733969412
81142660418086830619328460811191061556940512689692
51934325451728388641918047049293215058642563049483
62467221648435076201727918039944693004732956340691
15732444386908125794514089057706229429197107928209
55037687525678773091862540744969844508330393682126
18336384825330154686196124348767681297534375946515
80386287592878490201521685554828717201219257766954
78182833757993103614740356856449095527097864797581
16726320100436897842553539920931837441497806860984
48403098129077791799088218795327364475675590848030
87086987551392711854517078544161852424320693150332
59959406895756536782107074926966537676326235447210
69793950679652694742597709739166693763042633987085
41052684708299085211399427365734116182760315001271
65378607361501080857009149939512557028198746004375
35829035317434717326932123578154982629742552737307
94953759765105305946966067683156574377167401875275
88902802571733229619176668713819931811048770190271
25267680276078003013678680992525463401061632866526
36270218540497705585629946580636237993140746255962
24074486908231174977792365466257246923322810917141
91430288197103288597806669760892938638285025333403
34413065578016127815921815005561868836468420090470
23053081172816430487623791969842487255036638784583
11487696932154902810424020138335124462181441773470
63783299490636259666498587618221225225512486764533
67720186971698544312419572409913959008952310058822
95548255300263520781532296796249481641953868218774
76085327132285723110424803456124867697064507995236
37774242535411291684276865538926205024910326572967
23701913275725675285653248258265463092207058596522
29798860272258331913126375147341994889534765745501
18495701454879288984856827726077713721403798879715
38298203783031473527721580348144513491373226651381
34829543829199918180278916522431027392251122869539
40957953066405232632538044100059654939159879593635
29746152185502371307642255121183693803580388584903
41698116222072977186158236678424689157993532961922
62467957194401269043877107275048102390895523597457
23189706772547915061505504953922979530901129967519
86188088225875314529584099251203829009407770775672
11306739708304724483816533873502340845647058077308
82959174767140363198008187129011875491310547126581
97623331044818386269515456334926366572897563400500
42846280183517070527831839425882145521227251250327
55121603546981200581762165212827652751691296897789
32238195734329339946437501907836945765883352399886
75506164965184775180738168837861091527357929701337
62177842752192623401942399639168044983993173312731
32924185707147349566916674687634660915035914677504
99518671430235219628894890102423325116913619626622
73267460800591547471830798392868535206946944540724
76841822524674417161514036427982273348055556214818
97142617910342598647204516893989422179826088076852
87783646182799346313767754307809363333018982642090
10848802521674670883215120185883543223812876952786
71329612474782464538636993009049310363619763878039
62184073572399794223406235393808339651327408011116
66627891981488087797941876876144230030984490851411
60661826293682836764744779239180335110989069790714
85786944089552990653640447425576083659976645795096
66024396409905389607120198219976047599490197230297
64913982680032973156037120041377903785566085089252
16730939319872750275468906903707539413042652315011
94809377245048795150954100921645863754710598436791
78639167021187492431995700641917969777599028300699
15368713711936614952811305876380278410754449733078
40789923115535562561142322423255033685442488917353
44889911501440648020369068063960672322193204149535
41503128880339536053299340368006977710650566631954
81234880673210146739058568557934581403627822703280
82616570773948327592232845941706525094512325230608
22918802058777319719839450180888072429661980811197
77158542502016545090413245809786882778948721859617
72107838435069186155435662884062257473692284509516
20849603980134001723930671666823555245252804609722
53503534226472524250874054075591789781264330331690))
(defn solution
[]
(->> bignumbers
(reduce +)
(str)
((fn[x] (subs x 0 10)))))
(println (solution))
================================================
FILE: Problem014/Elixir/solution_1.exs
================================================
# Author: lubien
defmodule Euler14 do
def solve() do
largest_collatz(1, {0, 0})
end
defp largest_collatz(1_000_000, {_size, current}), do: current
defp largest_collatz(n, {size, _current} = acc) do
current_size = collatz(n)
if current_size > size do
largest_collatz n + 1, {current_size, n}
else
largest_collatz n + 1, acc
end
end
def collatz(n), do: collatz(n, 1)
defp collatz(1, acc), do: acc
defp collatz(n, acc) do
next = if rem(n, 2) == 0 do
div(n, 2)
else
(3 * n) + 1
end
collatz(next, acc + 1)
end
end
Euler14.solve
|> IO.puts
================================================
FILE: Problem014/Haskell/solution_slow_1.hs
================================================
-- Author: G4BB3R
getCollatzSequenceLen :: Int -> Int
getCollatzSequenceLen 1 = 1
getCollatzSequenceLen x = 1 + getCollatzSequenceLen (if even x then x `div` 2 else 3 * x + 1)
getHighestCollatz :: (Int, Int)
getHighestCollatz = getHighestCollatz' 1 (0, 0) where
getHighestCollatz' :: Int -> (Int, Int) -> (Int, Int)
getHighestCollatz' 999999 len = len
getHighestCollatz' n (index, len) = let len' = getCollatzSequenceLen n in
if len' > len then
getHighestCollatz' (n + 1) (n, len')
else
getHighestCollatz' (n + 1) (index, len)
main :: IO ()
main = print $ fst getHighestCollatz
================================================
FILE: Problem014/Python/solution_slow_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
# Python Script
#
# Copyleft © Manoel Vilela
#
#
# problem14.py dumb solution (not efficient)
"""
Longest Collatz sequence
Problem 14
The following iterative sequence is defined for the set of positive integers:
n → n/2 (n is even)
n → 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
It can be seen that this sequence
(starting at 13 and finishing at 1) contains 10 terms.
Although it has not been proved yet (Collatz Problem),
it is thought that all starting numbers finish at 1.
Which starting number, under one million, produces the longest chain?
NOTE: Once the chain starts the terms are allowed to go above one million.
"""
def sequence(n):
terms = 1
while n > 1:
if n % 2 == 0:
n = n / 2
else:
n = 3 * n + 1
terms += 1
return terms
def answer():
most = 0
i = 1
while i < 10 ** 6:
s = sequence(i)
if s > most:
most = s
value = i
i += 1
return value
print(answer())
================================================
FILE: Problem014/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=14)
================================================
FILE: Problem015/.hash
================================================
928f3957168ac592c4215dcd04e0b678
================================================
FILE: Problem015/C/solution_1.c
================================================
#include<stdio.h>
unsigned long long g[21][21];
int main()
{
int j,i;
for ( i = 0; i < 21; ++i) {
g[i][0] = 1;
g[0][i] = 1;
}
for (i = 1; i < 21; ++i) {
for (j = 1; j < 21; ++j) {
g[i][j] = g[i-1][j] + g[i][j-1];
}
}
printf("%lld\n", g[20][20]);
return 0;
}
================================================
FILE: Problem015/Clojure/solution_1.clj
================================================
;; Author: G4BB3R
(defn fat [n]
(if (<= n 1)
1
(* n (fat (- n 1)))))
(defn fatorial [n]
(fat (bigint n)))
;; (print (/ (fat 40) (Math/pow (fat 20) 2) )) overflow man
(println (str(bigint (/ (fatorial (bigint 40)) (Math/pow (fat (bigint 20)) 2) ))))
;; print(fat(40) / fat(20) ^ 2)
================================================
FILE: Problem015/Elixir/solution_1.exs
================================================
# Author: G4BB3R
defmodule Fat do
def fatorial(1), do: 1
def fatorial(n), do: n * fatorial(n - 1)
end
IO.puts round(Fat.fatorial(40) / round(:math.pow(Fat.fatorial(20), 2)))
================================================
FILE: Problem015/Haskell/solution_1.hs
================================================
{--
Starting in the top left corner of a 2×2 grid, and only being able to move to
the right and down, there are exactly 6 routes to the bottom right corner.
How many such routes are there through a 20×20 grid?
-}
main :: IO ()
main = print $ div (fat 40) ((fat 20)^2)
where fat = (\x -> product [1..x])
================================================
FILE: Problem015/Haskell/solution_2.hs
================================================
-- Author: G4BB3R
main :: IO ()
main = print $ div (fat 40 :: Integer) (fat 20 ^ (2 :: Integer))
where fat = product . enumFromTo 1
================================================
FILE: Problem015/Lua/solution_1.lua
================================================
-- Author: G4BB3R
local function fat (n)
return n <= 1 and 1 or n * fat(n - 1)
end
-- print(fat(40) // fat(20) ^ 2) bigint problem
print("wrong solution")
================================================
FILE: Problem015/Python/solution_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
# Python Script
#
# Copyleft © Manoel Vilela
#
#
"""
Lattice paths
Problem 15
Starting in the top left corner of a 2×2 grid,
and only being able to move to the right and down,
here are exactly 6 routes to the bottom right corner.
How many such routes are there through a 20×20 grid?
"""
# answer: 137846528820
# c(40,20) = 40!/20!20!
# Crazy Pascal Way
def pascal(n):
line = [1]
lines = 0
while lines < n:
i = 0
newline = [1, 1]
while len(newline) - 1 <= lines and len(line) - 1 > i:
new = line[i] + line[i + 1]
newline.insert(i + 1, new)
i += 1
line = newline
lines += 1
return line
def solution():
pascal_line = pascal(40)
middle = len(pascal_line) // 2
return pascal_line[middle]
print(solution())
================================================
FILE: Problem015/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=15)
================================================
FILE: Problem015/Ruby/solution_1.rb
================================================
#Author: tkovs
#Translation of the Haskell code P015
def solve
return ((1..40).inject(:*) / ((1..20).inject(:*) ** 2))
end
puts(solve)
================================================
FILE: Problem016/.hash
================================================
6a5889bb0190d0211a991f47bb19a777
================================================
FILE: Problem016/Clojure/solution_1.clj
================================================
(defn solution
[]
(->>
(repeat 1000 2)
(reduce *')
(str)
(seq)
(map #(Character/digit % 10))
(reduce +)))
(println (solution))
================================================
FILE: Problem016/CommonLisp/solution_1.lisp
================================================
;; Common Lisp Script
;; Manoel Vilela
(defun sum-digits (x)
(if (< x 10)
x
(+ (mod x 10) (sum-digits (floor (/ x 10))))))
(format t "~d~%" (sum-digits (expt 2 1000)))
================================================
FILE: Problem016/CommonLisp/solution_2.lisp
================================================
;; Common Lisp Script
;; Manoel Vilela
(defun integer-to-list (x)
(if (< x 10)
(cons x nil)
(cons (mod x 10)
(integer-to-list (floor (/ x 10))))))
(defun sum (the-list)
(reduce '+ the-list))
(defun solution ()
(sum (integer-to-list (expt 2 1000))))
(princ (solution))
================================================
FILE: Problem016/Elixir/solution_1.exs
================================================
:math.pow(2, 1000) |> round
|> to_charlist
|> Enum.map(fn (c) -> c - hd('0') end)
|> Enum.sum
|> inspect
|> IO.puts
================================================
FILE: Problem016/Haskell/solution_1.hs
================================================
import Data.Char (digitToInt)
sumDigits :: Integer -> Int
sumDigits = sum . map digitToInt . show
main :: IO ()
main = print . sumDigits $ (2 ^ (1000 :: Integer))
================================================
FILE: Problem016/Lua/solution_1.lua
================================================
-- Author: G4BB3R
-- 1386, arrumar D:
-- Lua tem problema com big int, precisaria usar uma lib externa, depois arrumo isso :(
local num_str = string.format("%18.0f", tostring(math.pow(2, 1000)))
-- print(num_str)
print("wrong solution")
local sum = 0
for i = 1, num_str:len() do
local x = tonumber(string.sub(num_str, i, i))
sum = sum + x
end
-- Lua 2 ^ 10: (ERRADO)
-- 10715086071862999163590588820647383440913642575258116846673707622968935536440923279124033348795639682170484286647580752132126263156615800081070401018029722553997945419726202612629300688266739378738989860216968431415297432702434337609682091577392386950658920903538338407947545379998315356201665846837248
-- Era esperado que 2 ^ 10 fosse:
-- 10715086071862673209484250490600018105510511249361224931983788156958581275940435984577574698574803934567774824230953046474983581941267398767559165543946429831652624386837205668069376
================================================
FILE: Problem016/Python/solution_1.py
================================================
#Project euler problem 16
n = 2**1000
tot=0
while(n>0):
dig=n%10
tot=tot+dig
n=n//10
print(tot)
================================================
FILE: Problem016/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=16)
================================================
FILE: Problem016/Ruby/solution_1.rb
================================================
#Author: tkovs
def solve
return((2**1000).to_s.split('').map{|digit| digit.to_i}.inject(:+))
end
puts(solve)
================================================
FILE: Problem017/.hash
================================================
6a979d4a9cf85135408529edc8a133d0
================================================
FILE: Problem017/Elixir/solution_1.exs
================================================
# Author: lubien
defmodule Euler17 do
def solve(n) do
1..n
|> Stream.map(&num_to_str/1)
|> Stream.map(&String.length/1)
|> Enum.reduce(&(&1 + &2))
end
# Since 1_000 isn't parsed right by my rules :p
def num_to_str(1000), do: "onethousand"
# Separate the number in a List of digits
def num_to_str(n), do: num_to_str(Integer.digits(n), [])
# When we've parsed all digits, make the word
defp num_to_str([], acc) do
case acc do
# "ten_name" is something like "twenty", "fourty", "ninety"
# and "unit_name" is empty because of a 0 unit
["", ten_name] -> ten_name
[unit_name, ten_name] -> ten_name <> "and" <> unit_name
_ -> acc |> Enum.reduce(&(&1 <> &2))
end
end
# Parse a digit
# It's important to you know that whenever we have 2 digits,
# we parse both together using ten_text/1
# units are only parsed alone for 1 digit sized numbers (1..9)
defp num_to_str([x | xs] = digits, acc) do
digits_length = length(digits)
text = case digits_length do
3 -> unit(x) <> "hundred"
2 -> ten_text(digits)
1 -> unit(x)
end
# Empty tail when we have 2 digits (see the comment above)
tail = if digits_length == 2 do [] else xs end
num_to_str(tail, [text | acc])
end
# Knowing that there's two digits at the tail
# let's parse it
defp ten_text([x | xs]) do
y = List.first xs
# For numbers in the "1y" pattern
if x == 1 do
cond do
y == 0 -> "ten"
y == 1 -> "eleven"
y == 2 -> "twelve"
y == 3 -> "thirteen"
y == 5 -> "fifteen"
y == 8 -> "eighteen"
y <= 9 -> unit(y) <> "teen"
end
else
case y do
0 -> ten(x)
_ -> ten(x) <> unit(y)
end
end
end
# Given a number "n", return the name of (n * 10)
# Excludes: 0, 1
def ten(n) do
{"", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"}
|> elem(n)
end
# Given a number, return it's name
def unit(n) do
{"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}
|> elem(n)
end
end
Euler17.solve(1_000)
|> IO.inspect
================================================
FILE: Problem017/Python/p17_dic.json
================================================
{
"1":"one",
"2":"two",
"3":"three",
"4":"four",
"5":"five",
"6":"six",
"7":"seven",
"8":"eight",
"9":"nine",
"10":"ten",
"11":"eleven",
"12":"twelve",
"13":"thirteen",
"14":"fourteen",
"15":"fifteen",
"16":"sixteen",
"17":"seventeen",
"18":"eighteen",
"19":"nineteen",
"20":"twenty",
"30":"thirty",
"40":"forty",
"50":"fifty",
"60":"sixty",
"70":"seventy",
"80":"eighty",
"90":"ninety",
"100":"one hundred",
"200":"two hundred",
"300":"three hundred",
"400":"four hundred",
"500":"five hundred",
"600":"six hundred",
"700":"seven hundred",
"800":"eight hundred",
"900":"nine hundred",
"1000":"one thousand"
}
================================================
FILE: Problem017/Python/solution_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
# Python Script
#
# Copyleft © Manoel Vilela
#
#
"""
Number letter counts
Problem 17
If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
NOTE: Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20 letters. The use of "and" when writing out numbers is in compliance with British usage.
"""
import json
from os.path import dirname
from os.path import join
# to work with stats.py
with open(join(dirname(__file__), 'p17_dic.json'), 'r') as f:
dic = json.load(f)
def parser(string):
if len(string) == 3:
a, b, c = dic[string[0]], dic[string[1]], dic[string[2]]
return a + ' and ' + b + '-' + c
elif len(string) == 2:
a, b = dic[string[0]], dic[string[1]]
if int(string[0]) >= 10 and sum([int(x) for x in string]) > 100:
conective = ' and '
else:
conective = '-'
return a + conective + b
else:
return dic[string[0]]
def decomp(string):
end = []
if int(string) % 100 in range(10, 20):
end = [str(int(string) % 100)]
string = str((int(string) // 100) * 100)
# LOOOOOOOOOOL
return [str((int(string[x]) * 10 ** (len(string) - (x + 1)))) for x in range(len(string)) if int(string[x]) != 0] + end
def clear(num):
return (''.join([c for c in num if c not in ' -']))
def solution():
nums = (decomp(str(x)) for x in range(1, 1001))
cordial = (parser(x) for x in nums)
clean = (clear(x) for x in cordial)
answer = sum(len(num) for num in clean)
return answer
print(solution())
================================================
FILE: Problem017/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=17)
================================================
FILE: Problem018/.hash
================================================
708f3cf8100d5e71834b1db77dfa15d6
================================================
FILE: Problem018/Elixir/solution_1.exs
================================================
tri_nums = [
["75"],
["95", "64"],
["17", "47", "82"],
["18", "35", "87", "10"],
["20", "04", "82", "47", "65"],
["19", "01", "23", "75", "03", "34"],
["88", "02", "77", "73", "07", "63", "67"],
["99", "65", "04", "28", "06", "16", "70", "92"],
["41", "41", "26", "56", "83", "40", "80", "70", "33"],
["41", "48", "72", "33", "47", "32", "37", "16", "94", "29"],
["53", "71", "44", "65", "25", "43", "91", "52", "97", "51", "14"],
["70", "11", "33", "28", "77", "73", "17", "78", "39", "68", "17", "57"],
["91", "71", "52", "38", "17", "14", "91", "43", "58", "50", "27", "29", "48"],
["63", "66", "04", "68", "89", "53", "67", "30", "73", "16", "69", "87", "40", "31"],
["04", "62", "98", "27", "23", "9", "70", "98", "73", "93", "38", "53", "60", "04", "23"]
]
defmodule MaximumPath do
def find([left|_]) when length(left) == 1 do
left
end
def find([left|[mid|right]]) when length(left) > 0 do
mid = for n <- (0..(length(left)-2)), do: Integer.to_string(new_val(left,mid,n))
find([mid|right])
end
def new_val(a,b,c), do: String.to_integer(Enum.at(b,c)) + Enum.max([String.to_integer(Enum.at(a,c)),String.to_integer(Enum.at(a,c+1))])
end
IO.puts MaximumPath.find(Enum.reverse(tri_nums))
================================================
FILE: Problem018/Python/solution_1.py
================================================
#search the biggest sum nums adjacent on the row of the triangle below
#python3.4
triangle = '''\
75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
41 48 72 33 47 32 37 16 94 29
53 71 44 65 25 43 91 52 97 51 14
70 11 33 28 77 73 17 78 39 68 17 57
91 71 52 38 17 14 91 43 58 50 27 29 48
63 66 04 68 89 53 67 30 73 16 69 87 40 31
04 62 98 27 23 09 70 98 73 93 38 53 60 04 23'''
def int_triangle(data):
return [[int(x) for x in y.split()] for y in [x for x in data.split('\n')]]
def arrows_recursive(data, total = [], main = [], x = 0, y = 0):
temp = [] + main
if x < len(data) and y < len(data):
temp.append(data[y][x])
total = arrows_recursive(data, total = total, main = temp, x = x, y = y + 1)
total = arrows_recursive(data, total = total, main = temp, x = x + 1, y = y + 1)
if len(temp) >= len(data):
total.append(temp)
return total
if __name__ == '__main__':
lista = int_triangle(triangle)
p = arrows_recursive(lista)
print(max(map(sum, p)))
================================================
FILE: Problem018/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=18)
================================================
FILE: Problem019/.hash
================================================
a4a042cf4fd6bfb47701cbc8a1653ada
================================================
FILE: Problem019/Elixir/solution_1.exs
================================================
defmodule Sundays do
def count(final,[year|[_|[count|_]]],_) when year == final do
count + 1
end
def count(final,[year|[day|count]],months) when year < final do
count(final,calendar(year,months, day,List.first(count)), months)
end
def calendar(year,months,day,count) when length(months) <= 0 do
[year + 1, day, count]
end
def calendar(year,months,day,count) when length(months) > 0 do
[month|rem_months] = months
[count|month] = check_day_and_month(count, day, month, year)
calendar(year, rem_months, (rem((month + day), 7)), count)
end
def check_day_and_month(count,day,month,year) do
count = cond do
day == 0 ->
count + 1
day != 0 ->
count
end
month = cond do
month == 28 and leap_year?(year) ->
29
true ->
month
end
[count|month]
end
def leap_year?(year) do
unless((rem(year, 100) == 0 and rem(year, 400) != 0), do: rem(year, 4) == 0)
end
end
IO.puts Sundays.count(2000,[1901,2,0],[31,28,31,30,31,30,31,31,30,31,30,31])
================================================
FILE: Problem019/Python/solution_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
# Python Script
#
# Copyleft © Manoel Vilela
#
#
"""
Counting Sundays
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)?
"""
# 0 - SUNDAY
# 1 - MONDAY
# 2 - THIRDDAY
# 3 - WEDNESDAY
# 4 - THURSDAY
# 5 - FRIDAY
# 6 - SATURDAY
days_dic = {
0: 'SUNDAY',
1: 'MONDAY',
2: 'THIRDDAY',
3: 'WEDNESDAY',
4: 'THURSDAY',
5: 'FRIDAY',
6: 'SATURDAY',
}
def howmanysundays(days, day):
some_incredible_stuff = int(days - (7 - day) > 28 or day == 0 and days > 28)
sundays_in_the_month = days // 7 + some_incredible_stuff
return sundays_in_the_month
def is_leap(year):
return (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0)
def solution(first_day):
months_days = {
1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30,
7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31
}
interval = range(1900, 2000 + 1)
day = 1 # MONDAY (first day of year 1900)
firsts = 0
for year in interval:
leap = is_leap(year)
for month, days in sorted(months_days.items()):
if month == 2 and leap:
days += 1
if year > 1900 and day == first_day:
firsts += 1
day += days % 7
if day > 6:
day -= 7
return firsts
print(solution(0))
================================================
FILE: Problem019/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=19)
================================================
FILE: Problem020/.hash
================================================
443cb001c138b2561a0d90720d6ce111
================================================
FILE: Problem020/Clojure/solution_1.clj
================================================
;Author: tkovs
(defn sum [x]
(apply + (map #(Integer. (str %)) (str x))))
(defn solve []
(sum (reduce *' (range 1 100))))
(println(solve))
================================================
FILE: Problem020/Clojure/solution_2.clj
================================================
;; very very VERY slow solution: take 1min to finish. (hahaha)
(defn solution
[]
(->> (range 1 100)
(reduce *')
(str)
(seq)
(pmap #(Character/getNumericValue %))
(reduce +)
(str)))
(println (solution))
;; weird bug here: if I don't force exit, the process continue about 1min
;; without need. Clojure 1.8.0 here. Need report bug?
(System/exit 0)
================================================
FILE: Problem020/CommonLisp/solution_1.lisp
================================================
;; Common Lisp Script
;; Manoel Vilela
(defun integer-to-list (x)
(if (< x 10)
(cons x nil)
(cons (mod x 10)
(integer-to-list (floor (/ x 10))))))
(defun sum (the-list)
(reduce '+ the-list))
(defun fat (x)
(if (<= x 2)
x
(* x (fat (1- x)))))
(defun solution ()
(sum (integer-to-list (fat 100))))
(princ (solution))
================================================
FILE: Problem020/Elixir/solution_1.exs
================================================
# Author: lubien
1..100
|> Enum.reduce(&(&1 * &2))
|> Integer.digits
|> Enum.reduce(&(&1 + &2))
|> IO.inspect
================================================
FILE: Problem020/Haskell/solution_1.hs
================================================
{-
n! means n × (n − 1) × ... × 3 × 2 × 1
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
-}
import Data.Char
main :: IO ()
main = print $ sum $ map (digitToInt) $ show $ product [1..100]
================================================
FILE: Problem020/JavaScript/solution_1.js
================================================
"use strict";
function getReducedFactorial() {
let prod = 1n, numOfTwo = 0, numOfFive = 0, num, sum = 0n;
for (let i = 2; i <= 100; i++) {
num = i;
while (!(num % 2) && num >= 2) (num = Math.floor(num / 2)) && ++numOfTwo;
while (!(num % 5) && num >= 5) (num = Math.floor(num / 5)) && ++numOfFive;
prod *= BigInt(num);
}
prod *= BigInt((numOfTwo > numOfFive) ? 2 ** (numOfTwo - numOfFive) : 5 ** (numOfFive - numOfTwo));
while (prod) (sum += prod % 10n) && (prod = prod / 10n);
return sum;
}
console.log(parseInt(getReducedFactorial()));
================================================
FILE: Problem020/Python/solution_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
# Python Script
#
# Copyleft © Manoel Vilela
#
#
from functools import reduce
import sys
if sys.version_info > (3, 0):
xrange = range
long = int
"""
Factorial digit sum
Problem 20
n! means n × (n − 1) × ... × 3 × 2 × 1
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
"""
print(reduce(long.__add__, map(long, str(reduce(long.__mul__, map(long, xrange(1, 100)))))))
================================================
FILE: Problem020/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=20)
================================================
FILE: Problem020/Ruby/solution_1.rb
================================================
#Author: tkovs
#Translation of CommonLisp code
def solve
1.upto(100).inject(:*).to_s.split('').map{|x| x.to_i}.inject(:+)
end
puts(solve)
================================================
FILE: Problem021/.hash
================================================
51e04cd4e55e7e415bf24de9e1b0f3ff
================================================
FILE: Problem021/Elixir/solution_1.exs
================================================
# Author: lubien
defmodule Euler21 do
def solve do
1..10_000
|> Stream.filter(&amicable/1)
|> Enum.reduce(&sum/2)
end
def d(1), do: 1
def d(n) do
1..(div(n, 2))
|> Stream.filter(&(rem(n, &1) == 0))
|> Enum.reduce(&sum/2)
end
def amicable(a) do
amic = d(a)
amic != a && d(amic) == a
end
defp sum(x, y), do: x + y
end
Euler21.solve
|> IO.puts
================================================
FILE: Problem021/Haskell/solution_slow_1.hs
================================================
d :: Int -> Int
d n = sum [x | x <- [1..div n 2], mod n x == 0]
amicable :: Int -> Bool
amicable n = (d n /= n && n == d (d n))
main :: IO ()
main = do
print . sum $ filter amicable [1..10000]
================================================
FILE: Problem021/Python/solution_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
# Python Script
#
# Copyleft © Manoel Vilela
#
#
from functools import reduce
"""
Amicable numbers
Problem 21
Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers.
For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284.
The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220.
Evaluate the sum of all the amicable numbers under 10000.
"""
# FUCK D: ? i WROTE THIS? MY LEVEL OF OBSCURITY IS MORE HIGHER WHOSE I THOUGH...
def d(n):
return sum(sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))[:-1])
print(sum(x for x in range(1, 10000) if d(x) > 0 and x != d(x) and x == d(d(x))))
================================================
FILE: Problem021/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=21)
================================================
FILE: Problem022/.hash
================================================
f2c9c91cb025746f781fa4db8be3983f
================================================
FILE: Problem022/Python/solution_1.py
================================================
#!/usr/bin/env python
# coding=utf-8
# Python Script
#
# Copyleft © Manoel Vilela
#
#
"""
Names scores
Problem 22
Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score.
For example, when the list is sorted into alphabetical order, COLIN, which is worth 3 + 15 + 12 + 9 + 14 = 53, is the 938th name in the list. So, COLIN would obtain a score of 938 × 53 = 49714.
What is the total of all the name scores in the file?
"""
from os.path import join, dirname
from string import ascii_uppercase as alf
f = open('../p022_names.txt', 'r').read()[:-1]
l = sorted([x[1:-1] for x in f.split(',')])
s = lambda x: sum(((alf.index(y) + 1) for y in x))
print(sum((s(l[x]) * (x + 1) for x in range(len(l)))))
================================================
FILE: Problem022/README.md
================================================
[The original source of problem](https://projecteuler.net/problem=22)
================================================
FILE: Problem022/p022_names.txt
================================================
"MARY","PATRICIA","LINDA","BARBARA","ELIZABETH","JENNIFER","MARIA","SUSAN","MARGARET","DOROTHY","LISA","NANCY","KAREN","BETTY","HELEN","SANDRA","DONNA","CAROL","RUTH","SHARON","MICHELLE","LAURA","SARAH","KIMBERLY","DEBORAH","JESSICA","SHIRLEY","CYNTHIA","ANGELA","MELISSA","BRENDA","AMY","ANNA","REBECCA","VIRGINIA","KATHLEEN","PAMELA","MARTHA","DEBRA","AMANDA","STEPHANIE","CAROLYN","CHRISTINE","MARIE","JANET","CATHERINE","FRANCES","ANN","JOYCE","DIANE","ALICE","JULIE","HEATHER","TERESA","DORIS","GLORIA","EVELYN","JEAN","CHERYL","MILDRED","KATHERINE","JOAN","ASHLEY","JUDITH","ROSE","JANICE","KELLY","NICOLE","JUDY","CHRISTINA","KATHY","THERESA","BEVERLY","DENISE","TAMMY","IRENE","JANE","LORI","RACHEL","MARILYN","ANDREA","KATHRYN","LOUISE","SARA","ANNE","JACQUELINE","WANDA","BONNIE","JULIA","RUBY","LOIS","TINA","PHYLLIS","NORMA","PAULA","DIANA","ANNIE","LILLIAN","EMILY","ROBIN","PEGGY","CRYSTAL","GLADYS","RITA","DAWN","CONNIE","FLORENCE","TRACY","EDNA","TIFFANY","CARMEN","ROSA","CINDY","GRACE","WENDY","VICTORIA","EDITH","KIM","SHERRY","SYLVIA","JOSEPHINE","THELMA","SHANNON","SHEILA","ETHEL","ELLEN","ELAINE","MARJORIE","CARRIE","CHARLOTTE","MONICA","ESTHER","PAULINE","EMMA","JUANITA","ANITA","RHONDA","HAZEL","AMBER","EVA","DEBBIE","APRIL","LESLIE","CLARA","LUCILLE","JAMIE","JOANNE","ELEANOR","VALERIE","DANIELLE","MEGAN","ALICIA","SUZANNE","MICHELE","GAIL","BERTHA","DARLENE","VERONICA","JILL","ERIN","GERALDINE","LAUREN","CATHY","JOANN","LORRAINE","LYNN","SALLY","REGINA","ERICA","BEATRICE","DOLORES","BERNICE","AUDREY","YVONNE","ANNETTE","JUNE","SAMANTHA","MARION","DANA","STACY","ANA","RENEE","IDA","VIVIAN","ROBERTA","HOLLY","BRITTANY","MELANIE","LORETTA","YOLANDA","JEANETTE","LAURIE","KATIE","KRISTEN","VANESSA","ALMA","SUE","ELSIE","BETH","JEANNE","VICKI","CARLA","TARA","ROSEMARY","EILEEN","TERRI","GERTRUDE","LUCY","TONYA","ELLA","STACEY","WILMA","GINA","KRISTIN","JESSIE","NATALIE","AGNES","VERA","WILLIE","CHARLENE","BESSIE","DELORES","MELINDA","PEARL","ARLENE","MAUREEN","COLLEEN","ALLISON","TAMARA","JOY","GEORGIA","CONSTANCE","LILLIE","CLAUDIA","JACKIE","MARCIA","TANYA","NELLIE","MINNIE","MARLENE","HEIDI","GLENDA","LYDIA","VIOLA","COURTNEY","MARIAN","STELLA","CAROLINE","DORA","JO","VICKIE","MATTIE","TERRY","MAXINE","IRMA","MABEL","MARSHA","MYRTLE","LENA","CHRISTY","DEANNA","PATSY","HILDA","GWENDOLYN","JENNIE","NORA","MARGIE","NINA","CASSANDRA","LEAH","PENNY","KAY","PRISCILLA","NAOMI","CAROLE","BRANDY","OLGA","BILLIE","DIANNE","TRACEY","LEONA","JENNY","FELICIA","SONIA","MIRIAM","VELMA","BECKY","BOBBIE","VIOLET","KRISTINA","TONI","MISTY","MAE","SHELLY","DAISY","RAMONA","SHERRI","ERIKA","KATRINA","CLAIRE","LINDSEY","LINDSAY","GENEVA","GUADALUPE","BELINDA","MARGARITA","SHERYL","CORA","FAYE","ADA","NATASHA","SABRINA","ISABEL","MARGUERITE","HATTIE","HARRIET","MOLLY","CECILIA","KRISTI","BRANDI","BLANCHE","SANDY","ROSIE","JOANNA","IRIS","EUNICE","ANGIE","INEZ","LYNDA","MADELINE","AMELIA","ALBERTA","GENEVIEVE","MONIQUE","JODI","JANIE","MAGGIE","KAYLA","SONYA","JAN","LEE","KRISTINE","CANDACE","FANNIE","MARYANN","OPAL","ALISON","YVETTE","MELODY","LUZ","SUSIE","OLIVIA","FLORA","SHELLEY","KRISTY","MAMIE","LULA","LOLA","VERNA","BEULAH","ANTOINETTE","CANDICE","JUANA","JEANNETTE","PAM","KELLI","HANNAH","WHITNEY","BRIDGET","KARLA","CELIA","LATOYA","PATTY","SHELIA","GAYLE","DELLA","VICKY","LYNNE","SHERI","MARIANNE","KARA","JACQUELYN","ERMA","BLANCA","MYRA","LETICIA","PAT","KRISTA","ROXANNE","ANGELICA","JOHNNIE","ROBYN","FRANCIS","ADRIENNE","ROSALIE","ALEXANDRA","BROOKE","BETHANY","SADIE","BERNADETTE","TRACI","JODY","KENDRA","JASMINE","NICHOLE","RACHAEL","CHELSEA","MABLE","ERNESTINE","MURIEL","MARCELLA","ELENA","KRYSTAL","ANGELINA","NADINE","KARI","ESTELLE","DIANNA","PAULETTE","LORA","MONA","DOREEN","ROSEMARIE","ANGEL","DESIREE","ANTONIA","HOPE","GINGER","JANIS","BETSY","CHRISTIE","FREDA","MERCEDES","MEREDITH","LYNETTE","TERI","CRISTINA","EULA","LEIGH","MEGHAN","SOPHIA","ELOISE","ROCHELLE","GRETCHEN","CECELIA","RAQUEL","HENRIETTA","ALYSSA","JANA","KELLEY","GWEN","KERRY","JENNA","TRICIA","LAVERNE","OLIVE","ALEXIS","TASHA","SILVIA","ELVIRA","CASEY","DELIA","SOPHIE","KATE","PATTI","LORENA","KELLIE","SONJA","LILA","LANA","DARLA","MAY","MINDY","ESSIE","MANDY","LORENE","ELSA","JOSEFINA","JEANNIE","MIRANDA","DIXIE","LUCIA","MARTA","FAITH","LELA","JOHANNA","SHARI","CAMILLE","TAMI","SHAWNA","ELISA","EBONY","MELBA","ORA","NETTIE","TABITHA","OLLIE","JAIME","WINIFRED","KRISTIE","MARINA","ALISHA","AIMEE","RENA","MYRNA","MARLA","TAMMIE","LATASHA","BONITA","PATRICE","RONDA","SHERRIE","ADDIE","FRANCINE","DELORIS","STACIE","ADRIANA","CHERI","SHELBY","ABIGAIL","CELESTE","JEWEL","CARA","ADELE","REBEKAH","LUCINDA","DORTHY","CHRIS","EFFIE","TRINA","REBA","SHAWN","SALLIE","AURORA","LENORA","ETTA","LOTTIE","KERRI","TRISHA","NIKKI","ESTELLA","FRANCISCA","JOSIE","TRACIE","MARISSA","KARIN","BRITTNEY","JANELLE","LOURDES","LAUREL","HELENE","FERN","ELVA","CORINNE","KELSEY","INA","BETTIE","ELISABETH","AIDA","CAITLIN","INGRID","IVA","EUGENIA","CHRISTA","GOLDIE","CASSIE","MAUDE","JENIFER","THERESE","FRANKIE","DENA","LORNA","JANETTE","LATONYA","CANDY","MORGAN","CONSUELO","TAMIKA","ROSETTA","DEBORA","CHERIE","POLLY","DINA","JEWELL","FAY","JILLIAN","DOROTHEA","NELL","TRUDY","ESPERANZA","PATRICA","KIMBERLEY","SHANNA","HELENA","CAROLINA","CLEO","STEFANIE","ROSARIO","OLA","JANINE","MOLLIE","LUPE","ALISA","LOU","MARIBEL","SUSANNE","BETTE","SUSANA","ELISE","CECILE","ISABELLE","LESLEY","JOCELYN","PAIGE","JONI","RACHELLE","LEOLA","DAPHNE","ALTA","ESTER","PETRA","GRACIELA","IMOGENE","JOLENE","KEISHA","LACEY","GLENNA","GABRIELA","KERI","URSULA","LIZZIE","KIRSTEN","SHANA","ADELINE","MAYRA","JAYNE","JACLYN","GRACIE","SONDRA","CARMELA","MARISA","ROSALIND","CHARITY","TONIA","BEATRIZ","MARISOL","CLARICE","JEANINE","SHEENA","ANGELINE","FRIEDA","LILY","ROBBIE","SHAUNA","MILLIE","CLAUDETTE","CATHLEEN","ANGELIA","GABRIELLE","AUTUMN","KATHARINE","SUMMER","JODIE","STACI","LEA","CHRISTI","JIMMIE","JUSTINE","ELMA","LUELLA","MARGRET","DOMINIQUE","SOCORRO","RENE","MARTINA","MARGO","MAVIS","CALLIE","BOBBI","MARITZA","LUCILE","LEANNE","JEANNINE","DEANA","AILEEN","LORIE","LADONNA","WILLA","MANUELA","GALE","SELMA","DOLLY","SYBIL","ABBY","LARA","DALE","IVY","DEE","WINNIE","MARCY","LUISA","JERI","MAGDALENA","OFELIA","MEAGAN","AUDRA","MATILDA","LEILA","CORNELIA","BIANCA","SIMONE","BETTYE","RANDI","VIRGIE","LATISHA","BARBRA","GEORGINA","ELIZA","LEANN","BRIDGETTE","RHODA","HALEY","ADELA","NOLA","BERNADINE","FLOSSIE","ILA","GRETA","RUTHIE","NELDA","MINERVA","LILLY","TERRIE","LETHA","HILARY","ESTELA","VALARIE","BRIANNA","ROSALYN","EARLINE","CATALINA","AVA","MIA","CLARISSA","LIDIA","CORRINE","ALEXANDRIA","CONCEPCION","TIA","SHARRON","RAE","DONA","ERICKA","JAMI","ELNORA","CHANDRA","LENORE","NEVA","MARYLOU","MELISA","TABATHA","SERENA","AVIS","ALLIE","SOFIA","JEANIE","ODESSA","NANNIE","HARRIETT","LORAINE","PENELOPE","MILAGROS","EMILIA","BENITA","ALLYSON","ASHLEE","TANIA","TOMMIE","ESMERALDA","KARINA","EVE","PEARLIE","ZELMA","MALINDA","NOREEN","TAMEKA","SAUNDRA","HILLARY","AMIE","ALTHEA","ROSALINDA","JORDAN","LILIA","ALANA","GAY","CLARE","ALEJANDRA","ELINOR","MICHAEL","LORRIE","JERRI","DARCY","EARNESTINE","CARMELLA","TAYLOR","NOEMI","MARCIE","LIZA","ANNABELLE","LOUISA","EARLENE","MALLORY","CARLENE","NITA","SELENA","TANISHA","KATY","JULIANNE","JOHN","LAKISHA","EDWINA","MARICELA","MARGERY","KENYA","DOLLIE","ROXIE","ROSLYN","KATHRINE","NANETTE","CHARMAINE","LAVONNE","ILENE","KRIS","TAMMI","SUZETTE","CORINE","KAYE","JERRY","MERLE","CHRYSTAL","LINA","DEANNE","LILIAN","JULIANA","ALINE","LUANN","KASEY","MARYANNE","EVANGELINE","COLETTE","MELVA","LAWANDA","YESENIA","NADIA","MADGE","KATHIE","EDDIE","OPHELIA","VALERIA","NONA","MITZI","MARI","GEORGETTE","CLAUDINE","FRAN","ALISSA","ROSEANN","LAKEISHA","SUSANNA","REVA","DEIDRE","CHASITY","SHEREE","CARLY","JAMES","ELVIA","ALYCE","DEIRDRE","GENA","BRIANA","ARACELI","KATELYN","ROSANNE","WENDI","TESSA","BERTA","MARVA","IMELDA","MARIETTA","MARCI","LEONOR","ARLINE","SASHA","MADELYN","JANNA","JULIETTE","DEENA","AURELIA","JOSEFA","AUGUSTA","LILIANA","YOUNG","CHRISTIAN","LESSIE","AMALIA","SAVANNAH","ANASTASIA","VILMA","NATALIA","ROSELLA","LYNNETTE","CORINA","ALFREDA","LEANNA","CAREY","AMPARO","COLEEN","TAMRA","AISHA","WILDA","KARYN","CHERRY","QUEEN","MAURA","MAI","EVANGELINA","ROSANNA","HALLIE","ERNA","ENID","MARIANA","LACY","JULIET","JACKLYN","FREIDA","MADELEINE","MARA","HESTER","CATHRYN","LELIA","CASANDRA","BRIDGETT","ANGELITA","JANNIE","DIONNE","ANNMARIE","KATINA","BERYL","PHOEBE","MILLICENT","KATHERYN","DIANN","CARISSA","MARYELLEN","LIZ","LAURI","HELGA","GILDA","ADRIAN","RHEA","MARQUITA","HOLLIE","TISHA","TAMERA","ANGELIQUE","FRANCESCA","BRITNEY","KAITLIN","LOLITA","FLORINE","ROWENA","REYNA","TWILA","FANNY","JANELL","INES","CONCETTA","BERTIE","ALBA","BRIGITTE","ALYSON","VONDA","PANSY","ELBA","NOELLE","LETITIA","KITTY","DEANN","BRANDIE","LOUELLA","LETA","FELECIA","SHARLENE","LESA","BEVERLEY","ROBERT","ISABELLA","HERMINIA","TERRA","CELINA","TORI","OCTAVIA","JADE","DENICE","GERMAINE","SIERRA","MICHELL","CORTNEY","NELLY","DORETHA","SYDNEY","DEIDRA","MONIKA","LASHONDA","JUDI","CHELSEY","ANTIONETTE","MARGOT","BOBBY","ADELAIDE","NAN","LEEANN","ELISHA","DESSIE","LIBBY","KATHI","GAYLA","LATANYA","MINA","MELLISA","KIMBERLEE","JASMIN","RENAE","ZELDA","ELDA","MA","JUSTINA","GUSSIE","EMILIE","CAMILLA","ABBIE","ROCIO","KAITLYN","JESSE","EDYTHE","ASHLEIGH","SELINA","LAKESHA","GERI","ALLENE","PAMALA","MICHAELA","DAYNA","CARYN","ROSALIA","SUN","JACQULINE","REBECA","MARYBETH","KRYSTLE","IOLA","DOTTIE","BENNIE","BELLE","AUBREY","GRISELDA","ERNESTINA","ELIDA","ADRIANNE","DEMETRIA","DELMA","CHONG","JAQUELINE","DESTINY","ARLEEN","VIRGINA","RETHA","FATIMA","TILLIE","ELEANORE","CARI","TREVA","BIRDIE","WILHELMINA","ROSALEE","MAURINE","LATRICE","YONG","JENA","TARYN","ELIA","DEBBY","MAUDIE","JEANNA","DELILAH","CATRINA","SHONDA","HORTENCIA","THEODORA","TERESITA","ROBBIN","DANETTE","MARYJANE","FREDDIE","DELPHINE","BRIANNE","NILDA","DANNA","CINDI","BESS","IONA","HANNA","ARIEL","WINONA","VIDA","ROSITA","MARIANNA","WILLIAM","RACHEAL","GUILLERMINA","ELOISA","CELESTINE","CAREN","MALISSA","LONA","CHANTEL","SHELLIE","MARISELA","LEORA","AGATHA","SOLEDAD","MIGDALIA","IVETTE","CHRISTEN","ATHENA","JANEL","CHLOE","VEDA","PATTIE","TESSIE","TERA","MARILYNN","LUCRETIA","KARRIE","DINAH","DANIELA","ALECIA","ADELINA","VERNICE","SHIELA","PORTIA","MERRY","LASHAWN","DEVON","DARA","TAWANA","OMA","VERDA","CHRISTIN","ALENE","ZELLA","SANDI","RAFAELA","MAYA","KIRA","CANDIDA","ALVINA","SUZAN","SHAYLA","LYN","LETTIE","ALVA","SAMATHA","ORALIA","MATILDE","MADONNA","LARISSA","VESTA","RENITA","INDIA","DELOIS","SHANDA","PHILLIS","LORRI","ERLINDA","CRUZ","CATHRINE","BARB","ZOE","ISABELL","IONE","GISELA","CHARLIE","VALENCIA","ROXANNA","MAYME","KISHA","ELLIE","MELLISSA","DORRIS","DALIA","BELLA","ANNETTA","ZOILA","RETA","REINA","LAURETTA","KYLIE","CHRISTAL","PILAR","CHARLA","ELISSA","TIFFANI","TANA","PAULINA","LEOTA","BREANNA","JAYME","CARMEL","VERNELL","TOMASA","MANDI","DOMINGA","SANTA","MELODIE","LURA","ALEXA","TAMELA","RYAN","MIRNA","KERRIE","VENUS","NOEL","FELICITA","CRISTY","CARMELITA","BERNIECE","ANNEMARIE","TIARA","ROSEANNE","MISSY","CORI","ROXANA","PRICILLA","KRISTAL","JUNG","ELYSE","HAYDEE","ALETHA","BETTINA","MARGE","GILLIAN","FILOMENA","CHARLES","ZENAIDA","HARRIETTE","CARIDAD","VADA","UNA","ARETHA","PEARLINE","MARJORY","MARCELA","FLOR","EVETTE","ELOUISE","ALINA","TRINIDAD","DAVID","DAMARIS","CATHARINE","CARROLL","BELVA","NAKIA","MARLENA","LUANNE","LORINE","KARON","DORENE","DANITA","BRENNA","TATIANA","SAMMIE","LOUANN","LOREN","JULIANNA","ANDRIA","PHILOMENA","LUCILA","LEONORA","DOVIE","ROMONA","MIMI","JACQUELIN","GAYE","TONJA","MISTI","JOE","GENE","CHASTITY","STACIA","ROXANN","MICAELA","NIKITA","MEI","VELDA","MARLYS","JOHNNA","AURA","LAVERN","IVONNE","HAYLEY","NICKI","MAJORIE","HERLINDA","GEORGE","ALPHA","YADIRA","PERLA","GREGORIA","DANIEL","ANTONETTE","SHELLI","MOZELLE","MARIAH","JOELLE","CORDELIA","JOSETTE","CHIQUITA","TRISTA","LOUIS","LAQUITA","GEORGIANA","CANDI","SHANON","LONNIE","HILDEGARD","CECIL","VALENTINA","STEPHANY","MAGDA","KAROL","GERRY","GABRIELLA","TIANA","ROMA","RICHELLE","RAY","PRINCESS","OLETA","JACQUE","IDELLA","ALAINA","SUZANNA","JOVITA","BLAIR","TOSHA","RAVEN","NEREIDA","MARLYN","KYLA","JOSEPH","DELFINA","TENA","STEPHENIE","SABINA","NATHALIE","MARCELLE","GERTIE","DARLEEN","THEA","SHARONDA","SHANTEL","BELEN","VENESSA","ROSALINA","ONA","GENOVEVA","COREY","CLEMENTINE","ROSALBA","RENATE","RENATA","MI","IVORY","GEORGIANNA","FLOY","DORCAS","ARIANA","TYRA","THEDA","MARIAM","JULI","JESICA","DONNIE","VIKKI","VERLA","ROSELYN","MELVINA","JANNETTE","GINNY","DEBRAH","CORRIE","ASIA","VIOLETA","MYRTIS","LATRICIA","COLLETTE","CHARLEEN","ANISSA","VIVIANA","TWYLA","PRECIOUS","NEDRA","LATONIA","LAN","HELLEN","FABIOLA","ANNAMARIE","ADELL","SHARYN","CHANTAL","NIKI","MAUD","LIZETTE","LINDY","KIA","KESHA","JEANA","DANELLE","CHARLINE","CHANEL","CARROL","VALORIE","LIA","DORTHA","CRISTAL","SUNNY","LEONE","LEILANI","GERRI","DEBI","ANDRA","KESHIA","IMA","EULALIA","EASTER","DULCE","NATIVIDAD","LINNIE","KAMI","GEORGIE","CATINA","BROOK","ALDA","WINNIFRED","SHARLA","RUTHANN","MEAGHAN","MAGDALENE","LISSETTE","ADELAIDA","VENITA","TRENA","S
gitextract_2dk6ce_6/ ├── .gitignore ├── .travis.yml ├── Dockerfile ├── LICENSE ├── Problem001/ │ ├── .hash │ ├── Brain/ │ │ └── solution_1.brain │ ├── C/ │ │ ├── Makefile │ │ ├── solution_1.c │ │ └── solution_2.c │ ├── C++/ │ │ ├── Makefile │ │ └── solution_1.cpp │ ├── Clojure/ │ │ └── solution_1.clj │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── D/ │ │ └── solution_1.d │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Erlang/ │ │ └── solution_1.erl │ ├── Go/ │ │ └── solution_1.go │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Java/ │ │ └── solution_1.java │ ├── JavaScript/ │ │ ├── solution_1.js │ │ └── solution_2.js │ ├── Kotlin/ │ │ └── solution_1.kt │ ├── Lua/ │ │ └── solution_1.lua │ ├── OCaml/ │ │ └── solution_1.ml │ ├── Objective-C/ │ │ └── solution_1.m │ ├── PHP/ │ │ ├── solution_1.php │ │ └── solution_2.php │ ├── Python/ │ │ ├── solution_1.py │ │ └── solution_2.py │ ├── R/ │ │ └── solution_1.R │ ├── README.md │ ├── Racket/ │ │ └── solution_1.rkt │ ├── Ruby/ │ │ └── solution_1.rb │ ├── Rust/ │ │ └── solution_1.rs │ ├── Scheme/ │ │ ├── solution_1.scm │ │ └── solution_2.scm │ ├── Shell/ │ │ └── solution_1.sh │ └── Swift/ │ └── solution_1.swift ├── Problem002/ │ ├── .hash │ ├── C/ │ │ ├── Makefile │ │ └── solution_1.c │ ├── C++/ │ │ ├── Makefile │ │ └── solution_1.cpp │ ├── Clojure/ │ │ ├── solution_1.clj │ │ └── solution_2.clj │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── D/ │ │ └── solution_1.d │ ├── Elixir/ │ │ └── solution_1.ex │ ├── Go/ │ │ └── solution_1.go │ ├── Haskell/ │ │ └── solution_1.hs │ ├── JavaScript/ │ │ └── solution_1.js │ ├── Lua/ │ │ └── solution_1.lua │ ├── OCaml/ │ │ └── solution_1.ml │ ├── PHP/ │ │ └── solution_1.php │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ ├── Ruby/ │ │ └── solution_1.rb │ └── Scheme/ │ └── solution_1.scm ├── Problem003/ │ ├── .hash │ ├── C++/ │ │ └── solution_1.cpp │ ├── Clojure/ │ │ └── solution_1.clj │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Go/ │ │ └── solution_1.go │ ├── Haskell/ │ │ ├── solution_1.hs │ │ └── solution_2.hs │ ├── JavaScript/ │ │ └── solution_1.js │ ├── PHP/ │ │ └── solution_1.php │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ ├── Scheme/ │ │ └── solution_1.scm │ └── Shell/ │ └── solution_1.sh ├── Problem004/ │ ├── .hash │ ├── C/ │ │ └── solution_1.c │ ├── Clojure/ │ │ └── solution_1.clj │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Go/ │ │ └── solution_1.go │ ├── Haskell/ │ │ └── solution_1.hs │ ├── JavaScript/ │ │ └── solution_1.js │ ├── Lua/ │ │ └── solution_1.lua │ ├── OCaml/ │ │ └── solution_1.ml │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── Ruby/ │ └── solution_01.rb ├── Problem005/ │ ├── .hash │ ├── C/ │ │ └── solution_1.c │ ├── C++/ │ │ └── solution_1.cpp │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Elixir/ │ │ ├── solution_1.exs │ │ ├── solution_2.exs │ │ └── solution_slow_1.exs │ ├── Haskell/ │ │ └── solution_1.hs │ ├── JavaScript/ │ │ └── solution_1.js │ ├── Lua/ │ │ └── solution_1.lua │ ├── OCaml/ │ │ └── solution_1.ml │ ├── Python/ │ │ ├── solution_2.py │ │ ├── solution_3.py │ │ └── solution_slow_1.py │ ├── README.md │ ├── Scheme/ │ │ └── solution_1.scm │ └── go/ │ └── solution_1.go ├── Problem006/ │ ├── .hash │ ├── C++/ │ │ ├── Makefile │ │ └── solution_1.cpp │ ├── Clojure/ │ │ └── solution_1.clj │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Haskell/ │ │ └── solution_1.hs │ ├── LaTeX/ │ │ └── solution_1.tex │ ├── OCaml/ │ │ └── solution_1.ml │ ├── Python/ │ │ ├── solution_1.py │ │ └── solution_2.py │ ├── README.md │ ├── Ruby/ │ │ └── solution_1.rb │ ├── Scheme/ │ │ └── solution_1.scm │ └── go/ │ └── solution_1.go ├── Problem007/ │ ├── .hash │ ├── C++/ │ │ ├── Makefile │ │ └── solution_1.cpp │ ├── Clojure/ │ │ ├── solution_1.clj │ │ └── solution_2.clj │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Elixir/ │ │ ├── solution_2.exs │ │ └── solution_slow_1.exs │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Lua/ │ │ └── solution_1.lua │ ├── Python/ │ │ ├── primes.py │ │ └── solution_1.py │ ├── README.md │ └── Scheme/ │ └── solution_1.scm ├── Problem008/ │ ├── .hash │ ├── Clojure/ │ │ └── solution_slow_1.clj │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem009/ │ ├── .hash │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Python/ │ │ ├── solution_1.py │ │ └── solution_2.py │ ├── README.md │ └── Ruby/ │ └── solution_1.rb ├── Problem010/ │ ├── .hash │ ├── C++/ │ │ ├── Makefile │ │ └── solution_1.cpp │ ├── Clojure/ │ │ └── solution_1.clj │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Haskell/ │ │ ├── solution_slow_1.hs │ │ └── solution_slow_2.hs │ ├── Python/ │ │ ├── primes.py │ │ └── solution_1.py │ └── README.md ├── Problem011/ │ ├── .hash │ ├── C++/ │ │ └── solution_1.cpp │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem012/ │ ├── .hash │ ├── C++/ │ │ └── solution_1.cpp │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Haskell/ │ │ └── solution_1.hs │ ├── JavaScript/ │ │ └── solution_1.js │ ├── Python/ │ │ ├── solution_1.py │ │ ├── solution_2.py │ │ └── solution_3.py │ └── README.md ├── Problem013/ │ ├── .hash │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Lua/ │ │ └── solution_1.lua │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── Ruby/ │ └── solution_1.rb ├── Problem014/ │ ├── .hash │ ├── Clojure/ │ │ └── solution_1.clj │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Haskell/ │ │ └── solution_slow_1.hs │ ├── Python/ │ │ └── solution_slow_1.py │ └── README.md ├── Problem015/ │ ├── .hash │ ├── C/ │ │ └── solution_1.c │ ├── Clojure/ │ │ └── solution_1.clj │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Haskell/ │ │ ├── solution_1.hs │ │ └── solution_2.hs │ ├── Lua/ │ │ └── solution_1.lua │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── Ruby/ │ └── solution_1.rb ├── Problem016/ │ ├── .hash │ ├── Clojure/ │ │ └── solution_1.clj │ ├── CommonLisp/ │ │ ├── solution_1.lisp │ │ └── solution_2.lisp │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Lua/ │ │ └── solution_1.lua │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── Ruby/ │ └── solution_1.rb ├── Problem017/ │ ├── .hash │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Python/ │ │ ├── p17_dic.json │ │ └── solution_1.py │ └── README.md ├── Problem018/ │ ├── .hash │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem019/ │ ├── .hash │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem020/ │ ├── .hash │ ├── Clojure/ │ │ ├── solution_1.clj │ │ └── solution_2.clj │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Haskell/ │ │ └── solution_1.hs │ ├── JavaScript/ │ │ └── solution_1.js │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── Ruby/ │ └── solution_1.rb ├── Problem021/ │ ├── .hash │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Haskell/ │ │ └── solution_slow_1.hs │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem022/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── p022_names.txt ├── Problem023/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem024/ │ ├── .hash │ ├── C++/ │ │ └── solution_1.cpp │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Python/ │ │ ├── solution_1.py │ │ └── solution_2.py │ ├── README.md │ └── Ruby/ │ └── solution_1.rb ├── Problem025/ │ ├── .hash │ ├── Clojure/ │ │ └── solution_1.clj │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem026/ │ ├── .hash │ ├── C++/ │ │ ├── Makefile │ │ └── solution_1.cpp │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem027/ │ ├── .hash │ ├── C/ │ │ ├── Makefile │ │ └── solution_1.c │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Go/ │ │ └── solution_1.go │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem028/ │ ├── .hash │ ├── C/ │ │ └── solution_1.c │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem029/ │ ├── .hash │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem030/ │ ├── .hash │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── Ruby/ │ └── solution_1.rb ├── Problem031/ │ ├── .hash │ ├── C/ │ │ ├── Makefile │ │ └── solution_1.c │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Haskell/ │ │ └── solution_slow_1.hs │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem032/ │ ├── .hash │ ├── Clojure/ │ │ └── solution_1.clj │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Lua/ │ │ └── solution_1.lua │ └── README.md ├── Problem033/ │ ├── .hash │ ├── Python/ │ │ ├── solution_1.py │ │ └── solution_2.py │ └── README.md ├── Problem034/ │ ├── .hash │ ├── C/ │ │ └── solution_1.c │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Python/ │ │ ├── solution_2.py │ │ └── solution_slow_1.py │ ├── README.md │ └── Ruby/ │ └── solution_1.rb ├── Problem035/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem036/ │ ├── .hash │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Go/ │ │ └── solution_1.go │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── Ruby/ │ └── solution_1.rb ├── Problem037/ │ ├── .hash │ ├── C++/ │ │ └── solution_1.cpp │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem038/ │ ├── .hash │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── Swift/ │ └── solution_1.swift ├── Problem039/ │ ├── .hash │ ├── C/ │ │ ├── Makefile │ │ └── solution_1.c │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Elixir/ │ │ └── solution_1.exs │ └── README.md ├── Problem040/ │ ├── .hash │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Python/ │ │ ├── solution_1.py │ │ └── solution_2.py │ └── README.md ├── Problem041/ │ ├── .hash │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Python/ │ │ └── solution_slow_1.py │ ├── README.md │ └── Swift/ │ └── solution_1.swift ├── Problem042/ │ ├── .hash │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Python/ │ │ ├── solution_1.py │ │ └── solution_2.py │ ├── README.md │ └── p042_words.txt ├── Problem043/ │ ├── .hash │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Python/ │ │ └── solution_slow_1.py │ ├── README.md │ └── Swift/ │ └── solution_1.swift ├── Problem044/ │ ├── .hash │ ├── Python/ │ │ ├── solution_1.py │ │ └── solution_2.py │ └── README.md ├── Problem045/ │ ├── .hash │ ├── C/ │ │ ├── Makefile │ │ └── solution_1.c │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Go/ │ │ └── solution_1.go │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ ├── Ruby/ │ │ └── solution_1.rb │ └── Swift/ │ └── solution_1.swift ├── Problem046/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── Ruby/ │ └── solution_1.rb ├── Problem047/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── Swift/ │ └── solution_1.swift ├── Problem048/ │ ├── .hash │ ├── C/ │ │ ├── Makefile │ │ └── solution_1.c │ ├── Clojure/ │ │ └── solution_1.clj │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Go/ │ │ └── solution_1.go │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── Ruby/ │ └── solution_1.rb ├── Problem049/ │ ├── .hash │ ├── Python/ │ │ ├── solution_1.py │ │ └── solution_2.py │ └── README.md ├── Problem050/ │ ├── .hash │ ├── Python/ │ │ └── solution_slow_1.py │ └── README.md ├── Problem052/ │ ├── .hash │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── Ruby/ │ └── solution_1.rb ├── Problem053/ │ ├── .hash │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Python/ │ │ ├── solution_1.py │ │ └── solution_2.py │ └── README.md ├── Problem054/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── p054_poker.txt ├── Problem055/ │ ├── .hash │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem056/ │ ├── .hash │ ├── Clojure/ │ │ └── solution_1.clj │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── Ruby/ │ └── solution_1.rb ├── Problem057/ │ ├── .hash │ ├── Haskell/ │ │ └── solution_slow_1.hs │ └── README.md ├── Problem058/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem059/ │ ├── .hash │ ├── Haskell/ │ │ └── solution_1.hs │ ├── README.md │ └── p059_cipher.txt ├── Problem062/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem063/ │ ├── .hash │ ├── C/ │ │ ├── Makefile │ │ └── solution_1.c │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Go/ │ │ └── solution_1.go │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Python/ │ │ ├── solution_1.py │ │ └── solution_2.py │ └── README.md ├── Problem067/ │ ├── .hash │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── p067_triangle.txt ├── Problem069/ │ ├── .hash │ ├── Python/ │ │ ├── solution_1.py │ │ └── solution_2.py │ └── README.md ├── Problem070/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem071/ │ ├── .hash │ ├── README.md │ └── Scheme/ │ └── solution_1.scm ├── Problem076/ │ ├── .hash │ ├── Elixir/ │ │ └── solution_1.exs │ └── README.md ├── Problem080/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem081/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── p081_matrix.txt ├── Problem085/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem087/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem089/ │ ├── .hash │ ├── Elixir/ │ │ └── solution_1.exs │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── p089_romans.txt ├── Problem092/ │ ├── .hash │ ├── Python/ │ │ ├── solution_slow_1.py │ │ └── solution_slow_2.py │ └── README.md ├── Problem097/ │ ├── .hash │ ├── CommonLisp/ │ │ └── solution_1.lisp │ ├── Haskell/ │ │ └── solution_1.hs │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── Ruby/ │ └── solution_slow_1.rb ├── Problem099/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── p099_base_exp.txt ├── Problem102/ │ ├── .hash │ ├── Haskell/ │ │ └── solution_1.hs │ ├── README.md │ └── p102_triangles.txt ├── Problem104/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem112/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem145/ │ ├── .hash │ ├── Python/ │ │ └── solution_slow_1.py │ └── README.md ├── Problem206/ │ ├── .hash │ ├── Haskell/ │ │ └── solution_1.hs │ └── README.md ├── Problem301/ │ ├── .hash │ ├── Python/ │ │ └── solution_1.py │ ├── README.md │ └── Scheme/ │ ├── solution_1.scm │ └── solution_2_slow.scm ├── Problem357/ │ ├── .hash │ ├── Python/ │ │ └── solution_slow_1.py │ └── README.md ├── Problem439/ │ ├── .hash │ ├── Python/ │ │ └── solution_slow_1.py │ └── README.md ├── Problem473/ │ ├── .hash │ ├── Python/ │ │ ├── solution_slow_1.py │ │ └── solution_slow_2.py │ └── README.md ├── Problem500/ │ ├── .hash │ ├── Bash/ │ │ └── solution_1.sh │ ├── Python/ │ │ └── solution_1.py │ └── README.md ├── Problem501/ │ ├── Python/ │ │ └── solution_slow_1.py │ └── README.md ├── README.md ├── RULES.md ├── SOLVERS.md ├── STATUS.md ├── add ├── docker-compose.yml ├── requirements.txt ├── stats.exs ├── stats.py └── test
SYMBOL INDEX (571 symbols across 155 files)
FILE: Problem001/C++/solution_1.cpp
function main (line 8) | int main(int argc, char* argv[])
FILE: Problem001/C/solution_1.c
function sumlista (line 44) | int sumlista(int* lista, int lenght){
function increase (line 53) | void increase(int **data, int *lenght){
function exist (line 60) | int exist(int *lista, int lenght, int num){
function main (line 69) | int main(void){
FILE: Problem001/C/solution_2.c
function main (line 11) | int main()
FILE: Problem001/Go/solution_1.go
function main (line 9) | func main() {
FILE: Problem001/Java/solution_1.java
class Main (line 1) | public class Main
method main (line 3) | public static void main(String[] args)
FILE: Problem001/Ruby/solution_1.rb
function solve (line 3) | def solve
FILE: Problem001/Rust/solution_1.rs
function sum_all_multiples (line 1) | fn sum_all_multiples(limit: i32) -> i32 {
function main (line 13) | fn main() {
FILE: Problem002/C++/solution_1.cpp
function main (line 8) | int main(int argc, char *argv[])
FILE: Problem002/C/solution_1.c
type _fib (line 15) | typedef struct fib {
function main (line 23) | int main(void) {
function even (line 40) | int even(int value) {
function _fib (line 44) | _fib fibonacci(int limit) {
FILE: Problem002/Go/solution_1.go
function p2 (line 5) | func p2(n int) int {
function main (line 18) | func main(){
FILE: Problem002/JavaScript/solution_1.js
function sequence_generator (line 7) | function sequence_generator(n, filter){
FILE: Problem002/Python/solution_1.py
function fib_generator (line 11) | def fib_generator(n):
function solution (line 18) | def solution(n):
FILE: Problem002/Ruby/solution_1.rb
function fib (line 3) | def fib(n)
function solve (line 15) | def solve
FILE: Problem003/C++/solution_1.cpp
function largestPrime (line 4) | long long int largestPrime(long long int num){
function main (line 15) | int main(){
FILE: Problem003/Elixir/solution_1.exs
class Prime (line 1) | defmodule Prime
method solve (line 2) | def solve(num), do: solve(num, 2)
FILE: Problem003/Go/solution_1.go
constant NUM (line 8) | NUM = 600851475143
function main (line 12) | func main() {
function isPrime (line 21) | func isPrime(n uint64) bool {
FILE: Problem003/PHP/solution_1.php
function prime (line 3) | function prime($num)
FILE: Problem003/Python/solution_1.py
function prime_gen (line 26) | def prime_gen(n):
FILE: Problem004/C/solution_1.c
function main (line 3) | int main()
FILE: Problem004/Go/solution_1.go
function main (line 9) | func main() {
function reverse (line 26) | func reverse(s string) (result string) {
FILE: Problem004/JavaScript/solution_1.js
function is_palindrome (line 3) | function is_palindrome(s){
function find_max_palindrom (line 7) | function find_max_palindrom(){
FILE: Problem004/Ruby/solution_01.rb
function palindrome (line 3) | def palindrome(n)
function solve (line 7) | def solve
FILE: Problem005/C++/solution_1.cpp
function main (line 3) | int main(int argc, char **argv)
FILE: Problem005/C/solution_1.c
function main (line 5) | int main(void) {
FILE: Problem005/Elixir/solution_1.exs
class Solution (line 1) | defmodule Solution
method solve (line 2) | def solve(n) do
method find_recur (line 7) | defp find_recur(n, dvs, inc_rate) do
FILE: Problem005/Elixir/solution_2.exs
class Euler5 (line 3) | defmodule Euler5
method solve (line 4) | def solve(n) do
method lcm (line 8) | def lcm(x, y), do: div(x * y, gcd(x, y))
method gcd (line 10) | def gcd(x, 0), do: x
method gcd (line 11) | def gcd(x, y) do
FILE: Problem005/JavaScript/solution_1.js
function smallest_multiple (line 3) | function smallest_multiple() {
FILE: Problem005/Python/solution_2.py
function div20 (line 2) | def div20(num):
FILE: Problem005/go/solution_1.go
function smallest_multiple (line 5) | func smallest_multiple(number int) int {
function main (line 20) | func main() {
FILE: Problem006/C++/solution_1.cpp
function main (line 19) | int main(int argc, char **argv)
function sum_of_squares (line 32) | long int sum_of_squares()
FILE: Problem006/Ruby/solution_1.rb
function solve (line 3) | def solve
FILE: Problem006/go/solution_1.go
function sumOfSquare (line 5) | func sumOfSquare(max int) int {
function squareOfSum (line 13) | func squareOfSum(max int) int {
function main (line 18) | func main() {
FILE: Problem007/C++/solution_1.cpp
function main (line 10) | int main(int argc, char **argv)
function is_prime (line 35) | bool is_prime(int n)
FILE: Problem007/Elixir/solution_2.exs
class Solution (line 1) | defmodule Solution
method nth_prime (line 2) | def nth_prime(n) do
method prime_sequence (line 9) | def prime_sequence do
method prime? (line 22) | def prime?(x) do
FILE: Problem007/Elixir/solution_slow_1.exs
class Problem007 (line 3) | defmodule Problem007
method isPrime (line 5) | def isPrime(1), do: false
method isPrime (line 6) | def isPrime(2), do: true
method isPrime (line 7) | def isPrime(3), do: true
method isPrime (line 8) | def isPrime(n), do: (2..(n - 1)) |> Enum.find(fn x -> rem(n, x) == 0 e...
method prime10001 (line 10) | def prime10001 , do: prime10001(1, 0)
method prime10001 (line 11) | defp prime10001(x, 10001), do: x + 1
method prime10001 (line 12) | defp prime10001(x, prime), do: prime10001(x + 1, prime + (if isPrime x...
FILE: Problem007/Python/primes.py
function primeGen (line 16) | def primeGen(n):
function primeGenEff (line 32) | def primeGenEff(n):
function sieve5 (line 53) | def sieve5(n):
FILE: Problem008/Python/solution_1.py
function product (line 55) | def product(num): return reduce(lambda x, y: x * y, [int(digit) for digi...
FILE: Problem009/Python/solution_1.py
function decompSum (line 25) | def decompSum(n):
function pythagorean (line 35) | def pythagorean(a, b, c):
function problem9 (line 39) | def problem9(n):
FILE: Problem009/Ruby/solution_1.rb
function solve (line 3) | def solve
FILE: Problem010/C++/solution_1.cpp
function main (line 10) | int main(int argc, char* argv[])
function is_prime (line 36) | bool is_prime(unsigned int number)
FILE: Problem010/Python/primes.py
function prime_gen (line 1) | def prime_gen(n):
function prime_gen_eff (line 17) | def prime_gen_eff(n):
function primes_list (line 36) | def primes_list(lim):
function sieve5 (line 248) | def sieve5(n):
FILE: Problem011/C++/solution_1.cpp
function main (line 3) | int main()
FILE: Problem011/Elixir/solution_1.exs
class GridProduct (line 22) | defmodule GridProduct
method search_grid (line 23) | def search_grid(grid) do
method find_val (line 43) | def find_val(horiz,diag,inner,outer,final) do
method find_product_h (line 57) | def find_product_h(grid,col,row) do
method find_product_d (line 63) | def find_product_d(grid,col,row) do
method coord_vals (line 69) | def coord_vals(l,i) do
method coord_val (line 73) | def coord_val(a,b,c) do
method map_list_to_i (line 77) | def map_list_to_i(a) do
method rev_transpose (line 81) | def rev_transpose(a,b) do
FILE: Problem011/Python/solution_1.py
function arrowsSearch (line 36) | def arrowsSearch(matrix, n):
function solution (line 59) | def solution(grid, arrow_length):
FILE: Problem012/C++/solution_1.cpp
function LL (line 5) | LL countDivisors(LL n)
function main (line 16) | int main()
FILE: Problem012/Elixir/solution_1.exs
class Euler12 (line 3) | defmodule Euler12
method solve (line 4) | def solve do
method count_divisors (line 12) | def count_divisors(n) do
FILE: Problem012/JavaScript/solution_1.js
function checkPrime (line 3) | function checkPrime(input, list) {
function getNumOfDivisor (line 9) | function getNumOfDivisor(input) {
function getTriangleNumber (line 44) | function getTriangleNumber() {
FILE: Problem012/Python/solution_1.py
function trianglenums (line 37) | def trianglenums():
function factoring (line 42) | def factoring(n):
function divisors (line 53) | def divisors(n):
function factors (line 68) | def factors(n):
FILE: Problem012/Python/solution_2.py
function divisors (line 6) | def divisors(x):
function diviTri (line 26) | def diviTri(n):
FILE: Problem012/Python/solution_3.py
function trianglenums (line 37) | def trianglenums():
function divisors (line 42) | def divisors(n):
FILE: Problem013/Ruby/solution_1.rb
function solve (line 104) | def solve
FILE: Problem014/Elixir/solution_1.exs
class Euler14 (line 3) | defmodule Euler14
method solve (line 4) | def solve() do
method largest_collatz (line 8) | defp largest_collatz(1_000_000, {_size, current}), do: current
method largest_collatz (line 9) | defp largest_collatz(n, {size, _current} = acc) do
method collatz (line 19) | def collatz(n), do: collatz(n, 1)
method collatz (line 21) | defp collatz(1, acc), do: acc
method collatz (line 22) | defp collatz(n, acc) do
FILE: Problem014/Python/solution_slow_1.py
function sequence (line 33) | def sequence(n):
function answer (line 44) | def answer():
FILE: Problem015/C/solution_1.c
function main (line 3) | int main()
FILE: Problem015/Elixir/solution_1.exs
class Fat (line 3) | defmodule Fat
method fatorial (line 5) | def fatorial(1), do: 1
method fatorial (line 6) | def fatorial(n), do: n * fatorial(n - 1)
FILE: Problem015/Python/solution_1.py
function pascal (line 25) | def pascal(n):
function solution (line 41) | def solution():
FILE: Problem015/Ruby/solution_1.rb
function solve (line 4) | def solve
FILE: Problem016/Ruby/solution_1.rb
function solve (line 3) | def solve
FILE: Problem017/Elixir/solution_1.exs
class Euler17 (line 3) | defmodule Euler17
method solve (line 4) | def solve(n) do
method num_to_str (line 12) | def num_to_str(1000), do: "onethousand"
method num_to_str (line 14) | def num_to_str(n), do: num_to_str(Integer.digits(n), [])
method num_to_str (line 17) | defp num_to_str([], acc) do
method num_to_str (line 30) | defp num_to_str([x | xs] = digits, acc) do
method ten_text (line 47) | defp ten_text([x | xs]) do
method ten (line 71) | def ten(n) do
method unit (line 77) | def unit(n) do
FILE: Problem017/Python/solution_1.py
function parser (line 29) | def parser(string):
function decomp (line 44) | def decomp(string):
function clear (line 54) | def clear(num):
function solution (line 58) | def solution():
FILE: Problem018/Elixir/solution_1.exs
class MaximumPath (line 19) | defmodule MaximumPath
method new_val (line 29) | def new_val(a,b,c), do: String.to_integer(Enum.at(b,c)) + Enum.max([St...
FILE: Problem018/Python/solution_1.py
function int_triangle (line 21) | def int_triangle(data):
function arrows_recursive (line 24) | def arrows_recursive(data, total = [], main = [], x = 0, y = 0):
FILE: Problem019/Elixir/solution_1.exs
class Sundays (line 1) | defmodule Sundays
method check_day_and_month (line 21) | def check_day_and_month(count,day,month,year) do
method leap_year? (line 39) | def leap_year?(year) do
FILE: Problem019/Python/solution_1.py
function howmanysundays (line 47) | def howmanysundays(days, day):
function is_leap (line 53) | def is_leap(year):
function solution (line 57) | def solution(first_day):
FILE: Problem020/JavaScript/solution_1.js
function getReducedFactorial (line 3) | function getReducedFactorial() {
FILE: Problem020/Ruby/solution_1.rb
function solve (line 4) | def solve
FILE: Problem021/Elixir/solution_1.exs
class Euler21 (line 3) | defmodule Euler21
method solve (line 4) | def solve do
method d (line 10) | def d(1), do: 1
method d (line 11) | def d(n) do
method amicable (line 17) | def amicable(a) do
method sum (line 23) | defp sum(x, y), do: x + y
FILE: Problem021/Python/solution_1.py
function d (line 26) | def d(n):
FILE: Problem023/Python/solution_1.py
function divisors (line 28) | def divisors(num):
function abundant (line 32) | def abundant(num):
FILE: Problem024/C++/solution_1.cpp
function main (line 4) | int main() {
FILE: Problem024/Python/solution_1.py
function factorial (line 28) | def factorial(n):
function problem24 (line 33) | def problem24(element):
FILE: Problem025/Python/solution_1.py
function fib (line 3) | def fib(max_lenght):
FILE: Problem026/C++/solution_1.cpp
function get_max_rec (line 8) | int get_max_rec(int n)
function main (line 28) | int main(int argc, char *argv[])
FILE: Problem026/Python/solution_1.py
function get_rec_cycle (line 62) | def get_rec_cycle(n):
function get_max_rec (line 82) | def get_max_rec(limit):
FILE: Problem027/C/solution_1.c
type Result (line 19) | typedef struct {
function quadratic (line 26) | int quadratic(int n, int a, int b) {
function is_prime (line 32) | int is_prime(int n) {
function eval_func (line 48) | int eval_func(int a, int b){
function get_result (line 65) | void get_result(Result *r) {
function main (line 81) | int main(int argc, char *argv[]) {
FILE: Problem027/Go/solution_1.go
constant limit (line 16) | limit = 1000
constant nThreads (line 17) | nThreads = 16
type result (line 20) | type result struct
function quadratic (line 33) | func quadratic(a, b int) func(int) int {
function memo (line 42) | func memo(f func(int) bool) func(int) bool {
function isPrime (line 54) | func isPrime(n int) bool {
function evalFunc (line 70) | func evalFunc(f func(int) int) int {
function worker (line 85) | func worker(split int) {
function receiver (line 102) | func receiver() (a int, b int, nPrimes int) {
function main (line 114) | func main() {
FILE: Problem027/Python/solution_1.py
function memo (line 15) | def memo(fn):
function quadratic (line 31) | def quadratic(a, b):
function isprime (line 39) | def isprime(n):
function eval_func (line 48) | def eval_func(func):
function search (line 59) | def search(limit):
function main (line 68) | def main():
FILE: Problem028/C/solution_1.c
function main (line 3) | int main()
FILE: Problem030/Elixir/solution_1.exs
class DigitPowers (line 1) | defmodule DigitPowers
method digit_power? (line 8) | def digit_power?(n) do
FILE: Problem030/Ruby/solution_1.rb
function sum_digits (line 1) | def sum_digits(value)
FILE: Problem031/C/solution_1.c
function different_ways (line 21) | int different_ways(int money, int *coins, int n_coins) {
function main (line 40) | int main(int argc, char **argv){
FILE: Problem031/Elixir/solution_1.exs
class Coins (line 1) | defmodule Coins
method count (line 2) | def count([],_,vals), do: vals
method ad (line 12) | def ad(a,b,c), do: Map.put(c,b,(Map.get(c,b) + Map.get(c,(b-a))))
FILE: Problem031/Python/solution_1.py
function different_ways (line 13) | def different_ways(money, coins, summation=0):
function main (line 26) | def main():
FILE: Problem033/Python/solution_1.py
function mdc (line 12) | def mdc(a, b):
class fraction (line 19) | class fraction(object):
method __init__ (line 21) | def __init__(self, x, y):
method __repr__ (line 26) | def __repr__(self):
method __mul__ (line 29) | def __mul__(self, frac):
method mfact (line 38) | def mfact(self):
method cfact (line 48) | def cfact(self):
method fact (line 52) | def fact(self):
method mdc (line 56) | def mdc(self):
method new (line 59) | def new(self, w, z):
method get (line 66) | def get(self, num):
method cross (line 70) | def cross(self):
method nums (line 74) | def nums(self):
method non_trivial (line 78) | def non_trivial(self):
method curious (line 84) | def curious(self):
function solution (line 88) | def solution():
FILE: Problem034/C/solution_1.c
function main (line 3) | int main()
FILE: Problem034/Elixir/solution_1.exs
class Factorial (line 1) | defmodule Factorial
class DigitFactorials (line 8) | defmodule DigitFactorials
method digit_factorial? (line 24) | def digit_factorial?(num,facts) do
FILE: Problem034/Python/solution_2.py
function findsum (line 6) | def findsum(n):
FILE: Problem034/Ruby/solution_1.rb
function fat (line 1) | def fat(n)
function check (line 9) | def check(n)
FILE: Problem035/Python/solution_1.py
function is_prime (line 10) | def is_prime(n):
function circPrime (line 21) | def circPrime(n):
FILE: Problem036/Elixir/solution_1.exs
class DoubleBase (line 1) | defmodule DoubleBase
method palindrome (line 2) | def palindrome(lim) do
method pal? (line 13) | def pal?(n) do
FILE: Problem036/Go/solution_1.go
function isPalindrome (line 8) | func isPalindrome(s string) bool {
function main (line 19) | func main() {
FILE: Problem036/Python/solution_1.py
function isPal (line 10) | def isPal(n):
function binDecPal (line 14) | def binDecPal(x):
FILE: Problem036/Ruby/solution_1.rb
function binary (line 1) | def binary(value)
function palindrome (line 5) | def palindrome(value)
function double_base (line 9) | def double_base(value)
FILE: Problem037/C++/solution_1.cpp
function sieve (line 7) | void sieve(){
function test (line 17) | bool test(int t)
function main (line 37) | int main()
FILE: Problem037/Python/solution_1.py
function memo (line 12) | def memo(fn):
class TruncatePrime (line 28) | class TruncatePrime(int):
method __init__ (line 37) | def __init__(self, x):
method __add__ (line 42) | def __add__(self, other):
method left (line 46) | def left(self):
method right (line 50) | def right(self):
method self (line 54) | def self(self):
method walk (line 57) | def walk(self, orientation):
method is_prime (line 64) | def is_prime(self, x):
method is_truncate (line 73) | def is_truncate(self):
function search_truncate (line 80) | def search_truncate(until=11):
FILE: Problem038/Elixir/solution_1.exs
class Pandigital (line 1) | defmodule Pandigital
method pandigital? (line 28) | def pandigital?(n) do
FILE: Problem038/Python/solution_1.py
class PanDigital (line 12) | class PanDigital(int):
method map (line 17) | def map(self, x):
method concat (line 20) | def concat(self, digits):
method can_continue (line 24) | def can_continue(self):
method count (line 28) | def count(self):
method sorted (line 32) | def sorted(self):
method ispandig (line 36) | def ispandig(self):
method transform (line 39) | def transform(self):
method value (line 49) | def value(self):
FILE: Problem039/C/solution_1.c
function main (line 4) | int main() {
FILE: Problem039/Elixir/solution_1.exs
class RightInteger (line 1) | defmodule RightInteger
method ad (line 25) | def ad(a,b), do: Map.put(b,a,(Map.get(b,a) + 1))
FILE: Problem040/Elixir/solution_1.exs
class Champernowne (line 1) | defmodule Champernowne
method constant (line 2) | def constant(lim) do
FILE: Problem040/Python/solution_1.py
function frac_series_generator (line 13) | def frac_series_generator():
function search_digit_by_index (line 20) | def search_digit_by_index(indexes):
function main (line 32) | def main():
FILE: Problem041/Python/solution_slow_1.py
function isPrime (line 3) | def isPrime(n) :
function checker (line 17) | def checker(a): #function to check if the number has zero in it or not
function repeatCheck (line 23) | def repeatCheck(a): #function to check if there is any repeating digit o...
FILE: Problem042/Elixir/solution_1.exs
class TriangleWords (line 30) | defmodule TriangleWords
method words (line 31) | def words(file,a_z_key) do
method parse (line 42) | def parse(body,a_z_key) do
method find (line 53) | def find([],count,_), do: count
method triangle_numbers (line 58) | def triangle_numbers(words) do
method triangle? (line 63) | def triangle?(word,tri_nums,count) do
FILE: Problem042/Python/solution_1.py
function memo (line 13) | def memo(fn):
function load_words (line 27) | def load_words():
function string_to_num (line 33) | def string_to_num(string):
function triangles (line 38) | def triangles():
function is_triangle (line 45) | def is_triangle(num):
function solution (line 53) | def solution():
FILE: Problem044/Python/solution_1.py
function pentagonal (line 28) | def pentagonal(n):
function pentagonal_list (line 32) | def pentagonal_list(n):
function solution (line 36) | def solution():
FILE: Problem044/Python/solution_2.py
function int_sqrt (line 12) | def int_sqrt(n):
function pentagonal_number (line 59) | def pentagonal_number(n):
function is_pentagonal (line 63) | def is_pentagonal(n):
function answer (line 83) | def answer():
FILE: Problem045/C/solution_1.c
type Polynom (line 24) | typedef struct {
function main (line 29) | int main(int argc, char *argv[]) {
FILE: Problem045/Elixir/solution_1.exs
class PolygonNumbers (line 1) | defmodule PolygonNumbers
method gen (line 15) | def gen(n), do: n * ((n * 2) - 1)
method pent? (line 16) | def pent?(n) do
FILE: Problem045/Go/solution_1.go
type Polynom (line 14) | type Polynom struct
function main (line 22) | func main() {
FILE: Problem045/Python/solution_1.py
function quadratic (line 29) | def quadratic(a, b, c):
function solution (line 33) | def solution():
FILE: Problem045/Ruby/solution_1.rb
class Integer (line 1) | class Integer
method is_pentagonal? (line 2) | def is_pentagonal? # Inverse of pentagonal function
method generate_hexagonal (line 6) | def generate_hexagonal
class TrianglePentagonHexagon (line 11) | class TrianglePentagonHexagon
method initialize (line 13) | def initialize
method find_pentagonal (line 17) | def find_pentagonal # All hexagonal are triagonal
FILE: Problem046/Python/solution_1.py
function sieve5 (line 10) | def sieve5(n): # from primes algorithms on problem10
function goldbach (line 26) | def goldbach(odd, p):
function solution (line 39) | def solution(heuristic_start=10000):
FILE: Problem046/Ruby/solution_1.rb
class Goldbach (line 1) | class Goldbach
method initialize (line 4) | def initialize(finish)
method find_goldbach (line 10) | def find_goldbach
method sieve_of_eratosthenes (line 14) | def sieve_of_eratosthenes
method generate_composites (line 18) | def generate_composites
method generate_squares (line 22) | def generate_squares
method sum_primes_and_squares (line 26) | def sum_primes_and_squares
FILE: Problem047/Python/solution_1.py
function solution (line 13) | def solution(q):
FILE: Problem048/C/solution_1.c
function pow_mod (line 32) | uint64_t pow_mod(uint64_t x, uint64_t e, uint64_t mod) {
function main (line 42) | int main(void) {
FILE: Problem048/Go/solution_1.go
function powMod (line 12) | func powMod(a float64, b float64, mod float64) float64 {
function main (line 22) | func main() {
FILE: Problem048/Ruby/solution_1.rb
function solve (line 3) | def solve
FILE: Problem049/Python/solution_1.py
class PrimePermutations (line 13) | class PrimePermutations(int):
method __init__ (line 23) | def __init__(self, x, min_permutations=3):
method permutations (line 28) | def permutations(self):
method primes (line 32) | def primes(self):
method is_candidate (line 36) | def is_candidate(self):
method _zip (line 39) | def _zip(self, content):
method had_some_sequence (line 43) | def had_some_sequence(self):
method sequence (line 47) | def sequence(self):
method max (line 51) | def max(self):
method diff (line 55) | def diff(self):
method concat (line 59) | def concat(self):
method solution (line 63) | def solution(cls):
FILE: Problem049/Python/solution_2.py
function isPrime (line 4) | def isPrime(n) :
FILE: Problem050/Python/solution_slow_1.py
function sumOfPrimes (line 28) | def sumOfPrimes(primes):
function main (line 44) | def main(n):
FILE: Problem052/Ruby/solution_1.rb
class PermutationMultiples (line 1) | class PermutationMultiples
method initialize (line 4) | def initialize(finish)
method find_permutations (line 8) | def find_permutations # Chose arbitrary number range => only checks un...
method six_time_permutation? (line 12) | def six_time_permutation?(num) # Only check if each proceeding multipl...
FILE: Problem054/Python/solution_1.py
function calculate_rank (line 9) | def calculate_rank(hand):
FILE: Problem055/Python/solution_1.py
function reverse (line 4) | def reverse(x):
function Palindrome (line 7) | def Palindrome(x):
function checkLyr (line 14) | def checkLyr(x):
FILE: Problem056/Ruby/solution_1.rb
function solve (line 3) | def solve
FILE: Problem058/Python/solution_1.py
function is_prime (line 3) | def is_prime(n):
class Problem058 (line 12) | class Problem058(object):
method __init__ (line 15) | def __init__(self):
method _diag_primes (line 20) | def _diag_primes(self):
method _record_next_diag_primes (line 27) | def _record_next_diag_primes(self):
method _solve (line 32) | def _solve(self, ratio_limit):
method solve (line 38) | def solve(cls):
FILE: Problem062/Python/solution_1.py
function cubesGen (line 19) | def cubesGen(n, start=1):
function getId (line 23) | def getId(n):
function isPerm (line 27) | def isPerm(a, b):
function cubeRoot (line 35) | def cubeRoot(n):
function mostCube (line 39) | def mostCube(n):
function lowerCube (line 44) | def lowerCube(n):
function solution (line 52) | def solution(max):
function solution_extern (line 64) | def solution_extern():
FILE: Problem063/C/solution_1.c
function num_length (line 4) | int num_length (double n) {
function main (line 12) | int main(int argc, char **argv) {
FILE: Problem063/Elixir/solution_1.exs
class PowerfulDigits (line 1) | defmodule PowerfulDigits
method greater_than_n? (line 31) | def greater_than_n?(num,n,count) do
method same_len? (line 40) | def same_len?(n,exp), do: exp == round(:math.pow(n,exp)) |> to_string ...
FILE: Problem063/Go/solution_1.go
function numLength (line 10) | func numLength(n float64) int {
function main (line 18) | func main() {
FILE: Problem067/Elixir/solution_1.exs
class MaximumPath (line 1) | defmodule MaximumPath
method new_val (line 11) | def new_val(a,b,c), do: String.to_integer(Enum.at(b,c)) + Enum.max([St...
class Triangle (line 14) | defmodule Triangle
method input (line 15) | def input(file) do
FILE: Problem067/Python/solution_1.py
function int_triangle (line 14) | def int_triangle(data):
class Tree (line 18) | class Tree(object):
method __init__ (line 20) | def __init__(self, data):
method solution (line 27) | def solution(self):
method calc_route (line 31) | def calc_route(self, route):
method num (line 34) | def num(self, index):
method search (line 37) | def search(self):
method insert_route (line 43) | def insert_route(self, last):
method decise (line 50) | def decise(self):
FILE: Problem069/Python/solution_1.py
function is_prime (line 3) | def is_prime(n):
function max_phi_ratio (line 11) | def max_phi_ratio(n):
function solve_problem_069 (line 20) | def solve_problem_069():
FILE: Problem069/Python/solution_2.py
function sieve (line 6) | def sieve():
function phi (line 16) | def phi(n):
FILE: Problem070/Python/solution_1.py
function _prime_sieve (line 4) | def _prime_sieve(start, limit):
function _is_permutation (line 19) | def _is_permutation(x, y):
function min_phi_ratio (line 22) | def min_phi_ratio(limit):
function solve (line 40) | def solve():
FILE: Problem076/Elixir/solution_1.exs
class Summations (line 1) | defmodule Summations
method count (line 2) | def count([],_,vals), do: vals
method ad (line 12) | def ad(a,b,c), do: Map.put(c,b,(Map.get(c,b) + Map.get(c,(b-a))))
FILE: Problem080/Python/solution_1.py
function solution (line 16) | def solution(limit):
FILE: Problem081/Python/solution_1.py
function parse_grid (line 24) | def parse_grid(data):
class Grid (line 28) | class Grid(object):
method __init__ (line 30) | def __init__(self, data):
method solution (line 37) | def solution(self):
method calcroute (line 41) | def calcroute(self, route):
method num (line 44) | def num(self, index):
method search (line 48) | def search(self):
method insert_route (line 56) | def insert_route(self, last):
method decise (line 63) | def decise(self):
function run_test (line 81) | def run_test():
function solution (line 92) | def solution():
FILE: Problem085/Python/solution_1.py
function solve (line 4) | def solve(limit):
FILE: Problem087/Python/solution_1.py
function _prime_sieve (line 3) | def _prime_sieve(start, limit):
function solve (line 22) | def solve(limit):
FILE: Problem089/Elixir/solution_1.exs
class RomanNumerals (line 1) | defmodule RomanNumerals
method convert (line 2) | def convert(file) do
method trunc_nums (line 11) | def trunc_nums(file) do
method diff (line 19) | def diff(replaced,original), do: original - replaced
FILE: Problem089/Python/solution_1.py
function check_valid_roman (line 15) | def check_valid_roman(string: str) -> int:
function parse_roman (line 39) | def parse_roman(string: str) -> int:
function to_roman (line 55) | def to_roman(integer: int) -> str:
function main (line 80) | def main():
FILE: Problem092/Python/solution_slow_1.py
function sequence_end (line 31) | def sequence_end(n, finalnum):
FILE: Problem092/Python/solution_slow_2.py
function sequence_end (line 19) | def sequence_end(start):
FILE: Problem104/Python/solution_1.py
function _is_pandigital (line 9) | def _is_pandigital(elem):
function _fermat_approximation (line 15) | def _fermat_approximation(n):
function _n_digit_of_decimal (line 18) | def _n_digit_of_decimal(d):
function solve (line 22) | def solve():
FILE: Problem112/Python/solution_1.py
function bouncy (line 34) | def bouncy(num: int) -> bool:
function bouncy_counter (line 49) | def bouncy_counter(threshold: float):
function main (line 62) | def main():
FILE: Problem145/Python/solution_slow_1.py
function sumreverse (line 30) | def sumreverse(num):
function reversible (line 32) | def reversible(num):
function gen_filtred (line 35) | def gen_filtred(n, start = 1): # n - potencia de 10
FILE: Problem301/Python/solution_1.py
function nim (line 3) | def nim():
FILE: Problem357/Python/solution_slow_1.py
function divisors (line 28) | def divisors(n):
function hnum (line 35) | def hnum(n, d):
class prime_divisors (line 39) | class prime_divisors(object):
method __init__ (line 45) | def __init__(self, max_value):
method sum (line 52) | def sum(self):
method is_hell (line 55) | def is_hell(self, n):
method next_prime (line 58) | def next_prime(self):
method run_from_hell (line 74) | def run_from_hell(self):
function main (line 93) | def main():
FILE: Problem439/Python/solution_slow_1.py
function gd (line 24) | def gd(k):
function d (line 30) | def d(k):
function g (line 34) | def g(n):
function s (line 40) | def s(n):
FILE: Problem473/Python/solution_slow_1.py
function gen (line 27) | def gen(x, sign = 1, start = 0, reverse = False):
function phi_index (line 38) | def phi_index(n, resto = 0, lista = []):
function suf_phi (line 58) | def suf_phi(n, resto = 0, lista = []):
function phibase (line 75) | def phibase(n):
function calc (line 97) | def calc(index):
function intphi (line 107) | def intphi(phinum):
function gen_palindromic (line 121) | def gen_palindromic(n):
function palindromic (line 124) | def palindromic(string):
FILE: Problem473/Python/solution_slow_2.py
function phi_pre_gen (line 26) | def phi_pre_gen(n):
function phi_suf_gen (line 37) | def phi_suf_gen(n, resto):
function checkpal (line 46) | def checkpal(n):
FILE: Problem500/Python/solution_1.py
function primes_list (line 14) | def primes_list(n):
function smallest_integer (line 19) | def smallest_integer(k, modulus=None):
FILE: Problem501/Python/solution_slow_1.py
function d (line 23) | def d(n):
function f (line 26) | def f(n):
function f_p (line 29) | def f_p(n):
FILE: stats.exs
class Settings (line 1) | defmodule Settings
method start_link (line 2) | def start_link do
method initial_state (line 6) | defp initial_state do
method get (line 17) | def get(key) do
method set (line 21) | def set(key, value) do
class CLI (line 26) | defmodule CLI
method run (line 45) | def run do
method process (line 50) | def process({[help: true], _, _}) do
method process (line 54) | def process({parsed, _, _}) do
method help (line 76) | defp help do
class Producer (line 85) | defmodule Producer
method start_link (line 88) | def start_link(languages, all_languages?) do
method init (line 92) | def init(problems) do
method pop (line 96) | def pop do
method handle_call (line 100) | def handle_call(:pop, _from, [h | t]) do
method handle_call (line 103) | def handle_call(:pop, _from, []) do
method problems (line 107) | defp problems(languages, all_languages?) do
class Manager (line 138) | defmodule Manager
method start_link (line 141) | def start_link do
method init (line 146) | def init(workers) do
method start_workers (line 156) | def start_workers do
method next (line 160) | def next do
method finished (line 164) | def finished(id, solution, time) do
method handle_cast (line 168) | def handle_cast(:start_workers, {workers, _} = state) do
method handle_cast (line 172) | def handle_cast(:next, {[id | available], workers}) do
method handle_cast (line 193) | def handle_cast({:finished, id, solution, time}, {available, workers}) do
method span_workers (line 200) | defp span_workers(n) do
class Worker (line 208) | defmodule Worker
method start_link (line 211) | def start_link(id) do
method init (line 215) | def init(id) do
method run (line 219) | def run(worker, solution) do
method handle_cast (line 223) | def handle_cast({:run, solution}, id) do
class Runner (line 235) | defmodule Runner
method run (line 318) | def run({problem, lang, file}) do
method run (line 323) | defp run(:build, cmd, {problem, lang, file}) do
method run (line 333) | defp run(:execute, cmd, {problem, lang, file}) do
method separate_command_from_flags (line 347) | defp separate_command_from_flags(cmd) do
class Consumer (line 352) | defmodule Consumer
method start_link (line 355) | def start_link do
method consume (line 359) | def consume({problem, language, file}, time) do
method output (line 363) | def output do
method handle_cast (line 367) | def handle_cast({problem, language, file, time}, state) do
method handle_cast (line 372) | def handle_cast(:output, state) do
class Zipper (line 443) | defmodule Zipper
method zip_with (line 447) | def zip_with([a|as], [b|bs], f) do
class Renderer (line 452) | defmodule Renderer
method start_link (line 463) | def start_link(quiet?) do
method init (line 473) | def init(labels) do
method render (line 479) | def render do
method set_label (line 483) | def set_label(id, label) do
method delete_label (line 487) | def delete_label(id) do
method stop (line 491) | def stop do
method handle_info (line 495) | def handle_info(:timeout, state) do
method handle_cast (line 500) | def handle_cast(:render, labels) do
method handle_cast (line 506) | def handle_cast({:set_label, id, label}, labels) do
method handle_cast (line 510) | def handle_cast({:delete_label, id}, labels) do
method handle_cast (line 514) | def handle_cast(:stop, labels) do
method render_labels (line 519) | defp render_labels(labels) do
class RendererQuiet (line 541) | defmodule RendererQuiet
method init (line 544) | def init(_) do
method handle_cast (line 548) | def handle_cast(_, _) do
class Spinner (line 553) | defmodule Spinner
method cursor_up (line 558) | def cursor_up, do: cursor_up(1)
method cursor_up (line 559) | def cursor_up(count) do
method erase_lines (line 563) | def erase_lines(count) do
FILE: stats.py
class TimeOutController (line 35) | class TimeOutController:
class TimeOut (line 36) | class TimeOut(Exception):
method __init__ (line 39) | def __init__(self, sec=SOLUTION_TIMEOUT_VALUE):
method cancel (line 43) | def cancel(self):
method raise_timeout (line 46) | def raise_timeout(self, a, n):
class Checker (line 50) | class Checker(object):
method __init__ (line 54) | def __init__(self, compiler, path):
method check (line 59) | def check(self):
class Execute (line 67) | class Execute(Checker):
method enter_dir (line 71) | def enter_dir(self):
method exit_dir (line 75) | def exit_dir(self):
method execute (line 78) | def execute(self):
class Build (line 97) | class Build(Checker):
method compile (line 103) | def compile(self):
method execute (line 108) | def execute(self):
function _callback (line 253) | def _callback(option, opt_str, value, parser):
function walk_problems (line 350) | def walk_problems(root="."):
function read_hashfile (line 365) | def read_hashfile(fpath):
function get_problem_hashes (line 370) | def get_problem_hashes():
function digest_answer (line 389) | def digest_answer(answer):
function search_language (line 394) | def search_language(query, languages):
function split_problem_language (line 410) | def split_problem_language(path):
function is_solution (line 425) | def is_solution(string):
function parse_solutions (line 430) | def parse_solutions(problems):
function load_dataframe (line 450) | def load_dataframe():
function solutions_paths (line 469) | def solutions_paths(df, from_files=None):
function count_solutions (line 499) | def count_solutions(df, solutions=True):
function handle_files (line 519) | def handle_files(files):
function spinner (line 543) | def spinner(control):
function choose_builder (line 558) | def choose_builder(lang, fpath):
function execute_builder (line 574) | def execute_builder(b):
function build_result (line 588) | def build_result(df, ignore_errors=False, blame=False, only=()):
function list_by_count (line 631) | def list_by_count(df):
function blame_solutions (line 639) | def blame_solutions(df):
function remove_problem (line 650) | def remove_problem(df):
function build_per_language (line 656) | def build_per_language(df):
function header (line 670) | def header(opts):
function handle_graph (line 674) | def handle_graph(df, options):
function handle_options (line 690) | def handle_options(options):
function main (line 760) | def main():
Condensed preview — 534 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (617K chars).
[
{
"path": ".gitignore",
"chars": 1503,
"preview": "## C and Cpp garbage ignore ##\n\n# Object files\n*.o\n*.ko\n*.obj\n*.elf\n*.slo\n*.lo\n\n\n# Precompiled Headers\n*.gch\n*.pch\n\n# Li"
},
{
"path": ".travis.yml",
"chars": 184,
"preview": "sudo: required\n\nservices:\n - docker\n\nscript:\n - sudo chmod +x ./test\n - docker-compose run -e \"TRAVIS_PULL_REQUEST=$T"
},
{
"path": "Dockerfile",
"chars": 1052,
"preview": "FROM ubuntu:trusty\n\nRUN apt-get update \\\n && apt-get -y upgrade \\\n && apt-get install -y\n\nRUN apt-get install -y softw"
},
{
"path": "LICENSE",
"chars": 1095,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2015 A group of problem solvers!\n\nPermission is hereby granted, free of charge, to "
},
{
"path": "Problem001/.hash",
"chars": 32,
"preview": "e1edf9d1967ca96767dcc2b2d6df69f4"
},
{
"path": "Problem001/Brain/solution_1.brain",
"chars": 667,
"preview": "++++++++++>+* make the number 999 at cell 1\n[ run while the number is greater than 0 at cell 1\n >+*>+*>+*>+*>+* copy nu"
},
{
"path": "Problem001/C/Makefile",
"chars": 361,
"preview": "CXX = gcc\nLFLAGS = -lm -Wall -o\nTARGET = solution_1\nTARGET2 = solution_2\nEXTENSION_TARGET = c\nEXTENSION_OUT = out\n\n\nal"
},
{
"path": "Problem001/C/solution_1.c",
"chars": 1962,
"preview": "/*\n * =====================================================================================\n *\n * C"
},
{
"path": "Problem001/C/solution_2.c",
"chars": 627,
"preview": "/*\n * Implementation of solution 1 using Principle of inclusion-exclusion\n * The proof is done on the related pull reque"
},
{
"path": "Problem001/C++/Makefile",
"chars": 247,
"preview": "CXX = g++\nLFLAGS = -lm -Wall -o\nTARGET = solution_1\nEXTENSION_TARGET = cpp\nEXTENSION_OUT = out\n\n\nall: \n\t$(CXX) $(LFLAGS"
},
{
"path": "Problem001/C++/solution_1.cpp",
"chars": 663,
"preview": "/*\n * Find the sum of all multiples of 3 and 5 below 1000\n */\n\n#include <iostream>\n#include <cstdlib>\n\nint main(int argc"
},
{
"path": "Problem001/Clojure/solution_1.clj",
"chars": 202,
"preview": ";; My first code in Clojure\n;; Manoel Vilela\n\n;; solution of problem001\n(defn solution [x]\n (reduce + (filter (fn [n]"
},
{
"path": "Problem001/CommonLisp/solution_1.lisp",
"chars": 217,
"preview": ";; Common Lisp version\n;; Manoel Vilela\n\n\n(defun div (x d)\n (= (mod x d) 0))\n\n(defun special-sum (n)\n (reduce '+ (loop"
},
{
"path": "Problem001/D/solution_1.d",
"chars": 176,
"preview": "import std.stdio : writeln;\n\nvoid main() \n{\n int total;\n\n foreach (n; 1..1000) {\n if (n % 3 == 0 || n % 5 ="
},
{
"path": "Problem001/Elixir/solution_1.exs",
"chars": 140,
"preview": "# Author: G4BB3R\n\n1..999 |> Enum.to_list\n |> Enum.filter(&(rem(&1, 3) == 0 or rem(&1, 5) == 0))\n |> Enum.sum"
},
{
"path": "Problem001/Erlang/solution_1.erl",
"chars": 165,
"preview": "%Autor: machad0\n\n-module(solution_1).\n-export([euler001/0]).\n\neuler001() -> \n lists:sum([Num || Num <- lists:seq(0, 999"
},
{
"path": "Problem001/Go/solution_1.go",
"chars": 314,
"preview": "// Copyright 2016 the <project> Authors. All rights reserved\n// Use of this source code is governed by a BSD-style\n// li"
},
{
"path": "Problem001/Haskell/solution_1.hs",
"chars": 276,
"preview": "{-\nIf we list all the natural numbers below 10 that are multiples of 3 or 5, we get\n3, 5, 6 and 9. The sum of these mult"
},
{
"path": "Problem001/Java/solution_1.java",
"chars": 209,
"preview": "public class Main\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tint total = 0;\n\t\tfor(int i = 1; i < 1000; i ++)\n\t\t{\n\t\t\t"
},
{
"path": "Problem001/JavaScript/solution_1.js",
"chars": 202,
"preview": "'use strict'\n\nconst sumAllMultiples = limit => {\n\tlet sum = 0\n\n\tfor(let i = 0; i < limit; i++) {\n\t\tif(i % 3 == 0 || i % "
},
{
"path": "Problem001/JavaScript/solution_2.js",
"chars": 214,
"preview": "'use strict'\n\nconst sumAllMultiples = limit => Array(limit).fill().map((_, i) => i).filter(number => number % 3 == 0 || "
},
{
"path": "Problem001/Kotlin/solution_1.kt",
"chars": 166,
"preview": "fun main(args: Array<String>) {\n val seq = (1..999)\n .asSequence()\n .filter { it % 3 == 0 || it %"
},
{
"path": "Problem001/Lua/solution_1.lua",
"chars": 144,
"preview": "-- Author: G4BB3R\n\nlocal resultado = 0\nfor i = 1, 999 do\n\tif i % 5 == 0 or i % 3 == 0 then\n\t\tresultado = resultado + i\n\t"
},
{
"path": "Problem001/OCaml/solution_1.ml",
"chars": 344,
"preview": "let check x =\n if x mod 3 = 0 || x mod 5 = 0 then\n 1\n else\n 0\n\nlet rec solve current top count =\n if current = "
},
{
"path": "Problem001/Objective-C/solution_1.m",
"chars": 324,
"preview": "#import <Foundation/Foundation.h>\n\nint main (int argc, const char * argv[])\n{\n NSAutoreleasePool * pool = [[NSAutorele"
},
{
"path": "Problem001/PHP/solution_1.php",
"chars": 137,
"preview": "<?php\n \n$sum = 0;\n\nforeach(range(1, 999) as $i)\n{\n if ($i % 5 == 0 || $i % 3 == 0)\n $sum += $i;\n}"
},
{
"path": "Problem001/PHP/solution_2.php",
"chars": 144,
"preview": "<?php\n\n \techo array_reduce(range(1, 999), function($carry, $x){\n\t\treturn $carry += (!($x % 3 && $x % 5)) * $x; //Morg"
},
{
"path": "Problem001/Python/solution_1.py",
"chars": 69,
"preview": "print(sum([x for x in range(1000) if (x % 3 == 0) or (x % 5 == 0)]))\n"
},
{
"path": "Problem001/Python/solution_2.py",
"chars": 101,
"preview": "count = 0\nfor i in range(1000):\n if (i % 3 == 0) or (i % 5 == 0):\n count += i\nprint(count)\n"
},
{
"path": "Problem001/R/solution_1.R",
"chars": 59,
"preview": "vector <- 1:1000\nsum(vector[vector%%3==0 | vector%%5==0])\n\n"
},
{
"path": "Problem001/README.md",
"chars": 69,
"preview": "[The original source of problem](https://projecteuler.net/problem=1)\n"
},
{
"path": "Problem001/Racket/solution_1.rkt",
"chars": 199,
"preview": "(define (mult3-5 x)\n (or (= (remainder x 3) 0)\n (= (remainder x 5) 0)))\n\n(define (main)\n (let ((answer (apply + ("
},
{
"path": "Problem001/Ruby/solution_1.rb",
"chars": 101,
"preview": "# Author: tkovs\n\ndef solve\n\t(0..999).select{|n| n % 3 == 0 || n % 5 == 0}.inject(:+)\nend\n\nputs(solve)"
},
{
"path": "Problem001/Rust/solution_1.rs",
"chars": 232,
"preview": "fn sum_all_multiples(limit: i32) -> i32 {\n let mut sum = 0;\n\n for i in 0..limit {\n \tif i % 3 == 0 || i % 5 == 0"
},
{
"path": "Problem001/Scheme/solution_1.scm",
"chars": 445,
"preview": "(define (range a b)\n (if (>= a b)\n '()\n (cons a (range (+ a 1) b))))\n\n(define (filter f l)\n (cond ((null? l)"
},
{
"path": "Problem001/Scheme/solution_2.scm",
"chars": 446,
"preview": "(define triangular\n (lambda (n)\n (/ (* (+ n 1) n) 2)))\n\n(define sum-multiples-less-than\n (lambda (n k)\n (* k (tr"
},
{
"path": "Problem001/Shell/solution_1.sh",
"chars": 156,
"preview": "#!/bin/bash\n\nfor i in {0..999}; do if !(($i%3)) || !(($i%5)); then multiples[$i]=$i; fi; done\nfor j in ${multiples[@]}; "
},
{
"path": "Problem001/Swift/solution_1.swift",
"chars": 108,
"preview": "var sum = 0\n\nfor i in 1..<1000\n{\n if i % 5 == 0 || i % 3 == 0\n {\n sum += i\n }\n}\n\nprint(sum)\n"
},
{
"path": "Problem002/.hash",
"chars": 32,
"preview": "4194eb91842c8e7e6df099ca73c38f28"
},
{
"path": "Problem002/C/Makefile",
"chars": 146,
"preview": "GCC = gcc\nLFLAGS = -lm -Wall -o\nTARGET = solution_1\n\nall: \n\t$(GCC) $(LFLAGS) $(TARGET).out $(TARGET).c\nclean: \n\trm -v *"
},
{
"path": "Problem002/C/solution_1.c",
"chars": 1158,
"preview": "/*\nEach new term in the Fibonacci sequence is generated by adding the previous two terms.\nBy starting with 1 and 2, the "
},
{
"path": "Problem002/C++/Makefile",
"chars": 259,
"preview": "CXX = g++\nLFLAGS = -lm -Wall -std=c++11 -o\nTARGET = solution_1\nEXTENSION_TARGET = cpp\nEXTENSION_OUT = out\n\n\nall: \n\t$(CX"
},
{
"path": "Problem002/C++/solution_1.cpp",
"chars": 687,
"preview": "/**\n * Find the sum of all even fibonacci numbers whose values are under 4E6.\n */\n\n#include <iostream>\n#include <cstdli"
},
{
"path": "Problem002/Clojure/solution_1.clj",
"chars": 205,
"preview": ";; Author: G4BB3R\n\n(def fib (cons 0 (cons 1 (lazy-seq (map + fib (rest fib))))))\n\n(def resultado\n (reduce + 0 (filter"
},
{
"path": "Problem002/Clojure/solution_2.clj",
"chars": 223,
"preview": "(def fib\n (->> [0 1]\n (iterate (fn [[x y]] [y (+' x y)]))\n (map first)))\n\n(defn solution []\n (->> fib\n "
},
{
"path": "Problem002/CommonLisp/solution_1.lisp",
"chars": 477,
"preview": ";; Common Lisp Script\n;; Manoel Vilela\n\n(defun fib (n)\n (labels ((tail-fib (n a b)\n (if (= n 0)\n "
},
{
"path": "Problem002/D/solution_1.d",
"chars": 426,
"preview": "import std.stdio : writeln;\nimport std.algorithm : filter, sum;\n\nenum int LIMIT = 50;\n\nulong[] _fibonacci() \n{\n ulong"
},
{
"path": "Problem002/Elixir/solution_1.ex",
"chars": 209,
"preview": "Stream.unfold({0, 1}, fn {a, b} -> {a, {b, a + b}} end)\n|> Stream.filter(&(rem(&1, 2) == 0))\n|> Enum.reduce_while(0, fn "
},
{
"path": "Problem002/Go/solution_1.go",
"chars": 259,
"preview": "package main\n\nimport \"fmt\"\n\nfunc p2(n int) int {\n\tsum, a, b, c := 0, 1, 1, 2 // c = a + b\n\tfor c < n {\n\t if n % 2"
},
{
"path": "Problem002/Haskell/solution_1.hs",
"chars": 458,
"preview": "{-\nEach new term in the Fibonacci sequence is generated by adding the previous two terms.\nBy starting with 1 and 2, the "
},
{
"path": "Problem002/JavaScript/solution_1.js",
"chars": 437,
"preview": "'use strict'\n\nLIMIT = 4000000\n\neven = (b) => b % 2 != 0\n\nfunction sequence_generator(n, filter){\n a=1;\n b=1;\n a"
},
{
"path": "Problem002/Lua/solution_1.lua",
"chars": 463,
"preview": "-- Author: G4BB3R\n\n-- Fibonacci function with memoization\nlocal fib_cache = {}\nlocal function fib (n)\n\tif fib_cache[n] t"
},
{
"path": "Problem002/OCaml/solution_1.ml",
"chars": 216,
"preview": "let rec solve a b top sum =\n if a > top then\n sum\n else if b mod 2 = 0 then\n solve b (a + b) top (sum + b)\n els"
},
{
"path": "Problem002/PHP/solution_1.php",
"chars": 370,
"preview": "<?php\n\n $fibonacci = array(1, 2);\n\n array_walk($fibonacci, function($x) use (&$fibonacci){\n if($x * 2.6180 "
},
{
"path": "Problem002/Python/solution_1.py",
"chars": 345,
"preview": "#!/usr/bin/env python\r\n# coding=utf-8\r\n#\r\n# Python Script\r\n#\r\n# Copyleft © Manoel Vilela\r\n#\r\n#\r\n\r\n\r\ndef fib_generato"
},
{
"path": "Problem002/README.md",
"chars": 69,
"preview": "[The original source of problem](https://projecteuler.net/problem=2)\n"
},
{
"path": "Problem002/Ruby/solution_1.rb",
"chars": 253,
"preview": "# Author: tkovs\n\ndef fib(n)\n a, b = 0, 1\n sequence = [a] # initialize\n\n while (b < n)\n sequence.push(b)\n"
},
{
"path": "Problem002/Scheme/solution_1.scm",
"chars": 468,
"preview": ";;\n;; The even Fibonacci numbers satisfy the recurrence\n;;\n;; A(n+2) = 4*A(n+1) + A(n) if n>0\n;; A(1) = 2, A(2) = 8\n;;\n\n"
},
{
"path": "Problem003/.hash",
"chars": 32,
"preview": "94c4dd41f9dddce696557d3717d98d82"
},
{
"path": "Problem003/C++/solution_1.cpp",
"chars": 380,
"preview": "#include<bits/stdc++.h>\nusing namespace std;\n\nlong long int largestPrime(long long int num){\n int j=2;\n while(num%j !="
},
{
"path": "Problem003/Clojure/solution_1.clj",
"chars": 799,
"preview": "(defn is-prime\n [n]\n (if (or (= n 1) (= n 4))\n false\n (loop [candidates (range 2 (+ 1 (Math/sqrt n)))]\n (co"
},
{
"path": "Problem003/CommonLisp/solution_1.lisp",
"chars": 482,
"preview": ";; Common Lisp Script\n;; Manoel Vilela\n\n(defun factors (n)\n \"Return a list of '(prime factor) for n\n (factors 100) =>"
},
{
"path": "Problem003/Elixir/solution_1.exs",
"chars": 355,
"preview": "defmodule Prime do\n def solve(num), do: solve(num, 2)\n defp solve(num, acc) when num <= acc, do: num |> IO.puts()\n de"
},
{
"path": "Problem003/Go/solution_1.go",
"chars": 496,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nconst NUM = 600851475143\n\nvar GrDiv = 1\n\nfunc main() {\n\tfor i := 3; float64(i) "
},
{
"path": "Problem003/Haskell/solution_1.hs",
"chars": 370,
"preview": "prime_acc :: Integer -> Integer -> Integer\nprime_acc value acc\n | acc < value = if mod value acc == 0 then \n "
},
{
"path": "Problem003/Haskell/solution_2.hs",
"chars": 191,
"preview": "prime value acc\n | acc >= value = acc\n | mod value acc == 0 = prime (div value acc) (acc + 1)\n | otherwise = pr"
},
{
"path": "Problem003/JavaScript/solution_1.js",
"chars": 196,
"preview": "'use strict'\n\nconst prime = num => {\n\n\tif(num == 1) {\n\t\treturn 1;\n\t}\n\n\tlet i;\n\n\tfor(i = 2; i < num; i++) {\n\t\tif(num % i "
},
{
"path": "Problem003/PHP/solution_1.php",
"chars": 180,
"preview": "<?php\n\nfunction prime($num)\n{\n for ($i = 2; $i < $num; $i++) {\n if ($num % $i == 0) {\n $num /= $i;\n"
},
{
"path": "Problem003/Python/solution_1.py",
"chars": 879,
"preview": "#!/usr/bin/env python\n# coding=utf-8\n#\n# Python Script\n#\n# Copyleft © Manoel Vilela\n#\n#\n\nfrom sys import version_inf"
},
{
"path": "Problem003/README.md",
"chars": 69,
"preview": "[The original source of problem](https://projecteuler.net/problem=3)\n"
},
{
"path": "Problem003/Scheme/solution_1.scm",
"chars": 778,
"preview": "(define divmod\n (lambda (n d)\n (let ((q (floor (/ n d)))\n (r (remainder n d)))\n (cons q r))))\n\n(define"
},
{
"path": "Problem003/Shell/solution_1.sh",
"chars": 212,
"preview": "#!/bin/bash\n\nprime () {\n num=$1\n\n counter=2\n while [ $counter -lt $num ]; do\n if !(($num % $counter)); then num="
},
{
"path": "Problem004/.hash",
"chars": 32,
"preview": "d4cfc27d16ea72a96b83d9bdef6ce2ec"
},
{
"path": "Problem004/C/solution_1.c",
"chars": 551,
"preview": "#include <stdio.h>\n#include <stdlib.h>\nint main()\n{\n unsigned long int m=0,n=0, palindrome=0,h;\n int i=0,j=0;\n "
},
{
"path": "Problem004/Clojure/solution_1.clj",
"chars": 194,
"preview": "(defn solution\n []\n (->>\n (for [x (range 100 1000) y (range 100 1000)\n :let [p (* x y)]\n :when (= (r"
},
{
"path": "Problem004/CommonLisp/solution_1.lisp",
"chars": 615,
"preview": ";; Common Lisp Script\n;; Manoel Vilela\n\n(defun reverse-digits (n)\n (labels ((next (n v)\n (if (zerop n)\n "
},
{
"path": "Problem004/Elixir/solution_1.exs",
"chars": 235,
"preview": "isPalindrome = fn num -> num\n\t|> Integer.to_string\n\t|> String.reverse\n\t|> String.to_integer\n\t|> (fn x -> x == num end).("
},
{
"path": "Problem004/Go/solution_1.go",
"chars": 423,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar MAX = 10000\n\tfor i := 100; i < 1000; i++ {\n\t\tf"
},
{
"path": "Problem004/Haskell/solution_1.hs",
"chars": 256,
"preview": "-- Author: G4BB3R\n\nisPalindrome :: Int -> Bool\nisPalindrome x = show x == (reverse . show $ x)\n\nlargestPalindrome :: Int"
},
{
"path": "Problem004/JavaScript/solution_1.js",
"chars": 365,
"preview": "'use strict'\n\nfunction is_palindrome(s){\n return s === s.split('').reverse().join('')\n}\n\nfunction find_max_palindrom("
},
{
"path": "Problem004/Lua/solution_1.lua",
"chars": 251,
"preview": "-- Author: G4BB3R\n\nlocal function isPalindrome (x)\n\treturn tonumber(string.reverse(x)) == x\nend\n\nlocal largest = 0\nfor a"
},
{
"path": "Problem004/OCaml/solution_1.ml",
"chars": 635,
"preview": "let rec ispalind s =\n if String.length s <= 1 then true\n else if s.[0] = s.[String.length s - 1] then ispalind (String"
},
{
"path": "Problem004/Python/solution_1.py",
"chars": 670,
"preview": "#!/usr/bin/env python\n# coding=utf-8\n#\n# Python Script\n#\n# Copyleft © Manoel Vilela\n#\n#\n\nfrom sys import version_inf"
},
{
"path": "Problem004/README.md",
"chars": 69,
"preview": "[The original source of problem](https://projecteuler.net/problem=4)\n"
},
{
"path": "Problem004/Ruby/solution_01.rb",
"chars": 223,
"preview": "# Author: tkovs\n\ndef palindrome(n)\n return (n.to_s.eql?(n.to_s.reverse))\nend\n\ndef solve\n list = (1..999).flat_map{"
},
{
"path": "Problem005/.hash",
"chars": 32,
"preview": "bc0d0a22a7a46212135ed0ba77d22f3a"
},
{
"path": "Problem005/C/solution_1.c",
"chars": 408,
"preview": "#include <stdio.h>\n// Author: tkovs\n// Used lua solution that uses python solution XD\n\nint main(void) {\n int k, i = 1"
},
{
"path": "Problem005/C++/solution_1.cpp",
"chars": 319,
"preview": "#include <iostream>\n\nint main(int argc, char **argv)\n{\n\tint number = 2520;\n\n\t// naive solution\n\twhile (true) {\n\t\tfor (in"
},
{
"path": "Problem005/CommonLisp/solution_1.lisp",
"chars": 109,
"preview": ";; Common Lisp Script\n;; Manoel Vilela\n\n(format t \"~a~%\" (reduce #'lcm (loop for x from 1 to 20 collect x)))\n"
},
{
"path": "Problem005/Elixir/solution_1.exs",
"chars": 300,
"preview": "defmodule Solution do\n def solve(n) do\n dvs = 2..n |> Enum.to_list\n find_recur(n, dvs, n)\n end\n\n defp find_recu"
},
{
"path": "Problem005/Elixir/solution_2.exs",
"chars": 245,
"preview": "# Author: lubien\n\ndefmodule Euler5 do\n def solve(n) do\n 1..n |> Enum.reduce(&lcm/2)\n end\n\n def lcm(x, y), do: div("
},
{
"path": "Problem005/Elixir/solution_slow_1.exs",
"chars": 123,
"preview": "# Author: G4BB3R\n\n1..999999999999 |> Enum.find(fn x -> Enum.all? 11..20, &(rem(x, &1) == 0) end)\n |> IO.p"
},
{
"path": "Problem005/Haskell/solution_1.hs",
"chars": 191,
"preview": "-- Author: G4BB3R\n\nimport Data.List (find)\nimport Data.Maybe (fromJust)\n\nsmallest :: Int\nsmallest = fromJust $ find (\\x "
},
{
"path": "Problem005/JavaScript/solution_1.js",
"chars": 294,
"preview": "\"use strict\";\n\nfunction smallest_multiple() {\n let i = 1;\n for (let k = 1; k < 21; k++) {\n if (i % k > 0) {\n f"
},
{
"path": "Problem005/Lua/solution_1.lua",
"chars": 195,
"preview": "-- Author: G4BB3R\n-- Used python solution XD\n\nlocal i = 1\nfor k = 1, 20 do\n\tif i % k > 0 then\n\t\tfor j = 1, 20 do\n\t\t\tif ("
},
{
"path": "Problem005/OCaml/solution_1.ml",
"chars": 717,
"preview": "let rec range i j = if i > j then [] else i :: (range (i+1) j)\n\nlet is_prime n =\n let is_divisor d p =\n if p mod d ="
},
{
"path": "Problem005/Python/solution_2.py",
"chars": 201,
"preview": "#Some milliseconds slower than solution 1\ndef div20(num):\n return all([num%x==0 for x in range(20, 10, -1)])\nnum = 25"
},
{
"path": "Problem005/Python/solution_3.py",
"chars": 202,
"preview": "# someone in the internet do that\n\ni = 1\nfor k in (range(1, 21)):\n if i % k > 0:\n for j in range(1, 21):\n "
},
{
"path": "Problem005/Python/solution_slow_1.py",
"chars": 600,
"preview": "#!/usr/bin/env python\n# coding=utf-8\n#\n# Python Script\n#\n# Copyleft © Manoel Vilela\n#\n#\n\n\"\"\"\nSmallest multiple\nProbl"
},
{
"path": "Problem005/README.md",
"chars": 69,
"preview": "[The original source of problem](https://projecteuler.net/problem=5)\n"
},
{
"path": "Problem005/Scheme/solution_1.scm",
"chars": 627,
"preview": ";;\n\n(define makelist\n (lambda (f min max L)\n (cond\n ((> min max) L)\n (else (makelist f (+ min 1) max (append"
},
{
"path": "Problem005/go/solution_1.go",
"chars": 300,
"preview": "package main\n\nimport \"fmt\"\n\nfunc smallest_multiple(number int) int {\n\tfor result := 2; ; result++ {\n\t\tfound := true\n\t\tfo"
},
{
"path": "Problem006/.hash",
"chars": 32,
"preview": "867380888952c39a131fe1d832246ecc"
},
{
"path": "Problem006/C++/Makefile",
"chars": 257,
"preview": "CXX = g++\nLFLAGS = -lm -Wall -std=c++0x -o\nTARGET = solution_01\nEXTENSION_TARGET = cpp\nEXTENSION_OUT = out\n\n\nall:\n\t$(CX"
},
{
"path": "Problem006/C++/solution_1.cpp",
"chars": 691,
"preview": "/*\n * Find the difference between the square of the sum and the sum of the squares\n * of the first one hundred numbers.\n"
},
{
"path": "Problem006/Clojure/solution_1.clj",
"chars": 236,
"preview": ";Author: tkovs\n\n(defn solve []\n (let [sum_square (reduce +' (map (fn [x] (* x x)) (range 1 101)))\n square_su"
},
{
"path": "Problem006/CommonLisp/solution_1.lisp",
"chars": 452,
"preview": ";; Common Lisp Script\n;; Manoel Vilela\n\n(defun square (x)\n (* x x))\n\n;; (1 2 3) => 1² + 2² + 3² => 14\n(defun square-sum"
},
{
"path": "Problem006/Elixir/solution_1.exs",
"chars": 172,
"preview": "# Author: G4BB3R\n\nx = 1..100 |> Enum.sum\n |> :math.pow(2)\n\t\ny = 1..100 |> Enum.to_list\n\t\t |> Enum.map(&:math"
},
{
"path": "Problem006/Haskell/solution_1.hs",
"chars": 526,
"preview": "{-\nThe sum of the squares of the first ten natural numbers is,\n12 + 22 + ... + 102 = 385\n\nThe square of the sum of the f"
},
{
"path": "Problem006/LaTeX/solution_1.tex",
"chars": 1226,
"preview": "\\documentclass[a4paper,12pt]{article}\n\\usepackage{amsmath, amssymb, amsthm}\n\\usepackage{mathtools}\n\\usepackage{tabulary}"
},
{
"path": "Problem006/OCaml/solution_1.ml",
"chars": 274,
"preview": "let rec pow n x =\n if n=0 then 1. else x *. pow (n-1) x;;\n\nlet f x = pow 2 (float_of_int ((x * (x + 1)) / 2))\nlet ff x "
},
{
"path": "Problem006/Python/solution_1.py",
"chars": 780,
"preview": "#!/usr/bin/env python\n# coding=utf-8\n#\n# Python Script\n#\n# Copyleft © Manoel Vilela\n#\n#\n\nfrom functools import reduc"
},
{
"path": "Problem006/Python/solution_2.py",
"chars": 298,
"preview": "#!/usr/bin/env python\n# coding=utf-8\n\n# remove unnecessary range in square of sum (solution inspired by Manoel Vilela)\n\n"
},
{
"path": "Problem006/README.md",
"chars": 69,
"preview": "[The original source of problem](https://projecteuler.net/problem=6)\n"
},
{
"path": "Problem006/Ruby/solution_1.rb",
"chars": 190,
"preview": "#Author: tkovs\n\ndef solve\n sum_square = (1..100).map{|x| x * x}.inject(:+)\n square_sum = (1..100).inject(:+) * (1."
},
{
"path": "Problem006/Scheme/solution_1.scm",
"chars": 269,
"preview": "\n(define square-of-sum\n (lambda (n)\n (/ (* n n (+ n 1) (+ n 1)) 4)))\n\n(define sum-of-squares\n (lambda (n)\n (/ (*"
},
{
"path": "Problem006/go/solution_1.go",
"chars": 321,
"preview": "package main\n\nimport \"fmt\"\n\nfunc sumOfSquare(max int) int {\n\tresult := 1\n\tfor i := 2; i <= max; i++ {\n\t\tresult += i * i\n"
},
{
"path": "Problem007/.hash",
"chars": 33,
"preview": "8c32ab09ec0210af60d392e9b2009560\n"
},
{
"path": "Problem007/C++/Makefile",
"chars": 257,
"preview": "CXX = g++\nLFLAGS = -lm -Wall -std=c++0x -o\nTARGET = solution_01\nEXTENSION_TARGET = cpp\nEXTENSION_OUT = out\n\n\nall:\n\t$(CX"
},
{
"path": "Problem007/C++/solution_1.cpp",
"chars": 639,
"preview": "/*\n * Finds the 10001 prime number.\n */\n\n#include <iostream>\n#include <cstdlib>\n\nbool is_prime(int n);\n\nint main(int arg"
},
{
"path": "Problem007/Clojure/solution_1.clj",
"chars": 522,
"preview": "(defn is-prime\n [n]\n (if (or (= n 1) (= n 4))\n false\n (loop [candidates (range 2 (+ 1 (Math/sqrt n)))]\n (co"
},
{
"path": "Problem007/Clojure/solution_2.clj",
"chars": 424,
"preview": "(defn prime? [n]\n (= 1 (->> (range 1 (inc (Math/sqrt n)))\n (map (partial rem n))\n (filter (partia"
},
{
"path": "Problem007/CommonLisp/solution_1.lisp",
"chars": 433,
"preview": ";; Common Lisp Script\n;; Manoel Vilela\n\n\n(defun primep (n)\n (let ((divisors (loop for x from 2 to (floor (1+ (sqrt n)))"
},
{
"path": "Problem007/Elixir/solution_2.exs",
"chars": 639,
"preview": "defmodule Solution do\n def nth_prime(n) do\n prime_sequence()\n |> Stream.take(n)\n |> Enum.to_list\n |> List.l"
},
{
"path": "Problem007/Elixir/solution_slow_1.exs",
"chars": 565,
"preview": "# Author: G4BB3R\n\ndefmodule Problem007 do\n\n\tdef isPrime(1), do: false\n\tdef isPrime(2), do: true\n\tdef isPrime(3), do: tru"
},
{
"path": "Problem007/Haskell/solution_1.hs",
"chars": 414,
"preview": "-- Author: G4BB3R\n\nimport Data.List (find)\nimport Data.Maybe (isNothing)\n\nisPrime :: Int -> Bool\nisPrime x\n | x == 1 "
},
{
"path": "Problem007/Lua/solution_1.lua",
"chars": 382,
"preview": "-- Author: G4BB3R\n\nlocal function isPrime (n)\n\tif n < 2 then\n\t\treturn false\n\telseif n == 2 or n == 3 then\n\t\treturn true\n"
},
{
"path": "Problem007/Python/primes.py",
"chars": 1338,
"preview": "#!/usr/bin/env python\n# coding=utf-8\n#\n# Python Script\n#\n# Copyleft © Manoel Vilela\n#\n#\n\nfrom sys import version_inf"
},
{
"path": "Problem007/Python/solution_1.py",
"chars": 396,
"preview": "#!/usr/bin/env python\n# coding=utf-8\n#\n# Python Script\n#\n# Copyleft © Manoel Vilela\n#\n#\n\n\"\"\"\n10001st prime\nProblem 7"
},
{
"path": "Problem007/README.md",
"chars": 69,
"preview": "[The original source of problem](https://projecteuler.net/problem=7)\n"
},
{
"path": "Problem007/Scheme/solution_1.scm",
"chars": 2162,
"preview": "(require srfi/9) ;; Records\n\n;; begin record :listcount\n\n(define-record-type :listcount\n (listcount lst cnt)\n listcoun"
},
{
"path": "Problem008/.hash",
"chars": 32,
"preview": "0f53ea7949d32ef24f9186207600403c"
},
{
"path": "Problem008/Clojure/solution_slow_1.clj",
"chars": 1243,
"preview": "(def bignumber \"73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586"
},
{
"path": "Problem008/CommonLisp/solution_1.lisp",
"chars": 1535,
"preview": ";; Common Lisp Script\n;; Manoel Vilela\n\n(defparameter *big-num* \"7316717653133062491922511967442657474235534919493496983"
},
{
"path": "Problem008/Elixir/solution_1.exs",
"chars": 1224,
"preview": "# Author: lubien\n\ndata = \"7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478"
},
{
"path": "Problem008/Haskell/solution_1.hs",
"chars": 1364,
"preview": "list :: String\nlist = \"7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851"
},
{
"path": "Problem008/Python/solution_1.py",
"chars": 1827,
"preview": "#!/usr/bin/env python\n# coding=utf-8\n#\n# Python Script\n#\n# Copyleft © Manoel Vilela\n#\n#\n\nfrom functools import reduc"
},
{
"path": "Problem008/README.md",
"chars": 69,
"preview": "[The original source of problem](https://projecteuler.net/problem=8)\n"
},
{
"path": "Problem009/.hash",
"chars": 32,
"preview": "24eaa9820350012ff678de47cb85b639"
},
{
"path": "Problem009/CommonLisp/solution_1.lisp",
"chars": 401,
"preview": ";; Common Lisp Script\n;; Manoel Vilela\n\n(defun pythagorean (a b c)\n (= (+ (* a a)\n (* b b))\n (* c c)))\n\n(def"
},
{
"path": "Problem009/Elixir/solution_1.exs",
"chars": 152,
"preview": "# Author: lubien\n\nfor a <- 1..444,\n b <- 1..444,\n c <- [1000 - b - a],\n a * a + b * b == c * c\n do a * b * c e"
},
{
"path": "Problem009/Haskell/solution_1.hs",
"chars": 193,
"preview": "-- Author: G4BB3R\n-- Help: tkovs\n\ntriangulo = head [(a, b, c) | a <- [1..444], b <- [a..444], c <- [1000 - b - a], a ^ 2"
},
{
"path": "Problem009/Python/solution_1.py",
"chars": 912,
"preview": "#!/usr/bin/env python\n# coding=utf-8\n# Python Script\n#\n# Copyleft © Manoel Vilela\n#\n#\n\nfrom __future__ import print_"
},
{
"path": "Problem009/Python/solution_2.py",
"chars": 231,
"preview": "#code created by NamanNimmo Gera\n#11:32am, April 30, 2019.\n\nfor i in range(1,1000):\n for j in range(i+1,1000):\n "
},
{
"path": "Problem009/README.md",
"chars": 69,
"preview": "[The original source of problem](https://projecteuler.net/problem=9)\n"
},
{
"path": "Problem009/Ruby/solution_1.rb",
"chars": 153,
"preview": "#Author: tkovs\n\ndef solve\n x = (1..444)\n x.each{|a| x.each{|b| [1000 - b - a].each{|c| return (a * b * c) if (a*a "
},
{
"path": "Problem010/.hash",
"chars": 32,
"preview": "d915b2a9ac8749a6b837404815f1ae25"
},
{
"path": "Problem010/C++/Makefile",
"chars": 247,
"preview": "CXX = g++\nLFLAGS = -lm -Wall -o\nTARGET = solution_1\nEXTENSION_TARGET = cpp\nEXTENSION_OUT = out\n\n\nall: \n\t$(CXX) $(LFLAGS"
},
{
"path": "Problem010/C++/solution_1.cpp",
"chars": 961,
"preview": "/**\n * C++ algorithm to get the sum of all prime numbers between a range of 2 and the number desired. \n */\n\n#include <io"
},
{
"path": "Problem010/Clojure/solution_1.clj",
"chars": 377,
"preview": "(defn prime? [n]\n (.isProbablePrime (BigInteger/valueOf n) 10))\n\n(defn next-prime\n [n]\n (loop [candidate n]\n (if ("
},
{
"path": "Problem010/CommonLisp/solution_1.lisp",
"chars": 411,
"preview": ";; Common Lisp Script\n;; Manoel Vilela\n\n(defun primep (n)\n (loop for d from 2 to (floor (1+ (sqrt n)))\n never (a"
},
{
"path": "Problem010/Haskell/solution_slow_1.hs",
"chars": 276,
"preview": "-- Author: G4BB3R\n-- Performance: 7643.2s (How to improve ?)\n\nprimes :: [Int]\nprimes = sieve [2..]\n where sieve :: [Int"
},
{
"path": "Problem010/Haskell/solution_slow_2.hs",
"chars": 684,
"preview": "-- Author: G4BB3R\n-- Performance: 38.8s (Improved: 196x faster)\n\nprimes = 2 : ([3..] `minus` composites)\n where compo"
},
{
"path": "Problem010/Python/primes.py",
"chars": 14356,
"preview": "def prime_gen(n):\n for i in xrange(2, n):\n prime = True\n if i % 2 == 0 and i != 2:\n continue"
},
{
"path": "Problem010/Python/solution_1.py",
"chars": 300,
"preview": "#!/usr/bin/env python2\n# coding=utf-8\n\"\"\"\nSummation of primes\nProblem 10\n\nThe sum of the primes below 10 is 2 + 3 + 5 + "
},
{
"path": "Problem010/README.md",
"chars": 70,
"preview": "[The original source of problem](https://projecteuler.net/problem=10)\n"
},
{
"path": "Problem011/.hash",
"chars": 32,
"preview": "678f5d2e1eaa42f04fa53411b4f441ac"
},
{
"path": "Problem011/C++/solution_1.cpp",
"chars": 2057,
"preview": "#include <iostream>\r\nusing namespace std;\r\nint main()\r\n{\r\n\tint i,j,max=0,pro;\r\n\tint a[20][20]={\r\n \t {8,2,22,"
},
{
"path": "Problem011/Elixir/solution_1.exs",
"chars": 3078,
"preview": "master_grid_array = \"08,02,22,97,38,15,00,40,00,75,04,05,07,78,52,12,50,77,91,08,\n49,49,99,40,17,81,18,57,60,87,17,40,98"
},
{
"path": "Problem011/Haskell/solution_1.hs",
"chars": 2687,
"preview": "list = [08,02,22,97,38,15,00,40,00,75,04,05,07,78,52,12,50,77,91,08,\n 49,49,99,40,17,81,18,57,60,87,17,40,98,43,6"
},
{
"path": "Problem011/Python/solution_1.py",
"chars": 2680,
"preview": "#!/usr/bin/env python\n# coding=utf-8\n# Python Script\n#\n# Copyleft © Manoel Vilela\n#\n#\n\nimport sys\nif sys.version_inf"
},
{
"path": "Problem011/README.md",
"chars": 70,
"preview": "[The original source of problem](https://projecteuler.net/problem=11)\n"
},
{
"path": "Problem012/.hash",
"chars": 32,
"preview": "8091de7d285989bbfa9a2f9f3bdcc7c0"
},
{
"path": "Problem012/C++/solution_1.cpp",
"chars": 512,
"preview": "#include<bits/stdc++.h>\nusing namespace std;\n#define MAX 1000000000\n#define LL long long int\nLL countDivisors(LL n)\n{\n "
},
{
"path": "Problem012/Elixir/solution_1.exs",
"chars": 498,
"preview": "# Author: lubien\n\ndefmodule Euler12 do\n def solve do\n Stream.iterate(1, &(&1 + 1))\n |> Stream.scan(&(&1 + &2))\n"
},
{
"path": "Problem012/Haskell/solution_1.hs",
"chars": 229,
"preview": "triangleList :: [Int]\n--triangleList = map ((\\xs -> (sum xs, xs)) . enumFromTo 1) [1..]\ntriangleList = map (\\n -> n * (n"
},
{
"path": "Problem012/JavaScript/solution_1.js",
"chars": 1641,
"preview": "\"use strict\"\r\n\r\nfunction checkPrime(input, list) {\r\n for (let i = 0; i < list.length && list[i] < input ** 0.5; i++) "
},
{
"path": "Problem012/Python/solution_1.py",
"chars": 1720,
"preview": "#!/usr/bin/env python\n# coding=utf-8\n# Python Script\n#\n# Copyleft © Manoel Vilela\n#\n#\n\n# Highly divisible triangular"
},
{
"path": "Problem012/Python/solution_2.py",
"chars": 1137,
"preview": "# Good Solution found on forum thread in the projecteuler\n\nfrom functools import reduce\n\n\ndef divisors(x):\n '''\n e"
},
{
"path": "Problem012/Python/solution_3.py",
"chars": 1223,
"preview": "#!/usr/bin/env python\n# coding=utf-8\n# Python Script\n#\n# Copyleft © Manoel Vilela\n#\n#\n\n# Highly divisible triangular"
},
{
"path": "Problem012/README.md",
"chars": 70,
"preview": "[The original source of problem](https://projecteuler.net/problem=12)\n"
},
{
"path": "Problem013/.hash",
"chars": 32,
"preview": "361113f19fd302adc31268f8283a4f2d"
},
{
"path": "Problem013/Elixir/solution_1.exs",
"chars": 5693,
"preview": "# Author: G4BB3R\n\n [37107287533902102798797998220837590246510135740250,\n 463769376774900097126481248969700780504170"
},
{
"path": "Problem013/Haskell/solution_1.hs",
"chars": 6359,
"preview": "main :: IO ()\nmain = putStr $ take 10 $ show $ sum numbers\n\nnumbers = [3710728753390210279879799822083759024651013574025"
},
{
"path": "Problem013/Lua/solution_1.lua",
"chars": 6471,
"preview": "-- Author: G4BB3R\n\nnumbers = {37107287533902102798797998220837590246510135740250,\n 463769376774900097126481248"
},
{
"path": "Problem013/Python/solution_1.py",
"chars": 5274,
"preview": "# Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.\ndata = '''37107287533902102798"
},
{
"path": "Problem013/README.md",
"chars": 70,
"preview": "[The original source of problem](https://projecteuler.net/problem=13)\n"
},
{
"path": "Problem013/Ruby/solution_1.rb",
"chars": 6387,
"preview": "#Author: tkovs\n\n$numbers = [37107287533902102798797998220837590246510135740250,\n 46376937677490009712648124896"
},
{
"path": "Problem014/.hash",
"chars": 32,
"preview": "5052c3765262bb2c6be537abd60b305e"
},
{
"path": "Problem014/Clojure/solution_1.clj",
"chars": 7047,
"preview": ";; wrong solution.\n\n(def bignumbers '(37107287533902102798797998220837590246510135740250\n 4637693767749"
},
{
"path": "Problem014/Elixir/solution_1.exs",
"chars": 622,
"preview": "# Author: lubien\n\ndefmodule Euler14 do\n def solve() do\n largest_collatz(1, {0, 0})\n end\n\n defp largest_collatz(1_0"
},
{
"path": "Problem014/Haskell/solution_slow_1.hs",
"chars": 635,
"preview": "-- Author: G4BB3R\n\ngetCollatzSequenceLen :: Int -> Int\ngetCollatzSequenceLen 1 = 1\ngetCollatzSequenceLen x = 1 + getColl"
},
{
"path": "Problem014/Python/solution_slow_1.py",
"chars": 1141,
"preview": "#!/usr/bin/env python\n# coding=utf-8\n# Python Script\n#\n# Copyleft © Manoel Vilela\n#\n#\n\n# problem14.py dumb solution "
},
{
"path": "Problem014/README.md",
"chars": 70,
"preview": "[The original source of problem](https://projecteuler.net/problem=14)\n"
},
{
"path": "Problem015/.hash",
"chars": 32,
"preview": "928f3957168ac592c4215dcd04e0b678"
},
{
"path": "Problem015/C/solution_1.c",
"chars": 332,
"preview": "#include<stdio.h>\nunsigned long long g[21][21];\nint main() \n{ \n int j,i;\n for ( i = 0; i < 21; ++i) {\n g[i]"
},
{
"path": "Problem015/Clojure/solution_1.clj",
"chars": 308,
"preview": ";; Author: G4BB3R\n\n(defn fat [n]\n (if (<= n 1)\n 1\n (* n (fat (- n 1)))))\n\n(defn fatorial [n]\n (fat (bi"
},
{
"path": "Problem015/Elixir/solution_1.exs",
"chars": 181,
"preview": "# Author: G4BB3R\n\ndefmodule Fat do\n\n\tdef fatorial(1), do: 1\n\tdef fatorial(n), do: n * fatorial(n - 1)\n\nend\n\n\tIO.puts rou"
},
{
"path": "Problem015/Haskell/solution_1.hs",
"chars": 313,
"preview": "{--\nStarting in the top left corner of a 2×2 grid, and only being able to move to\nthe right and down, there are exactly "
},
{
"path": "Problem015/Haskell/solution_2.hs",
"chars": 141,
"preview": "-- Author: G4BB3R\n\nmain :: IO ()\nmain = print $ div (fat 40 :: Integer) (fat 20 ^ (2 :: Integer))\n where fat = p"
},
{
"path": "Problem015/Lua/solution_1.lua",
"chars": 157,
"preview": "-- Author: G4BB3R\n\nlocal function fat (n)\n\treturn n <= 1 and 1 or n * fat(n - 1)\nend\n\n-- print(fat(40) // fat(20) ^ 2) b"
},
{
"path": "Problem015/Python/solution_1.py",
"chars": 856,
"preview": "#!/usr/bin/env python\n# coding=utf-8\n# Python Script\n#\n# Copyleft © Manoel Vilela\n#\n#\n\n\"\"\"\nLattice paths\nProblem 15\n"
},
{
"path": "Problem015/README.md",
"chars": 70,
"preview": "[The original source of problem](https://projecteuler.net/problem=15)\n"
},
{
"path": "Problem015/Ruby/solution_1.rb",
"chars": 140,
"preview": "#Author: tkovs\n#Translation of the Haskell code P015\n\ndef solve\n return ((1..40).inject(:*) / ((1..20).inject(:*) ** "
},
{
"path": "Problem016/.hash",
"chars": 32,
"preview": "6a5889bb0190d0211a991f47bb19a777"
},
{
"path": "Problem016/Clojure/solution_1.clj",
"chars": 150,
"preview": "(defn solution\n []\n (->>\n (repeat 1000 2)\n (reduce *')\n (str)\n (seq)\n (map #(Character/digit % 10))\n (redu"
},
{
"path": "Problem016/CommonLisp/solution_1.lisp",
"chars": 184,
"preview": ";; Common Lisp Script\n;; Manoel Vilela\n\n\n(defun sum-digits (x)\n (if (< x 10)\n x\n (+ (mod x 10) (sum-digits (f"
},
{
"path": "Problem016/CommonLisp/solution_2.lisp",
"chars": 304,
"preview": ";; Common Lisp Script\n;; Manoel Vilela\n\n\n(defun integer-to-list (x)\n (if (< x 10)\n (cons x nil)\n (cons (mod x"
},
{
"path": "Problem016/Elixir/solution_1.exs",
"chars": 211,
"preview": ":math.pow(2, 1000) |> round\n |> to_charlist\n |> Enum.map(fn (c) -> c - hd('0') end)\n"
},
{
"path": "Problem016/Haskell/solution_1.hs",
"chars": 165,
"preview": "import Data.Char (digitToInt)\n\nsumDigits :: Integer -> Int\nsumDigits = sum . map digitToInt . show\n\nmain :: IO ()\nmain ="
}
]
// ... and 334 more files (download for full content)
About this extraction
This page contains the full source code of the DestructHub/ProjectEuler GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 534 files (535.9 KB), approximately 231.8k tokens, and a symbol index with 571 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.