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 #include #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 #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 #include 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 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) { 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 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 ================================================ ================================================ FILE: Problem001/PHP/solution_2.php ================================================ ================================================ 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 #include #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 #include 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 ================================================ ∞ 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 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))< ((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 ================================================ = (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 #include 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 // 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 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 #include 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 #include 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 #include 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 nppint(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 sqrtnppint(lim): break """ If the next potential prime is greater than the user defined limit, then end the 'while nppint(lim): break """ If the next potential prime is greater than the user defined limit, then end the 'while nppint(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 sqrtnppint(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 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(max3;--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 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 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;i500) { 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 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","SHIRLENE","SHAMEKA","ELIZEBETH","DIAN","SHANTA","MICKEY","LATOSHA","CARLOTTA","WINDY","SOON","ROSINA","MARIANN","LEISA","JONNIE","DAWNA","CATHIE","BILLY","ASTRID","SIDNEY","LAUREEN","JANEEN","HOLLI","FAWN","VICKEY","TERESSA","SHANTE","RUBYE","MARCELINA","CHANDA","CARY","TERESE","SCARLETT","MARTY","MARNIE","LULU","LISETTE","JENIFFER","ELENOR","DORINDA","DONITA","CARMAN","BERNITA","ALTAGRACIA","ALETA","ADRIANNA","ZORAIDA","RONNIE","NICOLA","LYNDSEY","KENDALL","JANINA","CHRISSY","AMI","STARLA","PHYLIS","PHUONG","KYRA","CHARISSE","BLANCH","SANJUANITA","RONA","NANCI","MARILEE","MARANDA","CORY","BRIGETTE","SANJUANA","MARITA","KASSANDRA","JOYCELYN","IRA","FELIPA","CHELSIE","BONNY","MIREYA","LORENZA","KYONG","ILEANA","CANDELARIA","TONY","TOBY","SHERIE","OK","MARK","LUCIE","LEATRICE","LAKESHIA","GERDA","EDIE","BAMBI","MARYLIN","LAVON","HORTENSE","GARNET","EVIE","TRESSA","SHAYNA","LAVINA","KYUNG","JEANETTA","SHERRILL","SHARA","PHYLISS","MITTIE","ANABEL","ALESIA","THUY","TAWANDA","RICHARD","JOANIE","TIFFANIE","LASHANDA","KARISSA","ENRIQUETA","DARIA","DANIELLA","CORINNA","ALANNA","ABBEY","ROXANE","ROSEANNA","MAGNOLIA","LIDA","KYLE","JOELLEN","ERA","CORAL","CARLEEN","TRESA","PEGGIE","NOVELLA","NILA","MAYBELLE","JENELLE","CARINA","NOVA","MELINA","MARQUERITE","MARGARETTE","JOSEPHINA","EVONNE","DEVIN","CINTHIA","ALBINA","TOYA","TAWNYA","SHERITA","SANTOS","MYRIAM","LIZABETH","LISE","KEELY","JENNI","GISELLE","CHERYLE","ARDITH","ARDIS","ALESHA","ADRIANE","SHAINA","LINNEA","KAROLYN","HONG","FLORIDA","FELISHA","DORI","DARCI","ARTIE","ARMIDA","ZOLA","XIOMARA","VERGIE","SHAMIKA","NENA","NANNETTE","MAXIE","LOVIE","JEANE","JAIMIE","INGE","FARRAH","ELAINA","CAITLYN","STARR","FELICITAS","CHERLY","CARYL","YOLONDA","YASMIN","TEENA","PRUDENCE","PENNIE","NYDIA","MACKENZIE","ORPHA","MARVEL","LIZBETH","LAURETTE","JERRIE","HERMELINDA","CAROLEE","TIERRA","MIRIAN","META","MELONY","KORI","JENNETTE","JAMILA","ENA","ANH","YOSHIKO","SUSANNAH","SALINA","RHIANNON","JOLEEN","CRISTINE","ASHTON","ARACELY","TOMEKA","SHALONDA","MARTI","LACIE","KALA","JADA","ILSE","HAILEY","BRITTANI","ZONA","SYBLE","SHERRYL","RANDY","NIDIA","MARLO","KANDICE","KANDI","DEB","DEAN","AMERICA","ALYCIA","TOMMY","RONNA","NORENE","MERCY","JOSE","INGEBORG","GIOVANNA","GEMMA","CHRISTEL","AUDRY","ZORA","VITA","VAN","TRISH","STEPHAINE","SHIRLEE","SHANIKA","MELONIE","MAZIE","JAZMIN","INGA","HOA","HETTIE","GERALYN","FONDA","ESTRELLA","ADELLA","SU","SARITA","RINA","MILISSA","MARIBETH","GOLDA","EVON","ETHELYN","ENEDINA","CHERISE","CHANA","VELVA","TAWANNA","SADE","MIRTA","LI","KARIE","JACINTA","ELNA","DAVINA","CIERRA","ASHLIE","ALBERTHA","TANESHA","STEPHANI","NELLE","MINDI","LU","LORINDA","LARUE","FLORENE","DEMETRA","DEDRA","CIARA","CHANTELLE","ASHLY","SUZY","ROSALVA","NOELIA","LYDA","LEATHA","KRYSTYNA","KRISTAN","KARRI","DARLINE","DARCIE","CINDA","CHEYENNE","CHERRIE","AWILDA","ALMEDA","ROLANDA","LANETTE","JERILYN","GISELE","EVALYN","CYNDI","CLETA","CARIN","ZINA","ZENA","VELIA","TANIKA","PAUL","CHARISSA","THOMAS","TALIA","MARGARETE","LAVONDA","KAYLEE","KATHLENE","JONNA","IRENA","ILONA","IDALIA","CANDIS","CANDANCE","BRANDEE","ANITRA","ALIDA","SIGRID","NICOLETTE","MARYJO","LINETTE","HEDWIG","CHRISTIANA","CASSIDY","ALEXIA","TRESSIE","MODESTA","LUPITA","LITA","GLADIS","EVELIA","DAVIDA","CHERRI","CECILY","ASHELY","ANNABEL","AGUSTINA","WANITA","SHIRLY","ROSAURA","HULDA","EUN","BAILEY","YETTA","VERONA","THOMASINA","SIBYL","SHANNAN","MECHELLE","LUE","LEANDRA","LANI","KYLEE","KANDY","JOLYNN","FERNE","EBONI","CORENE","ALYSIA","ZULA","NADA","MOIRA","LYNDSAY","LORRETTA","JUAN","JAMMIE","HORTENSIA","GAYNELL","CAMERON","ADRIA","VINA","VICENTA","TANGELA","STEPHINE","NORINE","NELLA","LIANA","LESLEE","KIMBERELY","ILIANA","GLORY","FELICA","EMOGENE","ELFRIEDE","EDEN","EARTHA","CARMA","BEA","OCIE","MARRY","LENNIE","KIARA","JACALYN","CARLOTA","ARIELLE","YU","STAR","OTILIA","KIRSTIN","KACEY","JOHNETTA","JOEY","JOETTA","JERALDINE","JAUNITA","ELANA","DORTHEA","CAMI","AMADA","ADELIA","VERNITA","TAMAR","SIOBHAN","RENEA","RASHIDA","OUIDA","ODELL","NILSA","MERYL","KRISTYN","JULIETA","DANICA","BREANNE","AUREA","ANGLEA","SHERRON","ODETTE","MALIA","LORELEI","LIN","LEESA","KENNA","KATHLYN","FIONA","CHARLETTE","SUZIE","SHANTELL","SABRA","RACQUEL","MYONG","MIRA","MARTINE","LUCIENNE","LAVADA","JULIANN","JOHNIE","ELVERA","DELPHIA","CLAIR","CHRISTIANE","CHAROLETTE","CARRI","AUGUSTINE","ASHA","ANGELLA","PAOLA","NINFA","LEDA","LAI","EDA","SUNSHINE","STEFANI","SHANELL","PALMA","MACHELLE","LISSA","KECIA","KATHRYNE","KARLENE","JULISSA","JETTIE","JENNIFFER","HUI","CORRINA","CHRISTOPHER","CAROLANN","ALENA","TESS","ROSARIA","MYRTICE","MARYLEE","LIANE","KENYATTA","JUDIE","JANEY","IN","ELMIRA","ELDORA","DENNA","CRISTI","CATHI","ZAIDA","VONNIE","VIVA","VERNIE","ROSALINE","MARIELA","LUCIANA","LESLI","KARAN","FELICE","DENEEN","ADINA","WYNONA","TARSHA","SHERON","SHASTA","SHANITA","SHANI","SHANDRA","RANDA","PINKIE","PARIS","NELIDA","MARILOU","LYLA","LAURENE","LACI","JOI","JANENE","DOROTHA","DANIELE","DANI","CAROLYNN","CARLYN","BERENICE","AYESHA","ANNELIESE","ALETHEA","THERSA","TAMIKO","RUFINA","OLIVA","MOZELL","MARYLYN","MADISON","KRISTIAN","KATHYRN","KASANDRA","KANDACE","JANAE","GABRIEL","DOMENICA","DEBBRA","DANNIELLE","CHUN","BUFFY","BARBIE","ARCELIA","AJA","ZENOBIA","SHAREN","SHAREE","PATRICK","PAGE","MY","LAVINIA","KUM","KACIE","JACKELINE","HUONG","FELISA","EMELIA","ELEANORA","CYTHIA","CRISTIN","CLYDE","CLARIBEL","CARON","ANASTACIA","ZULMA","ZANDRA","YOKO","TENISHA","SUSANN","SHERILYN","SHAY","SHAWANDA","SABINE","ROMANA","MATHILDA","LINSEY","KEIKO","JOANA","ISELA","GRETTA","GEORGETTA","EUGENIE","DUSTY","DESIRAE","DELORA","CORAZON","ANTONINA","ANIKA","WILLENE","TRACEE","TAMATHA","REGAN","NICHELLE","MICKIE","MAEGAN","LUANA","LANITA","KELSIE","EDELMIRA","BREE","AFTON","TEODORA","TAMIE","SHENA","MEG","LINH","KELI","KACI","DANYELLE","BRITT","ARLETTE","ALBERTINE","ADELLE","TIFFINY","STORMY","SIMONA","NUMBERS","NICOLASA","NICHOL","NIA","NAKISHA","MEE","MAIRA","LOREEN","KIZZY","JOHNNY","JAY","FALLON","CHRISTENE","BOBBYE","ANTHONY","YING","VINCENZA","TANJA","RUBIE","RONI","QUEENIE","MARGARETT","KIMBERLI","IRMGARD","IDELL","HILMA","EVELINA","ESTA","EMILEE","DENNISE","DANIA","CARL","CARIE","ANTONIO","WAI","SANG","RISA","RIKKI","PARTICIA","MUI","MASAKO","MARIO","LUVENIA","LOREE","LONI","LIEN","KEVIN","GIGI","FLORENCIA","DORIAN","DENITA","DALLAS","CHI","BILLYE","ALEXANDER","TOMIKA","SHARITA","RANA","NIKOLE","NEOMA","MARGARITE","MADALYN","LUCINA","LAILA","KALI","JENETTE","GABRIELE","EVELYNE","ELENORA","CLEMENTINA","ALEJANDRINA","ZULEMA","VIOLETTE","VANNESSA","THRESA","RETTA","PIA","PATIENCE","NOELLA","NICKIE","JONELL","DELTA","CHUNG","CHAYA","CAMELIA","BETHEL","ANYA","ANDREW","THANH","SUZANN","SPRING","SHU","MILA","LILLA","LAVERNA","KEESHA","KATTIE","GIA","GEORGENE","EVELINE","ESTELL","ELIZBETH","VIVIENNE","VALLIE","TRUDIE","STEPHANE","MICHEL","MAGALY","MADIE","KENYETTA","KARREN","JANETTA","HERMINE","HARMONY","DRUCILLA","DEBBI","CELESTINA","CANDIE","BRITNI","BECKIE","AMINA","ZITA","YUN","YOLANDE","VIVIEN","VERNETTA","TRUDI","SOMMER","PEARLE","PATRINA","OSSIE","NICOLLE","LOYCE","LETTY","LARISA","KATHARINA","JOSELYN","JONELLE","JENELL","IESHA","HEIDE","FLORINDA","FLORENTINA","FLO","ELODIA","DORINE","BRUNILDA","BRIGID","ASHLI","ARDELLA","TWANA","THU","TARAH","SUNG","SHEA","SHAVON","SHANE","SERINA","RAYNA","RAMONITA","NGA","MARGURITE","LUCRECIA","KOURTNEY","KATI","JESUS","JESENIA","DIAMOND","CRISTA","AYANA","ALICA","ALIA","VINNIE","SUELLEN","ROMELIA","RACHELL","PIPER","OLYMPIA","MICHIKO","KATHALEEN","JOLIE","JESSI","JANESSA","HANA","HA","ELEASE","CARLETTA","BRITANY","SHONA","SALOME","ROSAMOND","REGENA","RAINA","NGOC","NELIA","LOUVENIA","LESIA","LATRINA","LATICIA","LARHONDA","JINA","JACKI","HOLLIS","HOLLEY","EMMY","DEEANN","CORETTA","ARNETTA","VELVET","THALIA","SHANICE","NETA","MIKKI","MICKI","LONNA","LEANA","LASHUNDA","KILEY","JOYE","JACQULYN","IGNACIA","HYUN","HIROKO","HENRY","HENRIETTE","ELAYNE","DELINDA","DARNELL","DAHLIA","COREEN","CONSUELA","CONCHITA","CELINE","BABETTE","AYANNA","ANETTE","ALBERTINA","SKYE","SHAWNEE","SHANEKA","QUIANA","PAMELIA","MIN","MERRI","MERLENE","MARGIT","KIESHA","KIERA","KAYLENE","JODEE","JENISE","ERLENE","EMMIE","ELSE","DARYL","DALILA","DAISEY","CODY","CASIE","BELIA","BABARA","VERSIE","VANESA","SHELBA","SHAWNDA","SAM","NORMAN","NIKIA","NAOMA","MARNA","MARGERET","MADALINE","LAWANA","KINDRA","JUTTA","JAZMINE","JANETT","HANNELORE","GLENDORA","GERTRUD","GARNETT","FREEDA","FREDERICA","FLORANCE","FLAVIA","DENNIS","CARLINE","BEVERLEE","ANJANETTE","VALDA","TRINITY","TAMALA","STEVIE","SHONNA","SHA","SARINA","ONEIDA","MICAH","MERILYN","MARLEEN","LURLINE","LENNA","KATHERIN","JIN","JENI","HAE","GRACIA","GLADY","FARAH","ERIC","ENOLA","EMA","DOMINQUE","DEVONA","DELANA","CECILA","CAPRICE","ALYSHA","ALI","ALETHIA","VENA","THERESIA","TAWNY","SONG","SHAKIRA","SAMARA","SACHIKO","RACHELE","PAMELLA","NICKY","MARNI","MARIEL","MAREN","MALISA","LIGIA","LERA","LATORIA","LARAE","KIMBER","KATHERN","KAREY","JENNEFER","JANETH","HALINA","FREDIA","DELISA","DEBROAH","CIERA","CHIN","ANGELIKA","ANDREE","ALTHA","YEN","VIVAN","TERRESA","TANNA","SUK","SUDIE","SOO","SIGNE","SALENA","RONNI","REBBECCA","MYRTIE","MCKENZIE","MALIKA","MAIDA","LOAN","LEONARDA","KAYLEIGH","FRANCE","ETHYL","ELLYN","DAYLE","CAMMIE","BRITTNI","BIRGIT","AVELINA","ASUNCION","ARIANNA","AKIKO","VENICE","TYESHA","TONIE","TIESHA","TAKISHA","STEFFANIE","SINDY","SANTANA","MEGHANN","MANDA","MACIE","LADY","KELLYE","KELLEE","JOSLYN","JASON","INGER","INDIRA","GLINDA","GLENNIS","FERNANDA","FAUSTINA","ENEIDA","ELICIA","DOT","DIGNA","DELL","ARLETTA","ANDRE","WILLIA","TAMMARA","TABETHA","SHERRELL","SARI","REFUGIO","REBBECA","PAULETTA","NIEVES","NATOSHA","NAKITA","MAMMIE","KENISHA","KAZUKO","KASSIE","GARY","EARLEAN","DAPHINE","CORLISS","CLOTILDE","CAROLYNE","BERNETTA","AUGUSTINA","AUDREA","ANNIS","ANNABELL","YAN","TENNILLE","TAMICA","SELENE","SEAN","ROSANA","REGENIA","QIANA","MARKITA","MACY","LEEANNE","LAURINE","KYM","JESSENIA","JANITA","GEORGINE","GENIE","EMIKO","ELVIE","DEANDRA","DAGMAR","CORIE","COLLEN","CHERISH","ROMAINE","PORSHA","PEARLENE","MICHELINE","MERNA","MARGORIE","MARGARETTA","LORE","KENNETH","JENINE","HERMINA","FREDERICKA","ELKE","DRUSILLA","DORATHY","DIONE","DESIRE","CELENA","BRIGIDA","ANGELES","ALLEGRA","THEO","TAMEKIA","SYNTHIA","STEPHEN","SOOK","SLYVIA","ROSANN","REATHA","RAYE","MARQUETTA","MARGART","LING","LAYLA","KYMBERLY","KIANA","KAYLEEN","KATLYN","KARMEN","JOELLA","IRINA","EMELDA","ELENI","DETRA","CLEMMIE","CHERYLL","CHANTELL","CATHEY","ARNITA","ARLA","ANGLE","ANGELIC","ALYSE","ZOFIA","THOMASINE","TENNIE","SON","SHERLY","SHERLEY","SHARYL","REMEDIOS","PETRINA","NICKOLE","MYUNG","MYRLE","MOZELLA","LOUANNE","LISHA","LATIA","LANE","KRYSTA","JULIENNE","JOEL","JEANENE","JACQUALINE","ISAURA","GWENDA","EARLEEN","DONALD","CLEOPATRA","CARLIE","AUDIE","ANTONIETTA","ALISE","ALEX","VERDELL","VAL","TYLER","TOMOKO","THAO","TALISHA","STEVEN","SO","SHEMIKA","SHAUN","SCARLET","SAVANNA","SANTINA","ROSIA","RAEANN","ODILIA","NANA","MINNA","MAGAN","LYNELLE","LE","KARMA","JOEANN","IVANA","INELL","ILANA","HYE","HONEY","HEE","GUDRUN","FRANK","DREAMA","CRISSY","CHANTE","CARMELINA","ARVILLA","ARTHUR","ANNAMAE","ALVERA","ALEIDA","AARON","YEE","YANIRA","VANDA","TIANNA","TAM","STEFANIA","SHIRA","PERRY","NICOL","NANCIE","MONSERRATE","MINH","MELYNDA","MELANY","MATTHEW","LOVELLA","LAURE","KIRBY","KACY","JACQUELYNN","HYON","GERTHA","FRANCISCO","ELIANA","CHRISTENA","CHRISTEEN","CHARISE","CATERINA","CARLEY","CANDYCE","ARLENA","AMMIE","YANG","WILLETTE","VANITA","TUYET","TINY","SYREETA","SILVA","SCOTT","RONALD","PENNEY","NYLA","MICHAL","MAURICE","MARYAM","MARYA","MAGEN","LUDIE","LOMA","LIVIA","LANELL","KIMBERLIE","JULEE","DONETTA","DIEDRA","DENISHA","DEANE","DAWNE","CLARINE","CHERRYL","BRONWYN","BRANDON","ALLA","VALERY","TONDA","SUEANN","SORAYA","SHOSHANA","SHELA","SHARLEEN","SHANELLE","NERISSA","MICHEAL","MERIDITH","MELLIE","MAYE","MAPLE","MAGARET","LUIS","LILI","LEONILA","LEONIE","LEEANNA","LAVONIA","LAVERA","KRISTEL","KATHEY","KATHE","JUSTIN","JULIAN","JIMMY","JANN","ILDA","HILDRED","HILDEGARDE","GENIA","FUMIKO","EVELIN","ERMELINDA","ELLY","DUNG","DOLORIS","DIONNA","DANAE","BERNEICE","ANNICE","ALIX","VERENA","VERDIE","TRISTAN","SHAWNNA","SHAWANA","SHAUNNA","ROZELLA","RANDEE","RANAE","MILAGRO","LYNELL","LUISE","LOUIE","LOIDA","LISBETH","KARLEEN","JUNITA","JONA","ISIS","HYACINTH","HEDY","GWENN","ETHELENE","ERLINE","EDWARD","DONYA","DOMONIQUE","DELICIA","DANNETTE","CICELY","BRANDA","BLYTHE","BETHANN","ASHLYN","ANNALEE","ALLINE","YUKO","VELLA","TRANG","TOWANDA","TESHA","SHERLYN","NARCISA","MIGUELINA","MERI","MAYBELL","MARLANA","MARGUERITA","MADLYN","LUNA","LORY","LORIANN","LIBERTY","LEONORE","LEIGHANN","LAURICE","LATESHA","LARONDA","KATRICE","KASIE","KARL","KALEY","JADWIGA","GLENNIE","GEARLDINE","FRANCINA","EPIFANIA","DYAN","DORIE","DIEDRE","DENESE","DEMETRICE","DELENA","DARBY","CRISTIE","CLEORA","CATARINA","CARISA","BERNIE","BARBERA","ALMETA","TRULA","TEREASA","SOLANGE","SHEILAH","SHAVONNE","SANORA","ROCHELL","MATHILDE","MARGARETA","MAIA","LYNSEY","LAWANNA","LAUNA","KENA","KEENA","KATIA","JAMEY","GLYNDA","GAYLENE","ELVINA","ELANOR","DANUTA","DANIKA","CRISTEN","CORDIE","COLETTA","CLARITA","CARMON","BRYNN","AZUCENA","AUNDREA","ANGELE","YI","WALTER","VERLIE","VERLENE","TAMESHA","SILVANA","SEBRINA","SAMIRA","REDA","RAYLENE","PENNI","PANDORA","NORAH","NOMA","MIREILLE","MELISSIA","MARYALICE","LARAINE","KIMBERY","KARYL","KARINE","KAM","JOLANDA","JOHANA","JESUSA","JALEESA","JAE","JACQUELYNE","IRISH","ILUMINADA","HILARIA","HANH","GENNIE","FRANCIE","FLORETTA","EXIE","EDDA","DREMA","DELPHA","BEV","BARBAR","ASSUNTA","ARDELL","ANNALISA","ALISIA","YUKIKO","YOLANDO","WONDA","WEI","WALTRAUD","VETA","TEQUILA","TEMEKA","TAMEIKA","SHIRLEEN","SHENITA","PIEDAD","OZELLA","MIRTHA","MARILU","KIMIKO","JULIANE","JENICE","JEN","JANAY","JACQUILINE","HILDE","FE","FAE","EVAN","EUGENE","ELOIS","ECHO","DEVORAH","CHAU","BRINDA","BETSEY","ARMINDA","ARACELIS","APRYL","ANNETT","ALISHIA","VEOLA","USHA","TOSHIKO","THEOLA","TASHIA","TALITHA","SHERY","RUDY","RENETTA","REIKO","RASHEEDA","OMEGA","OBDULIA","MIKA","MELAINE","MEGGAN","MARTIN","MARLEN","MARGET","MARCELINE","MANA","MAGDALEN","LIBRADA","LEZLIE","LEXIE","LATASHIA","LASANDRA","KELLE","ISIDRA","ISA","INOCENCIA","GWYN","FRANCOISE","ERMINIA","ERINN","DIMPLE","DEVORA","CRISELDA","ARMANDA","ARIE","ARIANE","ANGELO","ANGELENA","ALLEN","ALIZA","ADRIENE","ADALINE","XOCHITL","TWANNA","TRAN","TOMIKO","TAMISHA","TAISHA","SUSY","SIU","RUTHA","ROXY","RHONA","RAYMOND","OTHA","NORIKO","NATASHIA","MERRIE","MELVIN","MARINDA","MARIKO","MARGERT","LORIS","LIZZETTE","LEISHA","KAILA","KA","JOANNIE","JERRICA","JENE","JANNET","JANEE","JACINDA","HERTA","ELENORE","DORETTA","DELAINE","DANIELL","CLAUDIE","CHINA","BRITTA","APOLONIA","AMBERLY","ALEASE","YURI","YUK","WEN","WANETA","UTE","TOMI","SHARRI","SANDIE","ROSELLE","REYNALDA","RAGUEL","PHYLICIA","PATRIA","OLIMPIA","ODELIA","MITZIE","MITCHELL","MISS","MINDA","MIGNON","MICA","MENDY","MARIVEL","MAILE","LYNETTA","LAVETTE","LAURYN","LATRISHA","LAKIESHA","KIERSTEN","KARY","JOSPHINE","JOLYN","JETTA","JANISE","JACQUIE","IVELISSE","GLYNIS","GIANNA","GAYNELLE","EMERALD","DEMETRIUS","DANYELL","DANILLE","DACIA","CORALEE","CHER","CEOLA","BRETT","BELL","ARIANNE","ALESHIA","YUNG","WILLIEMAE","TROY","TRINH","THORA","TAI","SVETLANA","SHERIKA","SHEMEKA","SHAUNDA","ROSELINE","RICKI","MELDA","MALLIE","LAVONNA","LATINA","LARRY","LAQUANDA","LALA","LACHELLE","KLARA","KANDIS","JOHNA","JEANMARIE","JAYE","HANG","GRAYCE","GERTUDE","EMERITA","EBONIE","CLORINDA","CHING","CHERY","CAROLA","BREANN","BLOSSOM","BERNARDINE","BECKI","ARLETHA","ARGELIA","ARA","ALITA","YULANDA","YON","YESSENIA","TOBI","TASIA","SYLVIE","SHIRL","SHIRELY","SHERIDAN","SHELLA","SHANTELLE","SACHA","ROYCE","REBECKA","REAGAN","PROVIDENCIA","PAULENE","MISHA","MIKI","MARLINE","MARICA","LORITA","LATOYIA","LASONYA","KERSTIN","KENDA","KEITHA","KATHRIN","JAYMIE","JACK","GRICELDA","GINETTE","ERYN","ELINA","ELFRIEDA","DANYEL","CHEREE","CHANELLE","BARRIE","AVERY","AURORE","ANNAMARIA","ALLEEN","AILENE","AIDE","YASMINE","VASHTI","VALENTINE","TREASA","TORY","TIFFANEY","SHERYLL","SHARIE","SHANAE","SAU","RAISA","PA","NEDA","MITSUKO","MIRELLA","MILDA","MARYANNA","MARAGRET","MABELLE","LUETTA","LORINA","LETISHA","LATARSHA","LANELLE","LAJUANA","KRISSY","KARLY","KARENA","JON","JESSIKA","JERICA","JEANELLE","JANUARY","JALISA","JACELYN","IZOLA","IVEY","GREGORY","EUNA","ETHA","DREW","DOMITILA","DOMINICA","DAINA","CREOLA","CARLI","CAMIE","BUNNY","BRITTNY","ASHANTI","ANISHA","ALEEN","ADAH","YASUKO","WINTER","VIKI","VALRIE","TONA","TINISHA","THI","TERISA","TATUM","TANEKA","SIMONNE","SHALANDA","SERITA","RESSIE","REFUGIA","PAZ","OLENE","NA","MERRILL","MARGHERITA","MANDIE","MAN","MAIRE","LYNDIA","LUCI","LORRIANE","LORETA","LEONIA","LAVONA","LASHAWNDA","LAKIA","KYOKO","KRYSTINA","KRYSTEN","KENIA","KELSI","JUDE","JEANICE","ISOBEL","GEORGIANN","GENNY","FELICIDAD","EILENE","DEON","DELOISE","DEEDEE","DANNIE","CONCEPTION","CLORA","CHERILYN","CHANG","CALANDRA","BERRY","ARMANDINA","ANISA","ULA","TIMOTHY","TIERA","THERESSA","STEPHANIA","SIMA","SHYLA","SHONTA","SHERA","SHAQUITA","SHALA","SAMMY","ROSSANA","NOHEMI","NERY","MORIAH","MELITA","MELIDA","MELANI","MARYLYNN","MARISHA","MARIETTE","MALORIE","MADELENE","LUDIVINA","LORIA","LORETTE","LORALEE","LIANNE","LEON","LAVENIA","LAURINDA","LASHON","KIT","KIMI","KEILA","KATELYNN","KAI","JONE","JOANE","JI","JAYNA","JANELLA","JA","HUE","HERTHA","FRANCENE","ELINORE","DESPINA","DELSIE","DEEDRA","CLEMENCIA","CARRY","CAROLIN","CARLOS","BULAH","BRITTANIE","BOK","BLONDELL","BIBI","BEAULAH","BEATA","ANNITA","AGRIPINA","VIRGEN","VALENE","UN","TWANDA","TOMMYE","TOI","TARRA","TARI","TAMMERA","SHAKIA","SADYE","RUTHANNE","ROCHEL","RIVKA","PURA","NENITA","NATISHA","MING","MERRILEE","MELODEE","MARVIS","LUCILLA","LEENA","LAVETA","LARITA","LANIE","KEREN","ILEEN","GEORGEANN","GENNA","GENESIS","FRIDA","EWA","EUFEMIA","EMELY","ELA","EDYTH","DEONNA","DEADRA","DARLENA","CHANELL","CHAN","CATHERN","CASSONDRA","CASSAUNDRA","BERNARDA","BERNA","ARLINDA","ANAMARIA","ALBERT","WESLEY","VERTIE","VALERI","TORRI","TATYANA","STASIA","SHERISE","SHERILL","SEASON","SCOTTIE","SANDA","RUTHE","ROSY","ROBERTO","ROBBI","RANEE","QUYEN","PEARLY","PALMIRA","ONITA","NISHA","NIESHA","NIDA","NEVADA","NAM","MERLYN","MAYOLA","MARYLOUISE","MARYLAND","MARX","MARTH","MARGENE","MADELAINE","LONDA","LEONTINE","LEOMA","LEIA","LAWRENCE","LAURALEE","LANORA","LAKITA","KIYOKO","KETURAH","KATELIN","KAREEN","JONIE","JOHNETTE","JENEE","JEANETT","IZETTA","HIEDI","HEIKE","HASSIE","HAROLD","GIUSEPPINA","GEORGANN","FIDELA","FERNANDE","ELWANDA","ELLAMAE","ELIZ","DUSTI","DOTTY","CYNDY","CORALIE","CELESTA","ARGENTINA","ALVERTA","XENIA","WAVA","VANETTA","TORRIE","TASHINA","TANDY","TAMBRA","TAMA","STEPANIE","SHILA","SHAUNTA","SHARAN","SHANIQUA","SHAE","SETSUKO","SERAFINA","SANDEE","ROSAMARIA","PRISCILA","OLINDA","NADENE","MUOI","MICHELINA","MERCEDEZ","MARYROSE","MARIN","MARCENE","MAO","MAGALI","MAFALDA","LOGAN","LINN","LANNIE","KAYCE","KAROLINE","KAMILAH","KAMALA","JUSTA","JOLINE","JENNINE","JACQUETTA","IRAIDA","GERALD","GEORGEANNA","FRANCHESCA","FAIRY","EMELINE","ELANE","EHTEL","EARLIE","DULCIE","DALENE","CRIS","CLASSIE","CHERE","CHARIS","CAROYLN","CARMINA","CARITA","BRIAN","BETHANIE","AYAKO","ARICA","AN","ALYSA","ALESSANDRA","AKILAH","ADRIEN","ZETTA","YOULANDA","YELENA","YAHAIRA","XUAN","WENDOLYN","VICTOR","TIJUANA","TERRELL","TERINA","TERESIA","SUZI","SUNDAY","SHERELL","SHAVONDA","SHAUNTE","SHARDA","SHAKITA","SENA","RYANN","RUBI","RIVA","REGINIA","REA","RACHAL","PARTHENIA","PAMULA","MONNIE","MONET","MICHAELE","MELIA","MARINE","MALKA","MAISHA","LISANDRA","LEO","LEKISHA","LEAN","LAURENCE","LAKENDRA","KRYSTIN","KORTNEY","KIZZIE","KITTIE","KERA","KENDAL","KEMBERLY","KANISHA","JULENE","JULE","JOSHUA","JOHANNE","JEFFREY","JAMEE","HAN","HALLEY","GIDGET","GALINA","FREDRICKA","FLETA","FATIMAH","EUSEBIA","ELZA","ELEONORE","DORTHEY","DORIA","DONELLA","DINORAH","DELORSE","CLARETHA","CHRISTINIA","CHARLYN","BONG","BELKIS","AZZIE","ANDERA","AIKO","ADENA","YER","YAJAIRA","WAN","VANIA","ULRIKE","TOSHIA","TIFANY","STEFANY","SHIZUE","SHENIKA","SHAWANNA","SHAROLYN","SHARILYN","SHAQUANA","SHANTAY","SEE","ROZANNE","ROSELEE","RICKIE","REMONA","REANNA","RAELENE","QUINN","PHUNG","PETRONILA","NATACHA","NANCEY","MYRL","MIYOKO","MIESHA","MERIDETH","MARVELLA","MARQUITTA","MARHTA","MARCHELLE","LIZETH","LIBBIE","LAHOMA","LADAWN","KINA","KATHELEEN","KATHARYN","KARISA","KALEIGH","JUNIE","JULIEANN","JOHNSIE","JANEAN","JAIMEE","JACKQUELINE","HISAKO","HERMA","HELAINE","GWYNETH","GLENN","GITA","EUSTOLIA","EMELINA","ELIN","EDRIS","DONNETTE","DONNETTA","DIERDRE","DENAE","DARCEL","CLAUDE","CLARISA","CINDERELLA","CHIA","CHARLESETTA","CHARITA","CELSA","CASSY","CASSI","CARLEE","BRUNA","BRITTANEY","BRANDE","BILLI","BAO","ANTONETTA","ANGLA","ANGELYN","ANALISA","ALANE","WENONA","WENDIE","VERONIQUE","VANNESA","TOBIE","TEMPIE","SUMIKO","SULEMA","SPARKLE","SOMER","SHEBA","SHAYNE","SHARICE","SHANEL","SHALON","SAGE","ROY","ROSIO","ROSELIA","RENAY","REMA","REENA","PORSCHE","PING","PEG","OZIE","ORETHA","ORALEE","ODA","NU","NGAN","NAKESHA","MILLY","MARYBELLE","MARLIN","MARIS","MARGRETT","MARAGARET","MANIE","LURLENE","LILLIA","LIESELOTTE","LAVELLE","LASHAUNDA","LAKEESHA","KEITH","KAYCEE","KALYN","JOYA","JOETTE","JENAE","JANIECE","ILLA","GRISEL","GLAYDS","GENEVIE","GALA","FREDDA","FRED","ELMER","ELEONOR","DEBERA","DEANDREA","DAN","CORRINNE","CORDIA","CONTESSA","COLENE","CLEOTILDE","CHARLOTT","CHANTAY","CECILLE","BEATRIS","AZALEE","ARLEAN","ARDATH","ANJELICA","ANJA","ALFREDIA","ALEISHA","ADAM","ZADA","YUONNE","XIAO","WILLODEAN","WHITLEY","VENNIE","VANNA","TYISHA","TOVA","TORIE","TONISHA","TILDA","TIEN","TEMPLE","SIRENA","SHERRIL","SHANTI","SHAN","SENAIDA","SAMELLA","ROBBYN","RENDA","REITA","PHEBE","PAULITA","NOBUKO","NGUYET","NEOMI","MOON","MIKAELA","MELANIA","MAXIMINA","MARG","MAISIE","LYNNA","LILLI","LAYNE","LASHAUN","LAKENYA","LAEL","KIRSTIE","KATHLINE","KASHA","KARLYN","KARIMA","JOVAN","JOSEFINE","JENNELL","JACQUI","JACKELYN","HYO","HIEN","GRAZYNA","FLORRIE","FLORIA","ELEONORA","DWANA","DORLA","DONG","DELMY","DEJA","DEDE","DANN","CRYSTA","CLELIA","CLARIS","CLARENCE","CHIEKO","CHERLYN","CHERELLE","CHARMAIN","CHARA","CAMMY","BEE","ARNETTE","ARDELLE","ANNIKA","AMIEE","AMEE","ALLENA","YVONE","YUKI","YOSHIE","YEVETTE","YAEL","WILLETTA","VONCILE","VENETTA","TULA","TONETTE","TIMIKA","TEMIKA","TELMA","TEISHA","TAREN","TA","STACEE","SHIN","SHAWNTA","SATURNINA","RICARDA","POK","PASTY","ONIE","NUBIA","MORA","MIKE","MARIELLE","MARIELLA","MARIANELA","MARDELL","MANY","LUANNA","LOISE","LISABETH","LINDSY","LILLIANA","LILLIAM","LELAH","LEIGHA","LEANORA","LANG","KRISTEEN","KHALILAH","KEELEY","KANDRA","JUNKO","JOAQUINA","JERLENE","JANI","JAMIKA","JAME","HSIU","HERMILA","GOLDEN","GENEVIVE","EVIA","EUGENA","EMMALINE","ELFREDA","ELENE","DONETTE","DELCIE","DEEANNA","DARCEY","CUC","CLARINDA","CIRA","CHAE","CELINDA","CATHERYN","CATHERIN","CASIMIRA","CARMELIA","CAMELLIA","BREANA","BOBETTE","BERNARDINA","BEBE","BASILIA","ARLYNE","AMAL","ALAYNA","ZONIA","ZENIA","YURIKO","YAEKO","WYNELL","WILLOW","WILLENA","VERNIA","TU","TRAVIS","TORA","TERRILYN","TERICA","TENESHA","TAWNA","TAJUANA","TAINA","STEPHNIE","SONA","SOL","SINA","SHONDRA","SHIZUKO","SHERLENE","SHERICE","SHARIKA","ROSSIE","ROSENA","RORY","RIMA","RIA","RHEBA","RENNA","PETER","NATALYA","NANCEE","MELODI","MEDA","MAXIMA","MATHA","MARKETTA","MARICRUZ","MARCELENE","MALVINA","LUBA","LOUETTA","LEIDA","LECIA","LAURAN","LASHAWNA","LAINE","KHADIJAH","KATERINE","KASI","KALLIE","JULIETTA","JESUSITA","JESTINE","JESSIA","JEREMY","JEFFIE","JANYCE","ISADORA","GEORGIANNE","FIDELIA","EVITA","EURA","EULAH","ESTEFANA","ELSY","ELIZABET","ELADIA","DODIE","DION","DIA","DENISSE","DELORAS","DELILA","DAYSI","DAKOTA","CURTIS","CRYSTLE","CONCHA","COLBY","CLARETTA","CHU","CHRISTIA","CHARLSIE","CHARLENA","CARYLON","BETTYANN","ASLEY","ASHLEA","AMIRA","AI","AGUEDA","AGNUS","YUETTE","VINITA","VICTORINA","TYNISHA","TREENA","TOCCARA","TISH","THOMASENA","TEGAN","SOILA","SHILOH","SHENNA","SHARMAINE","SHANTAE","SHANDI","SEPTEMBER","SARAN","SARAI","SANA","SAMUEL","SALLEY","ROSETTE","ROLANDE","REGINE","OTELIA","OSCAR","OLEVIA","NICHOLLE","NECOLE","NAIDA","MYRTA","MYESHA","MITSUE","MINTA","MERTIE","MARGY","MAHALIA","MADALENE","LOVE","LOURA","LOREAN","LEWIS","LESHA","LEONIDA","LENITA","LAVONE","LASHELL","LASHANDRA","LAMONICA","KIMBRA","KATHERINA","KARRY","KANESHA","JULIO","JONG","JENEVA","JAQUELYN","HWA","GILMA","GHISLAINE","GERTRUDIS","FRANSISCA","FERMINA","ETTIE","ETSUKO","ELLIS","ELLAN","ELIDIA","EDRA","DORETHEA","DOREATHA","DENYSE","DENNY","DEETTA","DAINE","CYRSTAL","CORRIN","CAYLA","CARLITA","CAMILA","BURMA","BULA","BUENA","BLAKE","BARABARA","AVRIL","AUSTIN","ALAINE","ZANA","WILHEMINA","WANETTA","VIRGIL","VI","VERONIKA","VERNON","VERLINE","VASILIKI","TONITA","TISA","TEOFILA","TAYNA","TAUNYA","TANDRA","TAKAKO","SUNNI","SUANNE","SIXTA","SHARELL","SEEMA","RUSSELL","ROSENDA","ROBENA","RAYMONDE","PEI","PAMILA","OZELL","NEIDA","NEELY","MISTIE","MICHA","MERISSA","MAURITA","MARYLN","MARYETTA","MARSHALL","MARCELL","MALENA","MAKEDA","MADDIE","LOVETTA","LOURIE","LORRINE","LORILEE","LESTER","LAURENA","LASHAY","LARRAINE","LAREE","LACRESHA","KRISTLE","KRISHNA","KEVA","KEIRA","KAROLE","JOIE","JINNY","JEANNETTA","JAMA","HEIDY","GILBERTE","GEMA","FAVIOLA","EVELYNN","ENDA","ELLI","ELLENA","DIVINA","DAGNY","COLLENE","CODI","CINDIE","CHASSIDY","CHASIDY","CATRICE","CATHERINA","CASSEY","CAROLL","CARLENA","CANDRA","CALISTA","BRYANNA","BRITTENY","BEULA","BARI","AUDRIE","AUDRIA","ARDELIA","ANNELLE","ANGILA","ALONA","ALLYN","DOUGLAS","ROGER","JONATHAN","RALPH","NICHOLAS","BENJAMIN","BRUCE","HARRY","WAYNE","STEVE","HOWARD","ERNEST","PHILLIP","TODD","CRAIG","ALAN","PHILIP","EARL","DANNY","BRYAN","STANLEY","LEONARD","NATHAN","MANUEL","RODNEY","MARVIN","VINCENT","JEFFERY","JEFF","CHAD","JACOB","ALFRED","BRADLEY","HERBERT","FREDERICK","EDWIN","DON","RICKY","RANDALL","BARRY","BERNARD","LEROY","MARCUS","THEODORE","CLIFFORD","MIGUEL","JIM","TOM","CALVIN","BILL","LLOYD","DEREK","WARREN","DARRELL","JEROME","FLOYD","ALVIN","TIM","GORDON","GREG","JORGE","DUSTIN","PEDRO","DERRICK","ZACHARY","HERMAN","GLEN","HECTOR","RICARDO","RICK","BRENT","RAMON","GILBERT","MARC","REGINALD","RUBEN","NATHANIEL","RAFAEL","EDGAR","MILTON","RAUL","BEN","CHESTER","DUANE","FRANKLIN","BRAD","RON","ROLAND","ARNOLD","HARVEY","JARED","ERIK","DARRYL","NEIL","JAVIER","FERNANDO","CLINTON","TED","MATHEW","TYRONE","DARREN","LANCE","KURT","ALLAN","NELSON","GUY","CLAYTON","HUGH","MAX","DWAYNE","DWIGHT","ARMANDO","FELIX","EVERETT","IAN","WALLACE","KEN","BOB","ALFREDO","ALBERTO","DAVE","IVAN","BYRON","ISAAC","MORRIS","CLIFTON","WILLARD","ROSS","ANDY","SALVADOR","KIRK","SERGIO","SETH","KENT","TERRANCE","EDUARDO","TERRENCE","ENRIQUE","WADE","STUART","FREDRICK","ARTURO","ALEJANDRO","NICK","LUTHER","WENDELL","JEREMIAH","JULIUS","OTIS","TREVOR","OLIVER","LUKE","HOMER","GERARD","DOUG","KENNY","HUBERT","LYLE","MATT","ALFONSO","ORLANDO","REX","CARLTON","ERNESTO","NEAL","PABLO","LORENZO","OMAR","WILBUR","GRANT","HORACE","RODERICK","ABRAHAM","WILLIS","RICKEY","ANDRES","CESAR","JOHNATHAN","MALCOLM","RUDOLPH","DAMON","KELVIN","PRESTON","ALTON","ARCHIE","MARCO","WM","PETE","RANDOLPH","GARRY","GEOFFREY","JONATHON","FELIPE","GERARDO","ED","DOMINIC","DELBERT","COLIN","GUILLERMO","EARNEST","LUCAS","BENNY","SPENCER","RODOLFO","MYRON","EDMUND","GARRETT","SALVATORE","CEDRIC","LOWELL","GREGG","SHERMAN","WILSON","SYLVESTER","ROOSEVELT","ISRAEL","JERMAINE","FORREST","WILBERT","LELAND","SIMON","CLARK","IRVING","BRYANT","OWEN","RUFUS","WOODROW","KRISTOPHER","MACK","LEVI","MARCOS","GUSTAVO","JAKE","LIONEL","GILBERTO","CLINT","NICOLAS","ISMAEL","ORVILLE","ERVIN","DEWEY","AL","WILFRED","JOSH","HUGO","IGNACIO","CALEB","TOMAS","SHELDON","ERICK","STEWART","DOYLE","DARREL","ROGELIO","TERENCE","SANTIAGO","ALONZO","ELIAS","BERT","ELBERT","RAMIRO","CONRAD","NOAH","GRADY","PHIL","CORNELIUS","LAMAR","ROLANDO","CLAY","PERCY","DEXTER","BRADFORD","DARIN","AMOS","MOSES","IRVIN","SAUL","ROMAN","RANDAL","TIMMY","DARRIN","WINSTON","BRENDAN","ABEL","DOMINICK","BOYD","EMILIO","ELIJAH","DOMINGO","EMMETT","MARLON","EMANUEL","JERALD","EDMOND","EMIL","DEWAYNE","WILL","OTTO","TEDDY","REYNALDO","BRET","JESS","TRENT","HUMBERTO","EMMANUEL","STEPHAN","VICENTE","LAMONT","GARLAND","MILES","EFRAIN","HEATH","RODGER","HARLEY","ETHAN","ELDON","ROCKY","PIERRE","JUNIOR","FREDDY","ELI","BRYCE","ANTOINE","STERLING","CHASE","GROVER","ELTON","CLEVELAND","DYLAN","CHUCK","DAMIAN","REUBEN","STAN","AUGUST","LEONARDO","JASPER","RUSSEL","ERWIN","BENITO","HANS","MONTE","BLAINE","ERNIE","CURT","QUENTIN","AGUSTIN","MURRAY","JAMAL","ADOLFO","HARRISON","TYSON","BURTON","BRADY","ELLIOTT","WILFREDO","BART","JARROD","VANCE","DENIS","DAMIEN","JOAQUIN","HARLAN","DESMOND","ELLIOT","DARWIN","GREGORIO","BUDDY","XAVIER","KERMIT","ROSCOE","ESTEBAN","ANTON","SOLOMON","SCOTTY","NORBERT","ELVIN","WILLIAMS","NOLAN","ROD","QUINTON","HAL","BRAIN","ROB","ELWOOD","KENDRICK","DARIUS","MOISES","FIDEL","THADDEUS","CLIFF","MARCEL","JACKSON","RAPHAEL","BRYON","ARMAND","ALVARO","JEFFRY","DANE","JOESPH","THURMAN","NED","RUSTY","MONTY","FABIAN","REGGIE","MASON","GRAHAM","ISAIAH","VAUGHN","GUS","LOYD","DIEGO","ADOLPH","NORRIS","MILLARD","ROCCO","GONZALO","DERICK","RODRIGO","WILEY","RIGOBERTO","ALPHONSO","TY","NOE","VERN","REED","JEFFERSON","ELVIS","BERNARDO","MAURICIO","HIRAM","DONOVAN","BASIL","RILEY","NICKOLAS","MAYNARD","SCOT","VINCE","QUINCY","EDDY","SEBASTIAN","FEDERICO","ULYSSES","HERIBERTO","DONNELL","COLE","DAVIS","GAVIN","EMERY","WARD","ROMEO","JAYSON","DANTE","CLEMENT","COY","MAXWELL","JARVIS","BRUNO","ISSAC","DUDLEY","BROCK","SANFORD","CARMELO","BARNEY","NESTOR","STEFAN","DONNY","ART","LINWOOD","BEAU","WELDON","GALEN","ISIDRO","TRUMAN","DELMAR","JOHNATHON","SILAS","FREDERIC","DICK","IRWIN","MERLIN","CHARLEY","MARCELINO","HARRIS","CARLO","TRENTON","KURTIS","HUNTER","AURELIO","WINFRED","VITO","COLLIN","DENVER","CARTER","LEONEL","EMORY","PASQUALE","MOHAMMAD","MARIANO","DANIAL","LANDON","DIRK","BRANDEN","ADAN","BUFORD","GERMAN","WILMER","EMERSON","ZACHERY","FLETCHER","JACQUES","ERROL","DALTON","MONROE","JOSUE","EDWARDO","BOOKER","WILFORD","SONNY","SHELTON","CARSON","THERON","RAYMUNDO","DAREN","HOUSTON","ROBBY","LINCOLN","GENARO","BENNETT","OCTAVIO","CORNELL","HUNG","ARRON","ANTONY","HERSCHEL","GIOVANNI","GARTH","CYRUS","CYRIL","RONNY","LON","FREEMAN","DUNCAN","KENNITH","CARMINE","ERICH","CHADWICK","WILBURN","RUSS","REID","MYLES","ANDERSON","MORTON","JONAS","FOREST","MITCHEL","MERVIN","ZANE","RICH","JAMEL","LAZARO","ALPHONSE","RANDELL","MAJOR","JARRETT","BROOKS","ABDUL","LUCIANO","SEYMOUR","EUGENIO","MOHAMMED","VALENTIN","CHANCE","ARNULFO","LUCIEN","FERDINAND","THAD","EZRA","ALDO","RUBIN","ROYAL","MITCH","EARLE","ABE","WYATT","MARQUIS","LANNY","KAREEM","JAMAR","BORIS","ISIAH","EMILE","ELMO","ARON","LEOPOLDO","EVERETTE","JOSEF","ELOY","RODRICK","REINALDO","LUCIO","JERROD","WESTON","HERSHEL","BARTON","PARKER","LEMUEL","BURT","JULES","GIL","ELISEO","AHMAD","NIGEL","EFREN","ANTWAN","ALDEN","MARGARITO","COLEMAN","DINO","OSVALDO","LES","DEANDRE","NORMAND","KIETH","TREY","NORBERTO","NAPOLEON","JEROLD","FRITZ","ROSENDO","MILFORD","CHRISTOPER","ALFONZO","LYMAN","JOSIAH","BRANT","WILTON","RICO","JAMAAL","DEWITT","BRENTON","OLIN","FOSTER","FAUSTINO","CLAUDIO","JUDSON","GINO","EDGARDO","ALEC","TANNER","JARRED","DONN","TAD","PRINCE","PORFIRIO","ODIS","LENARD","CHAUNCEY","TOD","MEL","MARCELO","KORY","AUGUSTUS","KEVEN","HILARIO","BUD","SAL","ORVAL","MAURO","ZACHARIAH","OLEN","ANIBAL","MILO","JED","DILLON","AMADO","NEWTON","LENNY","RICHIE","HORACIO","BRICE","MOHAMED","DELMER","DARIO","REYES","MAC","JONAH","JERROLD","ROBT","HANK","RUPERT","ROLLAND","KENTON","DAMION","ANTONE","WALDO","FREDRIC","BRADLY","KIP","BURL","WALKER","TYREE","JEFFEREY","AHMED","WILLY","STANFORD","OREN","NOBLE","MOSHE","MIKEL","ENOCH","BRENDON","QUINTIN","JAMISON","FLORENCIO","DARRICK","TOBIAS","HASSAN","GIUSEPPE","DEMARCUS","CLETUS","TYRELL","LYNDON","KEENAN","WERNER","GERALDO","COLUMBUS","CHET","BERTRAM","MARKUS","HUEY","HILTON","DWAIN","DONTE","TYRON","OMER","ISAIAS","HIPOLITO","FERMIN","ADALBERTO","BO","BARRETT","TEODORO","MCKINLEY","MAXIMO","GARFIELD","RALEIGH","LAWERENCE","ABRAM","RASHAD","KING","EMMITT","DARON","SAMUAL","MIQUEL","EUSEBIO","DOMENIC","DARRON","BUSTER","WILBER","RENATO","JC","HOYT","HAYWOOD","EZEKIEL","CHAS","FLORENTINO","ELROY","CLEMENTE","ARDEN","NEVILLE","EDISON","DESHAWN","NATHANIAL","JORDON","DANILO","CLAUD","SHERWOOD","RAYMON","RAYFORD","CRISTOBAL","AMBROSE","TITUS","HYMAN","FELTON","EZEQUIEL","ERASMO","STANTON","LONNY","LEN","IKE","MILAN","LINO","JAROD","HERB","ANDREAS","WALTON","RHETT","PALMER","DOUGLASS","CORDELL","OSWALDO","ELLSWORTH","VIRGILIO","TONEY","NATHANAEL","DEL","BENEDICT","MOSE","JOHNSON","ISREAL","GARRET","FAUSTO","ASA","ARLEN","ZACK","WARNER","MODESTO","FRANCESCO","MANUAL","GAYLORD","GASTON","FILIBERTO","DEANGELO","MICHALE","GRANVILLE","WES","MALIK","ZACKARY","TUAN","ELDRIDGE","CRISTOPHER","CORTEZ","ANTIONE","MALCOM","LONG","KOREY","JOSPEH","COLTON","WAYLON","VON","HOSEA","SHAD","SANTO","RUDOLF","ROLF","REY","RENALDO","MARCELLUS","LUCIUS","KRISTOFER","BOYCE","BENTON","HAYDEN","HARLAND","ARNOLDO","RUEBEN","LEANDRO","KRAIG","JERRELL","JEROMY","HOBERT","CEDRICK","ARLIE","WINFORD","WALLY","LUIGI","KENETH","JACINTO","GRAIG","FRANKLYN","EDMUNDO","SID","PORTER","LEIF","JERAMY","BUCK","WILLIAN","VINCENZO","SHON","LYNWOOD","JERE","HAI","ELDEN","DORSEY","DARELL","BRODERICK","ALONSO" ================================================ FILE: Problem023/.hash ================================================ 2c8258c0604152962f7787571511cf28 ================================================ FILE: Problem023/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # """ A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A number n is called deficient if the sum of its proper divisors is less than n and it is called abundant if this sum exceeds n. As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16, the smallest number that can be written as the sum of two abundant numbers is 24. By mathematical analysis, it can be shown that all integers greater than 28123 can be written as the sum of two abundant numbers. However, this upper limit cannot be reduced any further by analysis even though it is known that the greatest number that cannot be expressed as the sum of two abundant numbers is less than this limit. Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers. """ from functools import reduce from itertools import combinations_with_replacement as combinations max_num = 28123 def divisors(num): return set(reduce(list.__add__, [[div, num//div] for div in range(2, int(num**0.5) + 1) if num % div == 0] + [[1]])) def abundant(num): return sum(divisors(num)) > num abundant_nums = (n for n in range(1, max_num) if abundant(n)) sum_of_two_abundants = set(a + b for a, b in combinations(abundant_nums, 2)) not_abundant_nums = (x for x in range(max_num) if x not in sum_of_two_abundants) print(sum(not_abundant_nums)) ================================================ FILE: Problem023/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=23) ================================================ FILE: Problem024/.hash ================================================ 7f155b45cb3f0a6e518d59ec348bff84 ================================================ FILE: Problem024/C++/solution_1.cpp ================================================ #include using namespace std; int main() { char numbers[] = "0123456789"; for(int i=1;i<1000000;i++) { next_permutation(numbers,numbers+10); } cout << numbers << endl; } ================================================ FILE: Problem024/Haskell/solution_1.hs ================================================ import Data.List (permutations, sort) import Data.Char (intToDigit) main :: IO () main = do putStr $ map intToDigit list where list = (sort . permutations $ [0..9]) !! 999999 ================================================ FILE: Problem024/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # """ Lexicographic permutations Problem 24 A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are: 012 021 102 120 201 210 What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9? """ def factorial(n): return 1 if n < 1 else n * factorial(n - 1) # let the entry of element number of the sorted element def problem24(element): from string import digits answer = '' nums = list(digits) while len(nums) != 0: # calculate the periodic of the unitary decimal actual factor_num = factorial(len(nums) - 1) # verify which must be the number of digit actual order = element//factor_num if element % factor_num != 0: order = element//factor_num + 1 # keep only the rest of periodicity, whose we say which number is. order %= len(nums) # insert the value on final of string answer += nums.pop(order - 1) return answer print(problem24(10 ** 6)) ================================================ FILE: Problem024/Python/solution_2.py ================================================ #code created by NamanNimmo Gera #12:42pm, April 10, 2019. from itertools import permutations perm = permutations([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) for count, item in enumerate(perm): #to find the millionth permutation if count == 999999: tup_join = item; str_join = "".join(str(x) for x in tup_join) print(str_join); break; ================================================ FILE: Problem024/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=24) ================================================ FILE: Problem024/Ruby/solution_1.rb ================================================ puts (0..9) .to_a .permutation .sort[999999] .join ================================================ FILE: Problem025/.hash ================================================ a376802c0811f1b9088828288eb0d3f0 ================================================ FILE: Problem025/Clojure/solution_1.clj ================================================ (defn fib-seq ([] (fib-seq (bigint 0) (bigint 1))) ([a b] (lazy-seq (cons b (fib-seq b (+ a b)))))) (defn solution [] (->> (fib-seq) (take-while #(< (count (str %)) 1000)) (count) (+ 1))) (println (solution)) ================================================ FILE: Problem025/Elixir/solution_1.exs ================================================ # Author: lubien Stream.unfold( {1, 1}, fn {a, b} -> next = a + b; case length(Integer.digits(a)) do 1_000 -> nil _ -> {next, {next, a}} end end ) |> Stream.with_index |> Enum.to_list |> List.last |> elem(1) |> (fn x -> x + 3 end).() |> IO.inspect ================================================ FILE: Problem025/Python/solution_1.py ================================================ #How the term of the first 1000-digit number in the fibonacci sequence? #answer: 4782 def fib(max_lenght): a, b = 1, 1 term = 1 while len(str(a)) < max_lenght: term += 1 a, b = b, a + b return term print(fib(1000)) ================================================ FILE: Problem025/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=25) ================================================ FILE: Problem026/.hash ================================================ 6aab1270668d8cac7cef2566a1c5f569 ================================================ FILE: Problem026/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: Problem026/C++/solution_1.cpp ================================================ #include #include #define max(x,y) (x)>(y)?(x):(y) #define D 1000 int remainders[D]; int get_max_rec(int n) { int times = 1,dividend = 1; memset(remainders, 0, D * sizeof(int)); //printf("-----------------------------\n"); //printf("%d\n",n); //printf("-----------------------------\n"); for(; dividend!=0 ;) { //printf("%d %d\n",dividend,times); if (remainders[dividend]) return times - remainders[dividend]; remainders[dividend] = times++; if (dividend < n) dividend *= 10; dividend = dividend % n; } return 0; } int main(int argc, char *argv[]) { int max_rec = 0, d, d_max; for( d = 3 ; d < D ; d++) { int new_max_rec = get_max_rec(d); //printf( "%d : %d\n",d , new_max_rec(d) ); if (new_max_rec > max_rec) { max_rec = new_max_rec; d_max = d; } } printf("%d\n", d_max); return 0; } ================================================ FILE: Problem026/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # # A unit fraction contains 1 in the numerator. # The decimal representation of the unit fractions # with denominators 2 to 10 are given: # 1/2 = 0.5 # 1/3 = 0.(3) # 1/4 = 0.25 # 1/5 = 0.2 # 1/6 = 0.1(6) # 1/7 = 0.(142857) # 1/8 = 0.125 # 1/9 = 0.(1) # 1/10 = 0.1 # 0.142857... = x # 0.142857... * 1000000 = 1000000x # 142857.142857... -0.142857... = 1000000x - x # 142857 = 999999x # x = 142857/999999 # Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. # It can be seen that 1/7 has a 6-digit recurring cycle. # Find the value of d < 1000 for which 1/d contains the longest # recurring cycle in its decimal fraction part. # replicação crua do algoritmo de divisão # manualmente, aplica uma memória dos divisores já efetuados # quando resto da divisão chegar num ponto onde se repete # retorna a quantidade de divisões menos a quantidade de vezes # que se repetiu # Exemplo [1/7] # # 10 |7 # 30 |_______ # 28 0,(1434851)... # 20 # 14 # 60 # 56 # 40 # 35 # 50 # 49 # (1) <= chegou ao remainder # retorna a função menos o número de iterações. # para o último dividendo # se resto for zero, retorna zero, pois não há recurring cycle # exemplos: 1/2, 1/4, 1/8 # only odd numbers need to be compute def get_rec_cycle(n): """1/x get the max abc recurring cycle length of 0.(abc) num""" dividend, times = 1, 1 remainder = [0 for x in range(n + 1)] while dividend != 0: times += 1 if (remainder[dividend]): return times - remainder[dividend] remainder[dividend] += times if dividend == 0: break if dividend < n: dividend *= 10 dividend %= n return 0 def get_max_rec(limit): return max([x for x in range(3, limit, 2)], key=get_rec_cycle) test = get_rec_cycle(7) assert test == 6, "Some wrong; got {}, expected 6.".format(test) if __name__ == '__main__': print(get_max_rec(1000)) ================================================ FILE: Problem026/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=26) ================================================ FILE: Problem027/.hash ================================================ 69d9e3218fd7abb6ff453ea96505183d ================================================ FILE: Problem027/C/Makefile ================================================ CXX = gcc LFLAGS = -lm -Wall -o TARGET = solution_1 EXTENSION_TARGET = c EXTENSION_OUT = out all: $(CXX) $(LFLAGS) $(TARGET).$(EXTENSION_OUT) $(TARGET).$(EXTENSION_TARGET) clean: rm -v *.$(EXTENSION_OUT) run: ./$(TARGET).$(EXTENSION_OUT) ================================================ FILE: Problem027/C/solution_1.c ================================================ /* * ===================================================================================== * * Copyleft 2016 Manoel Vilela * * Author: Manoel Vilela * Contact: manoel_vilela@engineer.com * Organization: UFPA * * ===================================================================================== **/ #include #include #include #define LIMIT 1000 typedef struct { int primes; int a; int b; } Result; int quadratic(int n, int a, int b) { return n*n + a*n + b; } // simple function // to check if is a prime int is_prime(int n) { if (n < 2) { return false; } for (int q = 2; q < sqrt(n) + 1; q++) { if (n % q == 0) { return false; } } return true; } // func evaluation n² + an + b // return the n primes generate without gaps // between [0, n] int eval_func(int a, int b){ int n = 0; while (true) { if (is_prime(quadratic(n, a, b))){ n += 1; } else { break; } } return n; } // get the optimal a, b // and the nPrimes for // equation f(n) = n² + an + b // whose f(n) -> [0, N] // and N is MAX for LIMIT void get_result(Result *r) { r->a = 0; r->b = 0; r->primes=0; for (int i = -LIMIT; i < LIMIT; i++) { for (int j = -LIMIT; j < LIMIT; j++ ) { int n = eval_func(i, j); if (n > r->primes) { r->a = i; r->b = j; r->primes = n;; } } } // save } int main(int argc, char *argv[]) { Result r; get_result(&r); printf("%d\n", r.a * r.b); } ================================================ FILE: Problem027/CommonLisp/solution_1.lisp ================================================ ;; Common Lisp version ;; Manoel Vilela (defun primep (n) (loop for d from 2 to (1+ (isqrt N)) never (and (= (mod n d) 0) (/= n d)))) (defun funcprimes (a b) (do* ((n 0 (+ n 1))) ((if (not (primep (abs (+ (* n n) ( * a n) b)))) (return n))))) (defun solution () (let (a b n (primes 0)) (do ((x -1000 (1+ x))) ((= x 1000)) (do ((y -1000 (1+ y))) ((= y 1000)) (setf n (funcprimes x y)) (when (> n primes) (setf a x b y primes n)))) (* a b))) (format t "~d~%" (solution)) ================================================ FILE: Problem027/Go/solution_1.go ================================================ // Copyleft 2016 the DestructHub Authors. All rights reserved // Use of this source code is governed by a MIT // license that can be found in the LICENSE file. // solution for the problem 27 of Project Euler // concurrent solution: take about 3.5~4 seconds (about 3x faster from python version) package main import ( "fmt" "math" ) const ( limit = 1000 // a, b limits to search nThreads = 16 // number of nThreads ) type result struct { primes int a int b int } var ( resultchan = make(chan result, nThreads) // used to get results concurrently memory = make(map[int]bool) // memory for primes numbers ) // quadratic function generator // n² + an + b func quadratic(a, b int) func(int) int { return func(n int) int { return n*n + a*n + b } } // decorator workaround on Go // check if the value was be computed before // return if exists, else compute func memo(f func(int) bool) func(int) bool { return func(n int) bool { if val, exists := memory[n]; exists { return val } else { return f(n) } } } // simple function // to check if is a prime func isPrime(n int) bool { if n < 2 { return false } for q := 2; float64(q) <= math.Floor(math.Sqrt(float64(n))); q++ { if n%q == 0 { return false } } return true } // func evaluation n² + an + b // return the n primes generate without gaps // between [0, n] func evalFunc(f func(int) int) int { n := 0 for { if memo(isPrime)(f(n)) { n += 1 } else { break } } return n } // make concurrent evaluation // of the equation whose have // generate more primes func worker(split int) { limitSplited := split * limit / nThreads a, b, nPrimes := 0, 0, 0 for i := -limitSplited; i < limitSplited; i++ { for j := -limit; j < limit; j++ { if n := evalFunc(quadratic(i, j)); n > nPrimes { a, b = i, j nPrimes = n } } } resultchan <- result{nPrimes, a, b} } // receiver the results // from workers func receiver() (a int, b int, nPrimes int) { a, b, nPrimes = 0, 0, 0 for i := 0; i < nThreads; i++ { result := <-resultchan if result.primes > nPrimes { a, b = result.a, result.b nPrimes = result.primes } } return a, b, nPrimes } func main() { for part := 1; part <= nThreads; part++ { go worker(part) } a, b, _ := receiver() fmt.Printf("%v\n", a*b) } ================================================ FILE: Problem027/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # from functools import wraps from itertools import combinations as comb LIMIT = 1000 def memo(fn): """Memorization decorator""" cache = {} miss = object() @wraps(fn) def wrapper(*args, **kwargs): result = cache.get(args, miss) if result is miss: result = fn(*args) cache[args] = result return result return wrapper def quadratic(a, b): """quadratic function abstraction""" def func(n): return n * n + a * n + b return func @memo def isprime(n): """memorized prime evaluation, 2x more faster on that algorithm""" for p in range(2, int(abs(n) ** 0.5) + 1): if n % p == 0: return False return True def eval_func(func): """eval func which primes will generate""" n = 0 while True: prime = isprime(func(n)) if prime: n += 1 else: return n def search(limit): """search for the best a, b coefficients for a quadratic func prime gen""" coffs = {} for t in comb(range(-limit, limit + 1), 2): coffs[t] = max([eval_func(quadratic(a, b)) for a, b in [t, t[::-1]]]) return max(coffs, key=lambda x: coffs[x]) def main(): from functools import reduce print(reduce(int.__mul__, search(LIMIT))) if __name__ == '__main__': main() ================================================ FILE: Problem027/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=27) ================================================ FILE: Problem028/.hash ================================================ 0d53425bd7c5bf9919df3718c8e49fa6 ================================================ FILE: Problem028/C/solution_1.c ================================================ #include long long int g[1001][1001]; int main() { long long int i=1,m=500,n=500,sum=0,j; g[m][n++]=i++; while(i<=1002001) { g[m++][n]=i++; while(m 1000) { g[m][n]=i++; --n; } g[m--][n]=i++; while(m>n) { g[m][n]=i++; --m; } g[m][n++]=i++; while(m+n < 1000) { g[m][n]=i++; ++n; } g[m][n++]=i++; } for(i=0;i<1001;++i) { for(j=0;j<1001;++j) { if(j==i || j+i==1000) sum=sum+g[i][j]; } } printf("%lld",sum); return 0; } ================================================ FILE: Problem028/Elixir/solution_1.exs ================================================ box = fn b -> (4 * (round(:math.pow(((2 * b) + 1), 2))) - (12 * b)) end Enum.map(1..500, fn x -> box.(x) end) |> Enum.reduce(fn c,d -> c + d end) |> Kernel.+(1) |> IO.puts ================================================ FILE: Problem028/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # """ Number spiral diagonals Problem 28 Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 13 It can be verified that the sum of the numbers on the diagonals is 101. What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed in the same way? """ # 1 +3 + 5 + 7 + 9 = 25 # (25) + 25 + 13 + 17 + 21 = 101 # 669171001 # LOOOOOOOOOOOOOOOOOOOOL, try understand this! I don't believe I wrote that... # the worse part is the solutions are right! black = lambda x: (num for num in range(x * x - 3 * (x - 1), x * x + 1, x - 1)) magic = sum(sum(black(i))for i in range(3, 1001 + 1, + 2)) + 1 print(magic) ================================================ FILE: Problem028/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=28) ================================================ FILE: Problem029/.hash ================================================ 6f0ca67289d79eb35d19decbc0a08453 ================================================ FILE: Problem029/Elixir/solution_1.exs ================================================ # Author: lubien ( for a <- 2..100, b <- 2..100, do: :math.pow(a, b) |> round ) |> Stream.uniq |> Enum.count |> IO.puts ================================================ FILE: Problem029/Haskell/solution_1.hs ================================================ import Data.List list :: [Integer] -- Not Int list = [a ^ b | a <- [2..100], b <- [2..100]] main :: IO () main = print . length $ f list where f = map head . group . sort ================================================ FILE: Problem029/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # """ Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5: 22=4, 23=8, 24=16, 25=32 32=9, 33=27, 34=81, 35=243 42=16, 43=64, 44=256, 45=1024 52=25, 53=125, 54=625, 55=3125 If they are then placed in numerical order, with any repeats removed, we get the following sequence of 15 distinct terms: 4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125 How many distinct terms are in the sequence generated by ab for 2 ≤ a ≤ 100 and 2 ≤ b ≤ 100? """ nums_distinct = [] for x in range(2, 101): for y in range(2, 101): num = x ** y if num not in nums_distinct: nums_distinct.append(num) print(len(nums_distinct)) ================================================ FILE: Problem029/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=29) ================================================ FILE: Problem030/.hash ================================================ 27a1779a8a8c323a307ac8a70bc4489d ================================================ FILE: Problem030/Elixir/solution_1.exs ================================================ defmodule DigitPowers do def fifth(num,lim,sum) when num > lim, do: sum def fifth(num,lim,sum) when num <= lim do val = if digit_power?(num), do: num, else: 0 fifth(num+1,lim,sum+val) end def digit_power?(n) do n == Integer.to_string(n) |> String.split("", trim: true) |> Enum.map(fn x -> round(:math.pow(String.to_integer(x),5)) end) |> Enum.reduce(fn a,b -> a + b end) end end IO.puts DigitPowers.fifth(2,round(:math.pow(9,6)),0) ================================================ FILE: Problem030/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # from functools import reduce """ Digit fifth powers Problem 30 Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits: 1634 = 1^4 + 6^4 + 3^4 + 4^4 8208 = 8^4 + 2^4 + 0^4 + 8^4 9474 = 9^4 + 4^4 + 7^4 + 4^4 As 1 = 14 is not a sum it is not included. The sum of these numbers is 1634 + 8208 + 9474 = 19316. Find the sum of all the numbers that can be written as the sum of fifth powers of their digits. """ """ Prova de um cara lá no fórum do PE sobre apenas ser necessário considerar números de 6 dígitos ou menos. Proof that one need only consider numbers 6 digits or less: If N has n digits, then 10^{n-1} <= N. If N is the sum of the 5th powers of its digits, N <= n*9^5. Thus, 10^{n-1} <= n*9^5. We now show by induction that if n>=7, then 10^{n-6} > n. 1) Basis step (n=7): 10^{7-6} = 10 > 7. 2) Induction step: suppose 10^{n-6} > n for some n>=7. Show this true for n+1 too. Well, 10^{(n+1)-6} = 10*10^{n-6} > 10n > 2n > n+1 QED. It follows that if n>=7, then 10^{n-1} = 10^{n-6}*10^5 > n * 10^5 > n*9^5. Hence the only way we can have 10^{n-1} <= n*9^5 is for n<=6. """ # Aqui foi pura sorte. # Inicialmente tentei pensar num limite para testes, seria o tamanho*9**5, mas não consegui deduzir o maior tamanho possível # Desse jeito, fiz alguns testes e descobri que a ocorrência de números que poderiam ser escritos como a soma de potência(5) # Era no tamanho intervalo de [4, 7) from itertools import combinations_with_replacement as c; from string import digits as d n = lambda num, digits: sorted(str(num)) == sorted(digits) p = lambda comb: sum([int(n) ** 5 for n in comb]) print(sum(set(reduce(list.__add__, ([p(cb) for cb in c(d, x) if n(p(cb), cb)] for x in range(7)))))) ================================================ FILE: Problem030/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=30) ================================================ FILE: Problem030/Ruby/solution_1.rb ================================================ def sum_digits(value) value.to_s .chars .map{|x| x.to_i ** 5} .reduce(:+) end puts (2..200000).to_a .select{|x| sum_digits(x) == x} .reduce(:+) ================================================ FILE: Problem031/.hash ================================================ 142dfe4a33d624d2b830a9257e96726d ================================================ FILE: Problem031/C/Makefile ================================================ GCC = gcc LFLAGS = -lm -Wall -o TARGET = solution_1 DEBUG = --debug all: $(GCC) $(LFLAGS) $(TARGET).out $(TARGET).c debug: $(GCC) $(DEBUG) $(LFLAGS) $(TARGET).out $(TARGET).c clean: rm -v *.out run: ./$(TARGET).out ================================================ FILE: Problem031/C/solution_1.c ================================================ /* * ===================================================================================== * * Copyleft 2015 Manoel Vilela * * * Filename: solution_1.c * * Description: Solution for Problem031 of ProjectEuler * * Author: Manoel Vilela * Contact: manoel_vilela@engineer.com * Organization: UFPA * Perfomance: 0.02s | Intel E7400 @ 3.5Ghz * * ===================================================================================== **/ #include int different_ways(int money, int *coins, int n_coins) { int max_coin = money / (*coins); int n, ways = 0; for (n = 0; n <= max_coin; n++) { int new_money = (*coins) * n; if (n_coins > 1 && new_money < money) ways += different_ways(money - new_money, coins + 1, n_coins - 1); if (new_money == money) { ways++; break; } } return ways; } int main(int argc, char **argv){ int coins[] = {200, 100, 50, 20, 10, 5, 2, 1}; int lenght = sizeof(coins) / sizeof(int); int money = 200; int answer = different_ways(money, coins, lenght); printf("%d\n", answer); return 0; } ================================================ FILE: Problem031/Elixir/solution_1.exs ================================================ defmodule Coins do def count([],_,vals), do: vals def count([coin|coins],lim,vals) when length(coins) >= 0 do count(coins,lim,ways(coin,coin,lim,vals)) end def ways(num,_, lim,vals) when num > lim, do: vals def ways(num,coin,lim,vals) when num <= lim do ways(num+1,coin,lim,ad(coin,num,vals)) end def ad(a,b,c), do: Map.put(c,b,(Map.get(c,b) + Map.get(c,(b-a)))) end vals = Map.put(Enum.into(Enum.zip(Enum.to_list(0..200),List.duplicate(0,201)),Map.new),0,1) Coins.count([1,2,5,10,20,50,100,200],200,vals) |> Map.values() |> Enum.max() |> IO.inspect ================================================ FILE: Problem031/Haskell/solution_slow_1.hs ================================================ -- Solução muito porca, performance bem ruim, preciso refazer D: -- Author: G4BB3R getTupleValue :: (Int, Int, Int, Int, Int, Int, Int, Int) -> Int getTupleValue (p1, p2, p5, p10, p20, p50, l1, l2) = p1 + p2 * 2 + p5 * 5 + p10 * 10 + p20 * 20 + p50 * 50 + l1 * 100 + l2 * 200 coinsPermutations :: [(Int, Int, Int, Int, Int, Int, Int, Int)] coinsPermutations = [(p1, p2, p5, p10, p20, p50, l1, l2) | p1 <- [1..200 `div` 1] , p2 <- [1..200 `div` 2] , p5 <- [1..200 `div` 5] , p10 <- [1..200 `div` 10] , p20 <- [1..200 `div` 20] , p50 <- [1..200 `div` 50] , l1 <- [1..200 `div` 100] , l2 <- [1..200 `div` 200] ] permutationsWith200p :: Int permutationsWith200p = foldr (\tuple acc -> acc + if getTupleValue tuple == 200 then 1 else 0) 0 coinsPermutations main :: IO () main = print permutationsWith200p ================================================ FILE: Problem031/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # # Answer: 73682 @ 0.6s # Hardware:Intel E7400 @ 3.5Ghz # black magic recursive def different_ways(money, coins, summation=0): ways = 0 max_coins_head = money // coins[0] for n in range(max_coins_head + 1): new_money = n * coins[0] if len(coins) > 1 and new_money < money: ways += different_ways(money - new_money, coins[1:], new_money) if new_money == money: ways += 1 break return ways def main(): coins = [200, 100, 50, 20, 10, 5, 2, 1] money = 200 solution = different_ways(money, coins) print(solution) if __name__ == '__main__': main() ================================================ FILE: Problem031/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=31) ================================================ FILE: Problem032/.hash ================================================ 100f6e37d0b0564490a2ee27eff0660d ================================================ FILE: Problem032/Clojure/solution_1.clj ================================================ (def xs (for [ x (range 1 (inc 9999)) y (range 1 (inc 99)) :let [xy (* x y)] :when (= "123456789" (apply str(sort (str x y xy)))) ] xy)) (println (reduce + (distinct xs))) ================================================ FILE: Problem032/CommonLisp/solution_1.lisp ================================================ ;; Common Lisp Script ;; Manoel Vilela (defun cat (&rest strings) (apply #'concatenate (cons 'string strings))) (defun string-to-list (string) (loop for c across string collect (parse-integer (string c)))) (defun nums-to-string (&rest x) (apply #'cat (mapcar #'write-to-string x))) (defun ordered-digits (&rest x) (apply #'nums-to-string (sort (string-to-list (apply #'nums-to-string x)) #'<))) (defun solution () (loop with pandigitals-table = (make-hash-table) with pandigitals = 0 for x from 1 to 9999 do (loop for y from 1 to 99 for xy = (* x y) unless (nth-value 1 (gethash xy pandigitals-table)) when (equalp "123456789" (ordered-digits x y xy)) do (progn (setf pandigitals (+ xy pandigitals)) (setf (gethash xy pandigitals-table) t))) finally (return pandigitals))) (prin1 (solution)) ================================================ FILE: Problem032/Elixir/solution_1.exs ================================================ # Author: G4BB3R for x <- 1..9999, y <- 1..99, xy = x * y, '123456789' == Enum.sort(to_charlist(Integer.to_string(x) <> Integer.to_string(y) <> Integer.to_string(xy))) do xy end |> Enum.uniq |> Enum.sum |> IO.puts ================================================ FILE: Problem032/Haskell/solution_1.hs ================================================ -- Author: G4BB3R import Data.List (sort, nub) main :: IO () main = print $ sum $ nub [ xy | x <- [1..9999 :: Int] , y <- [1..99 :: Int] , let xy = x * y , (== "123456789") . sort $ show x ++ show y ++ show xy ] ================================================ FILE: Problem032/Lua/solution_1.lua ================================================ table.find = function (xs, x) for _, v in pairs(xs) do if x == v then return true end end return false end local function sort (str) local xs = {} str:gsub(".",function (c) table.insert(xs, c) end) table.sort(xs) return table.concat(xs, "") end local function get_pandigal_products_sum () local sum = 0 local xs = {} for x = 1, 9999 do for y = 1, 99 do local xy = x * y if sort(x .. y .. xy) == "123456789" then if not table.find(xs, xy) then sum = sum + xy table.insert(xs, xy) end end end end return sum end print(get_pandigal_products_sum()) ================================================ FILE: Problem032/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=32) ================================================ FILE: Problem033/.hash ================================================ f899139df5e1059396431415e770c6dd ================================================ FILE: Problem033/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # limit = 100 def mdc(a, b): if (b == 0): return a else: return mdc(b, a % b) class fraction(object): def __init__(self, x, y): self.num = x self.den = y self.factored = False def __repr__(self): return '{}/{}'.format(self.num, self.den) def __mul__(self, frac): self.num *= frac.num self.den *= frac.den return self __rmul__ = __mul__ @property def mfact(self): a, b = self.num, self.den for x in self.cross: self.factored = True a = self.new(self.num, x) b = self.new(self.den, x) d = mdc(a, b) return (a // d, b // d) @property def cfact(self): return (self.num // self.mdc, self.den // self.mdc) @property def fact(self): return fraction(*self.cfact) @property def mdc(self): return mdc(self.num, self.den) def new(self, w, z): v = ''.join([x for x in str(w) if x != z]) if len(v) > 0: return int(v) else: return -1 def get(self, num): return set(str(num)) @property def cross(self): return self.get(self.num) & self.get(self.den) @property def nums(self): return (self.num, self.den) @property def non_trivial(self): nzeronegative = all(False for x in self.nums if x < 1) nontrivial = all(False for x in self.nums if x % 10 == 0) return nzeronegative and nontrivial and self.factored @property def curious(self): return self.non_trivial and (self.mfact == self.cfact) def solution(): from functools import reduce fracs = [] for up in range(limit): for down in range(limit): if up < down: f = fraction(up, down) f.mfact if f.curious: fracs.append(f) return reduce(lambda x, y: x * y, fracs).fact.den if __name__ == '__main__': print(solution()) ================================================ FILE: Problem033/Python/solution_2.py ================================================ import math frac=1.0 for b in range(1,10): for a in range(1,b): for c in range(1,10): if (a*10+b)/(b*10+c)==a/c: frac*=(a/c) print(math.ceil(1/frac)) ================================================ FILE: Problem033/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=33) ================================================ FILE: Problem034/.hash ================================================ 60803ea798a0c0dfb7f36397d8d4d772 ================================================ FILE: Problem034/C/solution_1.c ================================================ #include int main() { int fact=1,m,i,n,j,temp,sum=0,sum1=0; for(i=3;i<1000000;++i) { temp=i; n=i; sum=0; while(temp>0) { m=temp%10; fact=1; for(j=1;j<=m;++j){ fact*=j; } sum+=fact; temp=temp/10; } if(sum==n){ sum1+=n; } } printf("%d",sum1); return 0; } ================================================ FILE: Problem034/Elixir/solution_1.exs ================================================ defmodule Factorial do def find(count,facts) when count > 9, do: [Enum.reverse(facts),facts] def find(count,[last|facts]) when count <= 9 do find(count + 1,[count*last] ++ [last] ++ facts) end end defmodule DigitFactorials do def find(count,_,lim,sum) when count > lim do sum end def find(count,facts,lim,sum) when count <= lim do sum = cond do digit_factorial?(count,facts) -> sum + count true -> count end find(count + 1,facts,lim,sum) end def digit_factorial?(num,facts) do num == Integer.to_string(num) |> String.split("",trim: true) |> Enum.map(fn n -> Enum.at(facts,String.to_integer(n)) end) |> Enum.reduce(fn a,b -> a + b end) end end [facts,[lim|_]] = Factorial.find(1,[1]) IO.puts DigitFactorials.find(3,facts,lim,0) ================================================ FILE: Problem034/Haskell/solution_1.hs ================================================ import Data.Char (digitToInt) fat :: Int -> Int fat n = product [1..n] check :: Int -> Bool check n = (n == m) where m = sum . map fat $ map digitToInt $ show n main :: IO () main = do print . sum $ filter check [3..50000] ================================================ FILE: Problem034/Python/solution_2.py ================================================ #code created by NamanNimmo Gera #3:31pm, April 12, 2019. import math def findsum(n): smallsum = 0 while(n>0): smallsum = smallsum + math.factorial(n%10) n = n//10 return(smallsum) tot = 0 for i in range(10,50000): #see why this upper bound is being chosen ;) if findsum(i)==i: tot = tot + i print(tot) #145+40585 ================================================ FILE: Problem034/Python/solution_slow_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # # Python Script # # Copyleft © Manoel Vilela # # # get @90s to terminated, slow solution from functools import reduce """ Digit factorials Problem 34 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are equal to the sum of the factorial of their digits. Note: as 1! = 1 and 2! = 2 are not sums they are not included. """ f = lambda n: reduce(lambda a, b: a * b, [u for u in range(n + 1) if u != 0] + [1]) c = lambda x: sum([f(int(n)) for n in str(x)]) == x filtered_range = lambda i: filter(lambda x: not bool(sum([int(n) for n in str(x)]) & x), range(3, i)) gen = lambda y: (x for x in filtered_range(y) if c(x)) g = gen(10 ** 7) # because 9!*7 < 99999999 s = sum(x for x in g) print(s) ================================================ FILE: Problem034/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=34) ================================================ FILE: Problem034/Ruby/solution_1.rb ================================================ def fat(n) return 1 if n == 0 (1..n).to_a .reduce(:*) .to_i end def check(n) m = n.to_s .chars .map{|x| fat(x.to_i)} .reduce(:+) n == m end puts (3..50000).to_a.select{|x| check(x)}.reduce(:+) ================================================ FILE: Problem035/.hash ================================================ b53b3a3d6ab90ce0268229151c9bde11 ================================================ FILE: Problem035/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # def is_prime(n): if n <= 3: return n >= 2 if n % 2 == 0 or n % 3 == 0: return False for i in range(5, int(n ** 0.5) + 1, 6): if n % i == 0 or n % (i + 2) == 0: return False return True def circPrime(n): n1 = str(n)*2 for i in range(len(str(n))): if not is_prime(int(n1[i:len(str(n))+i])): return False return True print(len([x for x in range(1000000) if circPrime(x)])) ================================================ FILE: Problem035/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=35) ================================================ FILE: Problem036/.hash ================================================ 0e175dc2f28833885f62e7345addff03 ================================================ FILE: Problem036/CommonLisp/solution_1.lisp ================================================ ;; Common Lisp Script ;; Manoel Vilela (defun palindromep (s) (equal s (reverse s))) (defun bin (n) (format nil "~b" n)) (defun solution (n) (loop for x from 0 below n when (and (palindromep (write-to-string x)) (palindromep (bin x))) sum x)) (format t "~a~%" (solution 1000000)) ================================================ FILE: Problem036/Elixir/solution_1.exs ================================================ defmodule DoubleBase do def palindrome(lim) do (1..lim) |> Stream.map(fn a -> Integer.to_string(a) end) |> Stream.filter(fn b -> pal?(b) end) |> Stream.map(fn c -> Integer.to_string(String.to_integer(c),2) end) |> Stream.filter(fn d -> pal?(d) end) |> Stream.map(fn e -> String.to_integer(e,2) end) |> Enum.reduce(fn f,g -> f + g end) |> IO.inspect end def pal?(n) do n == String.split(n,"",trim: true) |> Enum.reverse() |> Enum.join() end end DoubleBase.palindrome(1_000_000) ================================================ FILE: Problem036/Go/solution_1.go ================================================ package main import ( "fmt" "strconv" ) func isPalindrome(s string) bool { for i := 0; i < len(s)/2; i++ { if s[i] != s[len(s)-i-1] { return false } } return true } var binary = func(i int64) string { return strconv.FormatInt(i, 2) } func main() { number := 0 for i := 0; i < 1000000; i++ { if isPalindrome(strconv.Itoa(i)) && isPalindrome(binary(int64(i))) { number += i } } fmt.Println(number) } ================================================ FILE: Problem036/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # def isPal(n): return str(n) == str(n)[::-1] def binDecPal(x): if isPal(x): n = bin(x)[2:] if isPal(n): return True return False print(sum([x for x in range(1000000) if binDecPal(x)])) ================================================ FILE: Problem036/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=36) ================================================ FILE: Problem036/Ruby/solution_1.rb ================================================ def binary(value) value.to_s(2) end def palindrome(value) value.to_s.eql?(value.to_s.reverse) end def double_base(value) palindrome(value) && palindrome(binary(value)) end puts (0..999999) .to_a .select{|x| double_base(x)} .reduce(:+) ================================================ FILE: Problem037/.hash ================================================ cace46c61b00de1b60874936a093981d ================================================ FILE: Problem037/C++/solution_1.cpp ================================================ #include using namespace std; const int much = 1000000; bool is_prime[much]; void sieve(){ memset (is_prime, true, sizeof(is_prime)); is_prime[0] = is_prime[1] = false; for (int i = 2; i < much; ++i) { for (int j = (i << 1); j < much; j += i) { is_prime[j] = false; } } } bool test(int t) { int orig = t, cnt = 0, tmp10 = 1; while (t > 0) { if (!is_prime[t]) { return false; } t /= 10; ++cnt; tmp10 *= 10; } while(orig > 0) { if (!is_prime[orig]) { return false; } orig = (orig % (tmp10 /= 10)); } return true; } int main() { long long sum = 0; sieve (); for (int i = 10; i < much; ++i) { if (test(i)) { sum += i; } } cout << sum << '\n'; return 0; } ================================================ FILE: Problem037/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # from functools import wraps def memo(fn): """Memorization decorator""" cache = {} miss = object() @wraps(fn) def wrapper(*args, **kwargs): result = cache.get(args, miss) if result is miss: result = fn(*args) cache[args] = result return result return wrapper class TruncatePrime(int): """ Class to verify if a prime is a truncate: Truncate prime example: 3797 pop left: 3797 -> 379 -> 37 -> 3 pop right: 3797 -> 797 -> 97 -> 7 """ def __init__(self, x): self.num = x self.string = str(x) self.len = len(self.string) def __add__(self, other): return self.num + other @property def left(self): return all([self.is_prime(x) for x in self.walk('left')]) @property def right(self): return all([self.is_prime(x) for x in self.walk('right')]) @property def self(self): return self.is_prime(self.num) def walk(self, orientation): if orientation is 'right': return (int(self.string[:x]) for x in range(1, self.len)) elif orientation is 'left': return (int(self.string[x:]) for x in range(1, self.len)) @memo def is_prime(self, x): if x < 2: return False for d in range(2, int(x ** 0.5) + 1): if x % d == 0: return False return True @property def is_truncate(self): if len(self.string) < 2: return False return self.self and self.left and self.right def search_truncate(until=11): n = 0 truncate_primes = [] while len(truncate_primes) < until: t = TruncatePrime(n) if t.is_truncate: truncate_primes.append(t) n += 1 return sum(truncate_primes) if __name__ == '__main__': print(search_truncate()) ================================================ FILE: Problem037/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=37) ================================================ FILE: Problem038/.hash ================================================ f2a29ede8dc9fae7926dc7a4357ac25e ================================================ FILE: Problem038/Elixir/solution_1.exs ================================================ defmodule Pandigital do def multiples(current,lim,pandigitals) when current > lim do pandigitals |> Enum.max() end def multiples(current,lim,pandigitals) when current <= lim do multiples(current+1,lim,products(2,4,Integer.to_string(current),pandigitals)) end def products(start,finish,_,pandigitals) when start > finish do pandigitals end def products(start,finish,current,pandigitals) when start <= finish do pan = current <> Integer.to_string(start*String.to_integer(current)) pandigitals = cond do pandigital?(pan) -> [pan] ++ pandigitals true -> pandigitals end products(start+1,finish,pan,pandigitals) end def pandigital?(n) do ~w(1 2 3 4 5 6 7 8 9) == n |> String.split("", trim: true) |> Enum.sort() end end IO.puts Pandigital.multiples(9_000,9_999,[]) ================================================ FILE: Problem038/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # from collections import Counter class PanDigital(int): dig = '' iteration = 1 def map(self, x): return str(self * x) def concat(self, digits): return self.dig + digits @property def can_continue(self): return len(self.dig) < 10 and self.count @property def count(self): return all(False for x in Counter(self.dig).values() if x > 1) @property def sorted(self): return ''.join(map(str, sorted(map(int, self.dig)))) @property def ispandig(self): return self.sorted == '123456789' def transform(self): while self.can_continue: self.dig = self.concat(self.map(self.iteration)) if self.ispandig: return self.dig self.iteration += 1 return None @property def value(self): v = self.transform() if v is not None: return int(v) return None p = PanDigital print(max(p(x).value for x in range(10000) if p(x).value)) ================================================ FILE: Problem038/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=38) ================================================ FILE: Problem038/Swift/solution_1.swift ================================================ import Glibc func is9Pandigital(value:String) -> Bool { return String(value.characters.sort()) == "123456789" } func nDigitsInMult(n1:Int, n2:Int) -> Int { return Int(floor((log10(Double(n1) + log10(Double(n2))) + 1))) } var max9Pandigital = -1 var i = 1 let maxNumber = Int(pow(10, 9 / 2)) while i < maxNumber { var concat = "" for j in 1...9 { if concat.characters.count + nDigitsInMult(i, n2:j) > 9 { break } concat += String(i * j) if (is9Pandigital(concat)) { max9Pandigital = max(max9Pandigital, Int(concat)!) } } i+=1 } print (max9Pandigital) ================================================ FILE: Problem039/.hash ================================================ fa83a11a198d5a7f0bf77a1987bcd006 ================================================ FILE: Problem039/C/Makefile ================================================ CXX = gcc LFLAGS = -lm -Wall -o TARGET = solution_1 EXTENSION_TARGET = c EXTENSION_OUT = out all: $(CXX) $(LFLAGS) $(TARGET).$(EXTENSION_OUT) $(TARGET).$(EXTENSION_TARGET) clean: rm -v *.$(EXTENSION_OUT) run: ./$(TARGET).$(EXTENSION_OUT) ================================================ FILE: Problem039/C/solution_1.c ================================================ #include #define MAX 1000 int main() { int i, j , k, maxP = 1; int ps[1001]; for (i=0; i <= MAX; ps[++i] =0); for(i = 1; i <= MAX; i++) { for(j = i;j <= MAX; j++) { for(k = j; (k * k) < (i * i + j * j); k++); if((i * i + j * j) == (k * k) && (i + j + k) <= MAX) { ps[i+j+k] += 1; } } } for(i = 1; i <= MAX; i++) { if(ps[maxP] < ps[i]) maxP = i; } printf("%d\n",maxP); return 0; } ================================================ FILE: Problem039/CommonLisp/solution_1.lisp ================================================ ;; Common Lisp Script ;; Manoel Vilela (defparameter *max-perimeter* 1000) (defparameter *perimeter-solutions* (make-array (1+ *max-perimeter*) :initial-element 0)) ;; (1+ *max-perimeter*) is just to avoid decrement later to access the index by perimeter-solution (defun pythagoreanp (a b c) (= (* a a) (+ (* b b) (* c c)))) (defun <=-perimeter (a b c) (<= (+ a b c) *max-perimeter*)) (defun solution () (loop for c from 1 to *max-perimeter* do (loop for b from c to *max-perimeter* for a = (loop for x from b while (< (* x x) (+ (* b b) (* c c))) finally (return x)) when (and (pythagoreanp a b c) (<=-perimeter a b c)) do (setf (aref *perimeter-solutions* (+ a b c)) (1+ (aref *perimeter-solutions* (+ a b c)))))) (loop with max-perimeter = 0 for i from 1 to *max-perimeter* when (> (aref *perimeter-solutions* i) (aref *perimeter-solutions* max-perimeter)) do (setf max-perimeter i) finally (return max-perimeter))) (format t "~a~%" (solution)) ================================================ FILE: Problem039/Elixir/solution_1.exs ================================================ defmodule RightInteger do def ways(vals,i,_,_) when i > 399 do vals end def ways(vals,i,j,_) when j > 399 do ways(vals,i+1,i+1,i+1) end def ways(vals,i,j,k) when k > 399 do ways(vals,i,j+1,j+1) end def ways(vals,i,j,k) when k <= 399 do vals = cond do ((i*i) + (j*j) == (k*k)) and ((i+j+k) < 1_000) -> ad((i+j+k),vals) true -> vals end ways(vals,i,j,k+1) end def ad(a,b), do: Map.put(b,a,(Map.get(b,a) + 1)) end Enum.into(Enum.zip(Enum.to_list(1..1_000),List.duplicate(0,1_000)),Map.new) |> RightInteger.ways(1,1,1) |> Enum.max_by(fn {_,y} -> y end) |> elem(0) |> IO.puts ================================================ FILE: Problem039/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=39) ================================================ FILE: Problem040/.hash ================================================ 6f3ef77ac0e3619e98159e9b6febf557 ================================================ FILE: Problem040/Elixir/solution_1.exs ================================================ defmodule Champernowne do def constant(lim) do (0..lim) |> Enum.map(fn x -> Integer.to_string(x) end) |> Enum.join() |> String.codepoints |> find(0,1,1) |> IO.inspect end def find(_,_,tens,final) when tens > 1_000_000 do final end def find([digit|digits],count,tens,final) when tens <= 1_000_000 do [final|tens] = cond do count == tens -> [final * String.to_integer(digit)|tens * 10] true -> [final|tens] end find(digits,count+1,tens,final) end end Champernowne.constant(1_000_000) ================================================ FILE: Problem040/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # from functools import reduce from itertools import count def frac_series_generator(): '''each n after 0.1 from 0.12345678910111213...''' for w in count(start=1, step=1): for s in str(w): yield s def search_digit_by_index(indexes): '''get the digits of indexes of frac_series''' limit = max(indexes) digits = {x: 0 for x in indexes} for c, n in enumerate(frac_series_generator()): if c + 1 in digits: digits[c + 1] = int(n) if c + 1 >= limit: break return digits.values() def main(): indexes = [1, 10, 100, 1000, 10000, 100000, 1000000] print(reduce(int.__mul__, search_digit_by_index(indexes))) if __name__ == '__main__': main() ================================================ FILE: Problem040/Python/solution_2.py ================================================ #code created by NamanNimmo Gera #1:20pm, April 15, 2019. string = "" for i in range(1,1000000): string = string + str(i) print(int(string[0])*int(string[9])*int(string[99])*int(string[999])*int(string[9999])*int(string[99999])*int(string[999999])) ================================================ FILE: Problem040/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=40) ================================================ FILE: Problem041/.hash ================================================ d0a1bd6ab4229b2d0754be8923431404 ================================================ FILE: Problem041/CommonLisp/solution_1.lisp ================================================ ;; Common Lisp Script ;; Manoel Vilela ;; next lexicographical permutation of a vector ;; borrowed from http://rosettacode.org/wiki/Permutations#Common_Lisp ;; (next-perm #(9 8 7 6 5 4 3 2 1)) => #(9 8 7 6 5 4 3 1 2) (defun next-perm (vec &optional (cmp '>)) ; modify vector (declare (type (simple-array * (*)) vec)) (macrolet ((el (i) `(aref vec ,i)) (cmp (i j) `(funcall cmp (el ,i) (el ,j)))) (loop with len = (1- (length vec)) for i from (1- len) downto 0 when (cmp i (1+ i)) do (loop for k from len downto i when (cmp i k) do (rotatef (el i) (el k)) (setf k (1+ len)) (loop while (< (incf i) (decf k)) do (rotatef (el i) (el k))) (return-from next-perm vec))))) ;; check if n is prime (defun primep (n) (loop for d from 2 to (1+ (isqrt n)) never (and (= (mod n d) 0) (/= n d)))) ;; vector of digits => integer ;; (vec->int #(9 8 7 6 5 4 3 2 1)) => 987654321 (defun vec->int (vec) (loop for d across vec for pos from (1- (length vec)) downto -1 sum (* (expt 10 pos) d))) ;; loop from the biggest to small pandigital, ;; get the first pandigital prime (defun solution (vec) (loop for pandigital = (vec->int vec) when (primep pandigital) return pandigital when (null (next-perm vec)) return (if (< (length vec) 2) ;; if is only #(1), calling solution again will make a infinity loop nil (solution (subseq (reverse vec) 1))))) (format t "~a~%" (solution #(9 8 7 6 5 4 3 2 1))) ================================================ FILE: Problem041/Python/solution_slow_1.py ================================================ from collections import Counter def isPrime(n) : if (n <= 1) : return False #this is my brute force approach, if I see a better solutionin the PE forum, will edit this :) if (n <= 3) : # EDIT: A much better approach: https://www.xarg.org/puzzle/project-euler/problem-41/ return True if (n % 2 == 0 or n % 3 == 0) : return False i = 5 while(i * i <= n) : if (n % i == 0 or n % (i + 2) == 0) : return False i = i + 6 return True def checker(a): #function to check if the number has zero in it or not for i in str(a): if str(i)=='0': return 1 return 0 def repeatCheck(a): #function to check if there is any repeating digit or not c = Counter(str(a)) if any(value > 1 for value in c.values()): return 1 else: return 0 highest = 0 for j in range(1000000,10000000): #the highest number below 1million is 4231 if isPrime(j) and (checker(j)==0) and (repeatCheck(j)==0): a = len(str(j)) k = (a*(a+1))/2 if sum(int(digit) for digit in str(j))==k: if j>highest: highest = j print(highest) ================================================ FILE: Problem041/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=41) ================================================ FILE: Problem041/Swift/solution_1.swift ================================================ import Glibc func swap (str:[Character], i:Int, j:Int) -> [Character] { var newStr = str let c = str[i] newStr.removeAtIndex(i) newStr.insert(str[j], atIndex:i) newStr.removeAtIndex(j) newStr.insert(c, atIndex:j) return newStr } func isPandigitalPrimeTest(n:Double) -> Bool { if n % 2 == 0 { return false } else { let end = sqrt(n) var i = Double(3) while i <= end { if (n % i == 0) { return false } i += 2 } } return true } func newStringScope(n:Int) -> String { var i = n - 1 var scope = "" while i > 0 { scope += String(i) i -= 1 } return scope } var maxPandigitalPrime = -1 func permuteString(str:[Character], i:Int, length:Int) { if length == i { if (isPandigitalPrimeTest(Double(String(str))!)) { maxPandigitalPrime = max (maxPandigitalPrime, Int(String(str))!) } return } var newStr = str; for j in i.. 0 { var fixedScope = Array((String(idx) + newStringScope(idx)).characters) permuteString(fixedScope, i:1, length:fixedScope.count) idx -= 1 } print (maxPandigitalPrime) ================================================ FILE: Problem042/.hash ================================================ 82aa4b0af34c2313a562076992e50aa3 ================================================ FILE: Problem042/Elixir/solution_1.exs ================================================ a_z_key = %{ "A" => 1, "B" => 2, "C" => 3, "D" => 4, "E" => 5, "F" => 6, "G" => 7, "H" => 8, "I" => 9, "J" => 10, "K" => 11, "L" => 12, "M" => 13, "N" => 14, "O" => 15, "P" => 16, "Q" => 17, "R" => 18, "S" => 19, "T" => 20, "U" => 21, "V" => 22, "W" => 23, "X" => 24, "Y" => 25, "Z" => 26 } defmodule TriangleWords do def words(file,a_z_key) do case File.read(file) do {:ok, body} -> body |> parse(a_z_key) |> IO.inspect {:error,reason} -> :file.format_error(reason) end end def parse(body,a_z_key) do body |> String.replace(~r/\W+/,",") |> String.split(",") |> Enum.slice(1,2000) |> Stream.map(fn x -> String.split(x, "", trim: true) end) |> Enum.map(fn y -> Enum.map(y, fn z -> a_z_key[z] end) |> Enum.reduce(0,fn a,b -> a + b end) end) |> triangle_numbers() end def find([],count,_), do: count def find([word|words],count,tri_nums) when length(words) >= 0 do find(words,triangle?(word,tri_nums,count),tri_nums) end def triangle_numbers(words) do tri_nums = for n <- (1..round(:math.sqrt(Enum.max(words)*2))), do: div(((n*n)+n),2) find(words,0,tri_nums) end def triangle?(word,tri_nums,count) do cond do Enum.member?(tri_nums,word) -> count + 1 true -> count end end end TriangleWords.words("../p042_words.txt",a_z_key) ================================================ FILE: Problem042/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # from functools import wraps from os.path import dirname, join def memo(fn): cache = {} miss = object() @wraps(fn) def wrapper(*args, **kwargs): result = cache.get(args, miss) if result is miss: result = fn(*args) cache[args] = result return result return wrapper def load_words(): with open("../p042_words.txt") as f: words = f.read().strip("\n").split(",") return [x.lower().strip("\"") for x in words] def string_to_num(string): from string import ascii_lowercase as alpha return sum([alpha.index(x) + 1 for x in string]) def triangles(): from itertools import count for n in count(start=1, step=1): yield ((n + 1) * n) // 2 @memo def is_triangle(num): for t in triangles(): if num == t: return True if t > num: return False def solution(): return sum(1 for x in load_words() if is_triangle(string_to_num(x))) if __name__ == '__main__': print(solution()) ================================================ FILE: Problem042/Python/solution_2.py ================================================ #code created by NamanNimmo Gera #8:07pm, April 13, 2019. list = ["A","ABILITY","ABLE","ABOUT","ABOVE","ABSENCE","ABSOLUTELY","ACADEMIC","ACCEPT","ACCESS","ACCIDENT","ACCOMPANY","ACCORDING","ACCOUNT","ACHIEVE","ACHIEVEMENT","ACID","ACQUIRE","ACROSS","ACT","ACTION","ACTIVE","ACTIVITY","ACTUAL","ACTUALLY","ADD","ADDITION","ADDITIONAL","ADDRESS","ADMINISTRATION","ADMIT","ADOPT","ADULT","ADVANCE","ADVANTAGE","ADVICE","ADVISE","AFFAIR","AFFECT","AFFORD","AFRAID","AFTER","AFTERNOON","AFTERWARDS","AGAIN","AGAINST","AGE","AGENCY","AGENT","AGO","AGREE","AGREEMENT","AHEAD","AID","AIM","AIR","AIRCRAFT","ALL","ALLOW","ALMOST","ALONE","ALONG","ALREADY","ALRIGHT","ALSO","ALTERNATIVE","ALTHOUGH","ALWAYS","AMONG","AMONGST","AMOUNT","AN","ANALYSIS","ANCIENT","AND","ANIMAL","ANNOUNCE","ANNUAL","ANOTHER","ANSWER","ANY","ANYBODY","ANYONE","ANYTHING","ANYWAY","APART","APPARENT","APPARENTLY","APPEAL","APPEAR","APPEARANCE","APPLICATION","APPLY","APPOINT","APPOINTMENT","APPROACH","APPROPRIATE","APPROVE","AREA","ARGUE","ARGUMENT","ARISE","ARM","ARMY","AROUND","ARRANGE","ARRANGEMENT","ARRIVE","ART","ARTICLE","ARTIST","AS","ASK","ASPECT","ASSEMBLY","ASSESS","ASSESSMENT","ASSET","ASSOCIATE","ASSOCIATION","ASSUME","ASSUMPTION","AT","ATMOSPHERE","ATTACH","ATTACK","ATTEMPT","ATTEND","ATTENTION","ATTITUDE","ATTRACT","ATTRACTIVE","AUDIENCE","AUTHOR","AUTHORITY","AVAILABLE","AVERAGE","AVOID","AWARD","AWARE","AWAY","AYE","BABY","BACK","BACKGROUND","BAD","BAG","BALANCE","BALL","BAND","BANK","BAR","BASE","BASIC","BASIS","BATTLE","BE","BEAR","BEAT","BEAUTIFUL","BECAUSE","BECOME","BED","BEDROOM","BEFORE","BEGIN","BEGINNING","BEHAVIOUR","BEHIND","BELIEF","BELIEVE","BELONG","BELOW","BENEATH","BENEFIT","BESIDE","BEST","BETTER","BETWEEN","BEYOND","BIG","BILL","BIND","BIRD","BIRTH","BIT","BLACK","BLOCK","BLOOD","BLOODY","BLOW","BLUE","BOARD","BOAT","BODY","BONE","BOOK","BORDER","BOTH","BOTTLE","BOTTOM","BOX","BOY","BRAIN","BRANCH","BREAK","BREATH","BRIDGE","BRIEF","BRIGHT","BRING","BROAD","BROTHER","BUDGET","BUILD","BUILDING","BURN","BUS","BUSINESS","BUSY","BUT","BUY","BY","CABINET","CALL","CAMPAIGN","CAN","CANDIDATE","CAPABLE","CAPACITY","CAPITAL","CAR","CARD","CARE","CAREER","CAREFUL","CAREFULLY","CARRY","CASE","CASH","CAT","CATCH","CATEGORY","CAUSE","CELL","CENTRAL","CENTRE","CENTURY","CERTAIN","CERTAINLY","CHAIN","CHAIR","CHAIRMAN","CHALLENGE","CHANCE","CHANGE","CHANNEL","CHAPTER","CHARACTER","CHARACTERISTIC","CHARGE","CHEAP","CHECK","CHEMICAL","CHIEF","CHILD","CHOICE","CHOOSE","CHURCH","CIRCLE","CIRCUMSTANCE","CITIZEN","CITY","CIVIL","CLAIM","CLASS","CLEAN","CLEAR","CLEARLY","CLIENT","CLIMB","CLOSE","CLOSELY","CLOTHES","CLUB","COAL","CODE","COFFEE","COLD","COLLEAGUE","COLLECT","COLLECTION","COLLEGE","COLOUR","COMBINATION","COMBINE","COME","COMMENT","COMMERCIAL","COMMISSION","COMMIT","COMMITMENT","COMMITTEE","COMMON","COMMUNICATION","COMMUNITY","COMPANY","COMPARE","COMPARISON","COMPETITION","COMPLETE","COMPLETELY","COMPLEX","COMPONENT","COMPUTER","CONCENTRATE","CONCENTRATION","CONCEPT","CONCERN","CONCERNED","CONCLUDE","CONCLUSION","CONDITION","CONDUCT","CONFERENCE","CONFIDENCE","CONFIRM","CONFLICT","CONGRESS","CONNECT","CONNECTION","CONSEQUENCE","CONSERVATIVE","CONSIDER","CONSIDERABLE","CONSIDERATION","CONSIST","CONSTANT","CONSTRUCTION","CONSUMER","CONTACT","CONTAIN","CONTENT","CONTEXT","CONTINUE","CONTRACT","CONTRAST","CONTRIBUTE","CONTRIBUTION","CONTROL","CONVENTION","CONVERSATION","COPY","CORNER","CORPORATE","CORRECT","COS","COST","COULD","COUNCIL","COUNT","COUNTRY","COUNTY","COUPLE","COURSE","COURT","COVER","CREATE","CREATION","CREDIT","CRIME","CRIMINAL","CRISIS","CRITERION","CRITICAL","CRITICISM","CROSS","CROWD","CRY","CULTURAL","CULTURE","CUP","CURRENT","CURRENTLY","CURRICULUM","CUSTOMER","CUT","DAMAGE","DANGER","DANGEROUS","DARK","DATA","DATE","DAUGHTER","DAY","DEAD","DEAL","DEATH","DEBATE","DEBT","DECADE","DECIDE","DECISION","DECLARE","DEEP","DEFENCE","DEFENDANT","DEFINE","DEFINITION","DEGREE","DELIVER","DEMAND","DEMOCRATIC","DEMONSTRATE","DENY","DEPARTMENT","DEPEND","DEPUTY","DERIVE","DESCRIBE","DESCRIPTION","DESIGN","DESIRE","DESK","DESPITE","DESTROY","DETAIL","DETAILED","DETERMINE","DEVELOP","DEVELOPMENT","DEVICE","DIE","DIFFERENCE","DIFFERENT","DIFFICULT","DIFFICULTY","DINNER","DIRECT","DIRECTION","DIRECTLY","DIRECTOR","DISAPPEAR","DISCIPLINE","DISCOVER","DISCUSS","DISCUSSION","DISEASE","DISPLAY","DISTANCE","DISTINCTION","DISTRIBUTION","DISTRICT","DIVIDE","DIVISION","DO","DOCTOR","DOCUMENT","DOG","DOMESTIC","DOOR","DOUBLE","DOUBT","DOWN","DRAW","DRAWING","DREAM","DRESS","DRINK","DRIVE","DRIVER","DROP","DRUG","DRY","DUE","DURING","DUTY","EACH","EAR","EARLY","EARN","EARTH","EASILY","EAST","EASY","EAT","ECONOMIC","ECONOMY","EDGE","EDITOR","EDUCATION","EDUCATIONAL","EFFECT","EFFECTIVE","EFFECTIVELY","EFFORT","EGG","EITHER","ELDERLY","ELECTION","ELEMENT","ELSE","ELSEWHERE","EMERGE","EMPHASIS","EMPLOY","EMPLOYEE","EMPLOYER","EMPLOYMENT","EMPTY","ENABLE","ENCOURAGE","END","ENEMY","ENERGY","ENGINE","ENGINEERING","ENJOY","ENOUGH","ENSURE","ENTER","ENTERPRISE","ENTIRE","ENTIRELY","ENTITLE","ENTRY","ENVIRONMENT","ENVIRONMENTAL","EQUAL","EQUALLY","EQUIPMENT","ERROR","ESCAPE","ESPECIALLY","ESSENTIAL","ESTABLISH","ESTABLISHMENT","ESTATE","ESTIMATE","EVEN","EVENING","EVENT","EVENTUALLY","EVER","EVERY","EVERYBODY","EVERYONE","EVERYTHING","EVIDENCE","EXACTLY","EXAMINATION","EXAMINE","EXAMPLE","EXCELLENT","EXCEPT","EXCHANGE","EXECUTIVE","EXERCISE","EXHIBITION","EXIST","EXISTENCE","EXISTING","EXPECT","EXPECTATION","EXPENDITURE","EXPENSE","EXPENSIVE","EXPERIENCE","EXPERIMENT","EXPERT","EXPLAIN","EXPLANATION","EXPLORE","EXPRESS","EXPRESSION","EXTEND","EXTENT","EXTERNAL","EXTRA","EXTREMELY","EYE","FACE","FACILITY","FACT","FACTOR","FACTORY","FAIL","FAILURE","FAIR","FAIRLY","FAITH","FALL","FAMILIAR","FAMILY","FAMOUS","FAR","FARM","FARMER","FASHION","FAST","FATHER","FAVOUR","FEAR","FEATURE","FEE","FEEL","FEELING","FEMALE","FEW","FIELD","FIGHT","FIGURE","FILE","FILL","FILM","FINAL","FINALLY","FINANCE","FINANCIAL","FIND","FINDING","FINE","FINGER","FINISH","FIRE","FIRM","FIRST","FISH","FIT","FIX","FLAT","FLIGHT","FLOOR","FLOW","FLOWER","FLY","FOCUS","FOLLOW","FOLLOWING","FOOD","FOOT","FOOTBALL","FOR","FORCE","FOREIGN","FOREST","FORGET","FORM","FORMAL","FORMER","FORWARD","FOUNDATION","FREE","FREEDOM","FREQUENTLY","FRESH","FRIEND","FROM","FRONT","FRUIT","FUEL","FULL","FULLY","FUNCTION","FUND","FUNNY","FURTHER","FUTURE","GAIN","GAME","GARDEN","GAS","GATE","GATHER","GENERAL","GENERALLY","GENERATE","GENERATION","GENTLEMAN","GET","GIRL","GIVE","GLASS","GO","GOAL","GOD","GOLD","GOOD","GOVERNMENT","GRANT","GREAT","GREEN","GREY","GROUND","GROUP","GROW","GROWING","GROWTH","GUEST","GUIDE","GUN","HAIR","HALF","HALL","HAND","HANDLE","HANG","HAPPEN","HAPPY","HARD","HARDLY","HATE","HAVE","HE","HEAD","HEALTH","HEAR","HEART","HEAT","HEAVY","HELL","HELP","HENCE","HER","HERE","HERSELF","HIDE","HIGH","HIGHLY","HILL","HIM","HIMSELF","HIS","HISTORICAL","HISTORY","HIT","HOLD","HOLE","HOLIDAY","HOME","HOPE","HORSE","HOSPITAL","HOT","HOTEL","HOUR","HOUSE","HOUSEHOLD","HOUSING","HOW","HOWEVER","HUGE","HUMAN","HURT","HUSBAND","I","IDEA","IDENTIFY","IF","IGNORE","ILLUSTRATE","IMAGE","IMAGINE","IMMEDIATE","IMMEDIATELY","IMPACT","IMPLICATION","IMPLY","IMPORTANCE","IMPORTANT","IMPOSE","IMPOSSIBLE","IMPRESSION","IMPROVE","IMPROVEMENT","IN","INCIDENT","INCLUDE","INCLUDING","INCOME","INCREASE","INCREASED","INCREASINGLY","INDEED","INDEPENDENT","INDEX","INDICATE","INDIVIDUAL","INDUSTRIAL","INDUSTRY","INFLUENCE","INFORM","INFORMATION","INITIAL","INITIATIVE","INJURY","INSIDE","INSIST","INSTANCE","INSTEAD","INSTITUTE","INSTITUTION","INSTRUCTION","INSTRUMENT","INSURANCE","INTEND","INTENTION","INTEREST","INTERESTED","INTERESTING","INTERNAL","INTERNATIONAL","INTERPRETATION","INTERVIEW","INTO","INTRODUCE","INTRODUCTION","INVESTIGATE","INVESTIGATION","INVESTMENT","INVITE","INVOLVE","IRON","IS","ISLAND","ISSUE","IT","ITEM","ITS","ITSELF","JOB","JOIN","JOINT","JOURNEY","JUDGE","JUMP","JUST","JUSTICE","KEEP","KEY","KID","KILL","KIND","KING","KITCHEN","KNEE","KNOW","KNOWLEDGE","LABOUR","LACK","LADY","LAND","LANGUAGE","LARGE","LARGELY","LAST","LATE","LATER","LATTER","LAUGH","LAUNCH","LAW","LAWYER","LAY","LEAD","LEADER","LEADERSHIP","LEADING","LEAF","LEAGUE","LEAN","LEARN","LEAST","LEAVE","LEFT","LEG","LEGAL","LEGISLATION","LENGTH","LESS","LET","LETTER","LEVEL","LIABILITY","LIBERAL","LIBRARY","LIE","LIFE","LIFT","LIGHT","LIKE","LIKELY","LIMIT","LIMITED","LINE","LINK","LIP","LIST","LISTEN","LITERATURE","LITTLE","LIVE","LIVING","LOAN","LOCAL","LOCATION","LONG","LOOK","LORD","LOSE","LOSS","LOT","LOVE","LOVELY","LOW","LUNCH","MACHINE","MAGAZINE","MAIN","MAINLY","MAINTAIN","MAJOR","MAJORITY","MAKE","MALE","MAN","MANAGE","MANAGEMENT","MANAGER","MANNER","MANY","MAP","MARK","MARKET","MARRIAGE","MARRIED","MARRY","MASS","MASTER","MATCH","MATERIAL","MATTER","MAY","MAYBE","ME","MEAL","MEAN","MEANING","MEANS","MEANWHILE","MEASURE","MECHANISM","MEDIA","MEDICAL","MEET","MEETING","MEMBER","MEMBERSHIP","MEMORY","MENTAL","MENTION","MERELY","MESSAGE","METAL","METHOD","MIDDLE","MIGHT","MILE","MILITARY","MILK","MIND","MINE","MINISTER","MINISTRY","MINUTE","MISS","MISTAKE","MODEL","MODERN","MODULE","MOMENT","MONEY","MONTH","MORE","MORNING","MOST","MOTHER","MOTION","MOTOR","MOUNTAIN","MOUTH","MOVE","MOVEMENT","MUCH","MURDER","MUSEUM","MUSIC","MUST","MY","MYSELF","NAME","NARROW","NATION","NATIONAL","NATURAL","NATURE","NEAR","NEARLY","NECESSARILY","NECESSARY","NECK","NEED","NEGOTIATION","NEIGHBOUR","NEITHER","NETWORK","NEVER","NEVERTHELESS","NEW","NEWS","NEWSPAPER","NEXT","NICE","NIGHT","NO","NOBODY","NOD","NOISE","NONE","NOR","NORMAL","NORMALLY","NORTH","NORTHERN","NOSE","NOT","NOTE","NOTHING","NOTICE","NOTION","NOW","NUCLEAR","NUMBER","NURSE","OBJECT","OBJECTIVE","OBSERVATION","OBSERVE","OBTAIN","OBVIOUS","OBVIOUSLY","OCCASION","OCCUR","ODD","OF","OFF","OFFENCE","OFFER","OFFICE","OFFICER","OFFICIAL","OFTEN","OIL","OKAY","OLD","ON","ONCE","ONE","ONLY","ONTO","OPEN","OPERATE","OPERATION","OPINION","OPPORTUNITY","OPPOSITION","OPTION","OR","ORDER","ORDINARY","ORGANISATION","ORGANISE","ORGANIZATION","ORIGIN","ORIGINAL","OTHER","OTHERWISE","OUGHT","OUR","OURSELVES","OUT","OUTCOME","OUTPUT","OUTSIDE","OVER","OVERALL","OWN","OWNER","PACKAGE","PAGE","PAIN","PAINT","PAINTING","PAIR","PANEL","PAPER","PARENT","PARK","PARLIAMENT","PART","PARTICULAR","PARTICULARLY","PARTLY","PARTNER","PARTY","PASS","PASSAGE","PAST","PATH","PATIENT","PATTERN","PAY","PAYMENT","PEACE","PENSION","PEOPLE","PER","PERCENT","PERFECT","PERFORM","PERFORMANCE","PERHAPS","PERIOD","PERMANENT","PERSON","PERSONAL","PERSUADE","PHASE","PHONE","PHOTOGRAPH","PHYSICAL","PICK","PICTURE","PIECE","PLACE","PLAN","PLANNING","PLANT","PLASTIC","PLATE","PLAY","PLAYER","PLEASE","PLEASURE","PLENTY","PLUS","POCKET","POINT","POLICE","POLICY","POLITICAL","POLITICS","POOL","POOR","POPULAR","POPULATION","POSITION","POSITIVE","POSSIBILITY","POSSIBLE","POSSIBLY","POST","POTENTIAL","POUND","POWER","POWERFUL","PRACTICAL","PRACTICE","PREFER","PREPARE","PRESENCE","PRESENT","PRESIDENT","PRESS","PRESSURE","PRETTY","PREVENT","PREVIOUS","PREVIOUSLY","PRICE","PRIMARY","PRIME","PRINCIPLE","PRIORITY","PRISON","PRISONER","PRIVATE","PROBABLY","PROBLEM","PROCEDURE","PROCESS","PRODUCE","PRODUCT","PRODUCTION","PROFESSIONAL","PROFIT","PROGRAM","PROGRAMME","PROGRESS","PROJECT","PROMISE","PROMOTE","PROPER","PROPERLY","PROPERTY","PROPORTION","PROPOSE","PROPOSAL","PROSPECT","PROTECT","PROTECTION","PROVE","PROVIDE","PROVIDED","PROVISION","PUB","PUBLIC","PUBLICATION","PUBLISH","PULL","PUPIL","PURPOSE","PUSH","PUT","QUALITY","QUARTER","QUESTION","QUICK","QUICKLY","QUIET","QUITE","RACE","RADIO","RAILWAY","RAIN","RAISE","RANGE","RAPIDLY","RARE","RATE","RATHER","REACH","REACTION","READ","READER","READING","READY","REAL","REALISE","REALITY","REALIZE","REALLY","REASON","REASONABLE","RECALL","RECEIVE","RECENT","RECENTLY","RECOGNISE","RECOGNITION","RECOGNIZE","RECOMMEND","RECORD","RECOVER","RED","REDUCE","REDUCTION","REFER","REFERENCE","REFLECT","REFORM","REFUSE","REGARD","REGION","REGIONAL","REGULAR","REGULATION","REJECT","RELATE","RELATION","RELATIONSHIP","RELATIVE","RELATIVELY","RELEASE","RELEVANT","RELIEF","RELIGION","RELIGIOUS","RELY","REMAIN","REMEMBER","REMIND","REMOVE","REPEAT","REPLACE","REPLY","REPORT","REPRESENT","REPRESENTATION","REPRESENTATIVE","REQUEST","REQUIRE","REQUIREMENT","RESEARCH","RESOURCE","RESPECT","RESPOND","RESPONSE","RESPONSIBILITY","RESPONSIBLE","REST","RESTAURANT","RESULT","RETAIN","RETURN","REVEAL","REVENUE","REVIEW","REVOLUTION","RICH","RIDE","RIGHT","RING","RISE","RISK","RIVER","ROAD","ROCK","ROLE","ROLL","ROOF","ROOM","ROUND","ROUTE","ROW","ROYAL","RULE","RUN","RURAL","SAFE","SAFETY","SALE","SAME","SAMPLE","SATISFY","SAVE","SAY","SCALE","SCENE","SCHEME","SCHOOL","SCIENCE","SCIENTIFIC","SCIENTIST","SCORE","SCREEN","SEA","SEARCH","SEASON","SEAT","SECOND","SECONDARY","SECRETARY","SECTION","SECTOR","SECURE","SECURITY","SEE","SEEK","SEEM","SELECT","SELECTION","SELL","SEND","SENIOR","SENSE","SENTENCE","SEPARATE","SEQUENCE","SERIES","SERIOUS","SERIOUSLY","SERVANT","SERVE","SERVICE","SESSION","SET","SETTLE","SETTLEMENT","SEVERAL","SEVERE","SEX","SEXUAL","SHAKE","SHALL","SHAPE","SHARE","SHE","SHEET","SHIP","SHOE","SHOOT","SHOP","SHORT","SHOT","SHOULD","SHOULDER","SHOUT","SHOW","SHUT","SIDE","SIGHT","SIGN","SIGNAL","SIGNIFICANCE","SIGNIFICANT","SILENCE","SIMILAR","SIMPLE","SIMPLY","SINCE","SING","SINGLE","SIR","SISTER","SIT","SITE","SITUATION","SIZE","SKILL","SKIN","SKY","SLEEP","SLIGHTLY","SLIP","SLOW","SLOWLY","SMALL","SMILE","SO","SOCIAL","SOCIETY","SOFT","SOFTWARE","SOIL","SOLDIER","SOLICITOR","SOLUTION","SOME","SOMEBODY","SOMEONE","SOMETHING","SOMETIMES","SOMEWHAT","SOMEWHERE","SON","SONG","SOON","SORRY","SORT","SOUND","SOURCE","SOUTH","SOUTHERN","SPACE","SPEAK","SPEAKER","SPECIAL","SPECIES","SPECIFIC","SPEECH","SPEED","SPEND","SPIRIT","SPORT","SPOT","SPREAD","SPRING","STAFF","STAGE","STAND","STANDARD","STAR","START","STATE","STATEMENT","STATION","STATUS","STAY","STEAL","STEP","STICK","STILL","STOCK","STONE","STOP","STORE","STORY","STRAIGHT","STRANGE","STRATEGY","STREET","STRENGTH","STRIKE","STRONG","STRONGLY","STRUCTURE","STUDENT","STUDIO","STUDY","STUFF","STYLE","SUBJECT","SUBSTANTIAL","SUCCEED","SUCCESS","SUCCESSFUL","SUCH","SUDDENLY","SUFFER","SUFFICIENT","SUGGEST","SUGGESTION","SUITABLE","SUM","SUMMER","SUN","SUPPLY","SUPPORT","SUPPOSE","SURE","SURELY","SURFACE","SURPRISE","SURROUND","SURVEY","SURVIVE","SWITCH","SYSTEM","TABLE","TAKE","TALK","TALL","TAPE","TARGET","TASK","TAX","TEA","TEACH","TEACHER","TEACHING","TEAM","TEAR","TECHNICAL","TECHNIQUE","TECHNOLOGY","TELEPHONE","TELEVISION","TELL","TEMPERATURE","TEND","TERM","TERMS","TERRIBLE","TEST","TEXT","THAN","THANK","THANKS","THAT","THE","THEATRE","THEIR","THEM","THEME","THEMSELVES","THEN","THEORY","THERE","THEREFORE","THESE","THEY","THIN","THING","THINK","THIS","THOSE","THOUGH","THOUGHT","THREAT","THREATEN","THROUGH","THROUGHOUT","THROW","THUS","TICKET","TIME","TINY","TITLE","TO","TODAY","TOGETHER","TOMORROW","TONE","TONIGHT","TOO","TOOL","TOOTH","TOP","TOTAL","TOTALLY","TOUCH","TOUR","TOWARDS","TOWN","TRACK","TRADE","TRADITION","TRADITIONAL","TRAFFIC","TRAIN","TRAINING","TRANSFER","TRANSPORT","TRAVEL","TREAT","TREATMENT","TREATY","TREE","TREND","TRIAL","TRIP","TROOP","TROUBLE","TRUE","TRUST","TRUTH","TRY","TURN","TWICE","TYPE","TYPICAL","UNABLE","UNDER","UNDERSTAND","UNDERSTANDING","UNDERTAKE","UNEMPLOYMENT","UNFORTUNATELY","UNION","UNIT","UNITED","UNIVERSITY","UNLESS","UNLIKELY","UNTIL","UP","UPON","UPPER","URBAN","US","USE","USED","USEFUL","USER","USUAL","USUALLY","VALUE","VARIATION","VARIETY","VARIOUS","VARY","VAST","VEHICLE","VERSION","VERY","VIA","VICTIM","VICTORY","VIDEO","VIEW","VILLAGE","VIOLENCE","VISION","VISIT","VISITOR","VITAL","VOICE","VOLUME","VOTE","WAGE","WAIT","WALK","WALL","WANT","WAR","WARM","WARN","WASH","WATCH","WATER","WAVE","WAY","WE","WEAK","WEAPON","WEAR","WEATHER","WEEK","WEEKEND","WEIGHT","WELCOME","WELFARE","WELL","WEST","WESTERN","WHAT","WHATEVER","WHEN","WHERE","WHEREAS","WHETHER","WHICH","WHILE","WHILST","WHITE","WHO","WHOLE","WHOM","WHOSE","WHY","WIDE","WIDELY","WIFE","WILD","WILL","WIN","WIND","WINDOW","WINE","WING","WINNER","WINTER","WISH","WITH","WITHDRAW","WITHIN","WITHOUT","WOMAN","WONDER","WONDERFUL","WOOD","WORD","WORK","WORKER","WORKING","WORKS","WORLD","WORRY","WORTH","WOULD","WRITE","WRITER","WRITING","WRONG","YARD","YEAH","YEAR","YES","YESTERDAY","YET","YOU","YOUNG","YOUR","YOURSELF","YOUTH"] newlist = [] for j in range(1,1000): #precomputing the values and appending into a list newlist.append((j*(j+1))/2) tot=0 #this will be our final answer below for i in list: summ = 0 for j in i: summ = summ + (ord(str(j))-64) if summ in newlist: tot = tot + 1 print(tot) ================================================ FILE: Problem042/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=42) ================================================ FILE: Problem042/p042_words.txt ================================================ "A","ABILITY","ABLE","ABOUT","ABOVE","ABSENCE","ABSOLUTELY","ACADEMIC","ACCEPT","ACCESS","ACCIDENT","ACCOMPANY","ACCORDING","ACCOUNT","ACHIEVE","ACHIEVEMENT","ACID","ACQUIRE","ACROSS","ACT","ACTION","ACTIVE","ACTIVITY","ACTUAL","ACTUALLY","ADD","ADDITION","ADDITIONAL","ADDRESS","ADMINISTRATION","ADMIT","ADOPT","ADULT","ADVANCE","ADVANTAGE","ADVICE","ADVISE","AFFAIR","AFFECT","AFFORD","AFRAID","AFTER","AFTERNOON","AFTERWARDS","AGAIN","AGAINST","AGE","AGENCY","AGENT","AGO","AGREE","AGREEMENT","AHEAD","AID","AIM","AIR","AIRCRAFT","ALL","ALLOW","ALMOST","ALONE","ALONG","ALREADY","ALRIGHT","ALSO","ALTERNATIVE","ALTHOUGH","ALWAYS","AMONG","AMONGST","AMOUNT","AN","ANALYSIS","ANCIENT","AND","ANIMAL","ANNOUNCE","ANNUAL","ANOTHER","ANSWER","ANY","ANYBODY","ANYONE","ANYTHING","ANYWAY","APART","APPARENT","APPARENTLY","APPEAL","APPEAR","APPEARANCE","APPLICATION","APPLY","APPOINT","APPOINTMENT","APPROACH","APPROPRIATE","APPROVE","AREA","ARGUE","ARGUMENT","ARISE","ARM","ARMY","AROUND","ARRANGE","ARRANGEMENT","ARRIVE","ART","ARTICLE","ARTIST","AS","ASK","ASPECT","ASSEMBLY","ASSESS","ASSESSMENT","ASSET","ASSOCIATE","ASSOCIATION","ASSUME","ASSUMPTION","AT","ATMOSPHERE","ATTACH","ATTACK","ATTEMPT","ATTEND","ATTENTION","ATTITUDE","ATTRACT","ATTRACTIVE","AUDIENCE","AUTHOR","AUTHORITY","AVAILABLE","AVERAGE","AVOID","AWARD","AWARE","AWAY","AYE","BABY","BACK","BACKGROUND","BAD","BAG","BALANCE","BALL","BAND","BANK","BAR","BASE","BASIC","BASIS","BATTLE","BE","BEAR","BEAT","BEAUTIFUL","BECAUSE","BECOME","BED","BEDROOM","BEFORE","BEGIN","BEGINNING","BEHAVIOUR","BEHIND","BELIEF","BELIEVE","BELONG","BELOW","BENEATH","BENEFIT","BESIDE","BEST","BETTER","BETWEEN","BEYOND","BIG","BILL","BIND","BIRD","BIRTH","BIT","BLACK","BLOCK","BLOOD","BLOODY","BLOW","BLUE","BOARD","BOAT","BODY","BONE","BOOK","BORDER","BOTH","BOTTLE","BOTTOM","BOX","BOY","BRAIN","BRANCH","BREAK","BREATH","BRIDGE","BRIEF","BRIGHT","BRING","BROAD","BROTHER","BUDGET","BUILD","BUILDING","BURN","BUS","BUSINESS","BUSY","BUT","BUY","BY","CABINET","CALL","CAMPAIGN","CAN","CANDIDATE","CAPABLE","CAPACITY","CAPITAL","CAR","CARD","CARE","CAREER","CAREFUL","CAREFULLY","CARRY","CASE","CASH","CAT","CATCH","CATEGORY","CAUSE","CELL","CENTRAL","CENTRE","CENTURY","CERTAIN","CERTAINLY","CHAIN","CHAIR","CHAIRMAN","CHALLENGE","CHANCE","CHANGE","CHANNEL","CHAPTER","CHARACTER","CHARACTERISTIC","CHARGE","CHEAP","CHECK","CHEMICAL","CHIEF","CHILD","CHOICE","CHOOSE","CHURCH","CIRCLE","CIRCUMSTANCE","CITIZEN","CITY","CIVIL","CLAIM","CLASS","CLEAN","CLEAR","CLEARLY","CLIENT","CLIMB","CLOSE","CLOSELY","CLOTHES","CLUB","COAL","CODE","COFFEE","COLD","COLLEAGUE","COLLECT","COLLECTION","COLLEGE","COLOUR","COMBINATION","COMBINE","COME","COMMENT","COMMERCIAL","COMMISSION","COMMIT","COMMITMENT","COMMITTEE","COMMON","COMMUNICATION","COMMUNITY","COMPANY","COMPARE","COMPARISON","COMPETITION","COMPLETE","COMPLETELY","COMPLEX","COMPONENT","COMPUTER","CONCENTRATE","CONCENTRATION","CONCEPT","CONCERN","CONCERNED","CONCLUDE","CONCLUSION","CONDITION","CONDUCT","CONFERENCE","CONFIDENCE","CONFIRM","CONFLICT","CONGRESS","CONNECT","CONNECTION","CONSEQUENCE","CONSERVATIVE","CONSIDER","CONSIDERABLE","CONSIDERATION","CONSIST","CONSTANT","CONSTRUCTION","CONSUMER","CONTACT","CONTAIN","CONTENT","CONTEXT","CONTINUE","CONTRACT","CONTRAST","CONTRIBUTE","CONTRIBUTION","CONTROL","CONVENTION","CONVERSATION","COPY","CORNER","CORPORATE","CORRECT","COS","COST","COULD","COUNCIL","COUNT","COUNTRY","COUNTY","COUPLE","COURSE","COURT","COVER","CREATE","CREATION","CREDIT","CRIME","CRIMINAL","CRISIS","CRITERION","CRITICAL","CRITICISM","CROSS","CROWD","CRY","CULTURAL","CULTURE","CUP","CURRENT","CURRENTLY","CURRICULUM","CUSTOMER","CUT","DAMAGE","DANGER","DANGEROUS","DARK","DATA","DATE","DAUGHTER","DAY","DEAD","DEAL","DEATH","DEBATE","DEBT","DECADE","DECIDE","DECISION","DECLARE","DEEP","DEFENCE","DEFENDANT","DEFINE","DEFINITION","DEGREE","DELIVER","DEMAND","DEMOCRATIC","DEMONSTRATE","DENY","DEPARTMENT","DEPEND","DEPUTY","DERIVE","DESCRIBE","DESCRIPTION","DESIGN","DESIRE","DESK","DESPITE","DESTROY","DETAIL","DETAILED","DETERMINE","DEVELOP","DEVELOPMENT","DEVICE","DIE","DIFFERENCE","DIFFERENT","DIFFICULT","DIFFICULTY","DINNER","DIRECT","DIRECTION","DIRECTLY","DIRECTOR","DISAPPEAR","DISCIPLINE","DISCOVER","DISCUSS","DISCUSSION","DISEASE","DISPLAY","DISTANCE","DISTINCTION","DISTRIBUTION","DISTRICT","DIVIDE","DIVISION","DO","DOCTOR","DOCUMENT","DOG","DOMESTIC","DOOR","DOUBLE","DOUBT","DOWN","DRAW","DRAWING","DREAM","DRESS","DRINK","DRIVE","DRIVER","DROP","DRUG","DRY","DUE","DURING","DUTY","EACH","EAR","EARLY","EARN","EARTH","EASILY","EAST","EASY","EAT","ECONOMIC","ECONOMY","EDGE","EDITOR","EDUCATION","EDUCATIONAL","EFFECT","EFFECTIVE","EFFECTIVELY","EFFORT","EGG","EITHER","ELDERLY","ELECTION","ELEMENT","ELSE","ELSEWHERE","EMERGE","EMPHASIS","EMPLOY","EMPLOYEE","EMPLOYER","EMPLOYMENT","EMPTY","ENABLE","ENCOURAGE","END","ENEMY","ENERGY","ENGINE","ENGINEERING","ENJOY","ENOUGH","ENSURE","ENTER","ENTERPRISE","ENTIRE","ENTIRELY","ENTITLE","ENTRY","ENVIRONMENT","ENVIRONMENTAL","EQUAL","EQUALLY","EQUIPMENT","ERROR","ESCAPE","ESPECIALLY","ESSENTIAL","ESTABLISH","ESTABLISHMENT","ESTATE","ESTIMATE","EVEN","EVENING","EVENT","EVENTUALLY","EVER","EVERY","EVERYBODY","EVERYONE","EVERYTHING","EVIDENCE","EXACTLY","EXAMINATION","EXAMINE","EXAMPLE","EXCELLENT","EXCEPT","EXCHANGE","EXECUTIVE","EXERCISE","EXHIBITION","EXIST","EXISTENCE","EXISTING","EXPECT","EXPECTATION","EXPENDITURE","EXPENSE","EXPENSIVE","EXPERIENCE","EXPERIMENT","EXPERT","EXPLAIN","EXPLANATION","EXPLORE","EXPRESS","EXPRESSION","EXTEND","EXTENT","EXTERNAL","EXTRA","EXTREMELY","EYE","FACE","FACILITY","FACT","FACTOR","FACTORY","FAIL","FAILURE","FAIR","FAIRLY","FAITH","FALL","FAMILIAR","FAMILY","FAMOUS","FAR","FARM","FARMER","FASHION","FAST","FATHER","FAVOUR","FEAR","FEATURE","FEE","FEEL","FEELING","FEMALE","FEW","FIELD","FIGHT","FIGURE","FILE","FILL","FILM","FINAL","FINALLY","FINANCE","FINANCIAL","FIND","FINDING","FINE","FINGER","FINISH","FIRE","FIRM","FIRST","FISH","FIT","FIX","FLAT","FLIGHT","FLOOR","FLOW","FLOWER","FLY","FOCUS","FOLLOW","FOLLOWING","FOOD","FOOT","FOOTBALL","FOR","FORCE","FOREIGN","FOREST","FORGET","FORM","FORMAL","FORMER","FORWARD","FOUNDATION","FREE","FREEDOM","FREQUENTLY","FRESH","FRIEND","FROM","FRONT","FRUIT","FUEL","FULL","FULLY","FUNCTION","FUND","FUNNY","FURTHER","FUTURE","GAIN","GAME","GARDEN","GAS","GATE","GATHER","GENERAL","GENERALLY","GENERATE","GENERATION","GENTLEMAN","GET","GIRL","GIVE","GLASS","GO","GOAL","GOD","GOLD","GOOD","GOVERNMENT","GRANT","GREAT","GREEN","GREY","GROUND","GROUP","GROW","GROWING","GROWTH","GUEST","GUIDE","GUN","HAIR","HALF","HALL","HAND","HANDLE","HANG","HAPPEN","HAPPY","HARD","HARDLY","HATE","HAVE","HE","HEAD","HEALTH","HEAR","HEART","HEAT","HEAVY","HELL","HELP","HENCE","HER","HERE","HERSELF","HIDE","HIGH","HIGHLY","HILL","HIM","HIMSELF","HIS","HISTORICAL","HISTORY","HIT","HOLD","HOLE","HOLIDAY","HOME","HOPE","HORSE","HOSPITAL","HOT","HOTEL","HOUR","HOUSE","HOUSEHOLD","HOUSING","HOW","HOWEVER","HUGE","HUMAN","HURT","HUSBAND","I","IDEA","IDENTIFY","IF","IGNORE","ILLUSTRATE","IMAGE","IMAGINE","IMMEDIATE","IMMEDIATELY","IMPACT","IMPLICATION","IMPLY","IMPORTANCE","IMPORTANT","IMPOSE","IMPOSSIBLE","IMPRESSION","IMPROVE","IMPROVEMENT","IN","INCIDENT","INCLUDE","INCLUDING","INCOME","INCREASE","INCREASED","INCREASINGLY","INDEED","INDEPENDENT","INDEX","INDICATE","INDIVIDUAL","INDUSTRIAL","INDUSTRY","INFLUENCE","INFORM","INFORMATION","INITIAL","INITIATIVE","INJURY","INSIDE","INSIST","INSTANCE","INSTEAD","INSTITUTE","INSTITUTION","INSTRUCTION","INSTRUMENT","INSURANCE","INTEND","INTENTION","INTEREST","INTERESTED","INTERESTING","INTERNAL","INTERNATIONAL","INTERPRETATION","INTERVIEW","INTO","INTRODUCE","INTRODUCTION","INVESTIGATE","INVESTIGATION","INVESTMENT","INVITE","INVOLVE","IRON","IS","ISLAND","ISSUE","IT","ITEM","ITS","ITSELF","JOB","JOIN","JOINT","JOURNEY","JUDGE","JUMP","JUST","JUSTICE","KEEP","KEY","KID","KILL","KIND","KING","KITCHEN","KNEE","KNOW","KNOWLEDGE","LABOUR","LACK","LADY","LAND","LANGUAGE","LARGE","LARGELY","LAST","LATE","LATER","LATTER","LAUGH","LAUNCH","LAW","LAWYER","LAY","LEAD","LEADER","LEADERSHIP","LEADING","LEAF","LEAGUE","LEAN","LEARN","LEAST","LEAVE","LEFT","LEG","LEGAL","LEGISLATION","LENGTH","LESS","LET","LETTER","LEVEL","LIABILITY","LIBERAL","LIBRARY","LIE","LIFE","LIFT","LIGHT","LIKE","LIKELY","LIMIT","LIMITED","LINE","LINK","LIP","LIST","LISTEN","LITERATURE","LITTLE","LIVE","LIVING","LOAN","LOCAL","LOCATION","LONG","LOOK","LORD","LOSE","LOSS","LOT","LOVE","LOVELY","LOW","LUNCH","MACHINE","MAGAZINE","MAIN","MAINLY","MAINTAIN","MAJOR","MAJORITY","MAKE","MALE","MAN","MANAGE","MANAGEMENT","MANAGER","MANNER","MANY","MAP","MARK","MARKET","MARRIAGE","MARRIED","MARRY","MASS","MASTER","MATCH","MATERIAL","MATTER","MAY","MAYBE","ME","MEAL","MEAN","MEANING","MEANS","MEANWHILE","MEASURE","MECHANISM","MEDIA","MEDICAL","MEET","MEETING","MEMBER","MEMBERSHIP","MEMORY","MENTAL","MENTION","MERELY","MESSAGE","METAL","METHOD","MIDDLE","MIGHT","MILE","MILITARY","MILK","MIND","MINE","MINISTER","MINISTRY","MINUTE","MISS","MISTAKE","MODEL","MODERN","MODULE","MOMENT","MONEY","MONTH","MORE","MORNING","MOST","MOTHER","MOTION","MOTOR","MOUNTAIN","MOUTH","MOVE","MOVEMENT","MUCH","MURDER","MUSEUM","MUSIC","MUST","MY","MYSELF","NAME","NARROW","NATION","NATIONAL","NATURAL","NATURE","NEAR","NEARLY","NECESSARILY","NECESSARY","NECK","NEED","NEGOTIATION","NEIGHBOUR","NEITHER","NETWORK","NEVER","NEVERTHELESS","NEW","NEWS","NEWSPAPER","NEXT","NICE","NIGHT","NO","NOBODY","NOD","NOISE","NONE","NOR","NORMAL","NORMALLY","NORTH","NORTHERN","NOSE","NOT","NOTE","NOTHING","NOTICE","NOTION","NOW","NUCLEAR","NUMBER","NURSE","OBJECT","OBJECTIVE","OBSERVATION","OBSERVE","OBTAIN","OBVIOUS","OBVIOUSLY","OCCASION","OCCUR","ODD","OF","OFF","OFFENCE","OFFER","OFFICE","OFFICER","OFFICIAL","OFTEN","OIL","OKAY","OLD","ON","ONCE","ONE","ONLY","ONTO","OPEN","OPERATE","OPERATION","OPINION","OPPORTUNITY","OPPOSITION","OPTION","OR","ORDER","ORDINARY","ORGANISATION","ORGANISE","ORGANIZATION","ORIGIN","ORIGINAL","OTHER","OTHERWISE","OUGHT","OUR","OURSELVES","OUT","OUTCOME","OUTPUT","OUTSIDE","OVER","OVERALL","OWN","OWNER","PACKAGE","PAGE","PAIN","PAINT","PAINTING","PAIR","PANEL","PAPER","PARENT","PARK","PARLIAMENT","PART","PARTICULAR","PARTICULARLY","PARTLY","PARTNER","PARTY","PASS","PASSAGE","PAST","PATH","PATIENT","PATTERN","PAY","PAYMENT","PEACE","PENSION","PEOPLE","PER","PERCENT","PERFECT","PERFORM","PERFORMANCE","PERHAPS","PERIOD","PERMANENT","PERSON","PERSONAL","PERSUADE","PHASE","PHONE","PHOTOGRAPH","PHYSICAL","PICK","PICTURE","PIECE","PLACE","PLAN","PLANNING","PLANT","PLASTIC","PLATE","PLAY","PLAYER","PLEASE","PLEASURE","PLENTY","PLUS","POCKET","POINT","POLICE","POLICY","POLITICAL","POLITICS","POOL","POOR","POPULAR","POPULATION","POSITION","POSITIVE","POSSIBILITY","POSSIBLE","POSSIBLY","POST","POTENTIAL","POUND","POWER","POWERFUL","PRACTICAL","PRACTICE","PREFER","PREPARE","PRESENCE","PRESENT","PRESIDENT","PRESS","PRESSURE","PRETTY","PREVENT","PREVIOUS","PREVIOUSLY","PRICE","PRIMARY","PRIME","PRINCIPLE","PRIORITY","PRISON","PRISONER","PRIVATE","PROBABLY","PROBLEM","PROCEDURE","PROCESS","PRODUCE","PRODUCT","PRODUCTION","PROFESSIONAL","PROFIT","PROGRAM","PROGRAMME","PROGRESS","PROJECT","PROMISE","PROMOTE","PROPER","PROPERLY","PROPERTY","PROPORTION","PROPOSE","PROPOSAL","PROSPECT","PROTECT","PROTECTION","PROVE","PROVIDE","PROVIDED","PROVISION","PUB","PUBLIC","PUBLICATION","PUBLISH","PULL","PUPIL","PURPOSE","PUSH","PUT","QUALITY","QUARTER","QUESTION","QUICK","QUICKLY","QUIET","QUITE","RACE","RADIO","RAILWAY","RAIN","RAISE","RANGE","RAPIDLY","RARE","RATE","RATHER","REACH","REACTION","READ","READER","READING","READY","REAL","REALISE","REALITY","REALIZE","REALLY","REASON","REASONABLE","RECALL","RECEIVE","RECENT","RECENTLY","RECOGNISE","RECOGNITION","RECOGNIZE","RECOMMEND","RECORD","RECOVER","RED","REDUCE","REDUCTION","REFER","REFERENCE","REFLECT","REFORM","REFUSE","REGARD","REGION","REGIONAL","REGULAR","REGULATION","REJECT","RELATE","RELATION","RELATIONSHIP","RELATIVE","RELATIVELY","RELEASE","RELEVANT","RELIEF","RELIGION","RELIGIOUS","RELY","REMAIN","REMEMBER","REMIND","REMOVE","REPEAT","REPLACE","REPLY","REPORT","REPRESENT","REPRESENTATION","REPRESENTATIVE","REQUEST","REQUIRE","REQUIREMENT","RESEARCH","RESOURCE","RESPECT","RESPOND","RESPONSE","RESPONSIBILITY","RESPONSIBLE","REST","RESTAURANT","RESULT","RETAIN","RETURN","REVEAL","REVENUE","REVIEW","REVOLUTION","RICH","RIDE","RIGHT","RING","RISE","RISK","RIVER","ROAD","ROCK","ROLE","ROLL","ROOF","ROOM","ROUND","ROUTE","ROW","ROYAL","RULE","RUN","RURAL","SAFE","SAFETY","SALE","SAME","SAMPLE","SATISFY","SAVE","SAY","SCALE","SCENE","SCHEME","SCHOOL","SCIENCE","SCIENTIFIC","SCIENTIST","SCORE","SCREEN","SEA","SEARCH","SEASON","SEAT","SECOND","SECONDARY","SECRETARY","SECTION","SECTOR","SECURE","SECURITY","SEE","SEEK","SEEM","SELECT","SELECTION","SELL","SEND","SENIOR","SENSE","SENTENCE","SEPARATE","SEQUENCE","SERIES","SERIOUS","SERIOUSLY","SERVANT","SERVE","SERVICE","SESSION","SET","SETTLE","SETTLEMENT","SEVERAL","SEVERE","SEX","SEXUAL","SHAKE","SHALL","SHAPE","SHARE","SHE","SHEET","SHIP","SHOE","SHOOT","SHOP","SHORT","SHOT","SHOULD","SHOULDER","SHOUT","SHOW","SHUT","SIDE","SIGHT","SIGN","SIGNAL","SIGNIFICANCE","SIGNIFICANT","SILENCE","SIMILAR","SIMPLE","SIMPLY","SINCE","SING","SINGLE","SIR","SISTER","SIT","SITE","SITUATION","SIZE","SKILL","SKIN","SKY","SLEEP","SLIGHTLY","SLIP","SLOW","SLOWLY","SMALL","SMILE","SO","SOCIAL","SOCIETY","SOFT","SOFTWARE","SOIL","SOLDIER","SOLICITOR","SOLUTION","SOME","SOMEBODY","SOMEONE","SOMETHING","SOMETIMES","SOMEWHAT","SOMEWHERE","SON","SONG","SOON","SORRY","SORT","SOUND","SOURCE","SOUTH","SOUTHERN","SPACE","SPEAK","SPEAKER","SPECIAL","SPECIES","SPECIFIC","SPEECH","SPEED","SPEND","SPIRIT","SPORT","SPOT","SPREAD","SPRING","STAFF","STAGE","STAND","STANDARD","STAR","START","STATE","STATEMENT","STATION","STATUS","STAY","STEAL","STEP","STICK","STILL","STOCK","STONE","STOP","STORE","STORY","STRAIGHT","STRANGE","STRATEGY","STREET","STRENGTH","STRIKE","STRONG","STRONGLY","STRUCTURE","STUDENT","STUDIO","STUDY","STUFF","STYLE","SUBJECT","SUBSTANTIAL","SUCCEED","SUCCESS","SUCCESSFUL","SUCH","SUDDENLY","SUFFER","SUFFICIENT","SUGGEST","SUGGESTION","SUITABLE","SUM","SUMMER","SUN","SUPPLY","SUPPORT","SUPPOSE","SURE","SURELY","SURFACE","SURPRISE","SURROUND","SURVEY","SURVIVE","SWITCH","SYSTEM","TABLE","TAKE","TALK","TALL","TAPE","TARGET","TASK","TAX","TEA","TEACH","TEACHER","TEACHING","TEAM","TEAR","TECHNICAL","TECHNIQUE","TECHNOLOGY","TELEPHONE","TELEVISION","TELL","TEMPERATURE","TEND","TERM","TERMS","TERRIBLE","TEST","TEXT","THAN","THANK","THANKS","THAT","THE","THEATRE","THEIR","THEM","THEME","THEMSELVES","THEN","THEORY","THERE","THEREFORE","THESE","THEY","THIN","THING","THINK","THIS","THOSE","THOUGH","THOUGHT","THREAT","THREATEN","THROUGH","THROUGHOUT","THROW","THUS","TICKET","TIME","TINY","TITLE","TO","TODAY","TOGETHER","TOMORROW","TONE","TONIGHT","TOO","TOOL","TOOTH","TOP","TOTAL","TOTALLY","TOUCH","TOUR","TOWARDS","TOWN","TRACK","TRADE","TRADITION","TRADITIONAL","TRAFFIC","TRAIN","TRAINING","TRANSFER","TRANSPORT","TRAVEL","TREAT","TREATMENT","TREATY","TREE","TREND","TRIAL","TRIP","TROOP","TROUBLE","TRUE","TRUST","TRUTH","TRY","TURN","TWICE","TYPE","TYPICAL","UNABLE","UNDER","UNDERSTAND","UNDERSTANDING","UNDERTAKE","UNEMPLOYMENT","UNFORTUNATELY","UNION","UNIT","UNITED","UNIVERSITY","UNLESS","UNLIKELY","UNTIL","UP","UPON","UPPER","URBAN","US","USE","USED","USEFUL","USER","USUAL","USUALLY","VALUE","VARIATION","VARIETY","VARIOUS","VARY","VAST","VEHICLE","VERSION","VERY","VIA","VICTIM","VICTORY","VIDEO","VIEW","VILLAGE","VIOLENCE","VISION","VISIT","VISITOR","VITAL","VOICE","VOLUME","VOTE","WAGE","WAIT","WALK","WALL","WANT","WAR","WARM","WARN","WASH","WATCH","WATER","WAVE","WAY","WE","WEAK","WEAPON","WEAR","WEATHER","WEEK","WEEKEND","WEIGHT","WELCOME","WELFARE","WELL","WEST","WESTERN","WHAT","WHATEVER","WHEN","WHERE","WHEREAS","WHETHER","WHICH","WHILE","WHILST","WHITE","WHO","WHOLE","WHOM","WHOSE","WHY","WIDE","WIDELY","WIFE","WILD","WILL","WIN","WIND","WINDOW","WINE","WING","WINNER","WINTER","WISH","WITH","WITHDRAW","WITHIN","WITHOUT","WOMAN","WONDER","WONDERFUL","WOOD","WORD","WORK","WORKER","WORKING","WORKS","WORLD","WORRY","WORTH","WOULD","WRITE","WRITER","WRITING","WRONG","YARD","YEAH","YEAR","YES","YESTERDAY","YET","YOU","YOUNG","YOUR","YOURSELF","YOUTH" ================================================ FILE: Problem043/.hash ================================================ 115253b7721af0fdff25cd391dfc70cf ================================================ FILE: Problem043/CommonLisp/solution_1.lisp ================================================ ;; Common Lisp Script ;; Manoel Vilela ;; Based on my own solution for Problem041 ;; borrowed functions: next-perm, primep, vec->int ;; next lexicographical permutation of a vector ;; borrowed from http://rosettacode.org/wiki/Permutations#Common_Lisp ;; (next-perm #(9 8 7 6 5 4 3 2 1)) => #(9 8 7 6 5 4 3 1 2) (defun next-perm (vec &optional (cmp '>)) ; modify vector (declare (type (simple-array * (*)) vec)) (macrolet ((el (i) `(aref vec ,i)) (cmp (i j) `(funcall cmp (el ,i) (el ,j)))) (loop with len = (1- (length vec)) for i from (1- len) downto 0 when (cmp i (1+ i)) do (loop for k from len downto i when (cmp i k) do (rotatef (el i) (el k)) (setf k (1+ len)) (loop while (< (incf i) (decf k)) do (rotatef (el i) (el k))) (return-from next-perm vec))))) ;; check if n is prime (defun primep (n) (loop for d from 2 to (1+ (isqrt n)) never (and (= (mod n d) 0) (/= n d)))) ;; vector of digits => integer ;; (vec->int #(9 8 7 6 5 4 3 2 1)) => 987654321 (defun vec->int (vec) (loop for d across vec for pos from (1- (length vec)) downto -1 sum (* (expt 10 pos) d))) (defvar *primes* '(2 3 5 7 11 13 17)) (defun sub-prime-divisible (vec) (loop for prime in *primes* for index from 1 to 7 for slice = (vec->int (subseq vec index (+ index 3))) always (= (mod slice prime) 0))) ;; loop from the biggest to small pandigital, ;; get the first pandigital prime (defun solution (vec) (loop when (sub-prime-divisible vec) sum (vec->int vec) into special-primes when (null (next-perm vec)) ;; permutations is finished return special-primes)) (format t "~a~%" (solution #(9 8 7 6 5 4 3 2 1 0))) ================================================ FILE: Problem043/Python/solution_slow_1.py ================================================ #code created by NamanNimmo Gera #2:21pm, April 18, 2019. from itertools import permutations perm = permutations([0,1,2,3,4,5,6,7,8,9]) prime_list = [2,3,5,7,11,13,17] tot=0 for i in list(perm): prime = 0 flag = 1 for j in range(1,8): string = "" string = string + str(i[j]) + str(i[j+1]) + str(i[j+2]) if int(string)%(prime_list[prime]) != 0: flag = 0 break else: prime = prime + 1 if flag == 1: tot = tot + int(''.join(map(str, i))) print(tot) ================================================ FILE: Problem043/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=43) ================================================ FILE: Problem043/Swift/solution_1.swift ================================================ // send the items from the right to the left func permute(array:[Int]) -> [Int] { var mutArr = array var i = mutArr.count - 2 loop: while true { switch i { case let x where x < 0: return [] case let x where mutArr[x] < mutArr[x+1]: break loop default: i -= 1 } } var j = 1 while j + i < mutArr.count - j { let n = mutArr[j + i] mutArr[j + i] = mutArr[mutArr.count - j] mutArr[mutArr.count - j] = n j += 1 } j = i + 1 while mutArr[j] <= mutArr[i] { j += 1 } let n = mutArr[i] mutArr[i] = mutArr[j] mutArr[j] = n return mutArr } let primes = [2, 3, 5, 7, 11, 13, 17] let numbers = Array("0123456789".characters).map{Int(String($0))!} var arr = permute(numbers) var sum:UInt64 = 0 while !arr.isEmpty { var i = 0 while i < primes.count { let n1 = Int(arr[i + 1]) * 100 let n2 = Int(arr[i + 2]) * 10 let n3 = Int(arr[i + 3]) if (n1+n2+n3) % primes[i] != 0 { break } i += 1 } if (i == primes.count) { var str = arr.map { String($0) }.joinWithSeparator("") sum += UInt64(str)! } arr = permute(arr) } print(sum) ================================================ FILE: Problem044/.hash ================================================ 2c2556cb85621309ca647465ffa62370 ================================================ FILE: Problem044/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # # Python Script # # Copyleft © Manoel Vilela # # """ Pentagonal numbers are generated by the formula, Pn=n(3n−1)/2. The first ten pentagonal numbers are: 1, 5, 12, 22, 35, 51, 70, 92, 117, 145, ... It can be seen that P4 + P7 = 22 + 70 = 92 = P8. However, their difference, 70 − 22 = 48, is not pentagonal. Find the pair of pentagonal numbers, Pj and Pk, for which their sum and difference are pentagonal and D = |Pk − Pj| is minimised; what is the value of D?""" from itertools import combinations from operator import add, sub def pentagonal(n): return (n * (3 * n - 1)) // 2 def pentagonal_list(n): return [pentagonal(x) for x in range(1, n)] def solution(): # lol, if i don't use 'set', the time explode! # the most curious is the list already uniq! # p = pentagonal_list(3000); len(p) == len(set(p)) => True!!! # My guess is combinations had some optimizations for set # set type doesn't ordered too... pentagonals = set(pentagonal_list(3000)) for c in combinations(pentagonals, 2): if add(*c) in pentagonals and abs(sub(*c)) in pentagonals: return abs(sub(*c)) if __name__ == '__main__': print(solution()) ================================================ FILE: Problem044/Python/solution_2.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Unknown Author # # from itertools import count def int_sqrt(n): # An integer-arithmetic variant of the Babylonian method for # calculating square roots. Given a non-negative integer n, we find # the greatest non-negative integer k such that k*k <= n. # # Suppose k > 0 is an integer such that k*k > n. Then # k + n//k < 2*k, and because 2*k is even it follows that # (k + n//k)//2 < k. Furthermore, # # (k + n/k)**2 # == k**2 + 2*n + (n/k)**2 # == k**2 - 2*n + (n/k)**2 + 4*n # == (k - n/k)**2 + 4*n # > 4*n # # so # # (k + n/k)/2 > sqrt(4*n)/2 == sqrt(n) # => (k + n//k)//2 >= int_sqrt(n). # # Thus, by starting with k such that k*k >= n and iteratively # replacing k with (k + n//k)//2 while k*k > n we will eventually # reach a point where k*k <= n. At this point, it must be that # k == int_sqrt(n). # # k = n is a natural starting point. Instead, we will take # # k = 1 << -(-n.bit_length()//2) # # which is a much better initial approximation and so will result in # fewer iterations. Note the use of the idiom -(-x//y) for "divide # x by y and round up". Note also that # # k*k # == (1 << -(-n.bit_length()//2))**2 # == 1 << (-(-n.bit_length()//2))*2 # >= 1 << n.bit_length() # > n, # # satisfying the algorithmic requirement that k*k >= n initially. # k = 1 << -(-n.bit_length()//2) while k*k > n: k = (k + n//k)//2 return k def pentagonal_number(n): return n*(3*n - 1)//2 def is_pentagonal(n): # If n is pentagonal then there exists k such that # # n == pentagonal_number(k) # => n == k*(3*k - 1)/2 # => 2*n == 3*k**2 - k # => 24*n == (6*k)**2 - 12*k # => 24*n + 1 == (6*k - 1)**2 # => int_sqrt(24*n + 1) == 6*k - 1 # => (int_sqrt(24*n + 1) + 1)//6 == k # # Thus, n is pentagonal if and only if it is the kth pentagonal # number where # # k = (int_sqrt(24*n + 1) + 1)//6. # k = (int_sqrt(24*n + 1) + 1)//6 return pentagonal_number(k) == n def answer(): # If p[j], p[k] are two pentagonal numbers with j < k then # # p[k] - p[j] # == k*(3*k - 1)/2 - j*(3*j - 1)/2 # == (3*k*k - k - 3*j*j + j)/2 # == (3*k*k - 6*k*j + 3*j*j - k + j + 6*k*j - 6*j*j)/2 # == (3*(k-j)**2 - (k-j) + 6*j*(k-j))/2 # == p[k-j] + 3*j*(k-j). # # We are interested only in pairs (j, k) where this differences is # itself a pentagonal number, p[t] say. Setting s = k - j we have # # p[t] == p[s] + 3*j*s. # # Thus, it suffices to consider only pairs (s, t) with s < t for # which p[t] - p[s] is a multiple of 3*s. Any such pair # automatically yields j and k such that p[k] - p[j] == p[t] leaving # us needing only to check that p[j] + p[k] is pentagonal. # # Because we want the minimum p[t] with the above properties, we # consider each s < t before moving on to t + 1. Given the relative # expense of calculating (p[t] - p[s]) % (3*s) we first screen # candidate values of s in view of the following. # # (1) For all non-negative integers n, # # (p[n] - n)%3 # == (n*(3*n - 1)/2 - n)%3 # == (n*(3*n - 3)/2)%3 # == 0 # # Thus, if (p[t] - p[s]) % (3*s) == 0 then we must have that # (t - s)%3 == 0. # # (2) If (p[t] - p[s]) % (3*s) == 0 then # # (p[t] - p[s]) % s == 0 # => (2*p[t] - 2*p[s]) % s == 0 # => (2*p[t] - s*(3*s - 1)) % s == 0 # => 2*p[t] % s == 0 # p = {} for t in count(): p[t] = pentagonal_number(t) double_p_t = 2 * p[t] for s in range(t - 3, 0, -3): if not double_p_t % s and not (p[t] - p[s]) % (3*s): j = (p[t] - p[s]) // (3*s) if is_pentagonal(p[t] + 2*pentagonal_number(j)): return p[t] print(answer()) ================================================ FILE: Problem044/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=44) ================================================ FILE: Problem045/.hash ================================================ 30dfe3e3b286add9d12e493ca7be63fc ================================================ FILE: Problem045/C/Makefile ================================================ CXX = gcc LFLAGS = -O3 -lm -Wall -o TARGET = solution_1 EXTENSION_TARGET = c EXTENSION_OUT = out all: $(CXX) $(TARGET).$(EXTENSION_TARGET) $(LFLAGS) $(TARGET).$(EXTENSION_OUT) clean: rm -v *.$(EXTENSION_OUT) run: ./$(TARGET).$(EXTENSION_OUT) ================================================ FILE: Problem045/C/solution_1.c ================================================ /* * =========================================================== * * Copyleft 2016 Manoel Vilela * * * Filename: solution_1.c * * Description: Solution of Problem045 of the ProjectEuler * * Author: Manoel Vilela * Contact: manoel_vilela@engineer.com * Organization: UFPA * * ============================================================ **/ // created by Manoel Vilela #include #include #define BModule 1 typedef struct { double a; double c; } Polynom; int main(int argc, char *argv[]) { Polynom P = {3, 2}; Polynom H = {2, 1}; double last_triangle = 285; while (1) { last_triangle += 1; double t = (pow(last_triangle, 2) + last_triangle) / 2; double Pn = (BModule + sqrt(BModule + 4 * P.a * P.c * t)) / (2 * P.a); double Hn = (BModule + sqrt(BModule + 4 * H.a * H.c * t)) / (2 * H.a); if (floor(Pn) == Pn && floor(Hn) == Hn) { printf("%.0f\n", t); break; } } return 0; } ================================================ FILE: Problem045/CommonLisp/solution_1.lisp ================================================ ;;; Common Lisp version ;;; Manoel Vilela ;; ProjectEuler Problem045 solution (defun quadratic (a b c) (/ ( + (- b) (sqrt (coerce (- (* b b) (* 4 a c)) 'long-float))) (* 2 a))) ;; x² + x => x * (x + 1) (defun triangle (x) (/ (* (+ x 1) x) 2)) (defun hexagonalp (x) (quadratic 2 -1 (* -1 x))) (defun pentagonalp (x) (quadratic 3 -1 (* -2 x))) (defun solution () (loop for last from 286 for tr = (triangle last) for hp = (hexagonalp tr) for tp = (pentagonalp tr) when (and (equalp (floor hp) hp) (equalp (floor tp) tp)) return tr)) (format t "~a" (solution)) ================================================ FILE: Problem045/Elixir/solution_1.exs ================================================ defmodule PolygonNumbers do def tri_pent_hex(_,final) when final > 0, do: final def tri_pent_hex(i,final) when final == 0 do hex = gen(i) final = cond do pent?(hex) -> hex true -> final end tri_pent_hex(i+1,final) end def gen(n), do: n * ((n * 2) - 1) def pent?(n) do m = (:math.sqrt((24 * n) + 1) + 1) (rem(round(Float.floor(m)),6) == 0) and (rem(round(Float.ceil(m)),6) == 0) end end IO.inspect PolygonNumbers.tri_pent_hex(144,0) ================================================ FILE: Problem045/Go/solution_1.go ================================================ // Copyright 2016 the DestructHub Authors. All rights reserved // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // created by Manoel Vilela package main import ( "fmt" "math" ) type Polynom struct { a, b, c float64 } var P = Polynom{a: 3, c: 2} var H = Polynom{a: 2, c: 1} var B float64 = 1 func main() { lastTriangle := 285.0 for { lastTriangle += 1 t := (math.Pow(lastTriangle, 2) + lastTriangle) / 2 p := (B + math.Sqrt(B+4*P.a*P.c*t)) / (2 * P.a) h := (B + math.Sqrt(B+4*H.a*H.c*t)) / (2 * H.a) if math.Floor(p) == p && math.Floor(h) == h { fmt.Printf("%.0f\n", t) break } } } ================================================ FILE: Problem045/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # # Python Script # # Copyleft © Manoel Vilela # # from math import floor from itertools import count # triangle # -> t = n² + n: n² + n - t = 0 # pentagonal (I) # -> p = (3n² - n) / 2: 3n² - n -2p = 0 # hexagonal (II) # -> h = (2n² - n) / 1: 2n² -n -h = 0 # for t = p = h, we have to found the root of equations (I) # and (II), whose are positive and integer. The root points # to the n when p, h, or t exists for integers. # so we compute the triangle nums after the last (285) # and considering p = t, and h = t. def quadratic(a, b, c): return (-b + (b ** 2 - 4 * a * c) ** 0.5) / (2 * a) def solution(): for x in count(start=286, step=1): t = (x * x + x) // 2 p = quadratic(3, -1, -2 * t) h = quadratic(2, -1, -1 * t) if floor(p) == p and floor(h) == h: return t if __name__ == '__main__': print(solution()) ================================================ FILE: Problem045/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=45) ================================================ FILE: Problem045/Ruby/solution_1.rb ================================================ class Integer def is_pentagonal? # Inverse of pentagonal function ((Math.sqrt((24 * self) + 1) + 1) % 6) == 0 end def generate_hexagonal self * ((self * 2) - 1) end end class TrianglePentagonHexagon attr_accessor :final def initialize @final = 0 end def find_pentagonal # All hexagonal are triagonal counter = 144 until final > 0 hex = counter.generate_hexagonal @final = hex if hex.is_pentagonal? counter += 1 end end end euler = TrianglePentagonHexagon.new euler.find_pentagonal p euler.final ================================================ FILE: Problem045/Swift/solution_1.swift ================================================ import Foundation var lastTriangleValue:Double = 285 var res:Double = 0 typealias Polynomial = (a:Double, c:Double) let P:Polynomial = (a:3, c:2) let H:Polynomial = (a:2, c:1) let PH_bModule:Double = 1 while true { lastTriangleValue += 1 res = (pow(lastTriangleValue, 2) + lastTriangleValue) / 2 let Pn = (PH_bModule + sqrt(PH_bModule + 4 * P.a * (P.c * res))) / (2 * P.a) let Hn = (PH_bModule + sqrt(PH_bModule + 4 * H.a * (H.c * res))) / (2 * H.a) if floor(Pn) == Pn && floor(Hn) == Hn { break } } #if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) print(String(format: "%.0f", res)) #else print(NSString(format: "%.0f", res)) #endif ================================================ FILE: Problem046/.hash ================================================ 89abe98de6071178edb1b28901a8f459 ================================================ FILE: Problem046/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # def sieve5(n): # from primes algorithms on problem10 """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 def goldbach(odd, p): """check if some odd composite can be equal with p prime whose follow the equation: odd_composite == prime + 2 * x² """ # that part is a analytical solution for get the x num: # the possible numbers to odd composite (not prime odd) is: # :: odd = prime + 2 * x² # so, x = sqrt((odd - prime) / 2), whose prime + 2 < odd. # simplification can be done yet, but I will keep that way return odd == (p + 2 * int(((odd - p) / 2) ** 0.5) ** 2) def solution(heuristic_start=10000): # i don't know the limit, so we start until 10.000 primes and composites primes = sieve5(heuristic_start) # n > 1 & doesn't primes composites = set(range(2, heuristic_start)) - set(primes) for odd in filter(lambda x: x % 2 != 0, composites): filtered_primes = filter(lambda x: odd > x - 2, primes) if not any(goldbach(odd, p) for p in filtered_primes): return odd return solution(heuristic_start*2) # if don't find, try other ranges if __name__ == '__main__': print(solution()) ================================================ FILE: Problem046/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=46) ================================================ FILE: Problem046/Ruby/solution_1.rb ================================================ class Goldbach attr_accessor :prime_array,:square_array,:sums attr_reader :finish,:all_composites,:squared_double,:composite def initialize(finish) @finish = finish @composite = 0 @prime_array = (3..finish).step(2).to_a.insert(0,2) end def find_goldbach @composite = all_composites.find { |n| !sums.include?(n) } end def sieve_of_eratosthenes (4..prime_array.last).each { |i| prime_array.delete_if { |num| num % i == 0 && num > i } } end def generate_composites @all_composites = (2..finish).select { |n| n.odd? && !prime_array.include?(n) } end def generate_squares @squared_double = (0..(finish/100)).map { |n| 2*(n**2) } end def sum_primes_and_squares @sums = prime_array.flat_map { |i| squared_double.map { |j| i + j } } end end euler = Goldbach.new(10000) euler.sieve_of_eratosthenes euler.generate_composites euler.generate_squares euler.sum_primes_and_squares euler.find_goldbach p euler.composite ================================================ FILE: Problem047/.hash ================================================ 748f517ecdc29106e2738f88aa7530f4 ================================================ FILE: Problem047/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # from itertools import count from sympy.ntheory import factorint def solution(q): c = 0 for p in count(start=1, step=1): if len(factorint(p)) == q: c += 1 if c == 1: last = p else: c = 0 if c == q: return last print(solution(4)) ================================================ FILE: Problem047/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=47) ================================================ FILE: Problem047/Swift/solution_1.swift ================================================ var nextNumber = 1 var primeArr:[Int] = [2,3,5,7] var checkArr:[Int] = [] loop:while true { nextNumber += 1 var remainder = nextNumber var count = 0 for i in 0.. (A_1 * A_2 * A_3 ... A_B) mod C (exponentiation definition) => ((A_1 mod C) * (A_2 mod C) * ... (A_B mod C)) (distributive mod property) => (A mod C) ^ B (exponentiation definition) */ #include #include #include #include #include uint64_t pow_mod(uint64_t x, uint64_t e, uint64_t mod) { uint64_t result = 1; x %= mod; while(e--) { result = (result % mod) * x; } return result; } int main(void) { uint64_t num = 0; uint64_t mod = (uint64_t) 1E10; for (uint64_t i = 1; i <= 1000; i++){ num = (num + pow_mod(i, i, mod)) % mod; } printf("%lu\n", num); return 0; } ================================================ FILE: Problem048/Clojure/solution_1.clj ================================================ ;; Clojure version of problem048 ;; Manoel Vilela (defn exp [x n] (reduce *' (repeat n x))) (defn series [x] (reduce +' (map (fn [x] (exp x x)) (range 1 (+ x 1)) ))) (defn answer [] (let [x (series 1000)] (mod x (exp 10 10)))) (println (str (answer))) ================================================ FILE: Problem048/CommonLisp/solution_1.lisp ================================================ ;; Problem 048 ;; Common Lisp #| The series, 1¹ + 2¹ + 3³ + ... + 10^10 = 10405071317. Find the last ten digits of the series, 1¹ + 2² + 3³ + ... + 1000^1000. |# (defun series (x) (reduce '+ (loop for x from 1 to x collect (expt x x)))) (defun solution () (let (answer) (setf answer (series 1000)) (mod answer (expt 10 10)))) (format t "~d" (solution)) ================================================ FILE: Problem048/Go/solution_1.go ================================================ // Copyright 2016 the DestructHub Authors. All rights reserved // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package main import ( "fmt" "math" ) func powMod(a float64, b float64, mod float64) float64 { var result float64 = 1 a = math.Mod(a, mod) for i := 1.0; i <= b; i++ { result = math.Mod((a * result), mod) } return result } func main() { var answer float64 = 0 var mod float64 = 1E10 for i := 1.0; i <= 1000; i++ { answer = math.Mod(powMod(i, i, mod)+answer, mod) } fmt.Println(int(answer)) } ================================================ FILE: Problem048/Haskell/solution_1.hs ================================================ {- The series, 1¹ + 2¹ + 3³ + ... + 10^10 = 10405071317. Find the last ten digits of the series, 1¹ + 2² + 3³ + ... + 1000^1000. -} main :: IO () main = putStrLn . reverse . take 10 . reverse . show . sum $ map (\x -> x^x) [1..1000] ================================================ FILE: Problem048/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyright © Manoel Vilela # # print(sum(map(lambda x: x ** x, range(1, 1000))) % 10 ** 10) ================================================ FILE: Problem048/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=48) ================================================ FILE: Problem048/Ruby/solution_1.rb ================================================ #Author: tkovs def solve return (1..1000).map{|x| x ** x}.inject(:+).modulo(10 ** 10) end puts (solve) ================================================ FILE: Problem049/.hash ================================================ 0b99933d3e2a9addccbb663d46cbb592 ================================================ FILE: Problem049/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # from itertools import permutations, chain from sympy.ntheory import Sieve class PrimePermutations(int): """ Class to verify if a prime can be had prime permutation itself: permutations primes: """ # class global variable, i only do that one time _primes = list(Sieve().primerange(1000, 9999)) def __init__(self, x, min_permutations=3): self.num = x self.min = min_permutations @property def permutations(self): return set(map(int, (''.join(x) for x in permutations(str(self))))) @property def primes(self): return sorted([p for p in self.permutations if p in self._primes]) @property def is_candidate(self): return len(self.primes) >= self.min def _zip(self, content): return zip(content, content[1:]) @property def had_some_sequence(self): return any(x == y for x, y in self._zip(self.diff)) @property def sequence(self): return [(x, y) for x, y in self._zip(self.primes) if y - x == self.max] @property def max(self): return max(self.diff, key=self.diff.count) @property def diff(self): return [y - x for x, y in self._zip(self.primes)] @property def concat(self): return ''.join(map(str, sorted(set(chain(*self.sequence))))) # lol @classmethod def solution(cls): to_check = cls._primes.copy() # make copy to not fuck the _primes while any(to_check): # if not all check p = cls(to_check.pop()) # instantiate last prime if p.is_candidate: # had at least 3 permutable primes? if p.had_some_sequence: # had some sequence between? return p.concat # is the answer, concat for x in p.primes: # remove checked primes if x in to_check: # remove checked primes to_check.remove(x) if __name__ == '__main__': print(PrimePermutations.solution()) ================================================ FILE: Problem049/Python/solution_2.py ================================================ #code created by NamanNimmo Gera #12:28pm, April 19, 2019. def isPrime(n) : if (n <= 1) : return False if (n <= 3) : return True if (n % 2 == 0 or n % 3 == 0) : return False i = 5 while(i * i <= n) : if (n % i == 0 or n % (i + 2) == 0) : return False i = i + 6 return True for i in range(1001,3338): if isPrime(i) and isPrime(i+3330) and isPrime(i + 2*3330): if set(list(str(i))) == set(list(str(i+3330))) == set(list(str(i + 2*3330))): if i!=1487: string = "" string = string + str(i) + str(i+3330)+ str(i + 2*3330) print(string) exit() ================================================ FILE: Problem049/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=49) ================================================ FILE: Problem050/.hash ================================================ 73229bab6c5dc1c7cf7a4fa123caf6bc ================================================ FILE: Problem050/Python/solution_slow_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # # problem50.py # solution not efficient D: much more 10min to process, i want a solution whose take below 1 minute of time. """ The prime 41, can be written as the sum of six consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive primes that adds to a prime below one-hundred. The longest sum of consecutive primes below one-thousand that adds to a prime, contains 21 terms, and is equal to 953. Which prime, below one-million, can be written as the sum of the most consecutive primes? """ from primes import primeGen max_n = 10 ** 6 def sumOfPrimes(primes): i = 0 prime = primes[-1] rangeTest = prime ** 1/2 while primes[i] < rangeTest: j = i sumTemp = 0 while primes[j] < rangeTest: sumTemp += primes[j] if sumTemp == prime: return prime, abs(j - i) + 1 j += 1 i += 1 return 0, 0 def main(n): primes = [] mostConsecutivePrime, mostSums = 0, 0 for prime in primeGen(n): primes.append(prime) prime, sums = sumOfPrimes(primes) if mostSums < sums: mostConsecutivePrime, mostSums = prime, sums print(mostConsecutivePrime) main(max_n) ================================================ FILE: Problem050/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=50) ================================================ FILE: Problem052/.hash ================================================ a420384997c8a1a93d5a84046117c2aa ================================================ FILE: Problem052/Haskell/solution_1.hs ================================================ {-- Author: Manoel Vilela It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits. --} import Data.List (sort, nub) sameDigits :: Integer -> Integer -> Bool sameDigits x y = f x == f y where f k = sort $ nub $ show k check :: Integer -> Bool check x = all (sameDigits x) $ map (* x) [2..6] solution :: Integer solution = head [x | x <- [1..], check x] main :: IO() main = print solution ================================================ FILE: Problem052/Python/solution_1.py ================================================ for i in range(101,1000000): #bruuuuuute force if set(list(str(i))) == set(list(str(2*i))) == set(list(str(3*i))) == set(list(str(4*i))) == set(list(str(5*i))) == set(list(str(6*i))): print(i) break ================================================ FILE: Problem052/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=52) ================================================ FILE: Problem052/Ruby/solution_1.rb ================================================ class PermutationMultiples attr_accessor :prime_array,:lowest attr_reader :finish def initialize(finish) @finish = finish end def find_permutations # Chose arbitrary number range => only checks until is true (1).upto(finish) { |num| return @lowest = num if six_time_permutation?(num) } end def six_time_permutation?(num) # Only check if each proceeding multiple is a permutation sorted = num.to_s.split("").sort (2..6).each { |n| return nil unless sorted == (n*num).to_s.split("").sort } end end euler = PermutationMultiples.new(1000000) euler.find_permutations p euler.lowest ================================================ FILE: Problem053/.hash ================================================ e3b21256183cf7c2c7a66be163579d37 ================================================ FILE: Problem053/Haskell/solution_1.hs ================================================ {-- Author: Manoel Vilela --} fat :: (Num b, Enum b) => b -> b fat n = product [1..n] choose :: (RealFrac a, Enum a, Integral b) => a -> a -> b choose n k = floor $ fat n /(fat k * fat (n - k)) bigCombs :: (RealFrac t, Enum t) => t -> Int bigCombs n = length [x | k <- [1..n], let x = choose n k, x > 1000000] solution :: Int solution = sum [k | n <- [1..100], let k = bigCombs n] main :: IO() main = print solution ================================================ FILE: Problem053/Python/solution_1.py ================================================ count=0 for i in range (1,101): for j in range(0,i): factn=factr=fact=1 ncr=0 m=i-j for x in range(1,i+1): factn*=x if j==0 or j==1: factr=1 else: for x in range(2,j+1): factr*=x for x in range(2,m+1): fact*=x ncr= factn / factr / fact if ncr>1000000: count+=1 print(count) ================================================ FILE: Problem053/Python/solution_2.py ================================================ #code created by NamanNimmo Gera #3:49pm, May 1, 2019. import math count = 0 for i in range(1,101): for j in range(0,i+1): if ((math.factorial(i))//(math.factorial(i-j)*math.factorial(j)))>1000000: count += 1 print(count) ================================================ FILE: Problem053/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=53) ================================================ FILE: Problem054/.hash ================================================ 142949df56ea8ae0be8b5306971900a4 - ================================================ FILE: Problem054/Python/solution_1.py ================================================ from collections import Counter hands = [line.split(' ') for line in open('../p054_poker.txt')] values = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 14} straights = [(v, v - 1, v - 2, v - 3, v - 4) for v in range(14, 5, -1)] ranks = [(1, 1, 1, 1, 1), (2, 1, 1, 1), (2, 2, 1), (3, 1, 1), (3, 2), (4, 1)] def calculate_rank(hand): score = list(zip(*sorted(((v, values[k]) for k, v in Counter(x[0] for x in hand).items()), reverse=True))) score[0] = ranks.index(score[0]) if len(set(card[1] for card in hand)) == 1: score[0] = 5 # flush if score[1] in straights: score[0] = 4 # straight return score p1_wins = sum(calculate_rank(hand[:5]) > calculate_rank(hand[5:]) for hand in hands) print(p1_wins) ================================================ FILE: Problem054/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=54) ================================================ FILE: Problem054/p054_poker.txt ================================================ 8C TS KC 9H 4S 7D 2S 5D 3S AC 5C AD 5D AC 9C 7C 5H 8D TD KS 3H 7H 6S KC JS QH TD JC 2D 8S TH 8H 5C QS TC 9H 4D JC KS JS 7C 5H KC QH JD AS KH 4C AD 4S 5H KS 9C 7D 9H 8D 3S 5D 5C AH 6H 4H 5C 3H 2H 3S QH 5S 6S AS TD 8C 4H 7C TC KC 4C 3H 7S KS 7C 9C 6D KD 3H 4C QS QC AC KH JC 6S 5H 2H 2D KD 9D 7C AS JS AD QH TH 9D 8H TS 6D 3S AS AC 2H 4S 5C 5S TC KC JD 6C TS 3C QD AS 6H JS 2C 3D 9H KC 4H 8S KD 8S 9S 7C 2S 3S 6D 6S 4H KC 3C 8C 2D 7D 4D 9S 4S QH 4H JD 8C KC 7S TC 2D TS 8H QD AC 5C 3D KH QD 6C 6S AD AS 8H 2H QS 6S 8D 4C 8S 6C QH TC 6D 7D 9D 2S 8D 8C 4C TS 9S 9D 9C AC 3D 3C QS 2S 4H JH 3D 2D TD 8S 9H 5H QS 8S 6D 3C 8C JD AS 7H 7D 6H TD 9D AS JH 6C QC 9S KD JC AH 8S QS 4D TH AC TS 3C 3D 5C 5S 4D JS 3D 8H 6C TS 3S AD 8C 6D 7C 5D 5H 3S 5C JC 2H 5S 3D 5H 6H 2S KS 3D 5D JD 7H JS 8H KH 4H AS JS QS QC TC 6D 7C KS 3D QS TS 2H JS 4D AS 9S JC KD QD 5H 4D 5D KH 7H 3D JS KD 4H 2C 9H 6H 5C 9D 6C JC 2D TH 9S 7D 6D AS QD JH 4D JS 7C QS 5C 3H KH QD AD 8C 8H 3S TH 9D 5S AH 9S 4D 9D 8S 4H JS 3C TC 8D 2C KS 5H QD 3S TS 9H AH AD 8S 5C 7H 5D KD 9H 4D 3D 2D KS AD KS KC 9S 6D 2C QH 9D 9H TS TC 9C 6H 5D QH 4D AD 6D QC JS KH 9S 3H 9D JD 5C 4D 9H AS TC QH 2C 6D JC 9C 3C AD 9S KH 9D 7D KC 9C 7C JC JS KD 3H AS 3C 7D QD KH QS 2C 3S 8S 8H 9H 9C JC QH 8D 3C KC 4C 4H 6D AD 9H 9D 3S KS QS 7H KH 7D 5H 5D JD AD 2H 2C 6H TH TC 7D 8D 4H 8C AS 4S 2H AC QC 3S 6D TH 4D 4C KH 4D TC KS AS 7C 3C 6D 2D 9H 6C 8C TD 5D QS 2C 7H 4C 9C 3H 9H 5H JH TS 7S TD 6H AD QD 8H 8S 5S AD 9C 8C 7C 8D 5H 9D 8S 2S 4H KH KS 9S 2S KC 5S AD 4S 7D QS 9C QD 6H JS 5D AC 8D 2S AS KH AC JC 3S 9D 9S 3C 9C 5S JS AD 3C 3D KS 3S 5C 9C 8C TS 4S JH 8D 5D 6H KD QS QD 3D 6C KC 8S JD 6C 3S 8C TC QC 3C QH JS KC JC 8H 2S 9H 9C JH 8S 8C 9S 8S 2H QH 4D QC 9D KC AS TH 3C 8S 6H TH 7C 2H 6S 3C 3H AS 7S QH 5S JS 4H 5H TS 8H AH AC JC 9D 8H 2S 4S TC JC 3C 7H 3H 5C 3D AD 3C 3S 4C QC AS 5D TH 8C 6S 9D 4C JS KH AH TS JD 8H AD 4C 6S 9D 7S AC 4D 3D 3S TC JD AD 7H 6H 4H JH KC TD TS 7D 6S 8H JH TC 3S 8D 8C 9S 2C 5C 4D 2C 9D KC QH TH QS JC 9C 4H TS QS 3C QD 8H KH 4H 8D TD 8S AC 7C 3C TH 5S 8H 8C 9C JD TC KD QC TC JD TS 8C 3H 6H KD 7C TD JH QS KS 9C 6D 6S AS 9H KH 6H 2H 4D AH 2D JH 6H TD 5D 4H JD KD 8C 9S JH QD JS 2C QS 5C 7C 4S TC 7H 8D 2S 6H 7S 9C 7C KC 8C 5D 7H 4S TD QC 8S JS 4H KS AD 8S JH 6D TD KD 7C 6C 2D 7D JC 6H 6S JS 4H QH 9H AH 4C 3C 6H 5H AS 7C 7S 3D KH KC 5D 5C JC 3D TD AS 4D 6D 6S QH JD KS 8C 7S 8S QH 2S JD 5C 7H AH QD 8S 3C 6H 6C 2C 8D TD 7D 4C 4D 5D QH KH 7C 2S 7H JS 6D QC QD AD 6C 6S 7D TH 6H 2H 8H KH 4H KS JS KD 5D 2D KH 7D 9C 8C 3D 9C 6D QD 3C KS 3S 7S AH JD 2D AH QH AS JC 8S 8H 4C KC TH 7D JC 5H TD 7C 5D KD 4C AD 8H JS KC 2H AC AH 7D JH KH 5D 7S 6D 9S 5S 9C 6H 8S TD JD 9H 6C AC 7D 8S 6D TS KD 7H AC 5S 7C 5D AH QC JC 4C TC 8C 2H TS 2C 7D KD KC 6S 3D 7D 2S 8S 3H 5S 5C 8S 5D 8H 4C 6H KC 3H 7C 5S KD JH 8C 3D 3C 6C KC TD 7H 7C 4C JC KC 6H TS QS TD KS 8H 8C 9S 6C 5S 9C QH 7D AH KS KC 9S 2C 4D 4S 8H TD 9C 3S 7D 9D AS TH 6S 7D 3C 6H 5D KD 2C 5C 9D 9C 2H KC 3D AD 3H QD QS 8D JC 4S 8C 3H 9C 7C AD 5D JC 9D JS AS 5D 9H 5C 7H 6S 6C QC JC QD 9S JC QS JH 2C 6S 9C QC 3D 4S TC 4H 5S 8D 3D 4D 2S KC 2H JS 2C TD 3S TH KD 4D 7H JH JS KS AC 7S 8C 9S 2D 8S 7D 5C AD 9D AS 8C 7H 2S 6C TH 3H 4C 3S 8H AC KD 5H JC 8H JD 2D 4H TD JH 5C 3D AS QH KS 7H JD 8S 5S 6D 5H 9S 6S TC QS JC 5C 5D 9C TH 8C 5H 3S JH 9H 2S 2C 6S 7S AS KS 8C QD JC QS TC QC 4H AC KH 6C TC 5H 7D JH 4H 2H 8D JC KS 4D 5S 9C KH KD 9H 5C TS 3D 7D 2D 5H AS TC 4D 8C 2C TS 9D 3H 8D 6H 8D 2D 9H JD 6C 4S 5H 5S 6D AD 9C JC 7D 6H 9S 6D JS 9H 3C AD JH TC QS 4C 5D 9S 7C 9C AH KD 6H 2H TH 8S QD KS 9D 9H AS 4H 8H 8D 5H 6C AH 5S AS AD 8S QS 5D 4S 2H TD KS 5H AC 3H JC 9C 7D QD KD AC 6D 5H QH 6H 5S KC AH QH 2H 7D QS 3H KS 7S JD 6C 8S 3H 6D KS QD 5D 5C 8H TC 9H 4D 4S 6S 9D KH QC 4H 6C JD TD 2D QH 4S 6H JH KD 3C QD 8C 4S 6H 7C QD 9D AS AH 6S AD 3C 2C KC TH 6H 8D AH 5C 6D 8S 5D TD TS 7C AD JC QD 9H 3C KC 7H 5D 4D 5S 8H 4H 7D 3H JD KD 2D JH TD 6H QS 4S KD 5C 8S 7D 8H AC 3D AS 8C TD 7H KH 5D 6C JD 9D KS 7C 6D QH TC JD KD AS KC JH 8S 5S 7S 7D AS 2D 3D AD 2H 2H 5D AS 3C QD KC 6H 9H 9S 2C 9D 5D TH 4C JH 3H 8D TC 8H 9H 6H KD 2C TD 2H 6C 9D 2D JS 8C KD 7S 3C 7C AS QH TS AD 8C 2S QS 8H 6C JS 4C 9S QC AD TD TS 2H 7C TS TC 8C 3C 9H 2D 6D JC TC 2H 8D JH KS 6D 3H TD TH 8H 9D TD 9H QC 5D 6C 8H 8C KC TS 2H 8C 3D AH 4D TH TC 7D 8H KC TS 5C 2D 8C 6S KH AH 5H 6H KC 5S 5D AH TC 4C JD 8D 6H 8C 6C KC QD 3D 8H 2D JC 9H 4H AD 2S TD 6S 7D JS KD 4H QS 2S 3S 8C 4C 9H JH TS 3S 4H QC 5S 9S 9C 2C KD 9H JS 9S 3H JC TS 5D AC AS 2H 5D AD 5H JC 7S TD JS 4C 2D 4S 8H 3D 7D 2C AD KD 9C TS 7H QD JH 5H JS AC 3D TH 4C 8H 6D KH KC QD 5C AD 7C 2D 4H AC 3D 9D TC 8S QD 2C JC 4H JD AH 6C TD 5S TC 8S AH 2C 5D AS AC TH 7S 3D AS 6C 4C 7H 7D 4H AH 5C 2H KS 6H 7S 4H 5H 3D 3C 7H 3C 9S AC 7S QH 2H 3D 6S 3S 3H 2D 3H AS 2C 6H TC JS 6S 9C 6C QH KD QD 6D AC 6H KH 2C TS 8C 8H 7D 3S 9H 5D 3H 4S QC 9S 5H 2D 9D 7H 6H 3C 8S 5H 4D 3S 4S KD 9S 4S TC 7S QC 3S 8S 2H 7H TC 3D 8C 3H 6C 2H 6H KS KD 4D KC 3D 9S 3H JS 4S 8H 2D 6C 8S 6H QS 6C TC QD 9H 7D 7C 5H 4D TD 9D 8D 6S 6C TC 5D TS JS 8H 4H KC JD 9H TC 2C 6S 5H 8H AS JS 9C 5C 6S 9D JD 8H KC 4C 6D 4D 8D 8S 6C 7C 6H 7H 8H 5C KC TC 3D JC 6D KS 9S 6H 7S 9C 2C 6C 3S KD 5H TS 7D 9H 9S 6H KH 3D QD 4C 6H TS AC 3S 5C 2H KD 4C AS JS 9S 7C TS 7H 9H JC KS 4H 8C JD 3H 6H AD 9S 4S 5S KS 4C 2C 7D 3D AS 9C 2S QS KC 6C 8S 5H 3D 2S AC 9D 6S 3S 4D TD QD TH 7S TS 3D AC 7H 6C 5D QC TC QD AD 9C QS 5C 8D KD 3D 3C 9D 8H AS 3S 7C 8S JD 2D 8D KC 4C TH AC QH JS 8D 7D 7S 9C KH 9D 8D 4C JH 2C 2S QD KD TS 4H 4D 6D 5D 2D JH 3S 8S 3H TC KH AD 4D 2C QS 8C KD JH JD AH 5C 5C 6C 5H 2H JH 4H KS 7C TC 3H 3C 4C QC 5D JH 9C QD KH 8D TC 3H 9C JS 7H QH AS 7C 9H 5H JC 2D 5S QD 4S 3C KC 6S 6C 5C 4C 5D KH 2D TS 8S 9C AS 9S 7C 4C 7C AH 8C 8D 5S KD QH QS JH 2C 8C 9D AH 2H AC QC 5S 8H 7H 2C QD 9H 5S QS QC 9C 5H JC TH 4H 6C 6S 3H 5H 3S 6H KS 8D AC 7S AC QH 7H 8C 4S KC 6C 3D 3S TC 9D 3D JS TH AC 5H 3H 8S 3S TC QD KH JS KS 9S QC 8D AH 3C AC 5H 6C KH 3S 9S JH 2D QD AS 8C 6C 4D 7S 7H 5S JC 6S 9H 4H JH AH 5S 6H 9S AD 3S TH 2H 9D 8C 4C 8D 9H 7C QC AD 4S 9C KC 5S 9D 6H 4D TC 4C JH 2S 5D 3S AS 2H 6C 7C KH 5C AD QS TH JD 8S 3S 4S 7S AH AS KC JS 2S AD TH JS KC 2S 7D 8C 5C 9C TS 5H 9D 7S 9S 4D TD JH JS KH 6H 5D 2C JD JS JC TH 2D 3D QD 8C AC 5H 7S KH 5S 9D 5D TD 4S 6H 3C 2D 4S 5D AC 8D 4D 7C AD AS AH 9C 6S TH TS KS 2C QC AH AS 3C 4S 2H 8C 3S JC 5C 7C 3H 3C KH JH 7S 3H JC 5S 6H 4C 2S 4D KC 7H 4D 7C 4H 9S 8S 6S AD TC 6C JC KH QS 3S TC 4C 8H 8S AC 3C TS QD QS TH 3C TS 7H 7D AH TD JC TD JD QC 4D 9S 7S TS AD 7D AC AH 7H 4S 6D 7C 2H 9D KS JC TD 7C AH JD 4H 6D QS TS 2H 2C 5C TC KC 8C 9S 4C JS 3C JC 6S AH AS 7D QC 3D 5S JC JD 9D TD KH TH 3C 2S 6H AH AC 5H 5C 7S 8H QC 2D AC QD 2S 3S JD QS 6S 8H KC 4H 3C 9D JS 6H 3S 8S AS 8C 7H KC 7D JD 2H JC QH 5S 3H QS 9H TD 3S 8H 7S AC 5C 6C AH 7C 8D 9H AH JD TD QS 7D 3S 9C 8S AH QH 3C JD KC 4S 5S 5D TD KS 9H 7H 6S JH TH 4C 7C AD 5C 2D 7C KD 5S TC 9D 6S 6C 5D 2S TH KC 9H 8D 5H 7H 4H QC 3D 7C AS 6S 8S QC TD 4S 5C TH QS QD 2S 8S 5H TH QC 9H 6S KC 7D 7C 5C 7H KD AH 4D KH 5C 4S 2D KC QH 6S 2C TD JC AS 4D 6C 8C 4H 5S JC TC JD 5S 6S 8D AS 9D AD 3S 6D 6H 5D 5S TC 3D 7D QS 9D QD 4S 6C 8S 3S 7S AD KS 2D 7D 7C KC QH JC AC QD 5D 8D QS 7H 7D JS AH 8S 5H 3D TD 3H 4S 6C JH 4S QS 7D AS 9H JS KS 6D TC 5C 2D 5C 6H TC 4D QH 3D 9H 8S 6C 6D 7H TC TH 5S JD 5C 9C KS KD 8D TD QH 6S 4S 6C 8S KC 5C TC 5S 3D KS AC 4S 7D QD 4C TH 2S TS 8H 9S 6S 7S QH 3C AH 7H 8C 4C 8C TS JS QC 3D 7D 5D 7S JH 8S 7S 9D QC AC 7C 6D 2H JH KC JS KD 3C 6S 4S 7C AH QC KS 5H KS 6S 4H JD QS TC 8H KC 6H AS KH 7C TC 6S TD JC 5C 7D AH 3S 3H 4C 4H TC TH 6S 7H 6D 9C QH 7D 5H 4S 8C JS 4D 3D 8S QH KC 3H 6S AD 7H 3S QC 8S 4S 7S JS 3S JD KH TH 6H QS 9C 6C 2D QD 4S QH 4D 5H KC 7D 6D 8D TH 5S TD AD 6S 7H KD KH 9H 5S KC JC 3H QC AS TS 4S QD KS 9C 7S KC TS 6S QC 6C TH TC 9D 5C 5D KD JS 3S 4H KD 4C QD 6D 9S JC 9D 8S JS 6D 4H JH 6H 6S 6C KS KH AC 7D 5D TC 9S KH 6S QD 6H AS AS 7H 6D QH 8D TH 2S KH 5C 5H 4C 7C 3D QC TC 4S KH 8C 2D JS 6H 5D 7S 5H 9C 9H JH 8S TH 7H AS JS 2S QD KH 8H 4S AC 8D 8S 3H 4C TD KD 8C JC 5C QS 2D JD TS 7D 5D 6C 2C QS 2H 3C AH KS 4S 7C 9C 7D JH 6C 5C 8H 9D QD 2S TD 7S 6D 9C 9S QS KH QH 5C JC 6S 9C QH JH 8D 7S JS KH 2H 8D 5H TH KC 4D 4S 3S 6S 3D QS 2D JD 4C TD 7C 6D TH 7S JC AH QS 7S 4C TH 9D TS AD 4D 3H 6H 2D 3H 7D JD 3D AS 2S 9C QC 8S 4H 9H 9C 2C 7S JH KD 5C 5D 6H TC 9H 8H JC 3C 9S 8D KS AD KC TS 5H JD QS QH QC 8D 5D KH AH 5D AS 8S 6S 4C AH QC QD TH 7H 3H 4H 7D 6S 4S 9H AS 8H JS 9D JD 8C 2C 9D 7D 5H 5S 9S JC KD KD 9C 4S QD AH 7C AD 9D AC TD 6S 4H 4S 9C 8D KS TC 9D JH 7C 5S JC 5H 4S QH AC 2C JS 2S 9S 8C 5H AS QD AD 5C 7D 8S QC TD JC 4C 8D 5C KH QS 4D 6H 2H 2C TH 4S 2D KC 3H QD AC 7H AD 9D KH QD AS 8H TH KC 8D 7S QH 8C JC 6C 7D 8C KH AD QS 2H 6S 2D JC KH 2D 7D JS QC 5H 4C 5D AD TS 3S AD 4S TD 2D TH 6S 9H JH 9H 2D QS 2C 4S 3D KH AS AC 9D KH 6S 8H 4S KD 7D 9D TS QD QC JH 5H AH KS AS AD JC QC 5S KH 5D 7D 6D KS KD 3D 7C 4D JD 3S AC JS 8D 5H 9C 3H 4H 4D TS 2C 6H KS KH 9D 7C 2S 6S 8S 2H 3D 6H AC JS 7S 3S TD 8H 3H 4H TH 9H TC QC KC 5C KS 6H 4H AC 8S TC 7D QH 4S JC TS 6D 6C AC KH QH 7D 7C JH QS QD TH 3H 5D KS 3D 5S 8D JS 4C 2C KS 7H 9C 4H 5H 8S 4H TD 2C 3S QD QC 3H KC QC JS KD 9C AD 5S 9D 7D 7H TS 8C JC KH 7C 7S 6C TS 2C QD TH 5S 9D TH 3C 7S QH 8S 9C 2H 5H 5D 9H 6H 2S JS KH 3H 7C 2H 5S JD 5D 5S 2C TC 2S 6S 6C 3C 8S 4D KH 8H 4H 2D KS 3H 5C 2S 9H 3S 2D TD 7H 8S 6H JD KC 9C 8D 6S QD JH 7C 9H 5H 8S 8H TH TD QS 7S TD 7D TS JC KD 7C 3C 2C 3C JD 8S 4H 2D 2S TD AS 4D AC AH KS 6C 4C 4S 7D 8C 9H 6H AS 5S 3C 9S 2C QS KD 4D 4S AC 5D 2D TS 2C JS KH QH 5D 8C AS KC KD 3H 6C TH 8S 7S KH 6H 9S AC 6H 7S 6C QS AH 2S 2H 4H 5D 5H 5H JC QD 2C 2S JD AS QC 6S 7D 6C TC AS KD 8H 9D 2C 7D JH 9S 2H 4C 6C AH 8S TD 3H TH 7C TS KD 4S TS 6C QH 8D 9D 9C AH 7D 6D JS 5C QD QC 9C 5D 8C 2H KD 3C QH JH AD 6S AH KC 8S 6D 6H 3D 7C 4C 7S 5S 3S 6S 5H JC 3C QH 7C 5H 3C 3S 8C TS 4C KD 9C QD 3S 7S 5H 7H QH JC 7C 8C KD 3C KD KH 2S 4C TS AC 6S 2C 7C 2C KH 3C 4C 6H 4D 5H 5S 7S QD 4D 7C 8S QD TS 9D KS 6H KD 3C QS 4D TS 7S 4C 3H QD 8D 9S TC TS QH AC 6S 3C 9H 9D QS 8S 6H 3S 7S 5D 4S JS 2D 6C QH 6S TH 4C 4H AS JS 5D 3D TS 9C AC 8S 6S 9C 7C 3S 5C QS AD AS 6H 3C 9S 8C 7H 3H 6S 7C AS 9H JD KH 3D 3H 7S 4D 6C 7C AC 2H 9C TH 4H 5S 3H AC TC TH 9C 9H 9S 8D 8D 9H 5H 4D 6C 2H QD 6S 5D 3S 4C 5C JD QS 4D 3H TH AC QH 8C QC 5S 3C 7H AD 4C KS 4H JD 6D QS AH 3H KS 9H 2S JS JH 5H 2H 2H 5S TH 6S TS 3S KS 3C 5H JS 2D 9S 7H 3D KC JH 6D 7D JS TD AC JS 8H 2C 8C JH JC 2D TH 7S 5D 9S 8H 2H 3D TC AH JC KD 9C 9D QD JC 2H 6D KH TS 9S QH TH 2C 8D 4S JD 5H 3H TH TC 9C KC AS 3D 9H 7D 4D TH KH 2H 7S 3H 4H 7S KS 2S JS TS 8S 2H QD 8D 5S 6H JH KS 8H 2S QC AC 6S 3S JC AS AD QS 8H 6C KH 4C 4D QD 2S 3D TS TD 9S KS 6S QS 5C 8D 3C 6D 4S QC KC JH QD TH KH AD 9H AH 4D KS 2S 8D JH JC 7C QS 2D 6C TH 3C 8H QD QH 2S 3S KS 6H 5D 9S 4C TS TD JS QD 9D JD 5H 8H KH 8S KS 7C TD AD 4S KD 2C 7C JC 5S AS 6C 7D 8S 5H 9C 6S QD 9S TS KH QS 5S QH 3C KC 7D 3H 3C KD 5C AS JH 7H 6H JD 9D 5C 9H KC 8H KS 4S AD 4D 2S 3S JD QD 8D 2S 7C 5S 6S 5H TS 6D 9S KC TD 3S 6H QD JD 5C 8D 5H 9D TS KD 8D 6H TD QC 4C 7D 6D 4S JD 9D AH 9S AS TD 9H QD 2D 5S 2H 9C 6H 9S TD QC 7D TC 3S 2H KS TS 2C 9C 8S JS 9D 7D 3C KC 6D 5D 6C 6H 8S AS 7S QS JH 9S 2H 8D 4C 8H 9H AD TH KH QC AS 2S JS 5C 6H KD 3H 7H 2C QD 8H 2S 8D 3S 6D AH 2C TC 5C JD JS TS 8S 3H 5D TD KC JC 6H 6S QS TC 3H 5D AH JC 7C 7D 4H 7C 5D 8H 9C 2H 9H JH KH 5S 2C 9C 7H 6S TH 3S QC QD 4C AC JD 2H 5D 9S 7D KC 3S QS 2D AS KH 2S 4S 2H 7D 5C TD TH QH 9S 4D 6D 3S TS 6H 4H KS 9D 8H 5S 2D 9H KS 4H 3S 5C 5D KH 6H 6S JS KC AS 8C 4C JC KH QC TH QD AH 6S KH 9S 2C 5H TC 3C 7H JC 4D JD 4S 6S 5S 8D 7H 7S 4D 4C 2H 7H 9H 5D KH 9C 7C TS TC 7S 5H 4C 8D QC TS 4S 9H 3D AD JS 7C 8C QS 5C 5D 3H JS AH KC 4S 9D TS JD 8S QS TH JH KH 2D QD JS JD QC 5D 6S 9H 3S 2C 8H 9S TS 2S 4C AD 7H JC 5C 2D 6D 4H 3D 7S JS 2C 4H 8C AD QD 9C 3S TD JD TS 4C 6H 9H 7D QD 6D 3C AS AS 7C 4C 6S 5D 5S 5C JS QC 4S KD 6S 9S 7C 3C 5S 7D JH QD JS 4S 7S JH 2C 8S 5D 7H 3D QH AD TD 6H 2H 8D 4H 2D 7C AD KH 5D TS 3S 5H 2C QD AH 2S 5C KH TD KC 4D 8C 5D AS 6C 2H 2S 9H 7C KD JS QC TS QS KH JH 2C 5D AD 3S 5H KC 6C 9H 3H 2H AD 7D 7S 7S JS JH KD 8S 7D 2S 9H 7C 2H 9H 2D 8D QC 6S AD AS 8H 5H 6C 2S 7H 6C 6D 7D 8C 5D 9D JC 3C 7C 9C 7H JD 2H KD 3S KH AD 4S QH AS 9H 4D JD KS KD TS KH 5H 4C 8H 5S 3S 3D 7D TD AD 7S KC JS 8S 5S JC 8H TH 9C 4D 5D KC 7C 5S 9C QD 2C QH JS 5H 8D KH TD 2S KS 3D AD KC 7S TC 3C 5D 4C 2S AD QS 6C 9S QD TH QH 5C 8C AD QS 2D 2S KC JD KS 6C JC 8D 4D JS 2H 5D QD 7S 7D QH TS 6S 7H 3S 8C 8S 9D QS 8H 6C 9S 4S TC 2S 5C QD 4D QS 6D TH 6S 3S 5C 9D 6H 8D 4C 7D TC 7C TD AH 6S AS 7H 5S KD 3H 5H AC 4C 8D 8S AH KS QS 2C AD 6H 7D 5D 6H 9H 9S 2H QS 8S 9C 5D 2D KD TS QC 5S JH 7D 7S TH 9S 9H AC 7H 3H 6S KC 4D 6D 5C 4S QD TS TD 2S 7C QD 3H JH 9D 4H 7S 7H KS 3D 4H 5H TC 2S AS 2D 6D 7D 8H 3C 7H TD 3H AD KC TH 9C KH TC 4C 2C 9S 9D 9C 5C 2H JD 3C 3H AC TS 5D AD 8D 6H QC 6S 8C 2S TS 3S JD 7H 8S QH 4C 5S 8D AC 4S 6C 3C KH 3D 7C 2D 8S 2H 4H 6C 8S TH 2H 4S 8H 9S 3H 7S 7C 4C 9C 2C 5C AS 5D KD 4D QH 9H 4H TS AS 7D 8D 5D 9S 8C 2H QC KD AC AD 2H 7S AS 3S 2D 9S 2H QC 8H TC 6D QD QS 5D KH 3C TH JD QS 4C 2S 5S AD 7H 3S AS 7H JS 3D 6C 3S 6D AS 9S AC QS 9C TS AS 8C TC 8S 6H 9D 8D 6C 4D JD 9C KC 7C 6D KS 3S 8C AS 3H 6S TC 8D TS 3S KC 9S 7C AS 8C QC 4H 4S 8S 6C 3S TC AH AC 4D 7D 5C AS 2H 6S TS QC AD TC QD QC 8S 4S TH 3D AH TS JH 4H 5C 2D 9S 2C 3H 3C 9D QD QH 7D KC 9H 6C KD 7S 3C 4D AS TC 2D 3D JS 4D 9D KS 7D TH QC 3H 3C 8D 5S 2H 9D 3H 8C 4C 4H 3C TH JC TH 4S 6S JD 2D 4D 6C 3D 4C TS 3S 2D 4H AC 2C 6S 2H JH 6H TD 8S AD TC AH AC JH 9S 6S 7S 6C KC 4S JD 8D 9H 5S 7H QH AH KD 8D TS JH 5C 5H 3H AD AS JS 2D 4H 3D 6C 8C 7S AD 5D 5C 8S TD 5D 7S 9C 4S 5H 6C 8C 4C 8S JS QH 9C AS 5C QS JC 3D QC 7C JC 9C KH JH QS QC 2C TS 3D AD 5D JH AC 5C 9S TS 4C JD 8C KS KC AS 2D KH 9H 2C 5S 4D 3D 6H TH AH 2D 8S JC 3D 8C QH 7S 3S 8H QD 4H JC AS KH KS 3C 9S 6D 9S QH 7D 9C 4S AC 7H KH 4D KD AH AD TH 6D 9C 9S KD KS QH 4H QD 6H 9C 7C QS 6D 6S 9D 5S JH AH 8D 5H QD 2H JC KS 4H KH 5S 5C 2S JS 8D 9C 8C 3D AS KC AH JD 9S 2H QS 8H 5S 8C TH 5C 4C QC QS 8C 2S 2C 3S 9C 4C KS KH 2D 5D 8S AH AD TD 2C JS KS 8C TC 5S 5H 8H QC 9H 6H JD 4H 9S 3C JH 4H 9H AH 4S 2H 4C 8D AC 8S TH 4D 7D 6D QD QS 7S TC 7C KH 6D 2D JD 5H JS QD JH 4H 4S 9C 7S JH 4S 3S TS QC 8C TC 4H QH 9D 4D JH QS 3S 2C 7C 6C 2D 4H 9S JD 5C 5H AH 9D TS 2D 4C KS JH TS 5D 2D AH JS 7H AS 8D JS AH 8C AD KS 5S 8H 2C 6C TH 2H 5D AD AC KS 3D 8H TS 6H QC 6D 4H TS 9C 5H JS JH 6S JD 4C JH QH 4H 2C 6D 3C 5D 4C QS KC 6H 4H 6C 7H 6S 2S 8S KH QC 8C 3H 3D 5D KS 4H TD AD 3S 4D TS 5S 7C 8S 7D 2C KS 7S 6C 8C JS 5D 2H 3S 7C 5C QD 5H 6D 9C 9H JS 2S KD 9S 8D TD TS AC 8C 9D 5H QD 2S AC 8C 9H KS 7C 4S 3C KH AS 3H 8S 9C JS QS 4S AD 4D AS 2S TD AD 4D 9H JC 4C 5H QS 5D 7C 4H TC 2D 6C JS 4S KC 3S 4C 2C 5D AC 9H 3D JD 8S QS QH 2C 8S 6H 3C QH 6D TC KD AC AH QC 6C 3S QS 4S AC 8D 5C AD KH 5S 4C AC KH AS QC 2C 5C 8D 9C 8H JD 3C KH 8D 5C 9C QD QH 9D 7H TS 2C 8C 4S TD JC 9C 5H QH JS 4S 2C 7C TH 6C AS KS 7S JD JH 7C 9H 7H TC 5H 3D 6D 5D 4D 2C QD JH 2H 9D 5S 3D TD AD KS JD QH 3S 4D TH 7D 6S QS KS 4H TC KS 5S 8D 8H AD 2S 2D 4C JH 5S JH TC 3S 2D QS 9D 4C KD 9S AC KH 3H AS 9D KC 9H QD 6C 6S 9H 7S 3D 5C 7D KC TD 8H 4H 6S 3C 7H 8H TC QD 4D 7S 6S QH 6C 6D AD 4C QD 6C 5D 7D 9D KS TS JH 2H JD 9S 7S TS KH 8D 5D 8H 2D 9S 4C 7D 9D 5H QD 6D AC 6S 7S 6D JC QD JH 4C 6S QS 2H 7D 8C TD JH KD 2H 5C QS 2C JS 7S TC 5H 4H JH QD 3S 5S 5D 8S KH KS KH 7C 2C 5D JH 6S 9C 6D JC 5H AH JD 9C JS KC 2H 6H 4D 5S AS 3C TH QC 6H 9C 8S 8C TD 7C KC 2C QD 9C KH 4D 7S 3C TS 9H 9C QC 2S TS 8C TD 9S QD 3S 3C 4D 9D TH JH AH 6S 2S JD QH JS QD 9H 6C KD 7D 7H 5D 6S 8H AH 8H 3C 4S 2H 5H QS QH 7S 4H AC QS 3C 7S 9S 4H 3S AH KS 9D 7C AD 5S 6S 2H 2D 5H TC 4S 3C 8C QH TS 6S 4D JS KS JH AS 8S 6D 2C 8S 2S TD 5H AS TC TS 6C KC KC TS 8H 2H 3H 7C 4C 5S TH TD KD AD KH 7H 7S 5D 5H 5S 2D 9C AD 9S 3D 7S 8C QC 7C 9C KD KS 3C QC 9S 8C 4D 5C AS QD 6C 2C 2H KC 8S JD 7S AC 8D 5C 2S 4D 9D QH 3D 2S TC 3S KS 3C 9H TD KD 6S AC 2C 7H 5H 3S 6C 6H 8C QH TC 8S 6S KH TH 4H 5D TS 4D 8C JS 4H 6H 2C 2H 7D AC QD 3D QS KC 6S 2D 5S 4H TD 3H JH 4C 7S 5H 7H 8H KH 6H QS TH KD 7D 5H AD KD 7C KH 5S TD 6D 3C 6C 8C 9C 5H JD 7C KC KH 7H 2H 3S 7S 4H AD 4D 8S QS TH 3D 7H 5S 8D TC KS KD 9S 6D AD JD 5C 2S 7H 8H 6C QD 2H 6H 9D TC 9S 7C 8D 6D 4C 7C 6C 3C TH KH JS JH 5S 3S 8S JS 9H AS AD 8H 7S KD JH 7C 2C KC 5H AS AD 9C 9S JS AD AC 2C 6S QD 7C 3H TH KS KD 9D JD 4H 8H 4C KH 7S TS 8C KC 3S 5S 2H 7S 6H 7D KS 5C 6D AD 5S 8C 9H QS 7H 7S 2H 6C 7D TD QS 5S TD AC 9D KC 3D TC 2D 4D TD 2H 7D JD QD 4C 7H 5D KC 3D 4C 3H 8S KD QH 5S QC 9H TC 5H 9C QD TH 5H TS 5C 9H AH QH 2C 4D 6S 3C AC 6C 3D 2C 2H TD TH AC 9C 5D QC 4D AD 8D 6D 8C KC AD 3C 4H AC 8D 8H 7S 9S TD JC 4H 9H QH JS 2D TH TD TC KD KS 5S 6S 9S 8D TH AS KH 5H 5C 8S JD 2S 9S 6S 5S 8S 5D 7S 7H 9D 5D 8C 4C 9D AD TS 2C 7D KD TC 8S QS 4D KC 5C 8D 4S KH JD KD AS 5C AD QH 7D 2H 9S 7H 7C TC 2S 8S JD KH 7S 6C 6D AD 5D QC 9H 6H 3S 8C 8H AH TC 4H JS TD 2C TS 4D 7H 2D QC 9C 5D TH 7C 6C 8H QC 5D TS JH 5C 5H 9H 4S 2D QC 7H AS JS 8S 2H 4C 4H 8D JS 6S AC KD 3D 3C 4S 7H TH KC QH KH 6S QS 5S 4H 3C QD 3S 3H 7H AS KH 8C 4H 9C 5S 3D 6S TS 9C 7C 3H 5S QD 2C 3D AD AC 5H JH TD 2D 4C TS 3H KH AD 3S 7S AS 4C 5H 4D 6S KD JC 3C 6H 2D 3H 6S 8C 2D TH 4S AH QH AD 5H 7C 2S 9H 7H KC 5C 6D 5S 3H JC 3C TC 9C 4H QD TD JH 6D 9H 5S 7C 6S 5C 5D 6C 4S 7H 9H 6H AH AD 2H 7D KC 2C 4C 2S 9S 7H 3S TH 4C 8S 6S 3S AD KS AS JH TD 5C TD 4S 4D AD 6S 5D TC 9C 7D 8H 3S 4D 4S 5S 6H 5C AC 3H 3D 9H 3C AC 4S QS 8S 9D QH 5H 4D JC 6C 5H TS AC 9C JD 8C 7C QD 8S 8H 9C JD 2D QC QH 6H 3C 8D KS JS 2H 6H 5H QH QS 3H 7C 6D TC 3H 4S 7H QC 2H 3S 8C JS KH AH 8H 5S 4C 9H JD 3H 7S JC AC 3C 2D 4C 5S 6C 4S QS 3S JD 3D 5H 2D TC AH KS 6D 7H AD 8C 6H 6C 7S 3C JD 7C 8H KS KH AH 6D AH 7D 3H 8H 8S 7H QS 5H 9D 2D JD AC 4H 7S 8S 9S KS AS 9D QH 7S 2C 8S 5S JH QS JC AH KD 4C AH 2S 9H 4H 8D TS TD 6H QH JD 4H JC 3H QS 6D 7S 9C 8S 9D 8D 5H TD 4S 9S 4C 8C 8D 7H 3H 3D QS KH 3S 2C 2S 3C 7S TD 4S QD 7C TD 4D 5S KH AC AS 7H 4C 6C 2S 5H 6D JD 9H QS 8S 2C 2H TD 2S TS 6H 9H 7S 4H JC 4C 5D 5S 2C 5H 7D 4H 3S QH JC JS 6D 8H 4C QH 7C QD 3S AD TH 8S 5S TS 9H TC 2S TD JC 7D 3S 3D TH QH 7D 4C 8S 5C JH 8H 6S 3S KC 3H JC 3H KH TC QH TH 6H 2C AC 5H QS 2H 9D 2C AS 6S 6C 2S 8C 8S 9H 7D QC TH 4H KD QS AC 7S 3C 4D JH 6S 5S 8H KS 9S QC 3S AS JD 2D 6S 7S TC 9H KC 3H 7D KD 2H KH 7C 4D 4S 3H JS QD 7D KC 4C JC AS 9D 3C JS 6C 8H QD 4D AH JS 3S 6C 4C 3D JH 6D 9C 9H 9H 2D 8C 7H 5S KS 6H 9C 2S TC 6C 8C AD 7H 6H 3D KH AS 5D TH KS 8C 3S TS 8S 4D 5S 9S 6C 4H 9H 4S 4H 5C 7D KC 2D 2H 9D JH 5C JS TC 9D 9H 5H 7S KH JC 6S 7C 9H 8H 4D JC KH JD 2H TD TC 8H 6C 2H 2C KH 6H 9D QS QH 5H AC 7D 2S 3D QD JC 2D 8D JD JH 2H JC 2D 7H 2C 3C 8D KD TD 4H 3S 4H 6D 8D TS 3H TD 3D 6H TH JH JC 3S AC QH 9H 7H 8S QC 2C 7H TD QS 4S 8S 9C 2S 5D 4D 2H 3D TS 3H 2S QC 8H 6H KC JC KS 5D JD 7D TC 8C 6C 9S 3D 8D AC 8H 6H JH 6C 5D 8D 8S 4H AD 2C 9D 4H 2D 2C 3S TS AS TC 3C 5D 4D TH 5H KS QS 6C 4S 2H 3D AD 5C KC 6H 2C 5S 3C 4D 2D 9H 9S JD 4C 3H TH QH 9H 5S AH 8S AC 7D 9S 6S 2H TD 9C 4H 8H QS 4C 3C 6H 5D 4H 8C 9C KC 6S QD QS 3S 9H KD TC 2D JS 8C 6S 4H 4S 2S 4C 8S QS 6H KH 3H TH 8C 5D 2C KH 5S 3S 7S 7H 6C 9D QD 8D 8H KS AC 2D KH TS 6C JS KC 7H 9C KS 5C TD QC AH 6C 5H 9S 7C 5D 4D 3H 4H 6S 7C 7S AH QD TD 2H 7D QC 6S TC TS AH 7S 9D 3H TH 5H QD 9S KS 7S 7C 6H 8C TD TH 2D 4D QC 5C 7D JD AH 9C 4H 4H 3H AH 8D 6H QC QH 9H 2H 2C 2D AD 4C TS 6H 7S TH 4H QS TD 3C KD 2H 3H QS JD TC QC 5D 8H KS JC QD TH 9S KD 8D 8C 2D 9C 3C QD KD 6D 4D 8D AH AD QC 8S 8H 3S 9D 2S 3H KS 6H 4C 7C KC TH 9S 5C 3D 7D 6H AC 7S 4D 2C 5C 3D JD 4D 2D 6D 5H 9H 4C KH AS 7H TD 6C 2H 3D QD KS 4C 4S JC 3C AC 7C JD JS 8H 9S QC 5D JD 6S 5S 2H AS 8C 7D 5H JH 3D 8D TC 5S 9S 8S 3H JC 5H 7S AS 5C TD 3D 7D 4H 8D 7H 4D 5D JS QS 9C KS TD 2S 8S 5C 2H 4H AS TH 7S 4H 7D 3H JD KD 5D 2S KC JD 7H 4S 8H 4C JS 6H QH 5S 4H 2C QS 8C 5S 3H QC 2S 6C QD AD 8C 3D JD TC 4H 2H AD 5S AC 2S 5D 2C JS 2D AD 9D 3D 4C 4S JH 8D 5H 5D 6H 7S 4D KS 9D TD JD 3D 6D 9C 2S AS 7D 5S 5C 8H JD 7C 8S 3S 6S 5H JD TC AD 7H 7S 2S 9D TS 4D AC 8D 6C QD JD 3H 9S KH 2C 3C AC 3D 5H 6H 8D 5D KS 3D 2D 6S AS 4C 2S 7C 7H KH AC 2H 3S JC 5C QH 4D 2D 5H 7S TS AS JD 8C 6H JC 8S 5S 2C 5D 7S QH 7H 6C QC 8H 2D 7C JD 2S 2C QD 2S 2H JC 9C 5D 2D JD JH 7C 5C 9C 8S 7D 6D 8D 6C 9S JH 2C AD 6S 5H 3S KS 7S 9D KH 4C 7H 6C 2C 5C TH 9D 8D 3S QC AH 5S KC 6H TC 5H 8S TH 6D 3C AH 9C KD 4H AD TD 9S 4S 7D 6H 5D 7H 5C 5H 6D AS 4C KD KH 4H 9D 3C 2S 5C 6C JD QS 2H 9D 7D 3H AC 2S 6S 7S JS QD 5C QS 6H AD 5H TH QC 7H TC 3S 7C 6D KC 3D 4H 3D QC 9S 8H 2C 3S JC KS 5C 4S 6S 2C 6H 8S 3S 3D 9H 3H JS 4S 8C 4D 2D 8H 9H 7D 9D AH TS 9S 2C 9H 4C 8D AS 7D 3D 6D 5S 6S 4C 7H 8C 3H 5H JC AH 9D 9C 2S 7C 5S JD 8C 3S 3D 4D 7D 6S 3C KC 4S 5D 7D 3D JD 7H 3H 4H 9C 9H 4H 4D TH 6D QD 8S 9S 7S 2H AC 8S 4S AD 8C 2C AH 7D TC TS 9H 3C AD KS TC 3D 8C 8H JD QC 8D 2C 3C 7D 7C JD 9H 9C 6C AH 6S JS JH 5D AS QC 2C JD TD 9H KD 2H 5D 2D 3S 7D TC AH TS TD 8H AS 5D AH QC AC 6S TC 5H KS 4S 7H 4D 8D 9C TC 2H 6H 3H 3H KD 4S QD QH 3D 8H 8C TD 7S 8S JD TC AH JS QS 2D KH KS 4D 3C AD JC KD JS KH 4S TH 9H 2C QC 5S JS 9S KS AS 7C QD 2S JD KC 5S QS 3S 2D AC 5D 9H 8H KS 6H 9C TC AD 2C 6D 5S JD 6C 7C QS KH TD QD 2C 3H 8S 2S QC AH 9D 9H JH TC QH 3C 2S JS 5C 7H 6C 3S 3D 2S 4S QD 2D TH 5D 2C 2D 6H 6D 2S JC QH AS 7H 4H KH 5H 6S KS AD TC TS 7C AC 4S 4H AD 3C 4H QS 8C 9D KS 2H 2D 4D 4S 9D 6C 6D 9C AC 8D 3H 7H KD JC AH 6C TS JD 6D AD 3S 5D QD JC JH JD 3S 7S 8S JS QC 3H 4S JD TH 5C 2C AD JS 7H 9S 2H 7S 8D 3S JH 4D QC AS JD 2C KC 6H 2C AC 5H KD 5S 7H QD JH AH 2D JC QH 8D 8S TC 5H 5C AH 8C 6C 3H JS 8S QD JH 3C 4H 6D 5C 3S 6D 4S 4C AH 5H 5S 3H JD 7C 8D 8H AH 2H 3H JS 3C 7D QC 4H KD 6S 2H KD 5H 8H 2D 3C 8S 7S QD 2S 7S KC QC AH TC QS 6D 4C 8D 5S 9H 2C 3S QD 7S 6C 2H 7C 9D 3C 6C 5C 5S JD JC KS 3S 5D TS 7C KS 6S 5S 2S 2D TC 2H 5H QS AS 7H 6S TS 5H 9S 9D 3C KD 2H 4S JS QS 3S 4H 7C 2S AC 6S 9D 8C JH 2H 5H 7C 5D QH QS KH QC 3S TD 3H 7C KC 8D 5H 8S KH 8C 4H KH JD TS 3C 7H AS QC JS 5S AH 9D 2C 8D 4D 2D 6H 6C KC 6S 2S 6H 9D 3S 7H 4D KH 8H KD 3D 9C TC AC JH KH 4D JD 5H TD 3S 7S 4H 9D AS 4C 7D QS 9S 2S KH 3S 8D 8S KS 8C JC 5C KH 2H 5D 8S QH 2C 4D KC JS QC 9D AC 6H 8S 8C 7C JS JD 6S 4C 9C AC 4S QH 5D 2C 7D JC 8S 2D JS JH 4C JS 4C 7S TS JH KC KH 5H QD 4S QD 8C 8D 2D 6S TD 9D AC QH 5S QH QC JS 3D 3C 5C 4H KH 8S 7H 7C 2C 5S JC 8S 3H QC 5D 2H KC 5S 8D KD 6H 4H QD QH 6D AH 3D 7S KS 6C 2S 4D AC QS 5H TS JD 7C 2D TC 5D QS AC JS QC 6C KC 2C KS 4D 3H TS 8S AD 4H 7S 9S QD 9H QH 5H 4H 4D KH 3S JC AD 4D AC KC 8D 6D 4C 2D KH 2C JD 2C 9H 2D AH 3H 6D 9C 7D TC KS 8C 3H KD 7C 5C 2S 4S 5H AS AH TH JD 4H KD 3H TC 5C 3S AC KH 6D 7H AH 7S QC 6H 2D TD JD AS JH 5D 7H TC 9S 7D JC AS 5S KH 2H 8C AD TH 6H QD KD 9H 6S 6C QH KC 9D 4D 3S JS JH 4H 2C 9H TC 7H KH 4H JC 7D 9S 3H QS 7S AD 7D JH 6C 7H 4H 3S 3H 4D QH JD 2H 5C AS 6C QC 4D 3C TC JH AC JD 3H 6H 4C JC AD 7D 7H 9H 4H TC TS 2C 8C 6S KS 2H JD 9S 4C 3H QS QC 9S 9H 6D KC 9D 9C 5C AD 8C 2C QH TH QD JC 8D 8H QC 2C 2S QD 9C 4D 3S 8D JH QS 9D 3S 2C 7S 7C JC TD 3C TC 9H 3C TS 8H 5C 4C 2C 6S 8D 7C 4H KS 7H 2H TC 4H 2C 3S AS AH QS 8C 2D 2H 2C 4S 4C 6S 7D 5S 3S TH QC 5D TD 3C QS KD KC KS AS 4D AH KD 9H KS 5C 4C 6H JC 7S KC 4H 5C QS TC 2H JC 9S AH QH 4S 9H 3H 5H 3C QD 2H QC JH 8H 5D AS 7H 2C 3D JH 6H 4C 6S 7D 9C JD 9H AH JS 8S QH 3H KS 8H 3S AC QC TS 4D AD 3D AH 8S 9H 7H 3H QS 9C 9S 5H JH JS AH AC 8D 3C JD 2H AC 9C 7H 5S 4D 8H 7C JH 9H 6C JS 9S 7H 8C 9D 4H 2D AS 9S 6H 4D JS JH 9H AD QD 6H 7S JH KH AH 7H TD 5S 6S 2C 8H JH 6S 5H 5S 9D TC 4C QC 9S 7D 2C KD 3H 5H AS QD 7H JS 4D TS QH 6C 8H TH 5H 3C 3H 9C 9D AD KH JS 5D 3H AS AC 9S 5C KC 2C KH 8C JC QS 6D AH 2D KC TC 9D 3H 2S 7C 4D 6D KH KS 8D 7D 9H 2S TC JH AC QC 3H 5S 3S 8H 3S AS KD 8H 4C 3H 7C JH QH TS 7S 6D 7H 9D JH 4C 3D 3S 6C AS 4S 2H 2C 4C 8S 5H KC 8C QC QD 3H 3S 6C QS QC 2D 6S 5D 2C 9D 2H 8D JH 2S 3H 2D 6C 5C 7S AD 9H JS 5D QH 8S TS 2H 7S 6S AD 6D QC 9S 7H 5H 5C 7D KC JD 4H QC 5S 9H 9C 4D 6S KS 2S 4C 7C 9H 7C 4H 8D 3S 6H 5C 8H JS 7S 2D 6H JS TD 4H 4D JC TH 5H KC AC 7C 8D TH 3H 9S 2D 4C KC 4D KD QS 9C 7S 3D KS AD TS 4C 4H QH 9C 8H 2S 7D KS 7H 5D KD 4C 9C 2S 2H JC 6S 6C TC QC JH 5C 7S AC 8H KC 8S 6H QS JC 3D 6S JS 2D JH 8C 4S 6H 8H 6D 5D AD 6H 7D 2S 4H 9H 7C AS AC 8H 5S 3C JS 4S 6D 5H 2S QH 6S 9C 2C 3D 5S 6S 9S 4C QS 8D QD 8S TC 9C 3D AH 9H 5S 2C 7D AD JC 3S 7H TC AS 3C 6S 6D 7S KH KC 9H 3S TC 8H 6S 5H JH 8C 7D AC 2S QD 9D 9C 3S JC 8C KS 8H 5D 4D JS AH JD 6D 9D 8C 9H 9S 8H 3H 2D 6S 4C 4D 8S AD 4S TC AH 9H TS AC QC TH KC 6D 4H 7S 8C 2H 3C QD JS 9D 5S JC AH 2H TS 9H 3H 4D QH 5D 9C 5H 7D 4S JC 3S 8S TH 3H 7C 2H JD JS TS AC 8D 9C 2H TD KC JD 2S 8C 5S AD 2C 3D KD 7C 5H 4D QH QD TC 6H 7D 7H 2C KC 5S KD 6H AH QC 7S QH 6H 5C AC 5H 2C 9C 2D 7C TD 2S 4D 9D AH 3D 7C JD 4H 8C 4C KS TH 3C JS QH 8H 4C AS 3D QS QC 4D 7S 5H JH 6D 7D 6H JS KH 3C QD 8S 7D 2H 2C 7C JC 2S 5H 8C QH 8S 9D TC 2H AD 7C 8D QD 6S 3S 7C AD 9H 2H 9S JD TS 4C 2D 3S AS 4H QC 2C 8H 8S 7S TD TC JH TH TD 3S 4D 4H 5S 5D QS 2C 8C QD QH TC 6D 4S 9S 9D 4H QC 8C JS 9D 6H JD 3H AD 6S TD QC KC 8S 3D 7C TD 7D 8D 9H 4S 3S 6C 4S 3D 9D KD TC KC KS AC 5S 7C 6S QH 3D JS KD 6H 6D 2D 8C JD 2S 5S 4H 8S AC 2D 6S TS 5C 5H 8C 5S 3C 4S 3D 7C 8D AS 3H AS TS 7C 3H AD 7D JC QS 6C 6H 3S 9S 4C AC QH 5H 5D 9H TS 4H 6C 5C 7H 7S TD AD JD 5S 2H 2S 7D 6C KC 3S JD 8D 8S TS QS KH 8S QS 8D 6C TH AC AH 2C 8H 9S 7H TD KH QH 8S 3D 4D AH JD AS TS 3D 2H JC 2S JH KH 6C QC JS KC TH 2D 6H 7S 2S TC 8C 9D QS 3C 9D 6S KH 8H 6D 5D TH 2C 2H 6H TC 7D AD 4D 8S TS 9H TD 7S JS 6D JD JC 2H AC 6C 3D KH 8D KH JD 9S 5D 4H 4C 3H 7S QS 5C 4H JD 5D 3S 3C 4D KH QH QS 7S JD TS 8S QD AH 4C 6H 3S 5S 2C QS 3D JD AS 8D TH 7C 6S QC KS 7S 2H 8C QC 7H AC 6D 2D TH KH 5S 6C 7H KH 7D AH 8C 5C 7S 3D 3C KD AD 7D 6C 4D KS 2D 8C 4S 7C 8D 5S 2D 2S AH AD 2C 9D TD 3C AD 4S KS JH 7C 5C 8C 9C TH AS TD 4D 7C JD 8C QH 3C 5H 9S 3H 9C 8S 9S 6S QD KS AH 5H JH QC 9C 5S 4H 2H TD 7D AS 8C 9D 8C 2C 9D KD TC 7S 3D KH QC 3C 4D AS 4C QS 5S 9D 6S JD QH KS 6D AH 6C 4C 5H TS 9H 7D 3D 5S QS JD 7C 8D 9C AC 3S 6S 6C KH 8H JH 5D 9S 6D AS 6S 3S QC 7H QD AD 5C JH 2H AH 4H AS KC 2C JH 9C 2C 6H 2D JS 5D 9H KC 6D 7D 9D KD TH 3H AS 6S QC 6H AD JD 4H 7D KC 3H JS 3C TH 3D QS 4C 3H 8C QD 5H 6H AS 8H AD JD TH 8S KD 5D QC 7D JS 5S 5H TS 7D KC 9D QS 3H 3C 6D TS 7S AH 7C 4H 7H AH QC AC 4D 5D 6D TH 3C 4H 2S KD 8H 5H JH TC 6C JD 4S 8C 3D 4H JS TD 7S JH QS KD 7C QC KD 4D 7H 6S AD TD TC KH 5H 9H KC 3H 4D 3D AD 6S QD 6H TH 7C 6H TS QH 5S 2C KC TD 6S 7C 4D 5S JD JH 7D AC KD KH 4H 7D 6C 8D 8H 5C JH 8S QD TH JD 8D 7D 6C 7C 9D KD AS 5C QH JH 9S 2C 8C 3C 4C KS JH 2D 8D 4H 7S 6C JH KH 8H 3H 9D 2D AH 6D 4D TC 9C 8D 7H TD KS TH KD 3C JD 9H 8D QD AS KD 9D 2C 2S 9C 8D 3H 5C 7H KS 5H QH 2D 8C 9H 2D TH 6D QD 6C KC 3H 3S AD 4C 4H 3H JS 9D 3C TC 5H QH QC JC 3D 5C 6H 3S 3C JC 5S 7S 2S QH AC 5C 8C 4D 5D 4H 2S QD 3C 3H 2C TD AH 9C KD JS 6S QD 4C QC QS 8C 3S 4H TC JS 3H 7C JC AD 5H 4D 9C KS JC TD 9S TS 8S 9H QD TS 7D AS AC 2C TD 6H 8H AH 6S AD 8C 4S 9H 8D 9D KH 8S 3C QS 4D 2D 7S KH JS JC AD 4C 3C QS 9S 7H KC TD TH 5H JS AC JH 6D AC 2S QS 7C AS KS 6S KH 5S 6D 8H KH 3C QS 2H 5C 9C 9D 6C JS 2C 4C 6H 7D JC AC QD TD 3H 4H QC 8H JD 4C KD KS 5C KC 7S 6D 2D 3H 2S QD 5S 7H AS TH 6S AS 6D 8D 2C 8S TD 8H QD JC AH 9C 9H 2D TD QH 2H 5C TC 3D 8H KC 8S 3D KH 2S TS TC 6S 4D JH 9H 9D QS AC KC 6H 5D 4D 8D AH 9S 5C QS 4H 7C 7D 2H 8S AD JS 3D AC 9S AS 2C 2D 2H 3H JC KH 7H QH KH JD TC KS 5S 8H 4C 8D 2H 7H 3S 2S 5H QS 3C AS 9H KD AD 3D JD 6H 5S 9C 6D AC 9S 3S 3D 5D 9C 2D AC 4S 2S AD 6C 6S QC 4C 2D 3H 6S KC QH QD 2H JH QC 3C 8S 4D 9S 2H 5C 8H QS QD 6D KD 6S 7H 3S KH 2H 5C JC 6C 3S 9S TC 6S 8H 2D AD 7S 8S TS 3C 6H 9C 3H 5C JC 8H QH TD QD 3C JS QD 5D TD 2C KH 9H TH AS 9S TC JD 3D 5C 5H AD QH 9H KC TC 7H 4H 8H 3H TD 6S AC 7C 2S QS 9D 5D 3C JC KS 4D 6C JH 2S 9S 6S 3C 7H TS 4C KD 6D 3D 9C 2D 9H AH AC 7H 2S JH 3S 7C QC QD 9H 3C 2H AC AS 8S KD 8C KH 2D 7S TD TH 6D JD 8D 4D 2H 5S 8S QH KD JD QS JH 4D KC 5H 3S 3C KH QC 6D 8H 3S AH 7D TD 2D 5S 9H QH 4S 6S 6C 6D TS TH 7S 6C 4C 6D QS JS 9C TS 3H 8D 8S JS 5C 7S AS 2C AH 2H AD 5S TC KD 6C 9C 9D TS 2S JC 4H 2C QD QS 9H TC 3H KC KS 4H 3C AD TH KH 9C 2H KD 9D TC 7S KC JH 2D 7C 3S KC AS 8C 5D 9C 9S QH 3H 2D 8C TD 4C 2H QC 5D TC 2C 7D KS 4D 6C QH TD KH 5D 7C AD 8D 2S 9S 8S 4C 8C 3D 6H QD 7C 7H 6C 8S QH 5H TS 5C 3C 4S 2S 2H 8S 6S 2H JC 3S 3H 9D 8C 2S 7H QC 2C 8H 9C AC JD 4C 4H 6S 3S 3H 3S 7D 4C 9S 5H 8H JC 3D TC QH 2S 2D 9S KD QD 9H AD 6D 9C 8D 2D KS 9S JC 4C JD KC 4S TH KH TS 6D 4D 5C KD 5H AS 9H AD QD JS 7C 6D 5D 5C TH 5H QH QS 9D QH KH 5H JH 4C 4D TC TH 6C KH AS TS 9D KD 9C 7S 4D 8H 5S KH AS 2S 7D 9D 4C TS TH AH 7C KS 4D AC 8S 9S 8D TH QH 9D 5C 5D 5C 8C QS TC 4C 3D 3S 2C 8D 9D KS 2D 3C KC 4S 8C KH 6C JC 8H AH 6H 7D 7S QD 3C 4C 6C KC 3H 2C QH 8H AS 7D 4C 8C 4H KC QD 5S 4H 2C TD AH JH QH 4C 8S 3H QS 5S JS 8H 2S 9H 9C 3S 2C 6H TS 7S JC QD AC TD KC 5S 3H QH AS QS 7D JC KC 2C 4C 5C 5S QH 3D AS JS 4H 8D 7H JC 2S 9C 5D 4D 2S 4S 9D 9C 2D QS 8H 7H 6D 7H 3H JS TS AC 2D JH 7C 8S JH 5H KC 3C TC 5S 9H 4C 8H 9D 8S KC 5H 9H AD KS 9D KH 8D AH JC 2H 9H KS 6S 3H QC 5H AH 9C 5C KH 5S AD 6C JC 9H QC 9C TD 5S 5D JC QH 2D KS 8H QS 2H TS JH 5H 5S AH 7H 3C 8S AS TD KH 6H 3D JD 2C 4C KC 7S AH 6C JH 4C KS 9D AD 7S KC 7D 8H 3S 9C 7H 5C 5H 3C 8H QC 3D KH 6D JC 2D 4H 5D 7D QC AD AH 9H QH 8H KD 8C JS 9D 3S 3C 2H 5D 6D 2S 8S 6S TS 3C 6H 8D 5S 3H TD 6C KS 3D JH 9C 7C 9S QS 5S 4H 6H 7S 6S TH 4S KC KD 3S JC JH KS 7C 3C 2S 6D QH 2C 7S 5H 8H AH KC 8D QD 6D KH 5C 7H 9D 3D 9C 6H 2D 8S JS 9S 2S 6D KC 7C TC KD 9C JH 7H KC 8S 2S 7S 3D 6H 4H 9H 2D 4C 8H 7H 5S 8S 2H 8D AD 7C 3C 7S 5S 4D 9H 3D JC KH 5D AS 7D 6D 9C JC 4C QH QS KH KD JD 7D 3D QS QC 8S 6D JS QD 6S 8C 5S QH TH 9H AS AC 2C JD QC KS QH 7S 3C 4C 5C KC 5D AH 6C 4H 9D AH 2C 3H KD 3D TS 5C TD 8S QS AS JS 3H KD AC 4H KS 7D 5D TS 9H 4H 4C 9C 2H 8C QC 2C 7D 9H 4D KS 4C QH AD KD JS QD AD AH KH 9D JS 9H JC KD JD 8S 3C 4S TS 7S 4D 5C 2S 6H 7C JS 7S 5C KD 6D QH 8S TD 2H 6S QH 6C TC 6H TD 4C 9D 2H QC 8H 3D TS 4D 2H 6H 6S 2C 7H 8S 6C 9H 9D JD JH 3S AH 2C 6S 3H 8S 2C QS 8C 5S 3H 2S 7D 3C AD 4S 5C QC QH AS TS 4S 6S 4C 5H JS JH 5C TD 4C 6H JS KD KH QS 4H TC KH JC 4D 9H 9D 8D KC 3C 8H 2H TC 8S AD 9S 4H TS 7H 2C 5C 4H 2S 6C 5S KS AH 9C 7C 8H KD TS QH TD QS 3C JH AH 2C 8D 7D 5D KC 3H 5S AC 4S 7H QS 4C 2H 3D 7D QC KH JH 6D 6C TD TH KD 5S 8D TH 6C 9D 7D KH 8C 9S 6D JD QS 7S QC 2S QH JC 4S KS 8D 7S 5S 9S JD KD 9C JC AD 2D 7C 4S 5H AH JH 9C 5D TD 7C 2D 6S KC 6C 7H 6S 9C QD 5S 4H KS TD 6S 8D KS 2D TH TD 9H JD TS 3S KH JS 4H 5D 9D TC TD QC JD TS QS QD AC AD 4C 6S 2D AS 3H KC 4C 7C 3C TD QS 9C KC AS 8D AD KC 7H QC 6D 8H 6S 5S AH 7S 8C 3S AD 9H JC 6D JD AS KH 6S JH AD 3D TS KS 7H JH 2D JS QD AC 9C JD 7C 6D TC 6H 6C JC 3D 3S QC KC 3S JC KD 2C 8D AH QS TS AS KD 3D JD 8H 7C 8C 5C QD 6C ================================================ FILE: Problem055/.hash ================================================ 077e29b11be80ab57e1a2ecabb7da330 ================================================ FILE: Problem055/CommonLisp/solution_1.lisp ================================================ ;; Common Lisp Script ;; Manoel Vilela (defmacro memoize (func) `(let ((table (make-hash-table :size 10000)) (old-function (symbol-function ',func))) (defun ,func (x &rest tail) (multiple-value-bind (value exists) (gethash x table) (if exists value (setf (gethash x table) (apply old-function (cons x tail)))))))) (defun reverse-integer (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) (= (reverse-integer n) n)) (defun iterative-palindromep (n &optional (depth 50)) (unless (= depth 0) (let ((next (+ n (reverse-integer n)))) (if (palindromep next) t (iterative-palindromep next (1- depth)))))) (defun lychrelp (x) (not (iterative-palindromep x))) (defun solution() (memoize palindromep) (memoize iterative-palindromep) (memoize reverse-integer) (loop for x from 1 below 10000 when (lychrelp x) count x )) (princ (solution)) ================================================ FILE: Problem055/Python/solution_1.py ================================================ #code created by NamanNimmo Gera #4:57pm, May 1, 2019. def reverse(x): return int(str(x)[::-1]) def Palindrome(x): if x == reverse(x): return True else: return False #function to check if a number is a Lychrel number or not def checkLyr(x): tot = 0 while True: x = x + reverse(x) if Palindrome(x): return False else: tot = tot + 1 if tot>50: return True count = 0 for i in range(1,10000): if checkLyr(i): count = count + 1 print(count) ================================================ FILE: Problem055/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=55) ================================================ FILE: Problem056/.hash ================================================ c22abfa379f38b5b0411bc11fa9bf92f ================================================ FILE: Problem056/Clojure/solution_1.clj ================================================ ;Author: tkovs (defn pow [x n] (reduce *' (repeat n x))) (defn sum [x] (apply + (map #(Integer. (str %)) (str x)))) (defn solve [] (let [list (range 1 100) numbers (mapcat (fn [x] (map (fn [y] (pow x y)) list)) list) sumDigits (map sum numbers)] (apply max sumDigits) )) (println (solve)) ================================================ FILE: Problem056/CommonLisp/solution_1.lisp ================================================ ;; Common Lisp Script ;; Manoel Vilela (defun sum-digits (number &optional (base 10)) (loop for n = number then q for (q r) = (multiple-value-list (truncate n base)) sum r until (zerop q))) (defun solution () (loop for a from 1 to 100 maximize (loop for b from 1 to 100 maximize (sum-digits (expt a b))))) (format t "~a~%" (solution)) ================================================ FILE: Problem056/Haskell/solution_1.hs ================================================ -- Author: tkovs numbers :: [Integer] numbers = [a^b | a <- [1..100], b <- [1..100]] sumDigits :: Integer -> Int sumDigits x = sum $ map (\x -> (fromEnum x) - 48) $ show x solve :: Int solve = maximum $ map sumDigits numbers main :: IO () main = do print solve ================================================ FILE: Problem056/Python/solution_1.py ================================================ #code created by NamanNimmo Gera #2:25pm, April 12, 2019. highest = 0 for i in range(90,100): for j in range(90,100): #another brute force :D if sum(map(int, str(i**j)))>highest: highest = sum(map(int, str(i**j))) #to calculate the sum of digits of the number(i**j) print(highest) ================================================ FILE: Problem056/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=56) ================================================ FILE: Problem056/Ruby/solution_1.rb ================================================ #Author: tkovs def solve #generate list a^b | a <- [1..99] and b <- [1..99] numbers = (1..99).flat_map{|a| (1..99).map{|b| a ** b}} #map digits' sum of each number sumDigits = numbers.map{|element| element.to_s.split('').map{|digit| digit.to_i}.inject(:+)} #return the maximum value return(sumDigits.max) end puts(solve) ================================================ FILE: Problem057/.hash ================================================ b3e3e393c77e35a4a3f3cbd1e429b5dc ================================================ FILE: Problem057/Haskell/solution_slow_1.hs ================================================ -- Author: Manoel Vilela -- Time: ~ 51s (how to improve?) import Data.Ratio (numerator, denominator) -- recursive part continuedFraction :: Rational -> Rational -> Rational continuedFraction _ 0 = 0 continuedFraction a 1 = a continuedFraction a n = a + 1/continuedFraction a (n-1) sqrt2Recursive :: Integer -> Rational sqrt2Recursive 0 = 0 sqrt2Recursive n = 1 + 1/continuedFraction 2 (toRational n) numGreaterThanDen :: Rational -> Bool numGreaterThanDen r = let n = length $ show $ numerator r d = length $ show $ denominator r in n > d main :: IO() main = print $ length $ filter numGreaterThanDen $ map sqrt2Recursive [1..1000] ================================================ FILE: Problem057/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=57) ================================================ FILE: Problem058/.hash ================================================ b62fc92a2561538525c89be63f36bf7b ================================================ FILE: Problem058/Python/solution_1.py ================================================ import math def is_prime(n): if n%2 == 0: return False for i in range(3, math.floor(math.sqrt(n)) + 1, 2): if n%i == 0: return False return True class Problem058(object): def __init__(self): self.nprimes = 8 self.level = 7 self.prime_ratio = 0.62 def _diag_primes(self): # Count primes on top left 3 corners # 3n - k(n + 1) / k => {1, 2, 3} return [is_prime(self.level**2 - self.level + 1), is_prime(self.level**2 - 2*self.level + 2), is_prime(self.level**2 - 3*self.level + 3)].count(True) def _record_next_diag_primes(self): self.level += 2 self.nprimes += self._diag_primes() self.prime_ratio = self.nprimes / (self.level * 2 - 1) def _solve(self, ratio_limit): while self.prime_ratio > ratio_limit: self._record_next_diag_primes() return self.level @classmethod def solve(cls): obj = object.__new__(cls) obj.__init__() return obj._solve(0.1) if __name__ == "__main__": print(Problem058.solve()) ================================================ FILE: Problem058/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=58) ================================================ FILE: Problem059/.hash ================================================ 68f891fe214e2bfa07c998ad5d0a390f ================================================ FILE: Problem059/Haskell/solution_1.hs ================================================ {-- Author: Manoel Vilela --} import Data.Char (chr, ord) import Data.Bits (xor) parseFile :: String -> [Int] parseFile s = read ("[" ++ s ++ "]") passwords :: [[Int]] passwords = [map ord [a,b,c] | a <- ['a'..'z'], b <- ['a'..'z'], c <- ['a'..'z']] applyKey :: [Int] -> [Int] -> [Int] applyKey content pass = [ x `xor` y | (x,y) <- pairs] where pairs = zip content $ concat $ repeat pass checkIt :: [Int] -> Bool checkIt = all commonAscii where commonAscii x = x `elem` asciiNumbers ++ asciiPunct || asciiLower x || asciiUpper x asciiNumbers = [48..57] asciiPunct = [32,33,34,39,40,41,44,45,46,58,59] asciiLower x = x >= 97 && x <= 122 asciiUpper x = x >= 65 && x <= 90 decrypt :: [Int] -> [Int] decrypt codes = head [decrypted | pass <- passwords, let decrypted = applyKey codes pass, checkIt decrypted] main = do content <- readFile "../p059_cipher.txt" print $ sum $ decrypt $ parseFile (head (lines content)) ================================================ FILE: Problem059/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=59) ================================================ FILE: Problem059/p059_cipher.txt ================================================ 79,59,12,2,79,35,8,28,20,2,3,68,8,9,68,45,0,12,9,67,68,4,7,5,23,27,1,21,79,85,78,79,85,71,38,10,71,27,12,2,79,6,2,8,13,9,1,13,9,8,68,19,7,1,71,56,11,21,11,68,6,3,22,2,14,0,30,79,1,31,6,23,19,10,0,73,79,44,2,79,19,6,28,68,16,6,16,15,79,35,8,11,72,71,14,10,3,79,12,2,79,19,6,28,68,32,0,0,73,79,86,71,39,1,71,24,5,20,79,13,9,79,16,15,10,68,5,10,3,14,1,10,14,1,3,71,24,13,19,7,68,32,0,0,73,79,87,71,39,1,71,12,22,2,14,16,2,11,68,2,25,1,21,22,16,15,6,10,0,79,16,15,10,22,2,79,13,20,65,68,41,0,16,15,6,10,0,79,1,31,6,23,19,28,68,19,7,5,19,79,12,2,79,0,14,11,10,64,27,68,10,14,15,2,65,68,83,79,40,14,9,1,71,6,16,20,10,8,1,79,19,6,28,68,14,1,68,15,6,9,75,79,5,9,11,68,19,7,13,20,79,8,14,9,1,71,8,13,17,10,23,71,3,13,0,7,16,71,27,11,71,10,18,2,29,29,8,1,1,73,79,81,71,59,12,2,79,8,14,8,12,19,79,23,15,6,10,2,28,68,19,7,22,8,26,3,15,79,16,15,10,68,3,14,22,12,1,1,20,28,72,71,14,10,3,79,16,15,10,68,3,14,22,12,1,1,20,28,68,4,14,10,71,1,1,17,10,22,71,10,28,19,6,10,0,26,13,20,7,68,14,27,74,71,89,68,32,0,0,71,28,1,9,27,68,45,0,12,9,79,16,15,10,68,37,14,20,19,6,23,19,79,83,71,27,11,71,27,1,11,3,68,2,25,1,21,22,11,9,10,68,6,13,11,18,27,68,19,7,1,71,3,13,0,7,16,71,28,11,71,27,12,6,27,68,2,25,1,21,22,11,9,10,68,10,6,3,15,27,68,5,10,8,14,10,18,2,79,6,2,12,5,18,28,1,71,0,2,71,7,13,20,79,16,2,28,16,14,2,11,9,22,74,71,87,68,45,0,12,9,79,12,14,2,23,2,3,2,71,24,5,20,79,10,8,27,68,19,7,1,71,3,13,0,7,16,92,79,12,2,79,19,6,28,68,8,1,8,30,79,5,71,24,13,19,1,1,20,28,68,19,0,68,19,7,1,71,3,13,0,7,16,73,79,93,71,59,12,2,79,11,9,10,68,16,7,11,71,6,23,71,27,12,2,79,16,21,26,1,71,3,13,0,7,16,75,79,19,15,0,68,0,6,18,2,28,68,11,6,3,15,27,68,19,0,68,2,25,1,21,22,11,9,10,72,71,24,5,20,79,3,8,6,10,0,79,16,8,79,7,8,2,1,71,6,10,19,0,68,19,7,1,71,24,11,21,3,0,73,79,85,87,79,38,18,27,68,6,3,16,15,0,17,0,7,68,19,7,1,71,24,11,21,3,0,71,24,5,20,79,9,6,11,1,71,27,12,21,0,17,0,7,68,15,6,9,75,79,16,15,10,68,16,0,22,11,11,68,3,6,0,9,72,16,71,29,1,4,0,3,9,6,30,2,79,12,14,2,68,16,7,1,9,79,12,2,79,7,6,2,1,73,79,85,86,79,33,17,10,10,71,6,10,71,7,13,20,79,11,16,1,68,11,14,10,3,79,5,9,11,68,6,2,11,9,8,68,15,6,23,71,0,19,9,79,20,2,0,20,11,10,72,71,7,1,71,24,5,20,79,10,8,27,68,6,12,7,2,31,16,2,11,74,71,94,86,71,45,17,19,79,16,8,79,5,11,3,68,16,7,11,71,13,1,11,6,1,17,10,0,71,7,13,10,79,5,9,11,68,6,12,7,2,31,16,2,11,68,15,6,9,75,79,12,2,79,3,6,25,1,71,27,12,2,79,22,14,8,12,19,79,16,8,79,6,2,12,11,10,10,68,4,7,13,11,11,22,2,1,68,8,9,68,32,0,0,73,79,85,84,79,48,15,10,29,71,14,22,2,79,22,2,13,11,21,1,69,71,59,12,14,28,68,14,28,68,9,0,16,71,14,68,23,7,29,20,6,7,6,3,68,5,6,22,19,7,68,21,10,23,18,3,16,14,1,3,71,9,22,8,2,68,15,26,9,6,1,68,23,14,23,20,6,11,9,79,11,21,79,20,11,14,10,75,79,16,15,6,23,71,29,1,5,6,22,19,7,68,4,0,9,2,28,68,1,29,11,10,79,35,8,11,74,86,91,68,52,0,68,19,7,1,71,56,11,21,11,68,5,10,7,6,2,1,71,7,17,10,14,10,71,14,10,3,79,8,14,25,1,3,79,12,2,29,1,71,0,10,71,10,5,21,27,12,71,14,9,8,1,3,71,26,23,73,79,44,2,79,19,6,28,68,1,26,8,11,79,11,1,79,17,9,9,5,14,3,13,9,8,68,11,0,18,2,79,5,9,11,68,1,14,13,19,7,2,18,3,10,2,28,23,73,79,37,9,11,68,16,10,68,15,14,18,2,79,23,2,10,10,71,7,13,20,79,3,11,0,22,30,67,68,19,7,1,71,8,8,8,29,29,71,0,2,71,27,12,2,79,11,9,3,29,71,60,11,9,79,11,1,79,16,15,10,68,33,14,16,15,10,22,73 ================================================ FILE: Problem062/.hash ================================================ 8f46b522b5401b8b6df99a7410eea44b ================================================ FILE: Problem062/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # Python Script # # Copyleft © Manoel Vilela # # """ Cubic permutations Problem 62 The cube, 41063625 (345^3), can be permuted to produce two other cubes: 56623104 (384^3) and 66430125 (405^3). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits which are also cube. Find the smallest cube for which exactly five permutations of its digits are cube. """ def cubesGen(n, start=1): return map(lambda x: str(x*x*x), range(start, n + 1)) def getId(n): return sum([2 ** int(x) for x in n]) * sum([int(x) for x in list(n)]) def isPerm(a, b): for i in a: for j in b: if i not in b or j not in a: return False return getId(a) == getId(b) def cubeRoot(n): return int(n ** (1/3) + 0.00001) def mostCube(n): most = int(''.join(sorted(n, reverse=True))) return cubeRoot(most) def lowerCube(n): lower = int(''.join(sorted(n))) return cubeRoot(lower) # my_solution... after much hard work the results final is this... # i want to break free XD def solution(max): maxCube = 10 ** 15 for cube_a in cubesGen(maxCube): permCubes = 0 for cube_b in cubesGen(int(mostCube(cube_a)), start=int(lowerCube(cube_a))): if isPerm(cube_a, cube_b): permCubes += 1 if permCubes == max: return cube_a #the solution of one guy, much more efficient. def solution_extern(): def cubes(): i = 1 while True: yield i * i * i i += 1 cube_dict = {} for c in cubes(): digits = ''.join(sorted(str(c))) if digits in cube_dict: cube_list = cube_dict[digits] cube_list.append(c) if(len(cube_list)) == 5: return min(cube_list) break else: cube_dict[digits] = [c] print(solution_extern()) #wrong answer: 1000600120008 (because its included the self number, this answer contain 6 permutations) #correct answer: 127035954683 (5 permutations!) ================================================ FILE: Problem062/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=62) ================================================ FILE: Problem063/.hash ================================================ f457c545a9ded88f18ecee47145a72c0 ================================================ FILE: Problem063/C/Makefile ================================================ CXX = gcc LFLAGS = -lm -Wall -o TARGET = solution_1 EXTENSION_TARGET = c EXTENSION_OUT = out all: $(CXX) $(LFLAGS) $(TARGET).$(EXTENSION_OUT) $(TARGET).$(EXTENSION_TARGET) clean: rm -v *.$(EXTENSION_OUT) run: ./$(TARGET).$(EXTENSION_OUT) ================================================ FILE: Problem063/C/solution_1.c ================================================ #include #include int num_length (double n) { if (n < 10) return 1; else return 1 + num_length(n / 10); } int main(int argc, char **argv) { int a, n; int ndigits = 0; for (a = 1; a < 10; a++) { for (n = 1; n < 22; n++) { if (num_length(pow(a,n)) == n) { ndigits += 1; } } } printf("%d\n", ndigits); return 0; } ================================================ FILE: Problem063/CommonLisp/solution_1.lisp ================================================ (defun range (n) (loop for x from 1 to n collect x)) (defun ilength (n) (length (write-to-string n))) (defun solution() (loop for a in (range 9) for tries = (loop for n in (range 21) for x = (expt a n) when (= (ilength x) n) collect x) sum (length tries))) (princ (solution)) ================================================ FILE: Problem063/Elixir/solution_1.exs ================================================ defmodule PowerfulDigits do def counts(_,_,count,len_bool) when len_bool == false, do: count def counts(exp,num,count,len_bool) when len_bool == true do [num,count] = cond do num != 9 -> exps(num,num,exp,count) true -> [num,count + 1] end counts(exp + 1,num,count,same_len?(9,exp)) end def exps(num,n,_,count) when n > 9 do [num,count] end def exps(num,n,exp,count) when n <= 9 do [num|count] = cond do same_len?(n,exp) -> [num|count + 1] true -> greater_than_n?(num,n,count) end exps(num,n + 1,exp,count) end def greater_than_n?(num,n,count) do cond do n > num -> [num|count] true -> [n|count] end end def same_len?(n,exp), do: exp == round(:math.pow(n,exp)) |> to_string |> String.length() end IO.puts PowerfulDigits.counts(1,1,0,true) ================================================ FILE: Problem063/Go/solution_1.go ================================================ // Copyright 2017 the DestructHub Authors. (Manoel Vilela wrote this shit) package main import ( "fmt" "math" ) func numLength(n float64) int { if n < 10 { return 1 } return 1 + numLength(n/10) } func main() { ndigits := 0 for a := 1; a <= 9; a += 1 { for n := 1; n <= 21; n += 1 { if numLength(math.Pow(float64(a), float64(n))) == n { ndigits += 1 } } } fmt.Println(ndigits) } ================================================ FILE: Problem063/Haskell/solution_1.hs ================================================ {-- Author: Manoel Vilela Time: 0.003s (3ms) @ Intel E7400 3.5Ghz The biggest solution for this problem is the mathematical background. The source code written here is just a straight forward evaluation of it. Well, to beginning this lets make clear the problem: :: How many n-digit positive integers exist which are also an nth power? So we are looking a arbitrary a^n = k whose k has length n. A arbitrary number k has the length n when this constraint is True: 10^(n-1) <= k < 10^n Let's take a example. For n <- 4 all the n-digits numbers are between that bounds: 10^3 <= k < 10^4 <=> 1000 <= k < 10000 Which seems true. For this be very trivial, I'll not write a proof here. But which the values possible for `a` and `n`? To start, let's look with `a` for k = a^n (more easy): 1 = 1^1 2 = 2^1 3 = 3^1 ... 9 = 9^1 but 10 = 10^1, length "10" == 2 and n == 1, so `a` cannot be 10. Looking at this and the constraint k < 10^n, if we write k as a^n, which means a^n < 10^n, then so the biggest integer for which this is True is when a = 9. 9^n < 10^n, any a > 9 this statement is false. So `a` is on the interval [1,9] In another case, which values `n` can assume? Let's look to this inequality: 10^(n-1) <= a^n What the max value that n can assumes? Let's assume `a` for the biggest value possible (9) and the case when this statement is a equality, so then: 10^(n - 1) = 9^n log(10^(n-1)) = log(9^n) {logarithm of base 10 on both sides} (n-1)*log(10) = n * log(9) {logarithm theorem log(a^b) = a * log(a)} n - 1 = n * log(3^2) {log(10)=1 and 9 = 3^2} n -1 = n * 2*log(3) {again logarithm theorem of power} n - n*2*log(3) = 1 {sum 1 - 2*log(3) on both sides} n(1 - 2*log(3)) = 1 {distributive law of multiplication} n = 1/(1 - 2*log(3)) {divide both sides for (1 - 2*log(3))} n ~= 21 {evaluation for n as integer} That means so we need look for a <- [1..9] and n <- [1..21]. The most simplest implementation on Haskell is given below. --} main :: IO() main = print $ length [x | a <- [1..9], n <- [1..21], let x = a^n, n == length (show x)] ================================================ FILE: Problem063/Python/solution_1.py ================================================ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Copyright © Manoel Vilela 2017 # # @team: DestructHub # @project: ProjectEuler # @author: Manoel Vilela # @email: manoel_vilela@engineer.com # print(len([a ** n for a in range(1, 10) for n in range(1, 22) if len(str(a ** n)) == n])) ================================================ FILE: Problem063/Python/solution_2.py ================================================ #code created by NamanNimmo Gera #2:34pm, April 15, 2019. from math import log10 count = 0 for i in range(1,10): count = count + int(1/(1-log10(i))) ##realise that for x > 10, x^n > 10^n print(count) ================================================ FILE: Problem063/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=63) ================================================ FILE: Problem067/.hash ================================================ 9d702ffd99ad9c70ac37e506facc8c38 ================================================ FILE: Problem067/Elixir/solution_1.exs ================================================ 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 defmodule Triangle do def input(file) do case File.read(file) do {:ok, body} -> body |> String.split("\n", trim: true) |> Enum.reverse() |> Enum.map(fn x -> String.split(x," ", trim: true) end) |> MaximumPath.find() |> IO.puts {:error,reason} -> :file.format_error(reason) end end end Triangle.input("../p067_triangle.txt") ================================================ FILE: Problem067/Python/solution_1.py ================================================ #coding=utf-8 # search the biggest sum nums adjacent on the row of the triangle below # python3.4 # need a more efficient algorithm to search the biggest sum # in a row in the tree binary. # The maxarrow function search for or all routes, # and the tree as been 100 lines, than have 2 ^ 100 routes! # Obviouslly, not is possible use this to solution that problem. # It's not possible to trying all routes, # it's take veryyyyyyyyyyyyy long time. # I used OO concept to construct a clever method! :D def int_triangle(data): return [[int(x) for x in y.split()] for y in [x for x in data.split('\n')]] class Tree(object): def __init__(self, data): self.data = data self.index = (0, 0) self.best_ways = {(0, 0): [(0, 0)]} self.sums = {} self.routes = [] def solution(self): self.search() return max(self.calc_route(route) for route in self.routes) def calc_route(self, route): return sum([self.data[y][x] for y, x in route]) def num(self, index): return self.data.__getitem__(*index) def search(self): for y in range(1, len(self.data)): for x in range(y + 1): self.index = (y, x) self.decise() def insert_route(self, last): newroute = self.best_ways[last] + [self.index] self.best_ways[self.index] = newroute self.sums[self.index] = self.calc_route(newroute) if len(newroute) == len(self.data): self.routes.append(newroute) def decise(self): y, x = self.index if x == y: # left extrem of the Tree, it's just possible to walk by left last = ((y - 1), (x - 1)) elif x == 0: # right extrem of the Tree , it's just possible to walk by right last = ((y - 1), x) else: left = ((y - 1), (x - 1)) right = ((y - 1), x) if self.sums[left] > self.sums[right]: last = left else: last = right self.insert_route(last) if __name__ == '__main__': from os.path import join, dirname with open('../p067_triangle.txt') as f: data = int_triangle(f.read()[:-1]) t = Tree(data) print(t.solution()) ================================================ FILE: Problem067/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=67) ================================================ FILE: Problem067/p067_triangle.txt ================================================ 59 73 41 52 40 09 26 53 06 34 10 51 87 86 81 61 95 66 57 25 68 90 81 80 38 92 67 73 30 28 51 76 81 18 75 44 84 14 95 87 62 81 17 78 58 21 46 71 58 02 79 62 39 31 09 56 34 35 53 78 31 81 18 90 93 15 78 53 04 21 84 93 32 13 97 11 37 51 45 03 81 79 05 18 78 86 13 30 63 99 95 39 87 96 28 03 38 42 17 82 87 58 07 22 57 06 17 51 17 07 93 09 07 75 97 95 78 87 08 53 67 66 59 60 88 99 94 65 55 77 55 34 27 53 78 28 76 40 41 04 87 16 09 42 75 69 23 97 30 60 10 79 87 12 10 44 26 21 36 32 84 98 60 13 12 36 16 63 31 91 35 70 39 06 05 55 27 38 48 28 22 34 35 62 62 15 14 94 89 86 66 56 68 84 96 21 34 34 34 81 62 40 65 54 62 05 98 03 02 60 38 89 46 37 99 54 34 53 36 14 70 26 02 90 45 13 31 61 83 73 47 36 10 63 96 60 49 41 05 37 42 14 58 84 93 96 17 09 43 05 43 06 59 66 57 87 57 61 28 37 51 84 73 79 15 39 95 88 87 43 39 11 86 77 74 18 54 42 05 79 30 49 99 73 46 37 50 02 45 09 54 52 27 95 27 65 19 45 26 45 71 39 17 78 76 29 52 90 18 99 78 19 35 62 71 19 23 65 93 85 49 33 75 09 02 33 24 47 61 60 55 32 88 57 55 91 54 46 57 07 77 98 52 80 99 24 25 46 78 79 05 92 09 13 55 10 67 26 78 76 82 63 49 51 31 24 68 05 57 07 54 69 21 67 43 17 63 12 24 59 06 08 98 74 66 26 61 60 13 03 09 09 24 30 71 08 88 70 72 70 29 90 11 82 41 34 66 82 67 04 36 60 92 77 91 85 62 49 59 61 30 90 29 94 26 41 89 04 53 22 83 41 09 74 90 48 28 26 37 28 52 77 26 51 32 18 98 79 36 62 13 17 08 19 54 89 29 73 68 42 14 08 16 70 37 37 60 69 70 72 71 09 59 13 60 38 13 57 36 09 30 43 89 30 39 15 02 44 73 05 73 26 63 56 86 12 55 55 85 50 62 99 84 77 28 85 03 21 27 22 19 26 82 69 54 04 13 07 85 14 01 15 70 59 89 95 10 19 04 09 31 92 91 38 92 86 98 75 21 05 64 42 62 84 36 20 73 42 21 23 22 51 51 79 25 45 85 53 03 43 22 75 63 02 49 14 12 89 14 60 78 92 16 44 82 38 30 72 11 46 52 90 27 08 65 78 03 85 41 57 79 39 52 33 48 78 27 56 56 39 13 19 43 86 72 58 95 39 07 04 34 21 98 39 15 39 84 89 69 84 46 37 57 59 35 59 50 26 15 93 42 89 36 27 78 91 24 11 17 41 05 94 07 69 51 96 03 96 47 90 90 45 91 20 50 56 10 32 36 49 04 53 85 92 25 65 52 09 61 30 61 97 66 21 96 92 98 90 06 34 96 60 32 69 68 33 75 84 18 31 71 50 84 63 03 03 19 11 28 42 75 45 45 61 31 61 68 96 34 49 39 05 71 76 59 62 67 06 47 96 99 34 21 32 47 52 07 71 60 42 72 94 56 82 83 84 40 94 87 82 46 01 20 60 14 17 38 26 78 66 81 45 95 18 51 98 81 48 16 53 88 37 52 69 95 72 93 22 34 98 20 54 27 73 61 56 63 60 34 63 93 42 94 83 47 61 27 51 79 79 45 01 44 73 31 70 83 42 88 25 53 51 30 15 65 94 80 44 61 84 12 77 02 62 02 65 94 42 14 94 32 73 09 67 68 29 74 98 10 19 85 48 38 31 85 67 53 93 93 77 47 67 39 72 94 53 18 43 77 40 78 32 29 59 24 06 02 83 50 60 66 32 01 44 30 16 51 15 81 98 15 10 62 86 79 50 62 45 60 70 38 31 85 65 61 64 06 69 84 14 22 56 43 09 48 66 69 83 91 60 40 36 61 92 48 22 99 15 95 64 43 01 16 94 02 99 19 17 69 11 58 97 56 89 31 77 45 67 96 12 73 08 20 36 47 81 44 50 64 68 85 40 81 85 52 09 91 35 92 45 32 84 62 15 19 64 21 66 06 01 52 80 62 59 12 25 88 28 91 50 40 16 22 99 92 79 87 51 21 77 74 77 07 42 38 42 74 83 02 05 46 19 77 66 24 18 05 32 02 84 31 99 92 58 96 72 91 36 62 99 55 29 53 42 12 37 26 58 89 50 66 19 82 75 12 48 24 87 91 85 02 07 03 76 86 99 98 84 93 07 17 33 61 92 20 66 60 24 66 40 30 67 05 37 29 24 96 03 27 70 62 13 04 45 47 59 88 43 20 66 15 46 92 30 04 71 66 78 70 53 99 67 60 38 06 88 04 17 72 10 99 71 07 42 25 54 05 26 64 91 50 45 71 06 30 67 48 69 82 08 56 80 67 18 46 66 63 01 20 08 80 47 07 91 16 03 79 87 18 54 78 49 80 48 77 40 68 23 60 88 58 80 33 57 11 69 55 53 64 02 94 49 60 92 16 35 81 21 82 96 25 24 96 18 02 05 49 03 50 77 06 32 84 27 18 38 68 01 50 04 03 21 42 94 53 24 89 05 92 26 52 36 68 11 85 01 04 42 02 45 15 06 50 04 53 73 25 74 81 88 98 21 67 84 79 97 99 20 95 04 40 46 02 58 87 94 10 02 78 88 52 21 03 88 60 06 53 49 71 20 91 12 65 07 49 21 22 11 41 58 99 36 16 09 48 17 24 52 36 23 15 72 16 84 56 02 99 43 76 81 71 29 39 49 17 64 39 59 84 86 16 17 66 03 09 43 06 64 18 63 29 68 06 23 07 87 14 26 35 17 12 98 41 53 64 78 18 98 27 28 84 80 67 75 62 10 11 76 90 54 10 05 54 41 39 66 43 83 18 37 32 31 52 29 95 47 08 76 35 11 04 53 35 43 34 10 52 57 12 36 20 39 40 55 78 44 07 31 38 26 08 15 56 88 86 01 52 62 10 24 32 05 60 65 53 28 57 99 03 50 03 52 07 73 49 92 66 80 01 46 08 67 25 36 73 93 07 42 25 53 13 96 76 83 87 90 54 89 78 22 78 91 73 51 69 09 79 94 83 53 09 40 69 62 10 79 49 47 03 81 30 71 54 73 33 51 76 59 54 79 37 56 45 84 17 62 21 98 69 41 95 65 24 39 37 62 03 24 48 54 64 46 82 71 78 33 67 09 16 96 68 52 74 79 68 32 21 13 78 96 60 09 69 20 36 73 26 21 44 46 38 17 83 65 98 07 23 52 46 61 97 33 13 60 31 70 15 36 77 31 58 56 93 75 68 21 36 69 53 90 75 25 82 39 50 65 94 29 30 11 33 11 13 96 02 56 47 07 49 02 76 46 73 30 10 20 60 70 14 56 34 26 37 39 48 24 55 76 84 91 39 86 95 61 50 14 53 93 64 67 37 31 10 84 42 70 48 20 10 72 60 61 84 79 69 65 99 73 89 25 85 48 92 56 97 16 03 14 80 27 22 30 44 27 67 75 79 32 51 54 81 29 65 14 19 04 13 82 04 91 43 40 12 52 29 99 07 76 60 25 01 07 61 71 37 92 40 47 99 66 57 01 43 44 22 40 53 53 09 69 26 81 07 49 80 56 90 93 87 47 13 75 28 87 23 72 79 32 18 27 20 28 10 37 59 21 18 70 04 79 96 03 31 45 71 81 06 14 18 17 05 31 50 92 79 23 47 09 39 47 91 43 54 69 47 42 95 62 46 32 85 37 18 62 85 87 28 64 05 77 51 47 26 30 65 05 70 65 75 59 80 42 52 25 20 44 10 92 17 71 95 52 14 77 13 24 55 11 65 26 91 01 30 63 15 49 48 41 17 67 47 03 68 20 90 98 32 04 40 68 90 51 58 60 06 55 23 68 05 19 76 94 82 36 96 43 38 90 87 28 33 83 05 17 70 83 96 93 06 04 78 47 80 06 23 84 75 23 87 72 99 14 50 98 92 38 90 64 61 58 76 94 36 66 87 80 51 35 61 38 57 95 64 06 53 36 82 51 40 33 47 14 07 98 78 65 39 58 53 06 50 53 04 69 40 68 36 69 75 78 75 60 03 32 39 24 74 47 26 90 13 40 44 71 90 76 51 24 36 50 25 45 70 80 61 80 61 43 90 64 11 18 29 86 56 68 42 79 10 42 44 30 12 96 18 23 18 52 59 02 99 67 46 60 86 43 38 55 17 44 93 42 21 55 14 47 34 55 16 49 24 23 29 96 51 55 10 46 53 27 92 27 46 63 57 30 65 43 27 21 20 24 83 81 72 93 19 69 52 48 01 13 83 92 69 20 48 69 59 20 62 05 42 28 89 90 99 32 72 84 17 08 87 36 03 60 31 36 36 81 26 97 36 48 54 56 56 27 16 91 08 23 11 87 99 33 47 02 14 44 73 70 99 43 35 33 90 56 61 86 56 12 70 59 63 32 01 15 81 47 71 76 95 32 65 80 54 70 34 51 40 45 33 04 64 55 78 68 88 47 31 47 68 87 03 84 23 44 89 72 35 08 31 76 63 26 90 85 96 67 65 91 19 14 17 86 04 71 32 95 37 13 04 22 64 37 37 28 56 62 86 33 07 37 10 44 52 82 52 06 19 52 57 75 90 26 91 24 06 21 14 67 76 30 46 14 35 89 89 41 03 64 56 97 87 63 22 34 03 79 17 45 11 53 25 56 96 61 23 18 63 31 37 37 47 77 23 26 70 72 76 77 04 28 64 71 69 14 85 96 54 95 48 06 62 99 83 86 77 97 75 71 66 30 19 57 90 33 01 60 61 14 12 90 99 32 77 56 41 18 14 87 49 10 14 90 64 18 50 21 74 14 16 88 05 45 73 82 47 74 44 22 97 41 13 34 31 54 61 56 94 03 24 59 27 98 77 04 09 37 40 12 26 87 09 71 70 07 18 64 57 80 21 12 71 83 94 60 39 73 79 73 19 97 32 64 29 41 07 48 84 85 67 12 74 95 20 24 52 41 67 56 61 29 93 35 72 69 72 23 63 66 01 11 07 30 52 56 95 16 65 26 83 90 50 74 60 18 16 48 43 77 37 11 99 98 30 94 91 26 62 73 45 12 87 73 47 27 01 88 66 99 21 41 95 80 02 53 23 32 61 48 32 43 43 83 14 66 95 91 19 81 80 67 25 88 08 62 32 18 92 14 83 71 37 96 11 83 39 99 05 16 23 27 10 67 02 25 44 11 55 31 46 64 41 56 44 74 26 81 51 31 45 85 87 09 81 95 22 28 76 69 46 48 64 87 67 76 27 89 31 11 74 16 62 03 60 94 42 47 09 34 94 93 72 56 18 90 18 42 17 42 32 14 86 06 53 33 95 99 35 29 15 44 20 49 59 25 54 34 59 84 21 23 54 35 90 78 16 93 13 37 88 54 19 86 67 68 55 66 84 65 42 98 37 87 56 33 28 58 38 28 38 66 27 52 21 81 15 08 22 97 32 85 27 91 53 40 28 13 34 91 25 01 63 50 37 22 49 71 58 32 28 30 18 68 94 23 83 63 62 94 76 80 41 90 22 82 52 29 12 18 56 10 08 35 14 37 57 23 65 67 40 72 39 93 39 70 89 40 34 07 46 94 22 20 05 53 64 56 30 05 56 61 88 27 23 95 11 12 37 69 68 24 66 10 87 70 43 50 75 07 62 41 83 58 95 93 89 79 45 39 02 22 05 22 95 43 62 11 68 29 17 40 26 44 25 71 87 16 70 85 19 25 59 94 90 41 41 80 61 70 55 60 84 33 95 76 42 63 15 09 03 40 38 12 03 32 09 84 56 80 61 55 85 97 16 94 82 94 98 57 84 30 84 48 93 90 71 05 95 90 73 17 30 98 40 64 65 89 07 79 09 19 56 36 42 30 23 69 73 72 07 05 27 61 24 31 43 48 71 84 21 28 26 65 65 59 65 74 77 20 10 81 61 84 95 08 52 23 70 47 81 28 09 98 51 67 64 35 51 59 36 92 82 77 65 80 24 72 53 22 07 27 10 21 28 30 22 48 82 80 48 56 20 14 43 18 25 50 95 90 31 77 08 09 48 44 80 90 22 93 45 82 17 13 96 25 26 08 73 34 99 06 49 24 06 83 51 40 14 15 10 25 01 54 25 10 81 30 64 24 74 75 80 36 75 82 60 22 69 72 91 45 67 03 62 79 54 89 74 44 83 64 96 66 73 44 30 74 50 37 05 09 97 70 01 60 46 37 91 39 75 75 18 58 52 72 78 51 81 86 52 08 97 01 46 43 66 98 62 81 18 70 93 73 08 32 46 34 96 80 82 07 59 71 92 53 19 20 88 66 03 26 26 10 24 27 50 82 94 73 63 08 51 33 22 45 19 13 58 33 90 15 22 50 36 13 55 06 35 47 82 52 33 61 36 27 28 46 98 14 73 20 73 32 16 26 80 53 47 66 76 38 94 45 02 01 22 52 47 96 64 58 52 39 88 46 23 39 74 63 81 64 20 90 33 33 76 55 58 26 10 46 42 26 74 74 12 83 32 43 09 02 73 55 86 54 85 34 28 23 29 79 91 62 47 41 82 87 99 22 48 90 20 05 96 75 95 04 43 28 81 39 81 01 28 42 78 25 39 77 90 57 58 98 17 36 73 22 63 74 51 29 39 74 94 95 78 64 24 38 86 63 87 93 06 70 92 22 16 80 64 29 52 20 27 23 50 14 13 87 15 72 96 81 22 08 49 72 30 70 24 79 31 16 64 59 21 89 34 96 91 48 76 43 53 88 01 57 80 23 81 90 79 58 01 80 87 17 99 86 90 72 63 32 69 14 28 88 69 37 17 71 95 56 93 71 35 43 45 04 98 92 94 84 96 11 30 31 27 31 60 92 03 48 05 98 91 86 94 35 90 90 08 48 19 33 28 68 37 59 26 65 96 50 68 22 07 09 49 34 31 77 49 43 06 75 17 81 87 61 79 52 26 27 72 29 50 07 98 86 01 17 10 46 64 24 18 56 51 30 25 94 88 85 79 91 40 33 63 84 49 67 98 92 15 26 75 19 82 05 18 78 65 93 61 48 91 43 59 41 70 51 22 15 92 81 67 91 46 98 11 11 65 31 66 10 98 65 83 21 05 56 05 98 73 67 46 74 69 34 08 30 05 52 07 98 32 95 30 94 65 50 24 63 28 81 99 57 19 23 61 36 09 89 71 98 65 17 30 29 89 26 79 74 94 11 44 48 97 54 81 55 39 66 69 45 28 47 13 86 15 76 74 70 84 32 36 33 79 20 78 14 41 47 89 28 81 05 99 66 81 86 38 26 06 25 13 60 54 55 23 53 27 05 89 25 23 11 13 54 59 54 56 34 16 24 53 44 06 13 40 57 72 21 15 60 08 04 19 11 98 34 45 09 97 86 71 03 15 56 19 15 44 97 31 90 04 87 87 76 08 12 30 24 62 84 28 12 85 82 53 99 52 13 94 06 65 97 86 09 50 94 68 69 74 30 67 87 94 63 07 78 27 80 36 69 41 06 92 32 78 37 82 30 05 18 87 99 72 19 99 44 20 55 77 69 91 27 31 28 81 80 27 02 07 97 23 95 98 12 25 75 29 47 71 07 47 78 39 41 59 27 76 13 15 66 61 68 35 69 86 16 53 67 63 99 85 41 56 08 28 33 40 94 76 90 85 31 70 24 65 84 65 99 82 19 25 54 37 21 46 33 02 52 99 51 33 26 04 87 02 08 18 96 54 42 61 45 91 06 64 79 80 82 32 16 83 63 42 49 19 78 65 97 40 42 14 61 49 34 04 18 25 98 59 30 82 72 26 88 54 36 21 75 03 88 99 53 46 51 55 78 22 94 34 40 68 87 84 25 30 76 25 08 92 84 42 61 40 38 09 99 40 23 29 39 46 55 10 90 35 84 56 70 63 23 91 39 52 92 03 71 89 07 09 37 68 66 58 20 44 92 51 56 13 71 79 99 26 37 02 06 16 67 36 52 58 16 79 73 56 60 59 27 44 77 94 82 20 50 98 33 09 87 94 37 40 83 64 83 58 85 17 76 53 02 83 52 22 27 39 20 48 92 45 21 09 42 24 23 12 37 52 28 50 78 79 20 86 62 73 20 59 54 96 80 15 91 90 99 70 10 09 58 90 93 50 81 99 54 38 36 10 30 11 35 84 16 45 82 18 11 97 36 43 96 79 97 65 40 48 23 19 17 31 64 52 65 65 37 32 65 76 99 79 34 65 79 27 55 33 03 01 33 27 61 28 66 08 04 70 49 46 48 83 01 45 19 96 13 81 14 21 31 79 93 85 50 05 92 92 48 84 59 98 31 53 23 27 15 22 79 95 24 76 05 79 16 93 97 89 38 89 42 83 02 88 94 95 82 21 01 97 48 39 31 78 09 65 50 56 97 61 01 07 65 27 21 23 14 15 80 97 44 78 49 35 33 45 81 74 34 05 31 57 09 38 94 07 69 54 69 32 65 68 46 68 78 90 24 28 49 51 45 86 35 41 63 89 76 87 31 86 09 46 14 87 82 22 29 47 16 13 10 70 72 82 95 48 64 58 43 13 75 42 69 21 12 67 13 64 85 58 23 98 09 37 76 05 22 31 12 66 50 29 99 86 72 45 25 10 28 19 06 90 43 29 31 67 79 46 25 74 14 97 35 76 37 65 46 23 82 06 22 30 76 93 66 94 17 96 13 20 72 63 40 78 08 52 09 90 41 70 28 36 14 46 44 85 96 24 52 58 15 87 37 05 98 99 39 13 61 76 38 44 99 83 74 90 22 53 80 56 98 30 51 63 39 44 30 91 91 04 22 27 73 17 35 53 18 35 45 54 56 27 78 48 13 69 36 44 38 71 25 30 56 15 22 73 43 32 69 59 25 93 83 45 11 34 94 44 39 92 12 36 56 88 13 96 16 12 55 54 11 47 19 78 17 17 68 81 77 51 42 55 99 85 66 27 81 79 93 42 65 61 69 74 14 01 18 56 12 01 58 37 91 22 42 66 83 25 19 04 96 41 25 45 18 69 96 88 36 93 10 12 98 32 44 83 83 04 72 91 04 27 73 07 34 37 71 60 59 31 01 54 54 44 96 93 83 36 04 45 30 18 22 20 42 96 65 79 17 41 55 69 94 81 29 80 91 31 85 25 47 26 43 49 02 99 34 67 99 76 16 14 15 93 08 32 99 44 61 77 67 50 43 55 87 55 53 72 17 46 62 25 50 99 73 05 93 48 17 31 70 80 59 09 44 59 45 13 74 66 58 94 87 73 16 14 85 38 74 99 64 23 79 28 71 42 20 37 82 31 23 51 96 39 65 46 71 56 13 29 68 53 86 45 33 51 49 12 91 21 21 76 85 02 17 98 15 46 12 60 21 88 30 92 83 44 59 42 50 27 88 46 86 94 73 45 54 23 24 14 10 94 21 20 34 23 51 04 83 99 75 90 63 60 16 22 33 83 70 11 32 10 50 29 30 83 46 11 05 31 17 86 42 49 01 44 63 28 60 07 78 95 40 44 61 89 59 04 49 51 27 69 71 46 76 44 04 09 34 56 39 15 06 94 91 75 90 65 27 56 23 74 06 23 33 36 69 14 39 05 34 35 57 33 22 76 46 56 10 61 65 98 09 16 69 04 62 65 18 99 76 49 18 72 66 73 83 82 40 76 31 89 91 27 88 17 35 41 35 32 51 32 67 52 68 74 85 80 57 07 11 62 66 47 22 67 65 37 19 97 26 17 16 24 24 17 50 37 64 82 24 36 32 11 68 34 69 31 32 89 79 93 96 68 49 90 14 23 04 04 67 99 81 74 70 74 36 96 68 09 64 39 88 35 54 89 96 58 66 27 88 97 32 14 06 35 78 20 71 06 85 66 57 02 58 91 72 05 29 56 73 48 86 52 09 93 22 57 79 42 12 01 31 68 17 59 63 76 07 77 73 81 14 13 17 20 11 09 01 83 08 85 91 70 84 63 62 77 37 07 47 01 59 95 39 69 39 21 99 09 87 02 97 16 92 36 74 71 90 66 33 73 73 75 52 91 11 12 26 53 05 26 26 48 61 50 90 65 01 87 42 47 74 35 22 73 24 26 56 70 52 05 48 41 31 18 83 27 21 39 80 85 26 08 44 02 71 07 63 22 05 52 19 08 20 17 25 21 11 72 93 33 49 64 23 53 82 03 13 91 65 85 02 40 05 42 31 77 42 05 36 06 54 04 58 07 76 87 83 25 57 66 12 74 33 85 37 74 32 20 69 03 97 91 68 82 44 19 14 89 28 85 85 80 53 34 87 58 98 88 78 48 65 98 40 11 57 10 67 70 81 60 79 74 72 97 59 79 47 30 20 54 80 89 91 14 05 33 36 79 39 60 85 59 39 60 07 57 76 77 92 06 35 15 72 23 41 45 52 95 18 64 79 86 53 56 31 69 11 91 31 84 50 44 82 22 81 41 40 30 42 30 91 48 94 74 76 64 58 74 25 96 57 14 19 03 99 28 83 15 75 99 01 89 85 79 50 03 95 32 67 44 08 07 41 62 64 29 20 14 76 26 55 48 71 69 66 19 72 44 25 14 01 48 74 12 98 07 64 66 84 24 18 16 27 48 20 14 47 69 30 86 48 40 23 16 61 21 51 50 26 47 35 33 91 28 78 64 43 68 04 79 51 08 19 60 52 95 06 68 46 86 35 97 27 58 04 65 30 58 99 12 12 75 91 39 50 31 42 64 70 04 46 07 98 73 98 93 37 89 77 91 64 71 64 65 66 21 78 62 81 74 42 20 83 70 73 95 78 45 92 27 34 53 71 15 30 11 85 31 34 71 13 48 05 14 44 03 19 67 23 73 19 57 06 90 94 72 57 69 81 62 59 68 88 57 55 69 49 13 07 87 97 80 89 05 71 05 05 26 38 40 16 62 45 99 18 38 98 24 21 26 62 74 69 04 85 57 77 35 58 67 91 79 79 57 86 28 66 34 72 51 76 78 36 95 63 90 08 78 47 63 45 31 22 70 52 48 79 94 15 77 61 67 68 23 33 44 81 80 92 93 75 94 88 23 61 39 76 22 03 28 94 32 06 49 65 41 34 18 23 08 47 62 60 03 63 33 13 80 52 31 54 73 43 70 26 16 69 57 87 83 31 03 93 70 81 47 95 77 44 29 68 39 51 56 59 63 07 25 70 07 77 43 53 64 03 94 42 95 39 18 01 66 21 16 97 20 50 90 16 70 10 95 69 29 06 25 61 41 26 15 59 63 35 ================================================ FILE: Problem069/.hash ================================================ bf08b01ead83cbd62a9839ca1cf35ada ================================================ FILE: Problem069/Python/solution_1.py ================================================ import math def is_prime(n): if n%2 == 0: return False for i in range(3, math.floor(math.sqrt(n)) + 1, 2): if n%i == 0: return False return True def max_phi_ratio(n): k = 3 prod = 2 while k * prod <= n: if is_prime(k): prod *= k k += 2 return prod def solve_problem_069(): return max_phi_ratio(1000000) if __name__ == "__main__": print(solve_problem_069()) ================================================ FILE: Problem069/Python/solution_2.py ================================================ #code created by NamanNimmo Gera #9:06am, April 16, 2019. MAX = 1000001 p = [] def sieve(): isPrime = [0] * (MAX + 1); for i in range(2, MAX + 1): if (isPrime[i] == 0): p.append(i) j = 2 while (i * j <= MAX): isPrime[i * j]= 1; j += 1 def phi(n): res = n i = 0 while (p[i] * p[i] <= n): if (n % p[i]== 0): res -= int(res / p[i]) while (n % p[i]== 0): n = int(n / p[i]) i += 1 if (n > 1): res -= int(res / n) return res sieve() nbyCount = 1 maxi = 1 for j in range(2,1000001): if (j/phi(j))>nbyCount: nbyCount = (j/phi(j)) maxi = j print(maxi) ================================================ FILE: Problem069/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=69) ================================================ FILE: Problem070/.hash ================================================ 1884dde67ced589082c8b7043abce181 ================================================ FILE: Problem070/Python/solution_1.py ================================================ import math from collections import Counter def _prime_sieve(start, limit): def is_prime(n): if n%2 == 0: return False for i in range(3, math.floor(math.sqrt(n)) + 1, 2): if n%i == 0: return False return True sieve = [] if start <= 2: sieve.append(2) for i in range(start, limit, 2): if is_prime(i): sieve.append(i) return sieve def _is_permutation(x, y): return Counter(str(x)) == Counter(str(y)) def min_phi_ratio(limit): sq = math.sqrt(limit) primes = _prime_sieve(math.floor(sq - sq*0.4), math.floor(sq + sq*0.4)) l = len(primes) min_ratio = 2 target = None for p in range(0, l): for q in range(p, l): n = primes[p] * primes[q] if n>limit: break; phi = (primes[p] - 1) * (primes[q] - 1) if _is_permutation(n, phi) and n/phi < min_ratio: target = n min_ratio = n/phi return target def solve(): return min_phi_ratio(10000000) if __name__ == "__main__": print(solve()) ================================================ FILE: Problem070/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=70) ================================================ FILE: Problem071/.hash ================================================ 71f38fa2f04db30be52f883d583bfd6f - ================================================ FILE: Problem071/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=71) ================================================ FILE: Problem071/Scheme/solution_1.scm ================================================ ;; -*- mode: scheme; coding: utf-8-unix -*- #| An implementation of Farey Sequence(s) References: - Cut the Knot article: https://www.cut-the-knot.org/blue/Farey.shtml - Stern-Brocott Tree: https://www.cut-the-knot.org/blue/Stern.shtml - Ivan Niven, Herbert S. Zuckerman, Hugh L. Montgomery, "An introduction to the theory of numbers", 5th Edition, Wiley, NY TODO: - Documentation |# (require srfi/9) (define gcd (lambda (m n) (cond ((= n 0) m) ((= n 1) 1) ((< m n) (gcd n m)) (else (gcd n (remainder m n)))))) (define-record-type :fraction (fraction numerator denominator) fraction? (numerator numerator set-numerator!) (denominator denominator set-denominator!)) (define pretty-print-fraction (lambda (header f) (display "Fraction: ") (display header) (newline) (display "Numerator: ") (display (numerator f)) (newline) (display "Denominator: ") (display (denominator f)) (newline))) (define simplify (lambda (f) (let ((num (numerator f)) (den (denominator f)) (g (gcd num den))) (fraction (/ num g) (/ den g))))) (define smaller? (lambda (f1 f2) (< (* (numerator f1) (denominator f2)) (* (numerator f2) (denominator f1))))) (define bigger? (lambda (f1 f2) (smaller? f2 f1))) (define equals? (lambda (f1 f2) (not (or (smaller? f1 f2) (bigger? f1 f2))))) (define zero (fraction 0 1)) (define one (fraction 1 1)) (define-record-type :interval (interval lower upper) interval? (lower lower set-lower!) (upper upper set-upper!)) (define canonical-order (lambda (i) (let ((low (lower i)) (upp (upper i))) (if (bigger? low upp) (interval upp low) (interval low upp))))) (define pretty-print-interval (lambda (header i) (display "Interval: ") (display header) (newline) (pretty-print-fraction "Lower" (lower i)) (pretty-print-fraction "Upper" (upper i)))) (define mediant (lambda (i) (let* ((f1 (lower i)) (f2 (upper i)) (n (+ (numerator f1) (numerator f2))) (d (+ (denominator f1) (denominator f2)))) (fraction n d)))) (define lower-mediant-split (lambda (i) (interval (lower i) (mediant i)))) (define upper-mediant-split (lambda (i) (interval (mediant i) (upper i)))) (define zero-one (interval zero one)) (define first-interval-mediant (lambda (f) (define first-interval-mediant-acc (lambda (f acc) (let* ((med (mediant acc)) (lower (lower-mediant-split acc)) (upper (upper-mediant-split acc))) (cond ((bigger? f med) (first-interval-mediant-acc f upper)) ((smaller? f med) (first-interval-mediant-acc f lower)) (else acc))))) (first-interval-mediant-acc f zero-one))) (define first-interval-upper (lambda (f) (lower-mediant-split (first-interval-mediant f)))) (define first-interval-lower (lambda (f) (upper-mediant-split (first-interval-mediant f)))) (define largest-fraction-inside-with-denominator-below (lambda (i limit) (let ((med (mediant i)) (up (upper-mediant-split i))) (cond ((> (denominator (lower i)) limit) (lower i)) ((> (denominator med) limit) (lower i)) (else (largest-fraction-inside-with-denominator-below up limit)))))) (define solve (let ((input1 (fraction 3 7)) (input2 1000000)) (numerator (largest-fraction-inside-with-denominator-below (first-interval-upper input1) input2)))) (display solve) (newline) ================================================ FILE: Problem076/.hash ================================================ 18ed0f01e082beffe0049ae1272689d2 ================================================ FILE: Problem076/Elixir/solution_1.exs ================================================ defmodule Summations do def count([],_,vals), do: vals def count([way|ways],lim,vals) when length(ways) >= 0 do count(ways,lim,sums(way,way,lim,vals)) end def sums(num,_, lim,vals) when num > lim, do: vals def sums(num,way,lim,vals) when num <= lim do sums(num+1,way,lim,ad(way,num,vals)) end def ad(a,b,c), do: Map.put(c,b,(Map.get(c,b) + Map.get(c,(b-a)))) end vals = Map.put(Enum.into(Enum.zip(Enum.to_list(0..100),List.duplicate(0,101)),Map.new),0,1) (1..99) |> Enum.to_list() |> Summations.count(100,vals) |> Map.values() |> Enum.max() |> IO.puts ================================================ FILE: Problem076/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=76) ================================================ FILE: Problem080/.hash ================================================ 6cc501a25298e4051886ef1a126e9484 ================================================ FILE: Problem080/Python/solution_1.py ================================================ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Copyright © Manoel Vilela 2017 # # @team: DestructHub # @project: ProjectEuler # @author: Manoel Vilela # @email: manoel_vilela@engineer.com # import decimal import math def solution(limit): decimal.getcontext().prec = 102 # more than 100 to avoid round errors result = 0 for n in range(limit + 1): if not math.sqrt(n).is_integer(): # check if is irrational # sum digits result += sum(decimal.Decimal(n).sqrt().as_tuple()[1][:100]) return result if __name__ == '__main__': print(solution(100)) ================================================ FILE: Problem080/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=80) ================================================ FILE: Problem081/.hash ================================================ f9ffec84499832add77e6a8bb00246ec ================================================ FILE: Problem081/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # # Python Script # # Copyleft © Manoel Vilela # # from os.path import dirname, join """ Path sum: two ways Problem 81 In the 5 by 5 matrix below, the minimal path sum from the top left to the bottom right, by only moving to the right and down, is indicated in bold red and is equal to 2427. link: https://projecteuler.net/problem=81 Find the minimal path sum, in matrix.txt (right click and "Save Link/Target As..."), a 31K text file containing a 80 by 80 matrix, from the top left to the bottom right by only moving right and down. """ def parse_grid(data): return [[int(x) for x in y.split(',')] for y in [x for x in data.split('\n')]] class Grid(object): # derived from class tree in problem67 def __init__(self, data): self.data = data self.index = (0, 0) self.best_ways = {(0, 0): [(0, 0)]} self.sums = {} self.routes = [] def solution(self): self.search() return min(self.calcroute(route) for route in self.routes) def calcroute(self, route): return sum([self.data[y][x] for y, x in route]) def num(self, index): y, x = index return self.data[y][x] def search(self): for y in range(len(self.data)): for x in range(len(self.data)): if (x + y) == 0: continue self.index = (y, x) self.decise() def insert_route(self, last): newroute = self.best_ways[last] + [self.index] self.best_ways[self.index] = newroute self.sums[self.index] = self.calcroute(newroute) if len(newroute) == len(self.data) * 2 - 1: self.routes.append(newroute) def decise(self): y, x = self.index if x == 0: # left extrem of the tree, it's just possible to walk by left last = ((y - 1), x) elif y == 0: # right extrem of the tree , it's just possible to walk by right last = (y, (x - 1)) else: up = (y, (x - 1)) left = ((y - 1), x) if self.sums[up] < self.sums[left]: last = up else: last = left self.insert_route(last) def run_test(): test = [[131, 673, 234, 103, 18], [201, 96, 342, 965, 150], [630, 803, 746, 422, 111], [537, 699, 497, 121, 956], [805, 732, 524, 37, 331]] # 2427 é o mínimo return Grid(test).solution() def solution(): with open('../p081_matrix.txt', 'r') as f: data = parse_grid(f.read()[:-1]) return Grid(data).solution() if __name__ == '__main__': print(solution()) ================================================ FILE: Problem081/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=81) ================================================ FILE: Problem081/p081_matrix.txt ================================================ 4445,2697,5115,718,2209,2212,654,4348,3079,6821,7668,3276,8874,4190,3785,2752,9473,7817,9137,496,7338,3434,7152,4355,4552,7917,7827,2460,2350,691,3514,5880,3145,7633,7199,3783,5066,7487,3285,1084,8985,760,872,8609,8051,1134,9536,5750,9716,9371,7619,5617,275,9721,2997,2698,1887,8825,6372,3014,2113,7122,7050,6775,5948,2758,1219,3539,348,7989,2735,9862,1263,8089,6401,9462,3168,2758,3748,5870 1096,20,1318,7586,5167,2642,1443,5741,7621,7030,5526,4244,2348,4641,9827,2448,6918,5883,3737,300,7116,6531,567,5997,3971,6623,820,6148,3287,1874,7981,8424,7672,7575,6797,6717,1078,5008,4051,8795,5820,346,1851,6463,2117,6058,3407,8211,117,4822,1317,4377,4434,5925,8341,4800,1175,4173,690,8978,7470,1295,3799,8724,3509,9849,618,3320,7068,9633,2384,7175,544,6583,1908,9983,481,4187,9353,9377 9607,7385,521,6084,1364,8983,7623,1585,6935,8551,2574,8267,4781,3834,2764,2084,2669,4656,9343,7709,2203,9328,8004,6192,5856,3555,2260,5118,6504,1839,9227,1259,9451,1388,7909,5733,6968,8519,9973,1663,5315,7571,3035,4325,4283,2304,6438,3815,9213,9806,9536,196,5542,6907,2475,1159,5820,9075,9470,2179,9248,1828,4592,9167,3713,4640,47,3637,309,7344,6955,346,378,9044,8635,7466,5036,9515,6385,9230 7206,3114,7760,1094,6150,5182,7358,7387,4497,955,101,1478,7777,6966,7010,8417,6453,4955,3496,107,449,8271,131,2948,6185,784,5937,8001,6104,8282,4165,3642,710,2390,575,715,3089,6964,4217,192,5949,7006,715,3328,1152,66,8044,4319,1735,146,4818,5456,6451,4113,1063,4781,6799,602,1504,6245,6550,1417,1343,2363,3785,5448,4545,9371,5420,5068,4613,4882,4241,5043,7873,8042,8434,3939,9256,2187 3620,8024,577,9997,7377,7682,1314,1158,6282,6310,1896,2509,5436,1732,9480,706,496,101,6232,7375,2207,2306,110,6772,3433,2878,8140,5933,8688,1399,2210,7332,6172,6403,7333,4044,2291,1790,2446,7390,8698,5723,3678,7104,1825,2040,140,3982,4905,4160,2200,5041,2512,1488,2268,1175,7588,8321,8078,7312,977,5257,8465,5068,3453,3096,1651,7906,253,9250,6021,8791,8109,6651,3412,345,4778,5152,4883,7505 1074,5438,9008,2679,5397,5429,2652,3403,770,9188,4248,2493,4361,8327,9587,707,9525,5913,93,1899,328,2876,3604,673,8576,6908,7659,2544,3359,3883,5273,6587,3065,1749,3223,604,9925,6941,2823,8767,7039,3290,3214,1787,7904,3421,7137,9560,8451,2669,9219,6332,1576,5477,6755,8348,4164,4307,2984,4012,6629,1044,2874,6541,4942,903,1404,9125,5160,8836,4345,2581,460,8438,1538,5507,668,3352,2678,6942 4295,1176,5596,1521,3061,9868,7037,7129,8933,6659,5947,5063,3653,9447,9245,2679,767,714,116,8558,163,3927,8779,158,5093,2447,5782,3967,1716,931,7772,8164,1117,9244,5783,7776,3846,8862,6014,2330,6947,1777,3112,6008,3491,1906,5952,314,4602,8994,5919,9214,3995,5026,7688,6809,5003,3128,2509,7477,110,8971,3982,8539,2980,4689,6343,5411,2992,5270,5247,9260,2269,7474,1042,7162,5206,1232,4556,4757 510,3556,5377,1406,5721,4946,2635,7847,4251,8293,8281,6351,4912,287,2870,3380,3948,5322,3840,4738,9563,1906,6298,3234,8959,1562,6297,8835,7861,239,6618,1322,2553,2213,5053,5446,4402,6500,5182,8585,6900,5756,9661,903,5186,7687,5998,7997,8081,8955,4835,6069,2621,1581,732,9564,1082,1853,5442,1342,520,1737,3703,5321,4793,2776,1508,1647,9101,2499,6891,4336,7012,3329,3212,1442,9993,3988,4930,7706 9444,3401,5891,9716,1228,7107,109,3563,2700,6161,5039,4992,2242,8541,7372,2067,1294,3058,1306,320,8881,5756,9326,411,8650,8824,5495,8282,8397,2000,1228,7817,2099,6473,3571,5994,4447,1299,5991,543,7874,2297,1651,101,2093,3463,9189,6872,6118,872,1008,1779,2805,9084,4048,2123,5877,55,3075,1737,9459,4535,6453,3644,108,5982,4437,5213,1340,6967,9943,5815,669,8074,1838,6979,9132,9315,715,5048 3327,4030,7177,6336,9933,5296,2621,4785,2755,4832,2512,2118,2244,4407,2170,499,7532,9742,5051,7687,970,6924,3527,4694,5145,1306,2165,5940,2425,8910,3513,1909,6983,346,6377,4304,9330,7203,6605,3709,3346,970,369,9737,5811,4427,9939,3693,8436,5566,1977,3728,2399,3985,8303,2492,5366,9802,9193,7296,1033,5060,9144,2766,1151,7629,5169,5995,58,7619,7565,4208,1713,6279,3209,4908,9224,7409,1325,8540 6882,1265,1775,3648,4690,959,5837,4520,5394,1378,9485,1360,4018,578,9174,2932,9890,3696,116,1723,1178,9355,7063,1594,1918,8574,7594,7942,1547,6166,7888,354,6932,4651,1010,7759,6905,661,7689,6092,9292,3845,9605,8443,443,8275,5163,7720,7265,6356,7779,1798,1754,5225,6661,1180,8024,5666,88,9153,1840,3508,1193,4445,2648,3538,6243,6375,8107,5902,5423,2520,1122,5015,6113,8859,9370,966,8673,2442 7338,3423,4723,6533,848,8041,7921,8277,4094,5368,7252,8852,9166,2250,2801,6125,8093,5738,4038,9808,7359,9494,601,9116,4946,2702,5573,2921,9862,1462,1269,2410,4171,2709,7508,6241,7522,615,2407,8200,4189,5492,5649,7353,2590,5203,4274,710,7329,9063,956,8371,3722,4253,4785,1194,4828,4717,4548,940,983,2575,4511,2938,1827,2027,2700,1236,841,5760,1680,6260,2373,3851,1841,4968,1172,5179,7175,3509 4420,1327,3560,2376,6260,2988,9537,4064,4829,8872,9598,3228,1792,7118,9962,9336,4368,9189,6857,1829,9863,6287,7303,7769,2707,8257,2391,2009,3975,4993,3068,9835,3427,341,8412,2134,4034,8511,6421,3041,9012,2983,7289,100,1355,7904,9186,6920,5856,2008,6545,8331,3655,5011,839,8041,9255,6524,3862,8788,62,7455,3513,5003,8413,3918,2076,7960,6108,3638,6999,3436,1441,4858,4181,1866,8731,7745,3744,1000 356,8296,8325,1058,1277,4743,3850,2388,6079,6462,2815,5620,8495,5378,75,4324,3441,9870,1113,165,1544,1179,2834,562,6176,2313,6836,8839,2986,9454,5199,6888,1927,5866,8760,320,1792,8296,7898,6121,7241,5886,5814,2815,8336,1576,4314,3109,2572,6011,2086,9061,9403,3947,5487,9731,7281,3159,1819,1334,3181,5844,5114,9898,4634,2531,4412,6430,4262,8482,4546,4555,6804,2607,9421,686,8649,8860,7794,6672 9870,152,1558,4963,8750,4754,6521,6256,8818,5208,5691,9659,8377,9725,5050,5343,2539,6101,1844,9700,7750,8114,5357,3001,8830,4438,199,9545,8496,43,2078,327,9397,106,6090,8181,8646,6414,7499,5450,4850,6273,5014,4131,7639,3913,6571,8534,9703,4391,7618,445,1320,5,1894,6771,7383,9191,4708,9706,6939,7937,8726,9382,5216,3685,2247,9029,8154,1738,9984,2626,9438,4167,6351,5060,29,1218,1239,4785 192,5213,8297,8974,4032,6966,5717,1179,6523,4679,9513,1481,3041,5355,9303,9154,1389,8702,6589,7818,6336,3539,5538,3094,6646,6702,6266,2759,4608,4452,617,9406,8064,6379,444,5602,4950,1810,8391,1536,316,8714,1178,5182,5863,5110,5372,4954,1978,2971,5680,4863,2255,4630,5723,2168,538,1692,1319,7540,440,6430,6266,7712,7385,5702,620,641,3136,7350,1478,3155,2820,9109,6261,1122,4470,14,8493,2095 1046,4301,6082,474,4974,7822,2102,5161,5172,6946,8074,9716,6586,9962,9749,5015,2217,995,5388,4402,7652,6399,6539,1349,8101,3677,1328,9612,7922,2879,231,5887,2655,508,4357,4964,3554,5930,6236,7384,4614,280,3093,9600,2110,7863,2631,6626,6620,68,1311,7198,7561,1768,5139,1431,221,230,2940,968,5283,6517,2146,1646,869,9402,7068,8645,7058,1765,9690,4152,2926,9504,2939,7504,6074,2944,6470,7859 4659,736,4951,9344,1927,6271,8837,8711,3241,6579,7660,5499,5616,3743,5801,4682,9748,8796,779,1833,4549,8138,4026,775,4170,2432,4174,3741,7540,8017,2833,4027,396,811,2871,1150,9809,2719,9199,8504,1224,540,2051,3519,7982,7367,2761,308,3358,6505,2050,4836,5090,7864,805,2566,2409,6876,3361,8622,5572,5895,3280,441,7893,8105,1634,2929,274,3926,7786,6123,8233,9921,2674,5340,1445,203,4585,3837 5759,338,7444,7968,7742,3755,1591,4839,1705,650,7061,2461,9230,9391,9373,2413,1213,431,7801,4994,2380,2703,6161,6878,8331,2538,6093,1275,5065,5062,2839,582,1014,8109,3525,1544,1569,8622,7944,2905,6120,1564,1839,5570,7579,1318,2677,5257,4418,5601,7935,7656,5192,1864,5886,6083,5580,6202,8869,1636,7907,4759,9082,5854,3185,7631,6854,5872,5632,5280,1431,2077,9717,7431,4256,8261,9680,4487,4752,4286 1571,1428,8599,1230,7772,4221,8523,9049,4042,8726,7567,6736,9033,2104,4879,4967,6334,6716,3994,1269,8995,6539,3610,7667,6560,6065,874,848,4597,1711,7161,4811,6734,5723,6356,6026,9183,2586,5636,1092,7779,7923,8747,6887,7505,9909,1792,3233,4526,3176,1508,8043,720,5212,6046,4988,709,5277,8256,3642,1391,5803,1468,2145,3970,6301,7767,2359,8487,9771,8785,7520,856,1605,8972,2402,2386,991,1383,5963 1822,4824,5957,6511,9868,4113,301,9353,6228,2881,2966,6956,9124,9574,9233,1601,7340,973,9396,540,4747,8590,9535,3650,7333,7583,4806,3593,2738,8157,5215,8472,2284,9473,3906,6982,5505,6053,7936,6074,7179,6688,1564,1103,6860,5839,2022,8490,910,7551,7805,881,7024,1855,9448,4790,1274,3672,2810,774,7623,4223,4850,6071,9975,4935,1915,9771,6690,3846,517,463,7624,4511,614,6394,3661,7409,1395,8127 8738,3850,9555,3695,4383,2378,87,6256,6740,7682,9546,4255,6105,2000,1851,4073,8957,9022,6547,5189,2487,303,9602,7833,1628,4163,6678,3144,8589,7096,8913,5823,4890,7679,1212,9294,5884,2972,3012,3359,7794,7428,1579,4350,7246,4301,7779,7790,3294,9547,4367,3549,1958,8237,6758,3497,3250,3456,6318,1663,708,7714,6143,6890,3428,6853,9334,7992,591,6449,9786,1412,8500,722,5468,1371,108,3939,4199,2535 7047,4323,1934,5163,4166,461,3544,2767,6554,203,6098,2265,9078,2075,4644,6641,8412,9183,487,101,7566,5622,1975,5726,2920,5374,7779,5631,3753,3725,2672,3621,4280,1162,5812,345,8173,9785,1525,955,5603,2215,2580,5261,2765,2990,5979,389,3907,2484,1232,5933,5871,3304,1138,1616,5114,9199,5072,7442,7245,6472,4760,6359,9053,7876,2564,9404,3043,9026,2261,3374,4460,7306,2326,966,828,3274,1712,3446 3975,4565,8131,5800,4570,2306,8838,4392,9147,11,3911,7118,9645,4994,2028,6062,5431,2279,8752,2658,7836,994,7316,5336,7185,3289,1898,9689,2331,5737,3403,1124,2679,3241,7748,16,2724,5441,6640,9368,9081,5618,858,4969,17,2103,6035,8043,7475,2181,939,415,1617,8500,8253,2155,7843,7974,7859,1746,6336,3193,2617,8736,4079,6324,6645,8891,9396,5522,6103,1857,8979,3835,2475,1310,7422,610,8345,7615 9248,5397,5686,2988,3446,4359,6634,9141,497,9176,6773,7448,1907,8454,916,1596,2241,1626,1384,2741,3649,5362,8791,7170,2903,2475,5325,6451,924,3328,522,90,4813,9737,9557,691,2388,1383,4021,1609,9206,4707,5200,7107,8104,4333,9860,5013,1224,6959,8527,1877,4545,7772,6268,621,4915,9349,5970,706,9583,3071,4127,780,8231,3017,9114,3836,7503,2383,1977,4870,8035,2379,9704,1037,3992,3642,1016,4303 5093,138,4639,6609,1146,5565,95,7521,9077,2272,974,4388,2465,2650,722,4998,3567,3047,921,2736,7855,173,2065,4238,1048,5,6847,9548,8632,9194,5942,4777,7910,8971,6279,7253,2516,1555,1833,3184,9453,9053,6897,7808,8629,4877,1871,8055,4881,7639,1537,7701,2508,7564,5845,5023,2304,5396,3193,2955,1088,3801,6203,1748,3737,1276,13,4120,7715,8552,3047,2921,106,7508,304,1280,7140,2567,9135,5266 6237,4607,7527,9047,522,7371,4883,2540,5867,6366,5301,1570,421,276,3361,527,6637,4861,2401,7522,5808,9371,5298,2045,5096,5447,7755,5115,7060,8529,4078,1943,1697,1764,5453,7085,960,2405,739,2100,5800,728,9737,5704,5693,1431,8979,6428,673,7540,6,7773,5857,6823,150,5869,8486,684,5816,9626,7451,5579,8260,3397,5322,6920,1879,2127,2884,5478,4977,9016,6165,6292,3062,5671,5968,78,4619,4763 9905,7127,9390,5185,6923,3721,9164,9705,4341,1031,1046,5127,7376,6528,3248,4941,1178,7889,3364,4486,5358,9402,9158,8600,1025,874,1839,1783,309,9030,1843,845,8398,1433,7118,70,8071,2877,3904,8866,6722,4299,10,1929,5897,4188,600,1889,3325,2485,6473,4474,7444,6992,4846,6166,4441,2283,2629,4352,7775,1101,2214,9985,215,8270,9750,2740,8361,7103,5930,8664,9690,8302,9267,344,2077,1372,1880,9550 5825,8517,7769,2405,8204,1060,3603,7025,478,8334,1997,3692,7433,9101,7294,7498,9415,5452,3850,3508,6857,9213,6807,4412,7310,854,5384,686,4978,892,8651,3241,2743,3801,3813,8588,6701,4416,6990,6490,3197,6838,6503,114,8343,5844,8646,8694,65,791,5979,2687,2621,2019,8097,1423,3644,9764,4921,3266,3662,5561,2476,8271,8138,6147,1168,3340,1998,9874,6572,9873,6659,5609,2711,3931,9567,4143,7833,8887 6223,2099,2700,589,4716,8333,1362,5007,2753,2848,4441,8397,7192,8191,4916,9955,6076,3370,6396,6971,3156,248,3911,2488,4930,2458,7183,5455,170,6809,6417,3390,1956,7188,577,7526,2203,968,8164,479,8699,7915,507,6393,4632,1597,7534,3604,618,3280,6061,9793,9238,8347,568,9645,2070,5198,6482,5000,9212,6655,5961,7513,1323,3872,6170,3812,4146,2736,67,3151,5548,2781,9679,7564,5043,8587,1893,4531 5826,3690,6724,2121,9308,6986,8106,6659,2142,1642,7170,2877,5757,6494,8026,6571,8387,9961,6043,9758,9607,6450,8631,8334,7359,5256,8523,2225,7487,1977,9555,8048,5763,2414,4948,4265,2427,8978,8088,8841,9208,9601,5810,9398,8866,9138,4176,5875,7212,3272,6759,5678,7649,4922,5422,1343,8197,3154,3600,687,1028,4579,2084,9467,4492,7262,7296,6538,7657,7134,2077,1505,7332,6890,8964,4879,7603,7400,5973,739 1861,1613,4879,1884,7334,966,2000,7489,2123,4287,1472,3263,4726,9203,1040,4103,6075,6049,330,9253,4062,4268,1635,9960,577,1320,3195,9628,1030,4092,4979,6474,6393,2799,6967,8687,7724,7392,9927,2085,3200,6466,8702,265,7646,8665,7986,7266,4574,6587,612,2724,704,3191,8323,9523,3002,704,5064,3960,8209,2027,2758,8393,4875,4641,9584,6401,7883,7014,768,443,5490,7506,1852,2005,8850,5776,4487,4269 4052,6687,4705,7260,6645,6715,3706,5504,8672,2853,1136,8187,8203,4016,871,1809,1366,4952,9294,5339,6872,2645,6083,7874,3056,5218,7485,8796,7401,3348,2103,426,8572,4163,9171,3176,948,7654,9344,3217,1650,5580,7971,2622,76,2874,880,2034,9929,1546,2659,5811,3754,7096,7436,9694,9960,7415,2164,953,2360,4194,2397,1047,2196,6827,575,784,2675,8821,6802,7972,5996,6699,2134,7577,2887,1412,4349,4380 4629,2234,6240,8132,7592,3181,6389,1214,266,1910,2451,8784,2790,1127,6932,1447,8986,2492,5476,397,889,3027,7641,5083,5776,4022,185,3364,5701,2442,2840,4160,9525,4828,6602,2614,7447,3711,4505,7745,8034,6514,4907,2605,7753,6958,7270,6936,3006,8968,439,2326,4652,3085,3425,9863,5049,5361,8688,297,7580,8777,7916,6687,8683,7141,306,9569,2384,1500,3346,4601,7329,9040,6097,2727,6314,4501,4974,2829 8316,4072,2025,6884,3027,1808,5714,7624,7880,8528,4205,8686,7587,3230,1139,7273,6163,6986,3914,9309,1464,9359,4474,7095,2212,7302,2583,9462,7532,6567,1606,4436,8981,5612,6796,4385,5076,2007,6072,3678,8331,1338,3299,8845,4783,8613,4071,1232,6028,2176,3990,2148,3748,103,9453,538,6745,9110,926,3125,473,5970,8728,7072,9062,1404,1317,5139,9862,6496,6062,3338,464,1600,2532,1088,8232,7739,8274,3873 2341,523,7096,8397,8301,6541,9844,244,4993,2280,7689,4025,4196,5522,7904,6048,2623,9258,2149,9461,6448,8087,7245,1917,8340,7127,8466,5725,6996,3421,5313,512,9164,9837,9794,8369,4185,1488,7210,1524,1016,4620,9435,2478,7765,8035,697,6677,3724,6988,5853,7662,3895,9593,1185,4727,6025,5734,7665,3070,138,8469,6748,6459,561,7935,8646,2378,462,7755,3115,9690,8877,3946,2728,8793,244,6323,8666,4271 6430,2406,8994,56,1267,3826,9443,7079,7579,5232,6691,3435,6718,5698,4144,7028,592,2627,217,734,6194,8156,9118,58,2640,8069,4127,3285,694,3197,3377,4143,4802,3324,8134,6953,7625,3598,3584,4289,7065,3434,2106,7132,5802,7920,9060,7531,3321,1725,1067,3751,444,5503,6785,7937,6365,4803,198,6266,8177,1470,6390,1606,2904,7555,9834,8667,2033,1723,5167,1666,8546,8152,473,4475,6451,7947,3062,3281 2810,3042,7759,1741,2275,2609,7676,8640,4117,1958,7500,8048,1757,3954,9270,1971,4796,2912,660,5511,3553,1012,5757,4525,6084,7198,8352,5775,7726,8591,7710,9589,3122,4392,6856,5016,749,2285,3356,7482,9956,7348,2599,8944,495,3462,3578,551,4543,7207,7169,7796,1247,4278,6916,8176,3742,8385,2310,1345,8692,2667,4568,1770,8319,3585,4920,3890,4928,7343,5385,9772,7947,8786,2056,9266,3454,2807,877,2660 6206,8252,5928,5837,4177,4333,207,7934,5581,9526,8906,1498,8411,2984,5198,5134,2464,8435,8514,8674,3876,599,5327,826,2152,4084,2433,9327,9697,4800,2728,3608,3849,3861,3498,9943,1407,3991,7191,9110,5666,8434,4704,6545,5944,2357,1163,4995,9619,6754,4200,9682,6654,4862,4744,5953,6632,1054,293,9439,8286,2255,696,8709,1533,1844,6441,430,1999,6063,9431,7018,8057,2920,6266,6799,356,3597,4024,6665 3847,6356,8541,7225,2325,2946,5199,469,5450,7508,2197,9915,8284,7983,6341,3276,3321,16,1321,7608,5015,3362,8491,6968,6818,797,156,2575,706,9516,5344,5457,9210,5051,8099,1617,9951,7663,8253,9683,2670,1261,4710,1068,8753,4799,1228,2621,3275,6188,4699,1791,9518,8701,5932,4275,6011,9877,2933,4182,6059,2930,6687,6682,9771,654,9437,3169,8596,1827,5471,8909,2352,123,4394,3208,8756,5513,6917,2056 5458,8173,3138,3290,4570,4892,3317,4251,9699,7973,1163,1935,5477,6648,9614,5655,9592,975,9118,2194,7322,8248,8413,3462,8560,1907,7810,6650,7355,2939,4973,6894,3933,3784,3200,2419,9234,4747,2208,2207,1945,2899,1407,6145,8023,3484,5688,7686,2737,3828,3704,9004,5190,9740,8643,8650,5358,4426,1522,1707,3613,9887,6956,2447,2762,833,1449,9489,2573,1080,4167,3456,6809,2466,227,7125,2759,6250,6472,8089 3266,7025,9756,3914,1265,9116,7723,9788,6805,5493,2092,8688,6592,9173,4431,4028,6007,7131,4446,4815,3648,6701,759,3312,8355,4485,4187,5188,8746,7759,3528,2177,5243,8379,3838,7233,4607,9187,7216,2190,6967,2920,6082,7910,5354,3609,8958,6949,7731,494,8753,8707,1523,4426,3543,7085,647,6771,9847,646,5049,824,8417,5260,2730,5702,2513,9275,4279,2767,8684,1165,9903,4518,55,9682,8963,6005,2102,6523 1998,8731,936,1479,5259,7064,4085,91,7745,7136,3773,3810,730,8255,2705,2653,9790,6807,2342,355,9344,2668,3690,2028,9679,8102,574,4318,6481,9175,5423,8062,2867,9657,7553,3442,3920,7430,3945,7639,3714,3392,2525,4995,4850,2867,7951,9667,486,9506,9888,781,8866,1702,3795,90,356,1483,4200,2131,6969,5931,486,6880,4404,1084,5169,4910,6567,8335,4686,5043,2614,3352,2667,4513,6472,7471,5720,1616 8878,1613,1716,868,1906,2681,564,665,5995,2474,7496,3432,9491,9087,8850,8287,669,823,347,6194,2264,2592,7871,7616,8508,4827,760,2676,4660,4881,7572,3811,9032,939,4384,929,7525,8419,5556,9063,662,8887,7026,8534,3111,1454,2082,7598,5726,6687,9647,7608,73,3014,5063,670,5461,5631,3367,9796,8475,7908,5073,1565,5008,5295,4457,1274,4788,1728,338,600,8415,8535,9351,7750,6887,5845,1741,125 3637,6489,9634,9464,9055,2413,7824,9517,7532,3577,7050,6186,6980,9365,9782,191,870,2497,8498,2218,2757,5420,6468,586,3320,9230,1034,1393,9886,5072,9391,1178,8464,8042,6869,2075,8275,3601,7715,9470,8786,6475,8373,2159,9237,2066,3264,5000,679,355,3069,4073,494,2308,5512,4334,9438,8786,8637,9774,1169,1949,6594,6072,4270,9158,7916,5752,6794,9391,6301,5842,3285,2141,3898,8027,4310,8821,7079,1307 8497,6681,4732,7151,7060,5204,9030,7157,833,5014,8723,3207,9796,9286,4913,119,5118,7650,9335,809,3675,2597,5144,3945,5090,8384,187,4102,1260,2445,2792,4422,8389,9290,50,1765,1521,6921,8586,4368,1565,5727,7855,2003,4834,9897,5911,8630,5070,1330,7692,7557,7980,6028,5805,9090,8265,3019,3802,698,9149,5748,1965,9658,4417,5994,5584,8226,2937,272,5743,1278,5698,8736,2595,6475,5342,6596,1149,6920 8188,8009,9546,6310,8772,2500,9846,6592,6872,3857,1307,8125,7042,1544,6159,2330,643,4604,7899,6848,371,8067,2062,3200,7295,1857,9505,6936,384,2193,2190,301,8535,5503,1462,7380,5114,4824,8833,1763,4974,8711,9262,6698,3999,2645,6937,7747,1128,2933,3556,7943,2885,3122,9105,5447,418,2899,5148,3699,9021,9501,597,4084,175,1621,1,1079,6067,5812,4326,9914,6633,5394,4233,6728,9084,1864,5863,1225 9935,8793,9117,1825,9542,8246,8437,3331,9128,9675,6086,7075,319,1334,7932,3583,7167,4178,1726,7720,695,8277,7887,6359,5912,1719,2780,8529,1359,2013,4498,8072,1129,9998,1147,8804,9405,6255,1619,2165,7491,1,8882,7378,3337,503,5758,4109,3577,985,3200,7615,8058,5032,1080,6410,6873,5496,1466,2412,9885,5904,4406,3605,8770,4361,6205,9193,1537,9959,214,7260,9566,1685,100,4920,7138,9819,5637,976 3466,9854,985,1078,7222,8888,5466,5379,3578,4540,6853,8690,3728,6351,7147,3134,6921,9692,857,3307,4998,2172,5783,3931,9417,2541,6299,13,787,2099,9131,9494,896,8600,1643,8419,7248,2660,2609,8579,91,6663,5506,7675,1947,6165,4286,1972,9645,3805,1663,1456,8853,5705,9889,7489,1107,383,4044,2969,3343,152,7805,4980,9929,5033,1737,9953,7197,9158,4071,1324,473,9676,3984,9680,3606,8160,7384,5432 1005,4512,5186,3953,2164,3372,4097,3247,8697,3022,9896,4101,3871,6791,3219,2742,4630,6967,7829,5991,6134,1197,1414,8923,8787,1394,8852,5019,7768,5147,8004,8825,5062,9625,7988,1110,3992,7984,9966,6516,6251,8270,421,3723,1432,4830,6935,8095,9059,2214,6483,6846,3120,1587,6201,6691,9096,9627,6671,4002,3495,9939,7708,7465,5879,6959,6634,3241,3401,2355,9061,2611,7830,3941,2177,2146,5089,7079,519,6351 7280,8586,4261,2831,7217,3141,9994,9940,5462,2189,4005,6942,9848,5350,8060,6665,7519,4324,7684,657,9453,9296,2944,6843,7499,7847,1728,9681,3906,6353,5529,2822,3355,3897,7724,4257,7489,8672,4356,3983,1948,6892,7415,4153,5893,4190,621,1736,4045,9532,7701,3671,1211,1622,3176,4524,9317,7800,5638,6644,6943,5463,3531,2821,1347,5958,3436,1438,2999,994,850,4131,2616,1549,3465,5946,690,9273,6954,7991 9517,399,3249,2596,7736,2142,1322,968,7350,1614,468,3346,3265,7222,6086,1661,5317,2582,7959,4685,2807,2917,1037,5698,1529,3972,8716,2634,3301,3412,8621,743,8001,4734,888,7744,8092,3671,8941,1487,5658,7099,2781,99,1932,4443,4756,4652,9328,1581,7855,4312,5976,7255,6480,3996,2748,1973,9731,4530,2790,9417,7186,5303,3557,351,7182,9428,1342,9020,7599,1392,8304,2070,9138,7215,2008,9937,1106,7110 7444,769,9688,632,1571,6820,8743,4338,337,3366,3073,1946,8219,104,4210,6986,249,5061,8693,7960,6546,1004,8857,5997,9352,4338,6105,5008,2556,6518,6694,4345,3727,7956,20,3954,8652,4424,9387,2035,8358,5962,5304,5194,8650,8282,1256,1103,2138,6679,1985,3653,2770,2433,4278,615,2863,1715,242,3790,2636,6998,3088,1671,2239,957,5411,4595,6282,2881,9974,2401,875,7574,2987,4587,3147,6766,9885,2965 3287,3016,3619,6818,9073,6120,5423,557,2900,2015,8111,3873,1314,4189,1846,4399,7041,7583,2427,2864,3525,5002,2069,748,1948,6015,2684,438,770,8367,1663,7887,7759,1885,157,7770,4520,4878,3857,1137,3525,3050,6276,5569,7649,904,4533,7843,2199,5648,7628,9075,9441,3600,7231,2388,5640,9096,958,3058,584,5899,8150,1181,9616,1098,8162,6819,8171,1519,1140,7665,8801,2632,1299,9192,707,9955,2710,7314 1772,2963,7578,3541,3095,1488,7026,2634,6015,4633,4370,2762,1650,2174,909,8158,2922,8467,4198,4280,9092,8856,8835,5457,2790,8574,9742,5054,9547,4156,7940,8126,9824,7340,8840,6574,3547,1477,3014,6798,7134,435,9484,9859,3031,4,1502,4133,1738,1807,4825,463,6343,9701,8506,9822,9555,8688,8168,3467,3234,6318,1787,5591,419,6593,7974,8486,9861,6381,6758,194,3061,4315,2863,4665,3789,2201,1492,4416 126,8927,6608,5682,8986,6867,1715,6076,3159,788,3140,4744,830,9253,5812,5021,7616,8534,1546,9590,1101,9012,9821,8132,7857,4086,1069,7491,2988,1579,2442,4321,2149,7642,6108,250,6086,3167,24,9528,7663,2685,1220,9196,1397,5776,1577,1730,5481,977,6115,199,6326,2183,3767,5928,5586,7561,663,8649,9688,949,5913,9160,1870,5764,9887,4477,6703,1413,4995,5494,7131,2192,8969,7138,3997,8697,646,1028 8074,1731,8245,624,4601,8706,155,8891,309,2552,8208,8452,2954,3124,3469,4246,3352,1105,4509,8677,9901,4416,8191,9283,5625,7120,2952,8881,7693,830,4580,8228,9459,8611,4499,1179,4988,1394,550,2336,6089,6872,269,7213,1848,917,6672,4890,656,1478,6536,3165,4743,4990,1176,6211,7207,5284,9730,4738,1549,4986,4942,8645,3698,9429,1439,2175,6549,3058,6513,1574,6988,8333,3406,5245,5431,7140,7085,6407 7845,4694,2530,8249,290,5948,5509,1588,5940,4495,5866,5021,4626,3979,3296,7589,4854,1998,5627,3926,8346,6512,9608,1918,7070,4747,4182,2858,2766,4606,6269,4107,8982,8568,9053,4244,5604,102,2756,727,5887,2566,7922,44,5986,621,1202,374,6988,4130,3627,6744,9443,4568,1398,8679,397,3928,9159,367,2917,6127,5788,3304,8129,911,2669,1463,9749,264,4478,8940,1109,7309,2462,117,4692,7724,225,2312 4164,3637,2000,941,8903,39,3443,7172,1031,3687,4901,8082,4945,4515,7204,9310,9349,9535,9940,218,1788,9245,2237,1541,5670,6538,6047,5553,9807,8101,1925,8714,445,8332,7309,6830,5786,5736,7306,2710,3034,1838,7969,6318,7912,2584,2080,7437,6705,2254,7428,820,782,9861,7596,3842,3631,8063,5240,6666,394,4565,7865,4895,9890,6028,6117,4724,9156,4473,4552,602,470,6191,4927,5387,884,3146,1978,3000 4258,6880,1696,3582,5793,4923,2119,1155,9056,9698,6603,3768,5514,9927,9609,6166,6566,4536,4985,4934,8076,9062,6741,6163,7399,4562,2337,5600,2919,9012,8459,1308,6072,1225,9306,8818,5886,7243,7365,8792,6007,9256,6699,7171,4230,7002,8720,7839,4533,1671,478,7774,1607,2317,5437,4705,7886,4760,6760,7271,3081,2997,3088,7675,6208,3101,6821,6840,122,9633,4900,2067,8546,4549,2091,7188,5605,8599,6758,5229 7854,5243,9155,3556,8812,7047,2202,1541,5993,4600,4760,713,434,7911,7426,7414,8729,322,803,7960,7563,4908,6285,6291,736,3389,9339,4132,8701,7534,5287,3646,592,3065,7582,2592,8755,6068,8597,1982,5782,1894,2900,6236,4039,6569,3037,5837,7698,700,7815,2491,7272,5878,3083,6778,6639,3589,5010,8313,2581,6617,5869,8402,6808,2951,2321,5195,497,2190,6187,1342,1316,4453,7740,4154,2959,1781,1482,8256 7178,2046,4419,744,8312,5356,6855,8839,319,2962,5662,47,6307,8662,68,4813,567,2712,9931,1678,3101,8227,6533,4933,6656,92,5846,4780,6256,6361,4323,9985,1231,2175,7178,3034,9744,6155,9165,7787,5836,9318,7860,9644,8941,6480,9443,8188,5928,161,6979,2352,5628,6991,1198,8067,5867,6620,3778,8426,2994,3122,3124,6335,3918,8897,2655,9670,634,1088,1576,8935,7255,474,8166,7417,9547,2886,5560,3842 6957,3111,26,7530,7143,1295,1744,6057,3009,1854,8098,5405,2234,4874,9447,2620,9303,27,7410,969,40,2966,5648,7596,8637,4238,3143,3679,7187,690,9980,7085,7714,9373,5632,7526,6707,3951,9734,4216,2146,3602,5371,6029,3039,4433,4855,4151,1449,3376,8009,7240,7027,4602,2947,9081,4045,8424,9352,8742,923,2705,4266,3232,2264,6761,363,2651,3383,7770,6730,7856,7340,9679,2158,610,4471,4608,910,6241 4417,6756,1013,8797,658,8809,5032,8703,7541,846,3357,2920,9817,1745,9980,7593,4667,3087,779,3218,6233,5568,4296,2289,2654,7898,5021,9461,5593,8214,9173,4203,2271,7980,2983,5952,9992,8399,3468,1776,3188,9314,1720,6523,2933,621,8685,5483,8986,6163,3444,9539,4320,155,3992,2828,2150,6071,524,2895,5468,8063,1210,3348,9071,4862,483,9017,4097,6186,9815,3610,5048,1644,1003,9865,9332,2145,1944,2213 9284,3803,4920,1927,6706,4344,7383,4786,9890,2010,5228,1224,3158,6967,8580,8990,8883,5213,76,8306,2031,4980,5639,9519,7184,5645,7769,3259,8077,9130,1317,3096,9624,3818,1770,695,2454,947,6029,3474,9938,3527,5696,4760,7724,7738,2848,6442,5767,6845,8323,4131,2859,7595,2500,4815,3660,9130,8580,7016,8231,4391,8369,3444,4069,4021,556,6154,627,2778,1496,4206,6356,8434,8491,3816,8231,3190,5575,1015 3787,7572,1788,6803,5641,6844,1961,4811,8535,9914,9999,1450,8857,738,4662,8569,6679,2225,7839,8618,286,2648,5342,2294,3205,4546,176,8705,3741,6134,8324,8021,7004,5205,7032,6637,9442,5539,5584,4819,5874,5807,8589,6871,9016,983,1758,3786,1519,6241,185,8398,495,3370,9133,3051,4549,9674,7311,9738,3316,9383,2658,2776,9481,7558,619,3943,3324,6491,4933,153,9738,4623,912,3595,7771,7939,1219,4405 2650,3883,4154,5809,315,7756,4430,1788,4451,1631,6461,7230,6017,5751,138,588,5282,2442,9110,9035,6349,2515,1570,6122,4192,4174,3530,1933,4186,4420,4609,5739,4135,2963,6308,1161,8809,8619,2796,3819,6971,8228,4188,1492,909,8048,2328,6772,8467,7671,9068,2226,7579,6422,7056,8042,3296,2272,3006,2196,7320,3238,3490,3102,37,1293,3212,4767,5041,8773,5794,4456,6174,7279,7054,2835,7053,9088,790,6640 3101,1057,7057,3826,6077,1025,2955,1224,1114,6729,5902,4698,6239,7203,9423,1804,4417,6686,1426,6941,8071,1029,4985,9010,6122,6597,1622,1574,3513,1684,7086,5505,3244,411,9638,4150,907,9135,829,981,1707,5359,8781,9751,5,9131,3973,7159,1340,6955,7514,7993,6964,8198,1933,2797,877,3993,4453,8020,9349,8646,2779,8679,2961,3547,3374,3510,1129,3568,2241,2625,9138,5974,8206,7669,7678,1833,8700,4480 4865,9912,8038,8238,782,3095,8199,1127,4501,7280,2112,2487,3626,2790,9432,1475,6312,8277,4827,2218,5806,7132,8752,1468,7471,6386,739,8762,8323,8120,5169,9078,9058,3370,9560,7987,8585,8531,5347,9312,1058,4271,1159,5286,5404,6925,8606,9204,7361,2415,560,586,4002,2644,1927,2824,768,4409,2942,3345,1002,808,4941,6267,7979,5140,8643,7553,9438,7320,4938,2666,4609,2778,8158,6730,3748,3867,1866,7181 171,3771,7134,8927,4778,2913,3326,2004,3089,7853,1378,1729,4777,2706,9578,1360,5693,3036,1851,7248,2403,2273,8536,6501,9216,613,9671,7131,7719,6425,773,717,8803,160,1114,7554,7197,753,4513,4322,8499,4533,2609,4226,8710,6627,644,9666,6260,4870,5744,7385,6542,6203,7703,6130,8944,5589,2262,6803,6381,7414,6888,5123,7320,9392,9061,6780,322,8975,7050,5089,1061,2260,3199,1150,1865,5386,9699,6501 3744,8454,6885,8277,919,1923,4001,6864,7854,5519,2491,6057,8794,9645,1776,5714,9786,9281,7538,6916,3215,395,2501,9618,4835,8846,9708,2813,3303,1794,8309,7176,2206,1602,1838,236,4593,2245,8993,4017,10,8215,6921,5206,4023,5932,6997,7801,262,7640,3107,8275,4938,7822,2425,3223,3886,2105,8700,9526,2088,8662,8034,7004,5710,2124,7164,3574,6630,9980,4242,2901,9471,1491,2117,4562,1130,9086,4117,6698 2810,2280,2331,1170,4554,4071,8387,1215,2274,9848,6738,1604,7281,8805,439,1298,8318,7834,9426,8603,6092,7944,1309,8828,303,3157,4638,4439,9175,1921,4695,7716,1494,1015,1772,5913,1127,1952,1950,8905,4064,9890,385,9357,7945,5035,7082,5369,4093,6546,5187,5637,2041,8946,1758,7111,6566,1027,1049,5148,7224,7248,296,6169,375,1656,7993,2816,3717,4279,4675,1609,3317,42,6201,3100,3144,163,9530,4531 7096,6070,1009,4988,3538,5801,7149,3063,2324,2912,7911,7002,4338,7880,2481,7368,3516,2016,7556,2193,1388,3865,8125,4637,4096,8114,750,3144,1938,7002,9343,4095,1392,4220,3455,6969,9647,1321,9048,1996,1640,6626,1788,314,9578,6630,2813,6626,4981,9908,7024,4355,3201,3521,3864,3303,464,1923,595,9801,3391,8366,8084,9374,1041,8807,9085,1892,9431,8317,9016,9221,8574,9981,9240,5395,2009,6310,2854,9255 8830,3145,2960,9615,8220,6061,3452,2918,6481,9278,2297,3385,6565,7066,7316,5682,107,7646,4466,68,1952,9603,8615,54,7191,791,6833,2560,693,9733,4168,570,9127,9537,1925,8287,5508,4297,8452,8795,6213,7994,2420,4208,524,5915,8602,8330,2651,8547,6156,1812,6271,7991,9407,9804,1553,6866,1128,2119,4691,9711,8315,5879,9935,6900,482,682,4126,1041,428,6247,3720,5882,7526,2582,4327,7725,3503,2631 2738,9323,721,7434,1453,6294,2957,3786,5722,6019,8685,4386,3066,9057,6860,499,5315,3045,5194,7111,3137,9104,941,586,3066,755,4177,8819,7040,5309,3583,3897,4428,7788,4721,7249,6559,7324,825,7311,3760,6064,6070,9672,4882,584,1365,9739,9331,5783,2624,7889,1604,1303,1555,7125,8312,425,8936,3233,7724,1480,403,7440,1784,1754,4721,1569,652,3893,4574,5692,9730,4813,9844,8291,9199,7101,3391,8914 6044,2928,9332,3328,8588,447,3830,1176,3523,2705,8365,6136,5442,9049,5526,8575,8869,9031,7280,706,2794,8814,5767,4241,7696,78,6570,556,5083,1426,4502,3336,9518,2292,1885,3740,3153,9348,9331,8051,2759,5407,9028,7840,9255,831,515,2612,9747,7435,8964,4971,2048,4900,5967,8271,1719,9670,2810,6777,1594,6367,6259,8316,3815,1689,6840,9437,4361,822,9619,3065,83,6344,7486,8657,8228,9635,6932,4864 8478,4777,6334,4678,7476,4963,6735,3096,5860,1405,5127,7269,7793,4738,227,9168,2996,8928,765,733,1276,7677,6258,1528,9558,3329,302,8901,1422,8277,6340,645,9125,8869,5952,141,8141,1816,9635,4025,4184,3093,83,2344,2747,9352,7966,1206,1126,1826,218,7939,2957,2729,810,8752,5247,4174,4038,8884,7899,9567,301,5265,5752,7524,4381,1669,3106,8270,6228,6373,754,2547,4240,2313,5514,3022,1040,9738 2265,8192,1763,1369,8469,8789,4836,52,1212,6690,5257,8918,6723,6319,378,4039,2421,8555,8184,9577,1432,7139,8078,5452,9628,7579,4161,7490,5159,8559,1011,81,478,5840,1964,1334,6875,8670,9900,739,1514,8692,522,9316,6955,1345,8132,2277,3193,9773,3923,4177,2183,1236,6747,6575,4874,6003,6409,8187,745,8776,9440,7543,9825,2582,7381,8147,7236,5185,7564,6125,218,7991,6394,391,7659,7456,5128,5294 2132,8992,8160,5782,4420,3371,3798,5054,552,5631,7546,4716,1332,6486,7892,7441,4370,6231,4579,2121,8615,1145,9391,1524,1385,2400,9437,2454,7896,7467,2928,8400,3299,4025,7458,4703,7206,6358,792,6200,725,4275,4136,7390,5984,4502,7929,5085,8176,4600,119,3568,76,9363,6943,2248,9077,9731,6213,5817,6729,4190,3092,6910,759,2682,8380,1254,9604,3011,9291,5329,9453,9746,2739,6522,3765,5634,1113,5789 5304,5499,564,2801,679,2653,1783,3608,7359,7797,3284,796,3222,437,7185,6135,8571,2778,7488,5746,678,6140,861,7750,803,9859,9918,2425,3734,2698,9005,4864,9818,6743,2475,132,9486,3825,5472,919,292,4411,7213,7699,6435,9019,6769,1388,802,2124,1345,8493,9487,8558,7061,8777,8833,2427,2238,5409,4957,8503,3171,7622,5779,6145,2417,5873,5563,5693,9574,9491,1937,7384,4563,6842,5432,2751,3406,7981 ================================================ FILE: Problem085/.hash ================================================ 92bf5e6240737e0326ea59846a83e076 ================================================ FILE: Problem085/Python/solution_1.py ================================================ LIMIT = 2000000; def solve(limit): a = 0 dam = limit for i in range(2, 101): for j in range(i, 101): d = abs(i*(i + 1) * j*(j + 1)/4 - limit) if d < dam: a, dam = i * j, d return a if __name__ == "__main__": print(solve(LIMIT)) ================================================ FILE: Problem085/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=85) ================================================ FILE: Problem087/.hash ================================================ e7fb7907f1af626cc42e787e367ec602 ================================================ FILE: Problem087/Python/solution_1.py ================================================ import math def _prime_sieve(start, limit): def is_prime(n): if n%2 == 0: return False for i in range(3, int(math.sqrt(n)) + 1, 2): if n%i == 0: return False return True sieve = [] if start <= 2: sieve.append(2) for i in range(start, limit): if is_prime(i): sieve.append(i) return sieve LIMIT = 50000000 s = lambda x: int(math.sqrt(x)) def solve(limit): numbers = {} primes_2 = _prime_sieve(2, s(limit)) primes_3 = _prime_sieve(2, int(limit**(1/3))+1) primes_4 = _prime_sieve(2, s(s(limit))+1) for i in primes_2: for j in primes_3: for k in primes_4: n = i**2 + j**3 + k**4 if n >= limit: break else: numbers[n] = 0 return len(numbers) if __name__ == "__main__": print(solve(LIMIT)) ================================================ FILE: Problem087/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=87) ================================================ FILE: Problem089/.hash ================================================ 5c572eca050594c7bc3c36e7e8ab9550 ================================================ FILE: Problem089/Elixir/solution_1.exs ================================================ defmodule RomanNumerals do def convert(file) do case File.read(file) do {:ok, body} -> trunc_nums(body) {:error,reason} -> :file.format_error(reason) end end def trunc_nums(file) do file |> String.replace(~r/CCCC|XXXX|IIII|LXXXX|DCCCC|VIIII/,"**") |> String.length() |> diff(String.length(file)) |> IO.puts end def diff(replaced,original), do: original - replaced end RomanNumerals.convert("../p089_romans.txt") ================================================ FILE: Problem089/Python/solution_1.py ================================================ from collections import Counter from operator import itemgetter units = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000 } def check_valid_roman(string: str) -> int: c = Counter(string) only_once = ['D', 'L', 'V'] invalid = { 'IIIIIIIIII', 'XXXXXXXXXX', 'CCCCCCCCCC', 'VV', 'DD', 'LL', } for k in only_once: if c.get(k, 0) > 1: return False for rule in invalid: unit = rule[0] if c.get(unit, 0) >= len(rule): return False return True def parse_roman(string: str) -> int: codification = list(map(units.get, string)) signal = [] for i in range(len(codification) - 1): if codification[i] >= codification[i+1]: signal.append(+1) else: signal.append(-1) signal.append(1) number = 0 for c, s in zip(codification, signal): number += c * s return number def to_roman(integer: int) -> str: characters_by_unit = sorted(units.items(), reverse=True, key=itemgetter(1)) roman = '' for c, unit in characters_by_unit: while integer - unit >= 0: roman += c integer -= unit if c in ('X', 'V') and integer - unit + 1 >= 0: roman += 'I' + c integer -= units[c] - 1 elif c in ('L', 'C') and integer - unit + 10 >= 0: roman += 'X' + c integer -= units[c] - 10 elif c in ('D', 'M') and integer - unit + 100 >= 0: roman += 'C' + c integer -= units[c] - 100 if integer == 0: break return roman def main(): with open('../p089_romans.txt') as f: romans = list(map(str.strip, f.readlines())) reduced = [to_roman(parse_roman(r)) for r in romans] # # inconsistency check # for r1, r2 in zip(romans, reduced): # v1, v2 = parse_roman(r1), parse_roman(r2) # if v1 != v2: # print(r1, r2, parse_roman(r1), parse_roman(r2)) print(len(''.join(romans)) - len(''.join(reduced))) if __name__ == '__main__': main() ================================================ FILE: Problem089/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=89) ================================================ FILE: Problem089/p089_romans.txt ================================================ MMMMDCLXXII MMDCCCLXXXIII MMMDLXVIIII MMMMDXCV DCCCLXXII MMCCCVI MMMCDLXXXVII MMMMCCXXI MMMCCXX MMMMDCCCLXXIII MMMCCXXXVII MMCCCLXXXXIX MDCCCXXIIII MMCXCVI CCXCVIII MMMCCCXXXII MDCCXXX MMMDCCCL MMMMCCLXXXVI MMDCCCXCVI MMMDCII MMMCCXII MMMMDCCCCI MMDCCCXCII MDCXX CMLXXXVII MMMXXI MMMMCCCXIV MLXXII MCCLXXVIIII MMMMCCXXXXI MMDCCCLXXII MMMMXXXI MMMDCCLXXX MMDCCCLXXIX MMMMLXXXV MCXXI MDCCCXXXVII MMCCCLXVII MCDXXXV CCXXXIII CMXX MMMCLXIV MCCCLXXXVI DCCCXCVIII MMMDCCCCXXXIV CDXVIIII MMCCXXXV MDCCCXXXII MMMMD MMDCCLXIX MMMMCCCLXXXXVI MMDCCXLII MMMDCCCVIIII DCCLXXXIIII MDCCCCXXXII MMCXXVII DCCCXXX CCLXIX MMMXI MMMMCMLXXXXVIII MMMMDLXXXVII MMMMDCCCLX MMCCLIV CMIX MMDCCCLXXXIIII CLXXXII MMCCCCXXXXV MMMMDLXXXVIIII MMMDCCCXXI MMDCCCCLXXVI MCCCCLXX MMCDLVIIII MMMDCCCLIX MMMMCCCCXIX MMMDCCCLXXV XXXI CDLXXXIII MMMCXV MMDCCLXIII MMDXXX MMMMCCCLVII MMMDCI MMMMCDLXXXIIII MMMMCCCXVI CCCLXXXVIII MMMMCML MMMMXXIV MMMCCCCXXX DCCX MMMCCLX MMDXXXIII CCCLXIII MMDCCXIII MMMCCCXLIV CLXXXXI CXVI MMMMCXXXIII CLXX DCCCXVIII MLXVII DLXXXX MMDXXI MMMMDLXXXXVIII MXXII LXI DCCCCXLIII MMMMDV MMMMXXXIV MDCCCLVIII MMMCCLXXII MMMMDCCXXXVI MMMMLXXXIX MDCCCLXXXI MMMMDCCCXV MMMMCCCCXI MMMMCCCLIII MDCCCLXXI MMCCCCXI MLXV MMCDLXII MMMMDXXXXII MMMMDCCCXL MMMMCMLVI CCLXXXIV MMMDCCLXXXVI MMCLII MMMCCCCXV MMLXXXIII MMMV MMMV DCCLXII MMDCCCCXVI MMDCXLVIII CCLIIII CCCXXV MMDCCLXXXVIIII MMMMDCLXXVIII MMMMDCCCXCI MMMMCCCXX MMCCXLV MMMDCCCLXIX MMCCLXIIII MMMDCCCXLIX MMMMCCCLXIX CMLXXXXI MCMLXXXIX MMCDLXI MMDCLXXVIII MMMMDCCLXI MCDXXV DL CCCLXXII MXVIIII MCCCCLXVIII CIII MMMDCCLXXIIII MMMDVIII MMMMCCCLXXXXVII MMDXXVII MMDCCLXXXXV MMMMCXLVI MMMDCCLXXXII MMMDXXXVI MCXXII CLI DCLXXXIX MMMCLI MDCLXIII MMMMDCCXCVII MMCCCLXXXV MMMDCXXVIII MMMCDLX MMMCMLII MMMIV MMMMDCCCLVIII MMMDLXXXVIII MCXXIV MMMMLXXVI CLXXIX MMMCCCCXXVIIII DCCLXXXV MMMDCCCVI LI CLXXXVI MMMMCCCLXXVI MCCCLXVI CCXXXIX MMDXXXXI MMDCCCXLI DCCCLXXXVIII MMMMDCCCIV MDCCCCXV MMCMVI MMMMCMLXXXXV MMDCCLVI MMMMCCXLVIII DCCCCIIII MMCCCCIII MMMDCCLXXXVIIII MDCCCLXXXXV DVII MMMV DCXXV MMDCCCXCV DCVIII MMCDLXVI MCXXVIII MDCCXCVIII MMDCLX MMMDCCLXIV MMCDLXXVII MMDLXXXIIII MMMMCCCXXII MMMDCCCXLIIII DCCCCLXVII MMMCLXXXXIII MCCXV MMMMDCXI MMMMDCLXXXXV MMMCCCLII MMCMIX MMDCCXXV MMDLXXXVI MMMMDCXXVIIII DCCCCXXXVIIII MMCCXXXIIII MMDCCLXXVIII MDCCLXVIIII MMCCLXXXV MMMMDCCCLXXXVIII MMCMXCI MDXLII MMMMDCCXIV MMMMLI DXXXXIII MMDCCXI MMMMCCLXXXIII MMMDCCCLXXIII MDCLVII MMCD MCCCXXVII MMMMDCCIIII MMMDCCXLVI MMMCLXXXVII MMMCCVIIII MCCCCLXXIX DL DCCCLXXVI MMDXCI MMMMDCCCCXXXVI MMCII MMMDCCCXXXXV MMMCDXLV MMDCXXXXIV MMD MDCCCLXXXX MMDCXLIII MMCCXXXII MMDCXXXXVIIII DCCCLXXI MDXCVIIII MMMMCCLXXVIII MDCLVIIII MMMCCCLXXXIX MDCLXXXV MDLVIII MMMMCCVII MMMMDCXIV MMMCCCLXIIII MMIIII MMMMCCCLXXIII CCIII MMMCCLV MMMDXIII MMMCCCXC MMMDCCCXXI MMMMCCCCXXXII CCCLVI MMMCCCLXXXVI MXVIIII MMMCCCCXIIII CLXVII MMMCCLXX CCCCLXIV MMXXXXII MMMMCCLXXXX MXL CCXVI CCCCLVIIII MMCCCII MCCCLVIII MMMMCCCX MCDLXXXXIV MDCCCXIII MMDCCCXL MMMMCCCXXIII DXXXIV CVI MMMMDCLXXX DCCCVII MMCMLXIIII MMMDCCCXXXIII DCCC MDIII MMCCCLXVI MMMCCCCLXXI MMDCCCCXVIII CCXXXVII CCCXXV MDCCCXII MMMCMV MMMMCMXV MMMMDCXCI DXXI MMCCXLVIIII MMMMCMLII MDLXXX MMDCLXVI CXXI MMMDCCCLIIII MMMCXXI MCCIII MMDCXXXXI CCXCII MMMMDXXXV MMMCCCLXV MMMMDLXV MMMCCCCXXXII MMMCCCVIII DCCCCLXXXXII MMCLXIV MMMMCXI MLXXXXVII MMMCDXXXVIII MDXXII MLV MMMMDLXVI MMMCXII XXXIII MMMMDCCCXXVI MMMLXVIIII MMMLX MMMCDLXVII MDCCCLVII MMCXXXVII MDCCCCXXX MMDCCCLXIII MMMMDCXLIX MMMMCMXLVIII DCCCLXXVIIII MDCCCLIII MMMCMLXI MMMMCCLXI MMDCCCLIII MMMDCCCVI MMDXXXXIX MMCLXXXXV MMDXXX MMMXIII DCLXXIX DCCLXII MMMMDCCLXVIII MDCCXXXXIII CCXXXII MMMMDCXXV MMMCCCXXVIII MDCVIII MMMCLXXXXIIII CLXXXI MDCCCCXXXIII MMMMDCXXX MMMDCXXIV MMMCCXXXVII MCCCXXXXIIII CXVIII MMDCCCCIV MMMMCDLXXV MMMDLXIV MDXCIII MCCLXXXI MMMDCCCXXIV MCXLIII MMMDCCCI MCCLXXX CCXV MMDCCLXXI MMDLXXXIII MMMMDCXVII MMMCMLXV MCLXVIII MMMMCCLXXVI MMMDCCLXVIIII MMMMDCCCIX DLXXXXIX DCCCXXII MMMMIII MMMMCCCLXXVI DCCCXCIII DXXXI MXXXIIII CCXII MMMDCCLXXXIIII MMMCXX MMMCMXXVII DCCCXXXX MMCDXXXVIIII MMMMDCCXVIII LV MMMDCCCCVI MCCCII MMCMLXVIIII MDCCXI MMMMDLXVII MMCCCCLXI MMDCCV MMMCCCXXXIIII MMMMDI MMMDCCCXCV MMDCCLXXXXI MMMDXXVI MMMDCCCLVI MMDCXXX MCCCVII MMMMCCCLXII MMMMXXV MMCMXXV MMLVI MMDXXX MMMMCVII MDC MCCIII MMMMDCC MMCCLXXV MMDCCCXXXXVI MMMMCCCLXV CDXIIII MLXIIII CCV MMMCMXXXI CCCCLXVI MDXXXII MMMMCCCLVIII MMV MMMCLII MCMLI MMDCCXX MMMMCCCCXXXVI MCCLXXXI MMMCMVI DCCXXX MMMMCCCLXV DCCCXI MMMMDCCCXIV CCCXXI MMDLXXV CCCCLXXXX MCCCLXXXXII MMDCIX DCCXLIIII DXIV MMMMCLII CDLXI MMMCXXVII MMMMDCCCCLXIII MMMDCLIIII MCCCCXXXXII MMCCCLX CCCCLIII MDCCLXXVI MCMXXIII MMMMDLXXVIII MMDCCCCLX MMMCCCLXXXX MMMCDXXVI MMMDLVIII CCCLXI MMMMDCXXII MMDCCCXXI MMDCCXIII MMMMCLXXXVI MDCCCCXXVI MDV MMDCCCCLXXVI MMMMCCXXXVII MMMDCCLXXVIIII MMMCCCCLXVII DCCXLI MMCLXXXVIII MCCXXXVI MMDCXLVIII MMMMCXXXII MMMMDCCLXVI MMMMCMLI MMMMCLXV MMMMDCCCXCIV MCCLXXVII LXXVIIII DCCLII MMMCCCXCVI MMMCLV MMDCCCXXXXVIII DCCCXV MXC MMDCCLXXXXVII MMMMCML MMDCCCLXXVIII DXXI MCCCXLI DCLXXXXI MMCCCLXXXXVIII MDCCCCLXXVIII MMMMDXXV MMMDCXXXVI MMMCMXCVII MMXVIIII MMMDCCLXXIV MMMCXXV DXXXVIII MMMMCLXVI MDXII MMCCCLXX CCLXXI DXIV MMMCLIII DLII MMMCCCXLIX MMCCCCXXVI MMDCXLIII MXXXXII CCCLXXXV MDCLXXVI MDCXII MMMCCCLXXXIII MMDCCCCLXXXII MMMMCCCLXXXV MMDCXXI DCCCXXX MMMDCCCCLII MMMDCCXXII MMMMCDXCVIII MMMCCLXVIIII MMXXV MMMMCDXIX MMMMCCCX MMMCCCCLXVI MMMMDCLXXVIIII MMMMDCXXXXIV MMMCMXII MMMMXXXIII MMMMDLXXXII DCCCLIV MDXVIIII MMMCLXXXXV CCCCXX MMDIX MMCMLXXXVIII DCCXLIII DCCLX D MCCCVII MMMMCCCLXXXIII MDCCCLXXIIII MMMDCCCCLXXXVII MMMMCCCVII MMMDCCLXXXXVI CDXXXIV MCCLXVIII MMMMDLX MMMMDXII MMMMCCCCLIIII MCMLXXXXIII MMMMDCCCIII MMDCLXXXIII MDCCCXXXXIV XXXXVII MMMDCCCXXXII MMMDCCCXLII MCXXXV MDCXXVIIII MMMCXXXXIIII MMMMCDXVII MMMDXXIII MMMMCCCCLXI DCLXXXXVIIII LXXXXI CXXXIII MCDX MCCLVII MDCXXXXII MMMCXXIV MMMMLXXXX MMDCCCCXLV MLXXX MMDCCCCLX MCDLIII MMMCCCLXVII MMMMCCCLXXIV MMMDCVIII DCCCCXXIII MMXCI MMDCCIV MMMMDCCCXXXIV CCCLXXI MCCLXXXII MCMIII CCXXXI DCCXXXVIII MMMMDCCXLVIIII MMMMCMXXXV DCCCLXXV DCCXCI MMMMDVII MMMMDCCCLXVIIII CCCXCV MMMMDCCXX MCCCCII MMMCCCXC MMMCCCII MMDCCLXXVII MMDCLIIII CCXLIII MMMDCXVIII MMMCCCIX MCXV MMCCXXV MLXXIIII MDCCXXVI MMMCCCXX MMDLXX MMCCCCVI MMDCCXX MMMMDCCCCXCV MDCCCXXXII MMMMDCCCCXXXX XCIV MMCCCCLX MMXVII MLXXI MMMDXXVIII MDCCCCII MMMCMLVII MMCLXXXXVIII MDCCCCLV MCCCCLXXIIII MCCCLII MCDXLVI MMMMDXVIII DCCLXXXIX MMMDCCLXIV MDCCCCXLIII CLXXXXV MMMMCCXXXVI MMMDCCCXXI MMMMCDLXXVII MCDLIII MMCCXLVI DCCCLV MCDLXX DCLXXVIII MMDCXXXIX MMMMDCLX MMDCCLI MMCXXXV MMMCCXII MMMMCMLXII MMMMCCV MCCCCLXIX MMMMCCIII CLXVII MCCCLXXXXIIII MMMMDCVIII MMDCCCLXI MMLXXIX CMLXIX MMDCCCXLVIIII DCLXII MMMCCCXLVII MDCCCXXXV MMMMDCCXCVI DCXXX XXVI MMLXIX MMCXI DCXXXVII MMMMCCCXXXXVIII MMMMDCLXI MMMMDCLXXIIII MMMMVIII MMMMDCCCLXII MDCXCI MMCCCXXIIII CCCCXXXXV MMDCCCXXI MCVI MMDCCLXVIII MMMMCXL MLXVIII CMXXVII CCCLV MDCCLXXXIX MMMCCCCLXV MMDCCLXII MDLXVI MMMCCCXVIII MMMMCCLXXXI MMCXXVII MMDCCCLXVIII MMMCXCII MMMMDCLVIII MMMMDCCCXXXXII MMDCCCCLXXXXVI MDCCXL MDCCLVII MMMMDCCCLXXXVI DCCXXXIII MMMMDCCCCLXXXV MMCCXXXXVIII MMMCCLXXVIII MMMDCLXXVIII DCCCI MMMMLXXXXVIIII MMMCCCCLXXII MMCLXXXVII CCLXVI MCDXLIII MMCXXVIII MDXIV CCCXCVIII CLXXVIII MMCXXXXVIIII MMMDCLXXXIV CMLVIII MCDLIX MMMMDCCCXXXII MMMMDCXXXIIII MDCXXI MMMDCXLV MCLXXVIII MCDXXII IV MCDLXXXXIII MMMMDCCLXV CCLI MMMMDCCCXXXVIII DCLXII MCCCLXVII MMMMDCCCXXXVI MMDCCXLI MLXI MMMCDLXVIII MCCCCXCIII XXXIII MMMDCLXIII MMMMDCL DCCCXXXXIIII MMDLVII DXXXVII MCCCCXXIIII MCVII MMMMDCCXL MMMMCXXXXIIII MCCCCXXIV MMCLXVIII MMXCIII MDCCLXXX MCCCLIIII MMDCLXXI MXI MCMLIV MMMCCIIII DCCLXXXVIIII MDCLIV MMMDCXIX CMLXXXI DCCLXXXVII XXV MMMXXXVI MDVIIII CLXIII MMMCDLVIIII MMCCCCVII MMMLXX MXXXXII MMMMCCCLXVIII MMDCCCXXVIII MMMMDCXXXXI MMMMDCCCXXXXV MMMXV MMMMCCXVIIII MMDCCXIIII MMMXXVII MDCCLVIIII MMCXXIIII MCCCLXXIV DCLVIII MMMLVII MMMCXLV MMXCVII MMMCCCLXXXVII MMMMCCXXII DXII MMMDLV MCCCLXXVIII MMMCLIIII MMMMCLXXXX MMMCLXXXIIII MDCXXIII MMMMCCXVI MMMMDLXXXIII MMMDXXXXIII MMMMCCCCLV MMMDLXXXI MMMCCLXXVI MMMMXX MMMMDLVI MCCCCLXXX MMMXXII MMXXII MMDCCCCXXXI MMMDXXV MMMDCLXXXVIIII MMMDLXXXXVII MDLXIIII CMXC MMMXXXVIII MDLXXXVIII MCCCLXXVI MMCDLIX MMDCCCXVIII MDCCCXXXXVI MMMMCMIV MMMMDCIIII MMCCXXXV XXXXVI MMMMCCXVII MMCCXXIV MCMLVIIII MLXXXIX MMMMLXXXIX CLXXXXIX MMMDCCCCLVIII MMMMCCLXXIII MCCCC DCCCLIX MMMCCCLXXXII MMMCCLXVIIII MCLXXXV CDLXXXVII DCVI MMX MMCCXIII MMMMDCXX MMMMXXVIII DCCCLXII MMMMCCCXLIII MMMMCLXV DXCI MMMMCLXXX MMMDCCXXXXI MMMMXXXXVI DCLX MMMCCCXI MCCLXXX MMCDLXXII DCCLXXI MMMCCCXXXVI MCCCCLXXXVIIII CDLVIII DCCLVI MMMMDCXXXVIII MMCCCLXXXIII MMMMDCCLXXV MMMXXXVI CCCLXXXXIX CV CCCCXIII CCCCXVI MDCCCLXXXIIII MMDCCLXXXII MMMMCCCCLXXXI MXXV MMCCCLXXVIIII MMMCCXII MMMMCCXXXIII MMCCCLXXXVI MMMDCCCLVIIII MCCXXXVII MDCLXXV XXXV MMDLI MMMCCXXX MMMMCXXXXV CCCCLIX MMMMDCCCLXXIII MMCCCXVII DCCCXVI MMMCCCXXXXV MDCCCCXCV CLXXXI MMMMDCCLXX MMMDCCCIII MMCLXXVII MMMDCCXXIX MMDCCCXCIIII MMMCDXXIIII MMMMXXVIII MMMMDCCCCLXVIII MDCCCXX MMMMCDXXI MMMMDLXXXIX CCXVI MDVIII MMCCLXXI MMMDCCCLXXI MMMCCCLXXVI MMCCLXI MMMMDCCCXXXIV DLXXXVI MMMMDXXXII MMMXXIIII MMMMCDIV MMMMCCCXLVIII MMMMCXXXVIII MMMCCCLXVI MDCCXVIII MMCXX CCCLIX MMMMDCCLXXII MDCCCLXXV MMMMDCCCXXIV DCCCXXXXVIII MMMDCCCCXXXVIIII MMMMCCXXXV MDCLXXXIII MMCCLXXXIV MCLXXXXIIII DXXXXIII MCCCXXXXVIII MMCLXXIX MMMMCCLXIV MXXII MMMCXIX MDCXXXVII MMDCCVI MCLXXXXVIII MMMCXVI MCCCLX MMMCDX CCLXVIIII MMMCCLX MCXXVIII LXXXII MCCCCLXXXI MMMI MMMCCCLXIV MMMCCCXXVIIII CXXXVIII MMCCCXX MMMCCXXVIIII MCCLXVI MMMCCCCXXXXVI MMDCCXCIX MCMLXXI MMCCLXVIII CDLXXXXIII MMMMDCCXXII MMMMDCCLXXXVII MMMDCCLIV MMCCLXIII MDXXXVII DCCXXXIIII MCII MMMDCCCLXXI MMMLXXIII MDCCCLIII MMXXXVIII MDCCXVIIII MDCCCCXXXVII MMCCCXVI MCMXXII MMMCCCLVIII MMMMDCCCXX MCXXIII MMMDLXI MMMMDXXII MDCCCX MMDXCVIIII MMMDCCCCVIII MMMMDCCCCXXXXVI MMDCCCXXXV MMCXCIV MCMLXXXXIII MMMCCCLXXVI MMMMDCLXXXV CMLXIX DCXCII MMXXVIII MMMMCCCXXX XXXXVIIII ================================================ FILE: Problem092/.hash ================================================ 6cee918c0612bccc2dac03d05e07035f ================================================ FILE: Problem092/Python/solution_slow_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # # Python Script # # Copyleft © Manoel Vilela # # """ Square digit chains Problem 92 A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before. For example, 44 → 32 → 13 → 10 → 1 → 1 85 → 89 → 145 → 42 → 20 → 4 → 16 → 37 → 58 → 89 Therefore any chain that arrives at 1 or 89 will become stuck in an endless loop. What is most amazing is that EVERY starting number will eventually arrive at 1 or 89. How many starting numbers below ten million will arrive at 89? """ # answer: 8581146 # primeiro algoritmo:230s+- (brute-force super simples) # outra versão usando lista = 314s # # usando dic(atual): 65s def sequence_end(n, finalnum): start = 0 dic = {} end_count = 0 while start + 1 < n: start += 1 if start in dic: if dic[start] == finalnum: end_count += 1 continue else: continue end = start nums = [end] while end != 1 and end != 89: end = sum(map(lambda x: x * x, (int(x) for x in str(end)))) if end in dic: end = dic[end] break else: nums.append(end) for num in nums: dic[num] = end if end == finalnum: end_count += 1 return end_count total = sequence_end(10 ** 7, 89) print(total) ================================================ FILE: Problem092/Python/solution_slow_2.py ================================================ #coding=utf-8 """ Square digit chains Problem 92 A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before. For example, 44 → 32 → 13 → 10 → 1 → 1 85 → 89 → 145 → 42 → 20 → 4 → 16 → 37 → 58 → 89 Therefore any chain that arrives at 1 or 89 will become stuck in an endless loop. What is most amazing is that EVERY starting number will eventually arrive at 1 or 89. How many starting numbers below ten million will arrive at 89? """ #simple version, not optmized. #230s+- def sequence_end(start): end = start while end != 1 and end != 89: end = sum(map(lambda x: x * x, [int(x) for x in str(end)])) return end total = 0 [total.__add__(1) for x in range(1, 10**7) if sequence_end(x) == 89] print(total) ================================================ FILE: Problem092/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=92) ================================================ FILE: Problem097/.hash ================================================ 68c8c919526039022b923a72d5cc12b1 ================================================ FILE: Problem097/CommonLisp/solution_1.lisp ================================================ ;; Common Lisp Script ;; Manoel Vilela (format t "~a~%" (mod (+ 1 (* 28433 (expt 2 7830457))) (expt 10 10))) ================================================ FILE: Problem097/Haskell/solution_1.hs ================================================ main :: IO () main = putStrLn . reverse . take 10 . reverse $ x where x = show (28433 * 2^7830457 + 1) ================================================ FILE: Problem097/Python/solution_1.py ================================================ if __name__ == "__main__": mersen_n = 28433 * (2 ** 7830457) + 1 print(mersen_n % 10**10) ================================================ FILE: Problem097/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=97) ================================================ FILE: Problem097/Ruby/solution_slow_1.rb ================================================ x = (28433 * 2 ** 7830457) + 1 puts x.to_s.reverse[0..9].reverse ================================================ FILE: Problem099/.hash ================================================ 1ecfb463472ec9115b10c292ef8bc986 ================================================ FILE: Problem099/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # # Python Script # # Copyleft © Manoel Vilela # # """ Largest exponential Problem 99 Comparing two numbers written in index form like 211 and 37 is not difficult, as any calculator would confirm that 211 = 2048 < 37 = 2187. However, confirming that 632382518061 > 519432525806 would be much more difficult, as both numbers contain over three million digits. Using base_exp.txt (right click and 'Save Link/Target As...'), a 22K text file containing one thousand lines with a base/exponent pair on each line, determine which line number has the greatest numerical value. NOTE: The first two lines in the file represent the numbers in the example given above. """ from math import log from os.path import dirname, join filedic = join('../p099_base_exp.txt') dic_evalued = {} with open(filedic, 'r') as f: nums = f.readlines() for line in range(len(nums)): num = nums[line].strip() base, exp = num.split(',') value = log(int(base)) * int(exp) dic_evalued[value] = line + 1 print(dic_evalued[max(dic_evalued)]) ================================================ FILE: Problem099/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=99) ================================================ FILE: Problem099/p099_base_exp.txt ================================================ 519432,525806 632382,518061 78864,613712 466580,530130 780495,510032 525895,525320 15991,714883 960290,502358 760018,511029 166800,575487 210884,564478 555151,523163 681146,515199 563395,522587 738250,512126 923525,503780 595148,520429 177108,572629 750923,511482 440902,532446 881418,505504 422489,534197 979858,501616 685893,514935 747477,511661 167214,575367 234140,559696 940238,503122 728969,512609 232083,560102 900971,504694 688801,514772 189664,569402 891022,505104 445689,531996 119570,591871 821453,508118 371084,539600 911745,504251 623655,518600 144361,582486 352442,541775 420726,534367 295298,549387 6530,787777 468397,529976 672336,515696 431861,533289 84228,610150 805376,508857 444409,532117 33833,663511 381850,538396 402931,536157 92901,604930 304825,548004 731917,512452 753734,511344 51894,637373 151578,580103 295075,549421 303590,548183 333594,544123 683952,515042 60090,628880 951420,502692 28335,674991 714940,513349 343858,542826 549279,523586 804571,508887 260653,554881 291399,549966 402342,536213 408889,535550 40328,652524 375856,539061 768907,510590 165993,575715 976327,501755 898500,504795 360404,540830 478714,529095 694144,514472 488726,528258 841380,507226 328012,544839 22389,690868 604053,519852 329514,544641 772965,510390 492798,527927 30125,670983 895603,504906 450785,531539 840237,507276 380711,538522 63577,625673 76801,615157 502694,527123 597706,520257 310484,547206 944468,502959 121283,591152 451131,531507 566499,522367 425373,533918 40240,652665 39130,654392 714926,513355 469219,529903 806929,508783 287970,550487 92189,605332 103841,599094 671839,515725 452048,531421 987837,501323 935192,503321 88585,607450 613883,519216 144551,582413 647359,517155 213902,563816 184120,570789 258126,555322 502546,527130 407655,535678 401528,536306 477490,529193 841085,507237 732831,512408 833000,507595 904694,504542 581435,521348 455545,531110 873558,505829 94916,603796 720176,513068 545034,523891 246348,557409 556452,523079 832015,507634 173663,573564 502634,527125 250732,556611 569786,522139 216919,563178 521815,525623 92304,605270 164446,576167 753413,511364 11410,740712 448845,531712 925072,503725 564888,522477 7062,780812 641155,517535 738878,512100 636204,517828 372540,539436 443162,532237 571192,522042 655350,516680 299741,548735 581914,521307 965471,502156 513441,526277 808682,508700 237589,559034 543300,524025 804712,508889 247511,557192 543486,524008 504383,526992 326529,545039 792493,509458 86033,609017 126554,589005 579379,521481 948026,502823 404777,535969 265767,554022 266876,553840 46631,643714 492397,527958 856106,506581 795757,509305 748946,511584 294694,549480 409781,535463 775887,510253 543747,523991 210592,564536 517119,525990 520253,525751 247926,557124 592141,520626 346580,542492 544969,523902 506501,526817 244520,557738 144745,582349 69274,620858 292620,549784 926027,503687 736320,512225 515528,526113 407549,535688 848089,506927 24141,685711 9224,757964 980684,501586 175259,573121 489160,528216 878970,505604 969546,502002 525207,525365 690461,514675 156510,578551 659778,516426 468739,529945 765252,510770 76703,615230 165151,575959 29779,671736 928865,503569 577538,521605 927555,503618 185377,570477 974756,501809 800130,509093 217016,563153 365709,540216 774508,510320 588716,520851 631673,518104 954076,502590 777828,510161 990659,501222 597799,520254 786905,509727 512547,526348 756449,511212 869787,505988 653747,516779 84623,609900 839698,507295 30159,670909 797275,509234 678136,515373 897144,504851 989554,501263 413292,535106 55297,633667 788650,509637 486748,528417 150724,580377 56434,632490 77207,614869 588631,520859 611619,519367 100006,601055 528924,525093 190225,569257 851155,506789 682593,515114 613043,519275 514673,526183 877634,505655 878905,505602 1926,914951 613245,519259 152481,579816 841774,507203 71060,619442 865335,506175 90244,606469 302156,548388 399059,536557 478465,529113 558601,522925 69132,620966 267663,553700 988276,501310 378354,538787 529909,525014 161733,576968 758541,511109 823425,508024 149821,580667 269258,553438 481152,528891 120871,591322 972322,501901 981350,501567 676129,515483 950860,502717 119000,592114 392252,537272 191618,568919 946699,502874 289555,550247 799322,509139 703886,513942 194812,568143 261823,554685 203052,566221 217330,563093 734748,512313 391759,537328 807052,508777 564467,522510 59186,629748 113447,594545 518063,525916 905944,504492 613922,519213 439093,532607 445946,531981 230530,560399 297887,549007 459029,530797 403692,536075 855118,506616 963127,502245 841711,507208 407411,535699 924729,503735 914823,504132 333725,544101 176345,572832 912507,504225 411273,535308 259774,555036 632853,518038 119723,591801 163902,576321 22691,689944 402427,536212 175769,572988 837260,507402 603432,519893 313679,546767 538165,524394 549026,523608 61083,627945 898345,504798 992556,501153 369999,539727 32847,665404 891292,505088 152715,579732 824104,507997 234057,559711 730507,512532 960529,502340 388395,537687 958170,502437 57105,631806 186025,570311 993043,501133 576770,521664 215319,563513 927342,503628 521353,525666 39563,653705 752516,511408 110755,595770 309749,547305 374379,539224 919184,503952 990652,501226 647780,517135 187177,570017 168938,574877 649558,517023 278126,552016 162039,576868 658512,516499 498115,527486 896583,504868 561170,522740 747772,511647 775093,510294 652081,516882 724905,512824 499707,527365 47388,642755 646668,517204 571700,522007 180430,571747 710015,513617 435522,532941 98137,602041 759176,511070 486124,528467 526942,525236 878921,505604 408313,535602 926980,503640 882353,505459 566887,522345 3326,853312 911981,504248 416309,534800 392991,537199 622829,518651 148647,581055 496483,527624 666314,516044 48562,641293 672618,515684 443676,532187 274065,552661 265386,554079 347668,542358 31816,667448 181575,571446 961289,502320 365689,540214 987950,501317 932299,503440 27388,677243 746701,511701 492258,527969 147823,581323 57918,630985 838849,507333 678038,515375 27852,676130 850241,506828 818403,508253 131717,587014 850216,506834 904848,504529 189758,569380 392845,537217 470876,529761 925353,503711 285431,550877 454098,531234 823910,508003 318493,546112 766067,510730 261277,554775 421530,534289 694130,514478 120439,591498 213308,563949 854063,506662 365255,540263 165437,575872 662240,516281 289970,550181 847977,506933 546083,523816 413252,535113 975829,501767 361540,540701 235522,559435 224643,561577 736350,512229 328303,544808 35022,661330 307838,547578 474366,529458 873755,505819 73978,617220 827387,507845 670830,515791 326511,545034 309909,547285 400970,536363 884827,505352 718307,513175 28462,674699 599384,520150 253565,556111 284009,551093 343403,542876 446557,531921 992372,501160 961601,502308 696629,514342 919537,503945 894709,504944 892201,505051 358160,541097 448503,531745 832156,507636 920045,503924 926137,503675 416754,534757 254422,555966 92498,605151 826833,507873 660716,516371 689335,514746 160045,577467 814642,508425 969939,501993 242856,558047 76302,615517 472083,529653 587101,520964 99066,601543 498005,527503 709800,513624 708000,513716 20171,698134 285020,550936 266564,553891 981563,501557 846502,506991 334,1190800 209268,564829 9844,752610 996519,501007 410059,535426 432931,533188 848012,506929 966803,502110 983434,501486 160700,577267 504374,526989 832061,507640 392825,537214 443842,532165 440352,532492 745125,511776 13718,726392 661753,516312 70500,619875 436952,532814 424724,533973 21954,692224 262490,554567 716622,513264 907584,504425 60086,628882 837123,507412 971345,501940 947162,502855 139920,584021 68330,621624 666452,516038 731446,512481 953350,502619 183157,571042 845400,507045 651548,516910 20399,697344 861779,506331 629771,518229 801706,509026 189207,569512 737501,512168 719272,513115 479285,529045 136046,585401 896746,504860 891735,505067 684771,514999 865309,506184 379066,538702 503117,527090 621780,518717 209518,564775 677135,515423 987500,501340 197049,567613 329315,544673 236756,559196 357092,541226 520440,525733 213471,563911 956852,502490 702223,514032 404943,535955 178880,572152 689477,514734 691351,514630 866669,506128 370561,539656 739805,512051 71060,619441 624861,518534 261660,554714 366137,540160 166054,575698 601878,519990 153445,579501 279899,551729 379166,538691 423209,534125 675310,515526 145641,582050 691353,514627 917468,504026 284778,550976 81040,612235 161699,576978 616394,519057 767490,510661 156896,578431 427408,533714 254849,555884 737217,512182 897133,504851 203815,566051 270822,553189 135854,585475 778805,510111 784373,509847 305426,547921 733418,512375 732087,512448 540668,524215 702898,513996 628057,518328 640280,517587 422405,534204 10604,746569 746038,511733 839808,507293 457417,530938 479030,529064 341758,543090 620223,518824 251661,556451 561790,522696 497733,527521 724201,512863 489217,528217 415623,534867 624610,518548 847541,506953 432295,533249 400391,536421 961158,502319 139173,584284 421225,534315 579083,521501 74274,617000 701142,514087 374465,539219 217814,562985 358972,540995 88629,607424 288597,550389 285819,550812 538400,524385 809930,508645 738326,512126 955461,502535 163829,576343 826475,507891 376488,538987 102234,599905 114650,594002 52815,636341 434037,533082 804744,508880 98385,601905 856620,506559 220057,562517 844734,507078 150677,580387 558697,522917 621751,518719 207067,565321 135297,585677 932968,503404 604456,519822 579728,521462 244138,557813 706487,513800 711627,513523 853833,506674 497220,527562 59428,629511 564845,522486 623621,518603 242689,558077 125091,589591 363819,540432 686453,514901 656813,516594 489901,528155 386380,537905 542819,524052 243987,557841 693412,514514 488484,528271 896331,504881 336730,543721 728298,512647 604215,519840 153729,579413 595687,520398 540360,524240 245779,557511 924873,503730 509628,526577 528523,525122 3509,847707 522756,525555 895447,504922 44840,646067 45860,644715 463487,530404 398164,536654 894483,504959 619415,518874 966306,502129 990922,501212 835756,507474 548881,523618 453578,531282 474993,529410 80085,612879 737091,512193 50789,638638 979768,501620 792018,509483 665001,516122 86552,608694 462772,530469 589233,520821 891694,505072 592605,520594 209645,564741 42531,649269 554376,523226 803814,508929 334157,544042 175836,572970 868379,506051 658166,516520 278203,551995 966198,502126 627162,518387 296774,549165 311803,547027 843797,507118 702304,514032 563875,522553 33103,664910 191932,568841 543514,524006 506835,526794 868368,506052 847025,506971 678623,515342 876139,505726 571997,521984 598632,520198 213590,563892 625404,518497 726508,512738 689426,514738 332495,544264 411366,535302 242546,558110 315209,546555 797544,509219 93889,604371 858879,506454 124906,589666 449072,531693 235960,559345 642403,517454 720567,513047 705534,513858 603692,519870 488137,528302 157370,578285 63515,625730 666326,516041 619226,518883 443613,532186 597717,520257 96225,603069 86940,608450 40725,651929 460976,530625 268875,553508 270671,553214 363254,540500 384248,538137 762889,510892 377941,538833 278878,551890 176615,572755 860008,506412 944392,502967 608395,519571 225283,561450 45095,645728 333798,544090 625733,518476 995584,501037 506135,526853 238050,558952 557943,522972 530978,524938 634244,517949 177168,572616 85200,609541 953043,502630 523661,525484 999295,500902 840803,507246 961490,502312 471747,529685 380705,538523 911180,504275 334149,544046 478992,529065 325789,545133 335884,543826 426976,533760 749007,511582 667067,516000 607586,519623 674054,515599 188534,569675 565185,522464 172090,573988 87592,608052 907432,504424 8912,760841 928318,503590 757917,511138 718693,513153 315141,546566 728326,512645 353492,541647 638429,517695 628892,518280 877286,505672 620895,518778 385878,537959 423311,534113 633501,517997 884833,505360 883402,505416 999665,500894 708395,513697 548142,523667 756491,511205 987352,501340 766520,510705 591775,520647 833758,507563 843890,507108 925551,503698 74816,616598 646942,517187 354923,541481 256291,555638 634470,517942 930904,503494 134221,586071 282663,551304 986070,501394 123636,590176 123678,590164 481717,528841 423076,534137 866246,506145 93313,604697 783632,509880 317066,546304 502977,527103 141272,583545 71708,618938 617748,518975 581190,521362 193824,568382 682368,515131 352956,541712 351375,541905 505362,526909 905165,504518 128645,588188 267143,553787 158409,577965 482776,528754 628896,518282 485233,528547 563606,522574 111001,595655 115920,593445 365510,540237 959724,502374 938763,503184 930044,503520 970959,501956 913658,504176 68117,621790 989729,501253 567697,522288 820427,508163 54236,634794 291557,549938 124961,589646 403177,536130 405421,535899 410233,535417 815111,508403 213176,563974 83099,610879 998588,500934 513640,526263 129817,587733 1820,921851 287584,550539 299160,548820 860621,506386 529258,525059 586297,521017 953406,502616 441234,532410 986217,501386 781938,509957 461247,530595 735424,512277 146623,581722 839838,507288 510667,526494 935085,503327 737523,512167 303455,548204 992779,501145 60240,628739 939095,503174 794368,509370 501825,527189 459028,530798 884641,505363 512287,526364 835165,507499 307723,547590 160587,577304 735043,512300 493289,527887 110717,595785 306480,547772 318593,546089 179810,571911 200531,566799 314999,546580 197020,567622 301465,548487 237808,559000 131944,586923 882527,505449 468117,530003 711319,513541 156240,578628 965452,502162 992756,501148 437959,532715 739938,512046 614249,519196 391496,537356 62746,626418 688215,514806 75501,616091 883573,505412 558824,522910 759371,511061 173913,573489 891351,505089 727464,512693 164833,576051 812317,508529 540320,524243 698061,514257 69149,620952 471673,529694 159092,577753 428134,533653 89997,606608 711061,513557 779403,510081 203327,566155 798176,509187 667688,515963 636120,517833 137410,584913 217615,563034 556887,523038 667229,515991 672276,515708 325361,545187 172115,573985 13846,725685 ================================================ FILE: Problem102/.hash ================================================ 74db120f0a8e5646ef5a30154e9f6deb ================================================ FILE: Problem102/Haskell/solution_1.hs ================================================ -- Autor: Manoel Vilela -- Generate the inequalities as delimiters based on the functions whose coincides with -- the segments of the triangle. If a arbitrary point (x,y) is valid for -- all delimiters so then the given point is inside of the triangle. delimeters :: (Fractional a, Ord a) => (a,a) -> (a,a) -> (a,a) -> [(a -> a -> Bool)] delimeters a b c = [delimiter x y z | (x,y,z) <- [(a,b,c), (b,c,a), (a,c,b)]] where delimiter (x1,y1) (x2,y2) (cx,cy) = let a = (y1 - y2) / (x1 - x2) b = y1 - (a * x1) in if cy > cx * a + b then (\x y -> y > x * a + b) else (\x y -> y < x * a + b) -- Check if given the points a b c, the coordinates (x,y) is inside of the -- triangle triangleContains :: (Fractional a, Ord a) => (a,a) -> (a,a) -> (a,a) -> (a,a) -> Bool triangleContains a b c (x,y) = and [delimiter x y | delimiter <- delimeters a b c] -- Check if the origin, point (0,0), is inside of the triangle ABC triangleContainsOrigin :: (Fractional a, Ord a) => ((a,a),(a,a),(a,a)) -> Bool triangleContainsOrigin (a,b,c) = triangleContains a b c (0,0) -- below is just parsing the file to compatible data to processing -- ugly part :[ replace :: Eq a => a -> a -> [a] -> [a] replace a b = map $ \c -> if c == a then b else c parseLine :: String -> [Float] parseLine s = map read $ words $ replace ',' ' ' s parseTriangle :: (Fractional a, Ord a) => [a] -> ((a, a), (a, a), (a, a)) parseTriangle xs = let (x1:y1:x2:y2:x3:y3:[]) = xs in ((x1,y1),(x2,y2),(x3,y3)) parse = parseTriangle . parseLine main = do triangles <- readFile "../p102_triangles.txt" print $ length $ filter triangleContainsOrigin $ map parse $ lines triangles ================================================ FILE: Problem102/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=102) ================================================ FILE: Problem102/p102_triangles.txt ================================================ -340,495,-153,-910,835,-947 -175,41,-421,-714,574,-645 -547,712,-352,579,951,-786 419,-864,-83,650,-399,171 -429,-89,-357,-930,296,-29 -734,-702,823,-745,-684,-62 -971,762,925,-776,-663,-157 162,570,628,485,-807,-896 641,91,-65,700,887,759 215,-496,46,-931,422,-30 -119,359,668,-609,-358,-494 440,929,968,214,760,-857 -700,785,838,29,-216,411 -770,-458,-325,-53,-505,633 -752,-805,349,776,-799,687 323,5,561,-36,919,-560 -907,358,264,320,204,274 -728,-466,350,969,292,-345 940,836,272,-533,748,185 411,998,813,520,316,-949 -152,326,658,-762,148,-651 330,507,-9,-628,101,174 551,-496,772,-541,-702,-45 -164,-489,-90,322,631,-59 673,366,-4,-143,-606,-704 428,-609,801,-449,740,-269 453,-924,-785,-346,-853,111 -738,555,-181,467,-426,-20 958,-692,784,-343,505,-569 620,27,263,54,-439,-726 804,87,998,859,871,-78 -119,-453,-709,-292,-115,-56 -626,138,-940,-476,-177,-274 -11,160,142,588,446,158 538,727,550,787,330,810 420,-689,854,-546,337,516 872,-998,-607,748,473,-192 653,440,-516,-985,808,-857 374,-158,331,-940,-338,-641 137,-925,-179,771,734,-715 -314,198,-115,29,-641,-39 759,-574,-385,355,590,-603 -189,-63,-168,204,289,305 -182,-524,-715,-621,911,-255 331,-816,-833,471,168,126 -514,581,-855,-220,-731,-507 129,169,576,651,-87,-458 783,-444,-881,658,-266,298 603,-430,-598,585,368,899 43,-724,962,-376,851,409 -610,-646,-883,-261,-482,-881 -117,-237,978,641,101,-747 579,125,-715,-712,208,534 672,-214,-762,372,874,533 -564,965,38,715,367,242 500,951,-700,-981,-61,-178 -382,-224,-959,903,-282,-60 -355,295,426,-331,-591,655 892,128,958,-271,-993,274 -454,-619,302,138,-790,-874 -642,601,-574,159,-290,-318 266,-109,257,-686,54,975 162,628,-478,840,264,-266 466,-280,982,1,904,-810 721,839,730,-807,777,981 -129,-430,748,263,943,96 434,-94,410,-990,249,-704 237,42,122,-732,44,-51 909,-116,-229,545,292,717 824,-768,-807,-370,-262,30 675,58,332,-890,-651,791 363,825,-717,254,684,240 405,-715,900,166,-589,422 -476,686,-830,-319,634,-807 633,837,-971,917,-764,207 -116,-44,-193,-70,908,809 -26,-252,998,408,70,-713 -601,645,-462,842,-644,-591 -160,653,274,113,-138,687 369,-273,-181,925,-167,-693 -338,135,480,-967,-13,-840 -90,-270,-564,695,161,907 607,-430,869,-713,461,-469 919,-165,-776,522,606,-708 -203,465,288,207,-339,-458 -453,-534,-715,975,838,-677 -973,310,-350,934,546,-805 -835,385,708,-337,-594,-772 -14,914,900,-495,-627,594 833,-713,-213,578,-296,699 -27,-748,484,455,915,291 270,889,739,-57,442,-516 119,811,-679,905,184,130 -678,-469,925,553,612,482 101,-571,-732,-842,644,588 -71,-737,566,616,957,-663 -634,-356,90,-207,936,622 598,443,964,-895,-58,529 847,-467,929,-742,91,10 -633,829,-780,-408,222,-30 -818,57,275,-38,-746,198 -722,-825,-549,597,-391,99 -570,908,430,873,-103,-360 342,-681,512,434,542,-528 297,850,479,609,543,-357 9,784,212,548,56,859 -152,560,-240,-969,-18,713 140,-133,34,-635,250,-163 -272,-22,-169,-662,989,-604 471,-765,355,633,-742,-118 -118,146,942,663,547,-376 583,16,162,264,715,-33 -230,-446,997,-838,561,555 372,397,-729,-318,-276,649 92,982,-970,-390,-922,922 -981,713,-951,-337,-669,670 -999,846,-831,-504,7,-128 455,-954,-370,682,-510,45 822,-960,-892,-385,-662,314 -668,-686,-367,-246,530,-341 -723,-720,-926,-836,-142,757 -509,-134,384,-221,-873,-639 -803,-52,-706,-669,373,-339 933,578,631,-616,770,555 741,-564,-33,-605,-576,275 -715,445,-233,-730,734,-704 120,-10,-266,-685,-490,-17 -232,-326,-457,-946,-457,-116 811,52,639,826,-200,147 -329,279,293,612,943,955 -721,-894,-393,-969,-642,453 -688,-826,-352,-75,371,79 -809,-979,407,497,858,-248 -485,-232,-242,-582,-81,849 141,-106,123,-152,806,-596 -428,57,-992,811,-192,478 864,393,122,858,255,-876 -284,-780,240,457,354,-107 956,605,-477,44,26,-678 86,710,-533,-815,439,327 -906,-626,-834,763,426,-48 201,-150,-904,652,475,412 -247,149,81,-199,-531,-148 923,-76,-353,175,-121,-223 427,-674,453,472,-410,585 931,776,-33,85,-962,-865 -655,-908,-902,208,869,792 -316,-102,-45,-436,-222,885 -309,768,-574,653,745,-975 896,27,-226,993,332,198 323,655,-89,260,240,-902 501,-763,-424,793,813,616 993,375,-938,-621,672,-70 -880,-466,-283,770,-824,143 63,-283,886,-142,879,-116 -964,-50,-521,-42,-306,-161 724,-22,866,-871,933,-383 -344,135,282,966,-80,917 -281,-189,420,810,362,-582 -515,455,-588,814,162,332 555,-436,-123,-210,869,-943 589,577,232,286,-554,876 -773,127,-58,-171,-452,125 -428,575,906,-232,-10,-224 437,276,-335,-348,605,878 -964,511,-386,-407,168,-220 307,513,912,-463,-423,-416 -445,539,273,886,-18,760 -396,-585,-670,414,47,364 143,-506,754,906,-971,-203 -544,472,-180,-541,869,-465 -779,-15,-396,890,972,-220 -430,-564,503,182,-119,456 89,-10,-739,399,506,499 954,162,-810,-973,127,870 890,952,-225,158,828,237 -868,952,349,465,574,750 -915,369,-975,-596,-395,-134 -135,-601,575,582,-667,640 413,890,-560,-276,-555,-562 -633,-269,561,-820,-624,499 371,-92,-784,-593,864,-717 -971,655,-439,367,754,-951 172,-347,36,279,-247,-402 633,-301,364,-349,-683,-387 -780,-211,-713,-948,-648,543 72,58,762,-465,-66,462 78,502,781,-832,713,836 -431,-64,-484,-392,208,-343 -64,101,-29,-860,-329,844 398,391,828,-858,700,395 578,-896,-326,-604,314,180 97,-321,-695,185,-357,852 854,839,283,-375,951,-209 194,96,-564,-847,162,524 -354,532,494,621,580,560 419,-678,-450,926,-5,-924 -661,905,519,621,-143,394 -573,268,296,-562,-291,-319 -211,266,-196,158,564,-183 18,-585,-398,777,-581,864 790,-894,-745,-604,-418,70 848,-339,150,773,11,851 -954,-809,-53,-20,-648,-304 658,-336,-658,-905,853,407 -365,-844,350,-625,852,-358 986,-315,-230,-159,21,180 -15,599,45,-286,-941,847 -613,-68,184,639,-987,550 334,675,-56,-861,923,340 -848,-596,960,231,-28,-34 707,-811,-994,-356,-167,-171 -470,-764,72,576,-600,-204 379,189,-542,-576,585,800 440,540,-445,-563,379,-334 -155,64,514,-288,853,106 -304,751,481,-520,-708,-694 -709,132,594,126,-844,63 723,471,421,-138,-962,892 -440,-263,39,513,-672,-954 775,809,-581,330,752,-107 -376,-158,335,-708,-514,578 -343,-769,456,-187,25,413 548,-877,-172,300,-500,928 938,-102,423,-488,-378,-969 -36,564,-55,131,958,-800 -322,511,-413,503,700,-847 -966,547,-88,-17,-359,-67 637,-341,-437,-181,527,-153 -74,449,-28,3,485,189 -997,658,-224,-948,702,-807 -224,736,-896,127,-945,-850 -395,-106,439,-553,-128,124 -841,-445,-758,-572,-489,212 633,-327,13,-512,952,771 -940,-171,-6,-46,-923,-425 -142,-442,-817,-998,843,-695 340,847,-137,-920,-988,-658 -653,217,-679,-257,651,-719 -294,365,-41,342,74,-892 690,-236,-541,494,408,-516 180,-807,225,790,494,59 707,605,-246,656,284,271 65,294,152,824,442,-442 -321,781,-540,341,316,415 420,371,-2,545,995,248 56,-191,-604,971,615,449 -981,-31,510,592,-390,-362 -317,-968,913,365,97,508 832,63,-864,-510,86,202 -483,456,-636,340,-310,676 981,-847,751,-508,-962,-31 -157,99,73,797,63,-172 220,858,872,924,866,-381 996,-169,805,321,-164,971 896,11,-625,-973,-782,76 578,-280,730,-729,307,-905 -580,-749,719,-698,967,603 -821,874,-103,-623,662,-491 -763,117,661,-644,672,-607 592,787,-798,-169,-298,690 296,644,-526,-762,-447,665 534,-818,852,-120,57,-379 -986,-549,-329,294,954,258 -133,352,-660,-77,904,-356 748,343,215,500,317,-277 311,7,910,-896,-809,795 763,-602,-753,313,-352,917 668,619,-474,-597,-650,650 -297,563,-701,-987,486,-902 -461,-740,-657,233,-482,-328 -446,-250,-986,-458,-629,520 542,-49,-327,-469,257,-947 121,-575,-634,-143,-184,521 30,504,455,-645,-229,-945 -12,-295,377,764,771,125 -686,-133,225,-25,-376,-143 -6,-46,338,270,-405,-872 -623,-37,582,467,963,898 -804,869,-477,420,-475,-303 94,41,-842,-193,-768,720 -656,-918,415,645,-357,460 -47,-486,-911,468,-608,-686 -158,251,419,-394,-655,-895 272,-695,979,508,-358,959 -776,650,-918,-467,-690,-534 -85,-309,-626,167,-366,-429 -880,-732,-186,-924,970,-875 517,645,-274,962,-804,544 721,402,104,640,478,-499 198,684,-134,-723,-452,-905 -245,745,239,238,-826,441 -217,206,-32,462,-981,-895 -51,989,526,-173,560,-676 -480,-659,-976,-580,-727,466 -996,-90,-995,158,-239,642 302,288,-194,-294,17,924 -943,969,-326,114,-500,103 -619,163,339,-880,230,421 -344,-601,-795,557,565,-779 590,345,-129,-202,-125,-58 -777,-195,159,674,775,411 -939,312,-665,810,121,855 -971,254,712,815,452,581 442,-9,327,-750,61,757 -342,869,869,-160,390,-772 620,601,565,-169,-69,-183 -25,924,-817,964,321,-970 -64,-6,-133,978,825,-379 601,436,-24,98,-115,940 -97,502,614,-574,922,513 -125,262,-946,695,99,-220 429,-721,719,-694,197,-558 326,689,-70,-908,-673,338 -468,-856,-902,-254,-358,305 -358,530,542,355,-253,-47 -438,-74,-362,963,988,788 137,717,467,622,319,-380 -86,310,-336,851,918,-288 721,395,646,-53,255,-425 255,175,912,84,-209,878 -632,-485,-400,-357,991,-608 235,-559,992,-297,857,-591 87,-71,148,130,647,578 -290,-584,-639,-788,-21,592 386,984,625,-731,-993,-336 -538,634,-209,-828,-150,-774 -754,-387,607,-781,976,-199 412,-798,-664,295,709,-537 -412,932,-880,-232,561,852 -656,-358,-198,-964,-433,-848 -762,-668,-632,186,-673,-11 -876,237,-282,-312,-83,682 403,73,-57,-436,-622,781 -587,873,798,976,-39,329 -369,-622,553,-341,817,794 -108,-616,920,-849,-679,96 290,-974,234,239,-284,-321 -22,394,-417,-419,264,58 -473,-551,69,923,591,-228 -956,662,-113,851,-581,-794 -258,-681,413,-471,-637,-817 -866,926,992,-653,-7,794 556,-350,602,917,831,-610 188,245,-906,361,492,174 -720,384,-818,329,638,-666 -246,846,890,-325,-59,-850 -118,-509,620,-762,-256,15 -787,-536,-452,-338,-399,813 458,560,525,-311,-608,-419 494,-811,-825,-127,-812,894 -801,890,-629,-860,574,925 -709,-193,-213,138,-410,-403 861,91,708,-187,5,-222 789,646,777,154,90,-49 -267,-830,-114,531,591,-698 -126,-82,881,-418,82,652 -894,130,-726,-935,393,-815 -142,563,654,638,-712,-597 -759,60,-23,977,100,-765 -305,595,-570,-809,482,762 -161,-267,53,963,998,-529 -300,-57,798,353,703,486 -990,696,-764,699,-565,719 -232,-205,566,571,977,369 740,865,151,-817,-204,-293 94,445,-768,229,537,-406 861,620,37,-424,-36,656 390,-369,952,733,-464,569 -482,-604,959,554,-705,-626 -396,-615,-991,108,272,-723 143,780,535,142,-917,-147 138,-629,-217,-908,905,115 915,103,-852,64,-468,-642 570,734,-785,-268,-326,-759 738,531,-332,586,-779,24 870,440,-217,473,-383,415 -296,-333,-330,-142,-924,950 118,120,-35,-245,-211,-652 61,634,153,-243,838,789 726,-582,210,105,983,537 -313,-323,758,234,29,848 -847,-172,-593,733,-56,617 54,255,-512,156,-575,675 -873,-956,-148,623,95,200 700,-370,926,649,-978,157 -639,-202,719,130,747,222 194,-33,955,943,505,114 -226,-790,28,-930,827,783 -392,-74,-28,714,218,-612 209,626,-888,-683,-912,495 487,751,614,933,631,445 -348,-34,-411,-106,835,321 -689,872,-29,-800,312,-542 -52,566,827,570,-862,-77 471,992,309,-402,389,912 24,520,-83,-51,555,503 -265,-317,283,-970,-472,690 606,526,137,71,-651,150 217,-518,663,66,-605,-331 -562,232,-76,-503,205,-323 842,-521,546,285,625,-186 997,-927,344,909,-546,974 -677,419,81,121,-705,771 719,-379,-944,-797,784,-155 -378,286,-317,-797,-111,964 -288,-573,784,80,-532,-646 -77,407,-248,-797,769,-816 -24,-637,287,-858,-927,-333 -902,37,894,-823,141,684 125,467,-177,-516,686,399 -321,-542,641,-590,527,-224 -400,-712,-876,-208,632,-543 -676,-429,664,-242,-269,922 -608,-273,-141,930,687,380 786,-12,498,494,310,326 -739,-617,606,-960,804,188 384,-368,-243,-350,-459,31 -550,397,320,-868,328,-279 969,-179,853,864,-110,514 910,793,302,-822,-285,488 -605,-128,218,-283,-17,-227 16,324,667,708,750,3 485,-813,19,585,71,930 -218,816,-687,-97,-732,-360 -497,-151,376,-23,3,315 -412,-989,-610,-813,372,964 -878,-280,87,381,-311,69 -609,-90,-731,-679,150,585 889,27,-162,605,75,-770 448,617,-988,0,-103,-504 -800,-537,-69,627,608,-668 534,686,-664,942,830,920 -238,775,495,932,-793,497 -343,958,-914,-514,-691,651 568,-136,208,359,728,28 286,912,-794,683,556,-102 -638,-629,-484,445,-64,-497 58,505,-801,-110,872,632 -390,777,353,267,976,369 -993,515,105,-133,358,-572 964,996,355,-212,-667,38 -725,-614,-35,365,132,-196 237,-536,-416,-302,312,477 -664,574,-210,224,48,-925 869,-261,-256,-240,-3,-698 712,385,32,-34,916,-315 895,-409,-100,-346,728,-624 -806,327,-450,889,-781,-939 -586,-403,698,318,-939,899 557,-57,-920,659,333,-51 -441,232,-918,-205,246,1 783,167,-797,-595,245,-736 -36,-531,-486,-426,-813,-160 777,-843,817,313,-228,-572 735,866,-309,-564,-81,190 -413,645,101,719,-719,218 -83,164,767,796,-430,-459 122,779,-15,-295,-96,-892 462,379,70,548,834,-312 -630,-534,124,187,-737,114 -299,-604,318,-591,936,826 -879,218,-642,-483,-318,-866 -691,62,-658,761,-895,-854 -822,493,687,569,910,-202 -223,784,304,-5,541,925 -914,541,737,-662,-662,-195 -622,615,414,358,881,-878 339,745,-268,-968,-280,-227 -364,855,148,-709,-827,472 -890,-532,-41,664,-612,577 -702,-859,971,-722,-660,-920 -539,-605,737,149,973,-802 800,42,-448,-811,152,511 -933,377,-110,-105,-374,-937 -766,152,482,120,-308,390 -568,775,-292,899,732,890 -177,-317,-502,-259,328,-511 612,-696,-574,-660,132,31 -119,563,-805,-864,179,-672 425,-627,183,-331,839,318 -711,-976,-749,152,-916,261 181,-63,497,211,262,406 -537,700,-859,-765,-928,77 892,832,231,-749,-82,613 816,216,-642,-216,-669,-912 -6,624,-937,-370,-344,268 737,-710,-869,983,-324,-274 565,952,-547,-158,374,-444 51,-683,645,-845,515,636 -953,-631,114,-377,-764,-144 -8,470,-242,-399,-675,-730 -540,689,-20,47,-607,590 -329,-710,-779,942,-388,979 123,829,674,122,203,563 46,782,396,-33,386,610 872,-846,-523,-122,-55,-190 388,-994,-525,974,127,596 781,-680,796,-34,-959,-62 -749,173,200,-384,-745,-446 379,618,136,-250,-224,970 -58,240,-921,-760,-901,-626 366,-185,565,-100,515,688 489,999,-893,-263,-637,816 838,-496,-316,-513,419,479 107,676,-15,882,98,-397 -999,941,-903,-424,670,-325 171,-979,835,178,169,-984 -609,-607,378,-681,184,402 -316,903,-575,-800,224,983 591,-18,-460,551,-167,918 -756,405,-117,441,163,-320 456,24,6,881,-836,-539 -489,-585,915,651,-892,-382 -177,-122,73,-711,-386,591 181,724,530,686,-131,241 737,288,886,216,233,33 -548,-386,-749,-153,-85,-982 -835,227,904,160,-99,25 -9,-42,-162,728,840,-963 217,-763,870,771,47,-846 -595,808,-491,556,337,-900 -134,281,-724,441,-134,708 -789,-508,651,-962,661,315 -839,-923,339,402,41,-487 300,-790,48,703,-398,-811 955,-51,462,-685,960,-717 910,-880,592,-255,-51,-776 -885,169,-793,368,-565,458 -905,940,-492,-630,-535,-988 245,797,763,869,-82,550 -310,38,-933,-367,-650,824 -95,32,-83,337,226,990 -218,-975,-191,-208,-785,-293 -672,-953,517,-901,-247,465 681,-148,261,-857,544,-923 640,341,446,-618,195,769 384,398,-846,365,671,815 578,576,-911,907,762,-859 548,-428,144,-630,-759,-146 710,-73,-700,983,-97,-889 -46,898,-973,-362,-817,-717 151,-81,-125,-900,-478,-154 483,615,-537,-932,181,-68 786,-223,518,25,-306,-12 -422,268,-809,-683,635,468 983,-734,-694,-608,-110,4 -786,-196,749,-354,137,-8 -181,36,668,-200,691,-973 -629,-838,692,-736,437,-871 -208,-536,-159,-596,8,197 -3,370,-686,170,913,-376 44,-998,-149,-993,-200,512 -519,136,859,497,536,434 77,-985,972,-340,-705,-837 -381,947,250,360,344,322 -26,131,699,750,707,384 -914,655,299,193,406,955 -883,-921,220,595,-546,794 -599,577,-569,-404,-704,489 -594,-963,-624,-460,880,-760 -603,88,-99,681,55,-328 976,472,139,-453,-531,-860 192,-290,513,-89,666,432 417,487,575,293,567,-668 655,711,-162,449,-980,972 -505,664,-685,-239,603,-592 -625,-802,-67,996,384,-636 365,-593,522,-666,-200,-431 -868,708,560,-860,-630,-355 -702,785,-637,-611,-597,960 -137,-696,-93,-803,408,406 891,-123,-26,-609,-610,518 133,-832,-198,555,708,-110 791,617,-69,487,696,315 -900,694,-565,517,-269,-416 914,135,-781,600,-71,-600 991,-915,-422,-351,-837,313 -840,-398,-302,21,590,146 62,-558,-702,-384,-625,831 -363,-426,-924,-496,792,-908 73,361,-817,-466,400,922 -626,-164,-626,860,-524,286 255,26,-944,809,-606,986 -457,-256,-103,50,-867,-871 -223,803,196,480,612,136 -820,-928,700,780,-977,721 717,332,53,-933,-128,793 -602,-648,562,593,890,702 -469,-875,-527,911,-475,-222 110,-281,-552,-536,-816,596 -981,654,413,-981,-75,-95 -754,-742,-515,894,-220,-344 795,-52,156,408,-603,76 474,-157,423,-499,-807,-791 260,688,40,-52,702,-122 -584,-517,-390,-881,302,-504 61,797,665,708,14,668 366,166,458,-614,564,-983 72,539,-378,796,381,-824 -485,201,-588,842,736,379 -149,-894,-298,705,-303,-406 660,-935,-580,521,93,633 -382,-282,-375,-841,-828,171 -567,743,-100,43,144,122 -281,-786,-749,-551,296,304 11,-426,-792,212,857,-175 594,143,-699,289,315,137 341,596,-390,107,-631,-804 -751,-636,-424,-854,193,651 -145,384,749,675,-786,517 224,-865,-323,96,-916,258 -309,403,-388,826,35,-270 -942,709,222,158,-699,-103 -589,842,-997,29,-195,-210 264,426,566,145,-217,623 217,965,507,-601,-453,507 -206,307,-982,4,64,-292 676,-49,-38,-701,550,883 5,-850,-438,659,745,-773 933,238,-574,-570,91,-33 -866,121,-928,358,459,-843 -568,-631,-352,-580,-349,189 -737,849,-963,-486,-662,970 135,334,-967,-71,-365,-792 789,21,-227,51,990,-275 240,412,-886,230,591,256 -609,472,-853,-754,959,661 401,521,521,314,929,982 -499,784,-208,71,-302,296 -557,-948,-553,-526,-864,793 270,-626,828,44,37,14 -412,224,617,-593,502,699 41,-908,81,562,-849,163 165,917,761,-197,331,-341 -687,314,799,755,-969,648 -164,25,578,439,-334,-576 213,535,874,-177,-551,24 -689,291,-795,-225,-496,-125 465,461,558,-118,-568,-909 567,660,-810,46,-485,878 -147,606,685,-690,-774,984 568,-886,-43,854,-738,616 -800,386,-614,585,764,-226 -518,23,-225,-732,-79,440 -173,-291,-689,636,642,-447 -598,-16,227,410,496,211 -474,-930,-656,-321,-420,36 -435,165,-819,555,540,144 -969,149,828,568,394,648 65,-848,257,720,-625,-851 981,899,275,635,465,-877 80,290,792,760,-191,-321 -605,-858,594,33,706,593 585,-472,318,-35,354,-927 -365,664,803,581,-965,-814 -427,-238,-480,146,-55,-606 879,-193,250,-890,336,117 -226,-322,-286,-765,-836,-218 -913,564,-667,-698,937,283 872,-901,810,-623,-52,-709 473,171,717,38,-429,-644 225,824,-219,-475,-180,234 -530,-797,-948,238,851,-623 85,975,-363,529,598,28 -799,166,-804,210,-769,851 -687,-158,885,736,-381,-461 447,592,928,-514,-515,-661 -399,-777,-493,80,-544,-78 -884,631,171,-825,-333,551 191,268,-577,676,137,-33 212,-853,709,798,583,-56 -908,-172,-540,-84,-135,-56 303,311,406,-360,-240,811 798,-708,824,59,234,-57 491,693,-74,585,-85,877 509,-65,-936,329,-51,722 -122,858,-52,467,-77,-609 850,760,547,-495,-953,-952 -460,-541,890,910,286,724 -914,843,-579,-983,-387,-460 989,-171,-877,-326,-899,458 846,175,-915,540,-1000,-982 -852,-920,-306,496,530,-18 338,-991,160,85,-455,-661 -186,-311,-460,-563,-231,-414 -932,-302,959,597,793,748 -366,-402,-788,-279,514,53 -940,-956,447,-956,211,-285 564,806,-911,-914,934,754 575,-858,-277,15,409,-714 848,462,100,-381,135,242 330,718,-24,-190,860,-78 479,458,941,108,-866,-653 212,980,962,-962,115,841 -827,-474,-206,881,323,765 506,-45,-30,-293,524,-133 832,-173,547,-852,-561,-842 -397,-661,-708,819,-545,-228 521,51,-489,852,36,-258 227,-164,189,465,-987,-882 -73,-997,641,-995,449,-615 151,-995,-638,415,257,-400 -663,-297,-748,537,-734,198 -585,-401,-81,-782,-80,-105 99,-21,238,-365,-704,-368 45,416,849,-211,-371,-1 -404,-443,795,-406,36,-933 272,-363,981,-491,-380,77 713,-342,-366,-849,643,911 -748,671,-537,813,961,-200 -194,-909,703,-662,-601,188 281,500,724,286,267,197 -832,847,-595,820,-316,637 520,521,-54,261,923,-10 4,-808,-682,-258,441,-695 -793,-107,-969,905,798,446 -108,-739,-590,69,-855,-365 380,-623,-930,817,468,713 759,-849,-236,433,-723,-931 95,-320,-686,124,-69,-329 -655,518,-210,-523,284,-866 144,303,639,70,-171,269 173,-333,947,-304,55,40 274,878,-482,-888,-835,375 -982,-854,-36,-218,-114,-230 905,-979,488,-485,-479,114 877,-157,553,-530,-47,-321 350,664,-881,442,-220,-284 434,-423,-365,878,-726,584 535,909,-517,-447,-660,-141 -966,191,50,353,182,-642 -785,-634,123,-907,-162,511 146,-850,-214,814,-704,25 692,1,521,492,-637,274 -662,-372,-313,597,983,-647 -962,-526,68,-549,-819,231 740,-890,-318,797,-666,948 -190,-12,-468,-455,948,284 16,478,-506,-888,628,-154 272,630,-976,308,433,3 -169,-391,-132,189,302,-388 109,-784,474,-167,-265,-31 -177,-532,283,464,421,-73 650,635,592,-138,1,-387 -932,703,-827,-492,-355,686 586,-311,340,-618,645,-434 -951,736,647,-127,-303,590 188,444,903,718,-931,500 -872,-642,-296,-571,337,241 23,65,152,125,880,470 512,823,-42,217,823,-263 180,-831,-380,886,607,762 722,443,-149,-216,-115,759 -19,660,-36,901,923,231 562,-322,-626,-968,194,-825 204,-920,938,784,362,150 -410,-266,-715,559,-672,124 -198,446,-140,454,-461,-447 83,-346,830,-493,-759,-382 -881,601,581,234,-134,-925 -494,914,-42,899,235,629 -390,50,956,437,774,-700 -514,514,44,-512,-576,-313 63,-688,808,-534,-570,-399 -726,572,-896,102,-294,-28 -688,757,401,406,955,-511 -283,423,-485,480,-767,908 -541,952,-594,116,-854,451 -273,-796,236,625,-626,257 -407,-493,373,826,-309,297 -750,955,-476,641,-809,713 8,415,695,226,-111,2 733,209,152,-920,401,995 921,-103,-919,66,871,-947 -907,89,-869,-214,851,-559 -307,748,524,-755,314,-711 188,897,-72,-763,482,103 545,-821,-232,-596,-334,-754 -217,-788,-820,388,-200,-662 779,160,-723,-975,-142,-998 -978,-519,-78,-981,842,904 -504,-736,-295,21,-472,-482 391,115,-705,574,652,-446 813,-988,865,830,-263,487 194,80,774,-493,-761,-872 -415,-284,-803,7,-810,670 -484,-4,881,-872,55,-852 -379,822,-266,324,-48,748 -304,-278,406,-60,959,-89 404,756,577,-643,-332,658 291,460,125,491,-312,83 311,-734,-141,582,282,-557 -450,-661,-981,710,-177,794 328,264,-787,971,-743,-407 -622,518,993,-241,-738,229 273,-826,-254,-917,-710,-111 809,770,96,368,-818,725 -488,773,502,-342,534,745 -28,-414,236,-315,-484,363 179,-466,-566,713,-683,56 560,-240,-597,619,916,-940 893,473,872,-868,-642,-461 799,489,383,-321,-776,-833 980,490,-508,764,-512,-426 917,961,-16,-675,440,559 -812,212,784,-987,-132,554 -886,454,747,806,190,231 910,341,21,-66,708,725 29,929,-831,-494,-303,389 -103,492,-271,-174,-515,529 -292,119,419,788,247,-951 483,543,-347,-673,664,-549 -926,-871,-437,337,162,-877 299,472,-771,5,-88,-643 -103,525,-725,-998,264,22 -505,708,550,-545,823,347 -738,931,59,147,-156,-259 456,968,-162,889,132,-911 535,120,968,-517,-864,-541 24,-395,-593,-766,-565,-332 834,611,825,-576,280,629 211,-548,140,-278,-592,929 -999,-240,-63,-78,793,573 -573,160,450,987,529,322 63,353,315,-187,-461,577 189,-950,-247,656,289,241 209,-297,397,664,-805,484 -655,452,435,-556,917,874 253,-756,262,-888,-778,-214 793,-451,323,-251,-401,-458 -396,619,-651,-287,-668,-781 698,720,-349,742,-807,546 738,280,680,279,-540,858 -789,387,530,-36,-551,-491 162,579,-427,-272,228,710 689,356,917,-580,729,217 -115,-638,866,424,-82,-194 411,-338,-917,172,227,-29 -612,63,630,-976,-64,-204 -200,911,583,-571,682,-579 91,298,396,-183,788,-955 141,-873,-277,149,-396,916 321,958,-136,573,541,-777 797,-909,-469,-877,988,-653 784,-198,129,883,-203,399 -68,-810,223,-423,-467,-512 531,-445,-603,-997,-841,641 -274,-242,174,261,-636,-158 -574,494,-796,-798,-798,99 95,-82,-613,-954,-753,986 -883,-448,-864,-401,938,-392 913,930,-542,-988,310,410 506,-99,43,512,790,-222 724,31,49,-950,260,-134 -287,-947,-234,-700,56,588 -33,782,-144,948,105,-791 548,-546,-652,-293,881,-520 691,-91,76,991,-631,742 -520,-429,-244,-296,724,-48 778,646,377,50,-188,56 -895,-507,-898,-165,-674,652 654,584,-634,177,-349,-620 114,-980,355,62,182,975 516,9,-442,-298,274,-579 -238,262,-431,-896,506,-850 47,748,846,821,-537,-293 839,726,593,285,-297,840 634,-486,468,-304,-887,-567 -864,914,296,-124,335,233 88,-253,-523,-956,-554,803 -587,417,281,-62,-409,-363 -136,-39,-292,-768,-264,876 -127,506,-891,-331,-744,-430 778,584,-750,-129,-479,-94 -876,-771,-987,-757,180,-641 -777,-694,411,-87,329,190 -347,-999,-882,158,-754,232 -105,918,188,237,-110,-591 -209,703,-838,77,838,909 -995,-339,-762,750,860,472 185,271,-289,173,811,-300 2,65,-656,-22,36,-139 765,-210,883,974,961,-905 -212,295,-615,-840,77,474 211,-910,-440,703,-11,859 -559,-4,-196,841,-277,969 -73,-159,-887,126,978,-371 -569,633,-423,-33,512,-393 503,143,-383,-109,-649,-998 -663,339,-317,-523,-2,596 690,-380,570,378,-652,132 72,-744,-930,399,-525,935 865,-983,115,37,995,826 594,-621,-872,443,188,-241 -1000,291,754,234,-435,-869 -868,901,654,-907,59,181 -868,-793,-431,596,-446,-564 900,-944,-680,-796,902,-366 331,430,943,853,-851,-942 315,-538,-354,-909,139,721 170,-884,-225,-818,-808,-657 -279,-34,-533,-871,-972,552 691,-986,-800,-950,654,-747 603,988,899,841,-630,591 876,-949,809,562,602,-536 -693,363,-189,495,738,-1000 -383,431,-633,297,665,959 -740,686,-207,-803,188,-520 -820,226,31,-339,10,121 -312,-844,624,-516,483,621 -822,-529,69,-278,800,328 834,-82,-759,420,811,-264 -960,-240,-921,561,173,46 -324,909,-790,-814,-2,-785 976,334,-290,-891,704,-581 150,-798,689,-823,237,-639 -551,-320,876,-502,-622,-628 -136,845,904,595,-702,-261 -857,-377,-522,-101,-943,-805 -682,-787,-888,-459,-752,-985 -571,-81,623,-133,447,643 -375,-158,72,-387,-324,-696 -660,-650,340,188,569,526 727,-218,16,-7,-595,-988 -966,-684,802,-783,-272,-194 115,-566,-888,47,712,180 -237,-69,45,-272,981,-812 48,897,439,417,50,325 348,616,180,254,104,-784 -730,811,-548,612,-736,790 138,-810,123,930,65,865 -768,-299,-49,-895,-692,-418 487,-531,802,-159,-12,634 808,-179,552,-73,470,717 720,-644,886,-141,625,144 -485,-505,-347,-244,-916,66 600,-565,995,-5,324,227 -771,-35,904,-482,753,-303 -701,65,426,-763,-504,-479 409,733,-823,475,64,718 865,975,368,893,-413,-433 812,-597,-970,819,813,624 193,-642,-381,-560,545,398 711,28,-316,771,717,-865 -509,462,809,-136,786,635 618,-49,484,169,635,547 -747,685,-882,-496,-332,82 -501,-851,870,563,290,570 -279,-829,-509,397,457,816 -508,80,850,-188,483,-326 860,-100,360,119,-205,787 -870,21,-39,-827,-185,932 826,284,-136,-866,-330,-97 -944,-82,745,899,-97,365 929,262,564,632,-115,632 244,-276,713,330,-897,-214 -890,-109,664,876,-974,-907 716,249,816,489,723,141 -96,-560,-272,45,-70,645 762,-503,414,-828,-254,-646 909,-13,903,-422,-344,-10 658,-486,743,545,50,674 -241,507,-367,18,-48,-241 886,-268,884,-762,120,-486 -412,-528,879,-647,223,-393 851,810,234,937,-726,797 -999,942,839,-134,-996,-189 100,979,-527,-521,378,800 544,-844,-832,-530,-77,-641 43,889,31,442,-934,-503 -330,-370,-309,-439,173,547 169,945,62,-753,-542,-597 208,751,-372,-647,-520,70 765,-840,907,-257,379,918 334,-135,-689,730,-427,618 137,-508,66,-695,78,169 -962,-123,400,-417,151,969 328,689,666,427,-555,-642 -907,343,605,-341,-647,582 -667,-363,-571,818,-265,-399 525,-938,904,898,725,692 -176,-802,-858,-9,780,275 580,170,-740,287,691,-97 365,557,-375,361,-288,859 193,737,842,-808,520,282 -871,65,-799,836,179,-720 958,-144,744,-789,797,-48 122,582,662,912,68,757 595,241,-801,513,388,186 -103,-677,-259,-731,-281,-857 921,319,-696,683,-88,-997 775,200,78,858,648,768 316,821,-763,68,-290,-741 564,664,691,504,760,787 694,-119,973,-385,309,-760 777,-947,-57,990,74,19 971,626,-496,-781,-602,-239 -651,433,11,-339,939,294 -965,-728,560,569,-708,-247 ================================================ FILE: Problem104/.hash ================================================ c8771ddd4df191098d70a8e94dd1cde7 ================================================ FILE: Problem104/Python/solution_1.py ================================================ import math import decimal # https://en.wikipedia.org/wiki/Fibonacci_number#Closed-form_expression sqrt = math.sqrt dec = decimal.Decimal def _is_pandigital(elem): return [str(i) for i in range(1, 10)] == sorted(list(elem)) _PHI = dec((1 + sqrt(5))/2) _PSI = dec(1 - _PHI) def _fermat_approximation(n): return (_PHI**dec(n) - _PSI**dec(n))/dec(sqrt(dec(5))) def _n_digit_of_decimal(d): s = str(d) return s[0] + s[2:10] def solve(): fa, fb, fc, t = 1, 1, 2, 2 while 1: t+=1 fc = (fa + fb) % 10 ** 9 fa = fb fb = fc if _is_pandigital(str(fc)): s_top = _n_digit_of_decimal(_fermat_approximation(t)) if _is_pandigital(s_top): return t if __name__ == "__main__": print(solve()) ================================================ FILE: Problem104/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=104) ================================================ FILE: Problem112/.hash ================================================ e08c982713a1c2bd3637dd489199722e - ================================================ FILE: Problem112/Python/solution_1.py ================================================ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Copyright © 2019 Manoel Vilela # # @project: Project Euler # @author: Manoel Vilela # @email: manoel_vilela@engineer.com # """ Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420. We shall call a positive integer that is neither increasing nor decreasing a "bouncy" number; for example, 155349. Clearly there cannot be any bouncy numbers below one-hundred, but just over half of the numbers below one-thousand (525) are bouncy. In fact, the least number for which the proportion of bouncy numbers first reaches 50% is 538. Surprisingly, bouncy numbers become more and more common and by the time we reach 21780 the proportion of bouncy numbers is equal to 90%. Find the least number for which the proportion of bouncy numbers is exactly 99%. """ def bouncy(num: int) -> bool: digits = str(num) comparisons = set() for d1, d2 in zip(digits, digits[1:]): if d1 == d2: continue state = 1 if int(d1) > int(d2) else 0 comparisons.add(state) if len(comparisons) == 2: return True return False def bouncy_counter(threshold: float): bouncy_numbers = 0 n = 100 percentage = 0 while percentage < threshold: n += 1 if bouncy(n): bouncy_numbers += 1 if bouncy_numbers > 0: percentage = bouncy_numbers / n return n def main(): print(bouncy_counter(0.99)) if __name__ == '__main__': main() ================================================ FILE: Problem112/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=112) ================================================ FILE: Problem145/.hash ================================================ 705e8444ad9c92e9a7589fb97515a9b6 ================================================ FILE: Problem145/Python/solution_slow_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # # Python Script # # Copyleft © Manoel Vilela # # """ How many reversible numbers are there below one-billion? Problem 145 Some positive integers n have the property that the sum [ n + reverse(n) ] consists entirely of odd (decimal) digits. For instance, 36 + 63 = 99 and 409 + 904 = 1313. We will call such numbers reversible; so 36, 63, 409, and 904 are reversible. Leading zeroes are not allowed in either n or reverse(n). There are 120 reversible numbers below one-thousand. How many reversible numbers are there below one-billion (10^9)? """ from functools import reduce from itertools import permutations, combinations_with_replacement # hahahhahaha!! consegui: answer 608720 # Demorou pra caramba, tem que melhorar ainda... mas funciona! combs = reduce(list.__add__, [[(x, y) for y in range(0, 10) if (x ^ y) & 1 or (x + y) < 10] for x in range(0, 10)]) def sumreverse(num): return str((int(str(num)[::-1]) + num)) def reversible(num): return bool(reduce(lambda a, b: a*b, [int(y) for y in sumreverse(num)]) & 1) def gen_filtred(n, start = 1): # n - potencia de 10 exp = start while exp < n: tamanho = (exp + 1)//2 # expoente impar na base 10 -> tamanho par for comb in combinations_with_replacement(combs, tamanho): for perm in sorted(set(permutations(comb))): head, tail = perm[0] if head == 0 or tail == 0 or not bool((head + tail) & 1): continue if exp & 1 == 1: index = exp newnum = 0 for leftnum, rightnum in perm: newnum += (leftnum * 10 ** index) + (rightnum * 10 ** abs(index - exp)) index -= 1 yield newnum else: for middle in range(10): index = exp newnum = middle * 10 ** (index // 2) for leftnum, rightnum in perm: newnum += (leftnum * 10 ** index ) + (rightnum * 10 ** abs(index - exp)) index -= 1 yield newnum exp += 1 range_x = lambda x: gen_filtred(len(str(x)) - 1) test = 100000000 total = 0 for i in range_x(test): if reversible(i): total += 1 print(total) ================================================ FILE: Problem145/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=145) ================================================ FILE: Problem206/.hash ================================================ 09f9d87cb4b1ebb34e1f607e55a351d8 ================================================ FILE: Problem206/Haskell/solution_1.hs ================================================ {-- Author: Manoel Vilela Find the unique positive integer whose square has the form 1_2_3_4_5_6_7_8_9_0, where each “_” is a single digit. --} {-- Some thoughts: As n² = 1_2_3_4_5_6_7_8_9_0 terminates with 0, so then n as well terminates with 0. But any number terminated with 0 and squared will have two zeros. (x * 10)^2 = 100 * x^2 So the number we are looking has the form: 1_2_3_4_5_6_7_8_900 Ignoring the last two zeros we have 1_2_3_4_5_6_7_8_9. A number terminated with 9. So the square root of this must terminated with a digit 7 or 3 (because 3² => 9 and 7² => 49). That way we just look for n values whose the last digits is 3 or 7. The max value to check is sqrt(19293949596979899) The min value to check is sqrt(10203040506070809) Range of almost 5 millions. But using numbers terminated with 3 or 7 will cut this to 1/5. So we'll check, in the worst case, 1 million of numbers. (much better to check 1 billion using brute-force) --} -- check if n match on the mask 1_2_3_4_5_6_7_8_9 numFitness :: Integer -> Bool numFitness n = and [a == b | (a,b) <- zip ['1'..'9'] num] where num = [str !! k | k <- filter even [0..length str]] str = show n -- For some reason looking for the maxValue to minValue we got a AWESOME -- optimization on final performance magicNum :: Integer magicNum = (* 10) $ head $ filter (numFitness . \x -> x * x) nums where minv = floor $ (sqrt 10203040506070809)/10 maxv = floor $ (sqrt 19293949596979899)/10 nums = concatMap (\n -> [n*10 + 3, n*10 + 7]) [maxv,maxv-1..minv] main :: IO() main = print magicNum ================================================ FILE: Problem206/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=206) ================================================ FILE: Problem301/.hash ================================================ f47b7d975a5ebd3b66af0968ef5e1cdb ================================================ FILE: Problem301/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 def nim(): binary_map = [0,1] total = 3 for k in range(28): binary_map_new = [] for i in range(0, len(binary_map), 2): if binary_map[i:i+2] == [0,0]: binary_map_new.extend([0,0,0,1]) total += 3 elif binary_map[i:i+2] == [0,1]: binary_map_new.extend([0,0]) total += 2 binary_map = binary_map_new return total if __name__ == "__main__": print(nim()) ================================================ FILE: Problem301/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=301) ================================================ FILE: Problem301/Scheme/solution_1.scm ================================================ ;; -*- mode: scheme; coding: utf-8-unix -*- #| A somewhat easy to demonstrate theorem: the desired number is a Fibonacci one! |# (define fibonacci (lambda (n) (define fibonacci-acc (lambda (n acc1 acc2) (cond ((= n 0) acc1) ((= n 1) acc2) (else (fibonacci-acc (- n 1) acc2 (+ acc2 acc1)))))) (fibonacci-acc n 0 1))) (define solve (let ((input 30)) (fibonacci (+ input 2)))) (display solve) (newline) ================================================ FILE: Problem301/Scheme/solution_2_slow.scm ================================================ ;; -*- mode: scheme; coding: utf-8-unix -*- ;; Racket doesn't define SRFI-151 (Bitwise Operations) - yet ;; (require srfi/151) (define loser? (lambda (n) (= (bitwise-xor n (* 2 n) (* 3 n)) 0))) (define list-losers-not-greater-than (lambda (n) (define list-losers-not-greater-than-acc (lambda (n acc) (cond ((= n 0) acc) ((loser? n) (list-losers-not-greater-than-acc (- n 1) (append (list n) acc))) (else (list-losers-not-greater-than-acc (- n 1) acc))))) (list-losers-not-greater-than-acc n '()))) (define count-losers-not-greater-than (lambda (n) (define count-losers-not-greater-than-acc (lambda (n acc) (cond ((= n 0) acc) ((loser? n) (count-losers-not-greater-than-acc (- n 1) (+ acc 1))) (else (count-losers-not-greater-than-acc (- n 1) acc))))) (count-losers-not-greater-than-acc n 0))) (define power (lambda (base exp) (define power-acc (lambda (base exp acc) (cond ((= exp 0) acc) (else (power-acc base (- exp 1) (* base acc)))))) (power-acc base exp 1))) (define solve (let ((input 30)) (count-losers-not-greater-than (power 2 input)))) (display solve) (newline) ================================================ FILE: Problem357/.hash ================================================ ed25b13b18a21c1077fed00ef42f503b ================================================ FILE: Problem357/Python/solution_slow_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # # Python Script # # Copyleft © Manoel Vilela # # """ THAT IS A WRONG APPROACH FOR THIS PROBLEM! SLOWWWWWW """ """ Consider the divisors of 30: 1,2,3,5,6,10,15,30. It can be seen that for every divisor d of 30, d+30/d is prime. Find the sum of all positive integers n not exceeding 100 000 000 such that for every divisor d of n, d+n/d is prime. """ # black magic divisors def divisors(n): from functools import reduce to_reduce = [[i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i is 0] return set(reduce(list.__add__, to_reduce)) def hnum(n, d): return d + (n // d) class prime_divisors(object): """ The solution provider from the depth of hell """ def __init__(self, max_value): self.max = max_value self.primes = [2] self.hell_numbers = [] self.run_from_hell() @property def sum(self): return sum(self.hell_numbers) def is_hell(self, n): return all([0 for d in divisors(n) if hnum(n, d) not in self.primes]) def next_prime(self): for p in range(3, self.max + 2): is_prime = True for prime in self.primes: if p % prime == 0: is_prime = False break if is_prime: self.primes += [p] else: continue # print('next_prime: {}'.format(p)) yield p def run_from_hell(self): # it's only possible even numbers, because: # if n = 2k + 1 # and d = n # 2k + 1 + [2k + 1]/[2k + 1] # 2k + 1 + 1 => 2k + 2 # even + even = even # if even, unique primes is two # but two don't is a hell number: 2 + 1/2: 2.5 for n in range(2, self.max + 1, 2): if n > self.primes[-1]: for p in self.next_prime(): if p > n: break if self.is_hell(n): self.hell_numbers += [n] # print('matched: {}'.format(n)) def main(): w = prime_divisors(100000000) print(w.sum) if __name__ == '__main__': main() ================================================ FILE: Problem357/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=357) ================================================ FILE: Problem439/.hash ================================================ 5058f1af8388633f609cadb75a75dc9d ================================================ FILE: Problem439/Python/solution_slow_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # # Python Script # # Copyleft © Manoel Vilela # # # THAT IS A BOMB! """ Let d(k) be the sum of all divisors of k. We define the function S(N) = ∑1≤i≤N ∑1≤j≤N d(i·j). For example, S(3) = d(1) + d(2) + d(3) + d(2) + d(4) + d(6) + d(3) + d(6) + d(9) = 59. You are given that S(10^3) = 563576517282 and S(10^5) mod 10^9 = 215766508. Find S(10^11) mod 10^9 """ from functools import reduce def gd(k): for x in range(1, k + 1): if k % x == 0: yield x def d(k): return reduce(lambda x, y: x + y, gd(k)) def g(n): for x in range(1, n + 1): for y in range(1, n + 1): yield x * y def s(n): dic = {} _sum = 0 for i in g(n): if i not in dic: dic[i] = d(i) _sum += dic[i] return _sum print(s(10 ** 11) % 10 ** 9) ================================================ FILE: Problem439/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=439) ================================================ FILE: Problem473/.hash ================================================ 835379a1ecfb7d86c9f9c5bc7c1d2d99 ================================================ FILE: Problem473/Python/solution_slow_1.py ================================================ # -*- coding: utf-8 -*- #problem 473 """ Let φ be the golden ratio: φ=1+5√2. Remarkably it is possible to write every positive integer as a sum of powers of φ even if we require that every power of φ is used at most once in this sum. Even then this representation is not unique. We can make it unique by requiring that no powers with consecutive exponents are used and that the representation is finite. E.g: 2=φ+φ^-2 and 3=φ^2+φ^-2 To represent this sum of powers of φ we use a string of 0's and 1's with a point to indicate where the negative exponents start. We call this the representation in the phigital numberbase. So 1=1φ, 2=10.01φ, 3=100.01φ and 14=100100.001001φ. The strings representing 1, 2 and 14 in the phigital number base are palindromic, while the string representating 3 is not. (the phigital point is not the middle character). The sum of the positive integers not exceeding 1000 whose phigital representation is palindromic is 4345. Find the sum of the positive integers not exceeding 10^10 whose phigital representation is palindromic. """ from math import * from string import ascii_lowercase as alf from random import sample #from kbhit_unix import KBHit as kbhit phi = ((1+sqrt(5))/2) def gen(x, sign = 1, start = 0, reverse = False): if not reverse: i = start while i < x: i += 1 yield i * sign else: while x > start: x -= 1 yield x * sign def phi_index(n, resto = 0, lista = []): if resto == 0: resto = n last = 0 for i in gen(n): if phi ** i > resto: lista.append(last) break last = i resto -= phi ** last if resto <= 1: if resto != 0: return suf_phi(n, resto, lista) else: return lista else: return phi_index(n, resto, lista) def suf_phi(n, resto = 0, lista = []): if resto == 0: resto = n last = -n for i in gen(n, sign = -1, start = -1, reverse = True): if phi ** i - 0.000001 > resto: lista.append(last) break last = i resto -= phi ** last if resto <= 0.000001: return lista else: return suf_phi(n, resto, lista) def phibase(n): index = phi_index(n, lista = []) msb = max(index); lsb = min(index) #Inicializar string a direita (prefixa) pre = [] for i in range(msb + 1): pre.append('0') #Inicializar string a esquerda (sufixa) suf = [] for i in range(abs(lsb)): suf.append('0') for i in index: if i >= 0: pre[i] = '1' else: suf[~i] = '1' return ''.join(pre[::-1]) + '.' + ''.join(suf) def calc(index): _sum_ = 0 for i in index: _sum_ += phi ** i if _sum_ + 0.0001 >= int(_sum_): return int(_sum_) else: return _sum_ def intphi(phinum): point = phinum.find('.') pre, suf = phinum[:point][::-1], phinum[point + 1:] index = [] for i in range(len(pre)): if pre[i] == '1': index.append(i) for i in range(len(suf)): if suf[i] == '1': index.append(~i) return calc(index) def gen_palindromic(n): pass def palindromic(string): if string != None: return string == string[::-1] test = 10 ** 10 #last: 6 num = phibase(test) with open('test' +'/'+ 'p473_' + ''.join(sample(alf, 8)) + '.txt', 'x') as f: f.write(num) ================================================ FILE: Problem473/Python/solution_slow_2.py ================================================ # -*- coding: utf-8 -*- #problem 473 """ Let φ be the golden ratio: φ=1+5√2. Remarkably it is possible to write every positive integer as a sum of powers of φ even if we require that every power of φ is used at most once in this sum. Even then this representation is not unique. We can make it unique by requiring that no powers with consecutive exponents are used and that the representation is finite. E.g: 2=φ+φ^-2 and 3=φ^2+φ^-2 To represent this sum of powers of φ we use a string of 0's and 1's with a point to indicate where the negative exponents start. We call this the representation in the phigital numberbase. So 1=1φ, 2=10.01φ, 3=100.01φ and 14=100100.001001φ. The strings representing 1, 2 and 14 in the phigital number base are palindromic, while the string representating 3 is not. (the phigital point is not the middle character). The sum of the positive integers not exceeding 1000 whose phigital representation is palindromic is 4345. Find the sum of the positive integers not exceeding 10^10 whose phigital representation is palindromic. """ from math import * from kbhit_unix import KBHit as kbhit phi = ((1+sqrt(5))/2) def phi_pre_gen(n): resto = n while resto >= 1: last = 0 for i in xrange(n): if phi ** i > resto: break last = i resto -= phi ** last yield last yield resto def phi_suf_gen(n, resto): while resto >= 0.0001: last = -n for i in xrange(-n, -1): if phi ** i - 0.0001 > resto: break last = i resto -= phi ** last yield last def checkpal(n): if n == 1: return True pre = [x for x in phi_pre_gen(n)] pre, resto = pre[:-1], pre[-1] suf = [x for x in phi_suf_gen(n, resto)] for i in xrange(len(pre)): try: if pre[i] != ~suf[~i]: return False except IndexError: return False return len(pre) == len(suf) sum = 0 kb = kbhit() total = 10 ** 10 for i in xrange(total): if checkpal(i): sum += i if kb.kbhit() and kb.getch(): print 'Atual: %*s / %d | %4.2f %% | Sum: %d' %(len(str(total)), str(i), total, i * 100 / total, sum) print sum ================================================ FILE: Problem473/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=473) ================================================ FILE: Problem500/.hash ================================================ 99bbf7af6066bfe2281bb18d667fb87c ================================================ FILE: Problem500/Bash/solution_1.sh ================================================ #!/usr/bin/bash seq -f '%.0f' 3 2 8000000 | factor | gawk '/ .* /{next} BEGIN{f=0;t=1;fifo[0]=2} {while(fifo[f]<$2){print fifo[f];fifo[t]=fifo[f]**2;f+=1;t+=1}} {print $2; fifo[t]=$2*$2;t+=1}' | head -500500 | gawk 'BEGIN{s=1}{s=(s*$1)%500500507}END{print s}' ================================================ FILE: Problem500/Python/solution_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # # Python Script # # Copyleft © Manoel Vilela # # import heapq from sympy.ntheory import Sieve, prime # I tired... more prime algorithms.... def primes_list(n): """Return the list of [2,..., n] n-th primes""" return [x for x in Sieve().primerange(2, prime(n))] def smallest_integer(k, modulus=None): """Calculate the smallest number with 2**k divisors. The math stuff about this in a simply way The achieve is got the all range of primes [p_0 ** x, p_n ** z] multiplied with factors minimized, even the smallest. For example the 120 on factored prime form is: 120 = 2³ * 3¹ * 5¹, by the formula we got the numbers divisors that way: (3 + 1) (1 + 1) (1 + 1) => 4 * 2 * 2 = 16 divisors! So the formula is: if p = (a ** x) * (b ** y) * (c ** z)... div(p) = (x + 1) * (y + 1) * (z + 1)... Anyway, because 2 ** k, so k = x + y + z. Since a_n < b_m and a_n, b_m are primes nums, for a smallest integer with d divisors we want (a_n ** x_i) < (b_m ** y_j)... and existence of primes [a_n, b_m] are maximized. That way, the p num will be minimized. Because that, we use a heap queue, to get ever the smallest num and push the used with the cost: pop: smallest from primes costed with use push: p ** 2 That way if the num was selected again, he'll be costed with x ** 2. As we have an expected num of 2 ** k divisors, we need iterate the heap k times. For each k, is a operation with more one divisor prime or factor. So the algorithm is O(K), considering the prime calculation stuff apart. Runs about 3s (more slow part is prime getting) See an iteration for execution of smallest_integer(k=4): Initial Heap with 4-th: [2, 3, 5] Heap: [2, 3, 5] Pop: 2 | Push: 4 => n = 1 * 2 Heap: [3, 5, 4] Pop: 3 | Push: 9 => n = 2 * 3 Heap: [4, 5, 9] Pop: 4 | Push: 16 => n = 6 * 4 Heap: [5, 9, 16] Pop: 5 | Push: 25 => n = 24 * 5 Answer: 120 n = 2 * 3 * 4 * 5 = 120! = 2³ * 3 * 5 Other example smallest_integer(k=6): Initial Heap with 6-th: [2, 3, 5, 7, 11] Heap: [2, 3, 5, 7, 11] Pop: 2 | Push: 4 => n = 1 * 2 Heap: [3, 4, 5, 11, 7] Pop: 3 | Push: 9 => n = 2 * 3 Heap: [4, 7, 5, 11, 9] Pop: 4 | Push: 16 => n = 6 * 4 Heap: [5, 7, 9, 11, 16] Pop: 5 | Push: 25 => n = 24 * 5 Heap: [7, 11, 9, 16, 25] Pop: 7 | Push: 49 => n = 120 * 7 Heap: [9, 11, 25, 16, 49] Pop: 9 | Push: 81 => n = 840 * 9 Answer: 7560 n = 2 * 3 * 4 * 5 * 7 * 9 = 2³ * 3 ³ * 5 * 7 So well: (3 + 1) (3 + 1) (1 + 1) (1 + 1) = 4 * 4 * 2 * 2 => 4² * 2² = 2 ** 6 CQD. """ n = 1 # our last value # condition, that working only for k > 1 costs = primes_list(k) # more than necessary # print("Initial Heap with {}-th: {}".format(k, costs)) for i in range(k): # print("Heap: {}".format(costs)) # get the minor prime on costs c = heapq.heappop(costs) # set the prime before with c to heap! heapq.heappush(costs, c**2) # print("Pop: {} | Push: {} => n = {} * {}".format(c, c ** 2, n, c)) n *= c # that way the n value is small at each iteration # and we calculate more faster so well # try remove that with the block of 'for' # and the time get a worse cost: 3s -> 3min! if modulus: n %= modulus # print("Answer: {}".format(n)) return n test = smallest_integer(4) assert test == 120, "solve(4) got {}, expected 120".format(test) if __name__ == "__main__": print(smallest_integer(500500, 500500507)) ================================================ FILE: Problem500/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=500) ================================================ FILE: Problem501/Python/solution_slow_1.py ================================================ #!/usr/bin/env python # coding=utf-8 # # Python Script # # Copyleft © Manoel Vilela # # # PROBABLY THAT IS REALLY WRONG """ Eight Divisors Problem 501 The eight divisors of 24 are 1, 2, 3, 4, 6, 8, 12 and 24. The ten numbers not exceeding 100 having exactly eight divisors are 24, 30, 40, 42, 54, 56, 66, 70, 78 and 88. Let f(n) be the count of numbers not exceeding n with exactly eight divisors. You are given f(100) = 10, f(1000) = 180 and f(10^6) = 224427. Find f(10^12). """ def d(n): return set(reduce(list.__add__, [[i, n//i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0])) def f(n): return sum([1 for x in xrange(2, n) if len(d(x)) == 8]) def f_p(n): last = 0 for x in xrange(2, n): if len(d(x)) == 8: print x, (x - last) last = x return last # Another comment f_p(10 ** 12) ================================================ FILE: Problem501/README.md ================================================ [The original source of problem](https://projecteuler.net/problem=501) ================================================ FILE: README.md ================================================ [![Build Status](https://travis-ci.org/DestructHub/ProjectEuler.svg?branch=master)](https://travis-ci.org/DestructHub/ProjectEuler) [![Telegram Chat](https://patrolavia.github.io/telegram-badge/chat.png)](https://telegram.me/destructhub) # ProjectEuler Compilation of some solutions of the challenges existent in the website www.projecteuler.net ## Graphs ![Solutions by Language](data/count.png) ![Time Execution by Language](data/time.png) ## Test You can now test the algoritms just using on our Docker image hosted on `destructhub/project_euler` just calling: `docker-compose run async` or `docker-compose run sync`. Assuming of course that you have a `docker` installation with `docker-compose`. On the end of execution, will be print a tabular-like structure with information about problem, language, time execution and if the answer is correct. The asynchronous build is written in Elixir, the synchronous version is written in Python. You can look on both systems at `stats.exs` and `stats.py`. ## Status Check the status of our roadmap here: [STATUS.md](STATUS.md) ## Rules Check the rules of the repository here: [RULES.md](RULES.md) ### Authors and Contributors Check the ProjectEuler badges and tables by nickname: [SOLVERS.md](SOLVERS.md) ================================================ FILE: RULES.md ================================================ # Repository Rules 1. We want good solutions for the problems. A good solution can be relative, but until one minute is acceptable. If your solution breaks the one-minute rule of project euler, the file solution can be pushed with one condition: use the suffix `slow` like `solution_slow_1.xy`. That way, the `stats.py` will not execute that. 2. Please update the [STATUS.md](STATUS.md) in order for us to know what you are doing. That way we can attack more solutions in parallel. 3. CamelCase for folders and underscore for files. For each solution ensure using the layout of the example on final of this document. 4. On push if you get `! [rejected] master -> master (fetch first)`, **PLEASE**, don't create a useless fucking merge with `git pull`, instead this, execute `git pull --rebase`. The repository's history line will be glad with this. 5. Do not write solutions reading from stdin in any ways! That would make harder to generate a script for time measurement. 6. Optionally send PR with info about your processor and the time in which your solution takes to finish. 7. Add a md5sum hash of your solution on root of the `Problem00x` if no one exists yet. # Example ``` Problem00X/ .. Python/ .. solution_1.py .. README.md .. .hash ``` ``` $ cat README.md [The original source of problem](https://projecteuler.net/problem=29) ``` You can easily add a new template using the `add` script on the root of the repository. Just call: `./add ` ================================================ FILE: SOLVERS.md ================================================ ## Solvers! ![[lerax](www.github.com/ryukinix)](https://projecteuler.net/profile/lerax.png) ![[lubien](www.github.com/lubien)](https://projecteuler.net/profile/lubien.png) ![[leorog](www.github.com/leorog)](https://projecteuler.net/profile/leorog.png) ![[tkovs](www.github.com/tkovs)](https://projecteuler.net/profile/tkovs.png) ![[mateusjatenee](www.github.com/mateusjatenee)](https://projecteuler.net/profile/mateusjatenee.png) ![[rafaelcn](www.github.com/rafaelcn)](https://projecteuler.net/profile/rafaelcamposn.png) ![[a-hilaly](www.github.com/a-hilaly)](https://projecteuler.net/profile/mellatora.png) | Solver Name | ProjectEuler NickName | | :--------------------| :-------------------- | | Manoel Vilela | lerax | | João Ferreira | lubien | | Leonardo Rogerio | leorog | | Vitor Rodrigues | tkovs | | Mateus Guimarães | mateusjatenee | | Rafael Campos Nunes | rafaelcamposn | | Lucas Machado | machad0 | | M. A. Hilaly | mellatora | ================================================ FILE: STATUS.md ================================================ - [X] [Problem041](https://projecteuler.net/problem=41) - [X] Swift, @luizperes - [X] [Problem042](https://projecteuler.net/problem=42) - [X] Python, @ryukinix - [X] [Problem043](https://projecteuler.net/problem=43) - [X] Swift, @luizperes - [X] [Problem044](https://projecteuler.net/problem=44) - [X] Python, @ryukinix - [X] [Problem045](https://projecteuler.net/problem=45) - [X] Swift, @luizperes - [X] Python, @ryukinix - [X] C, @ryukinix and @luizperes - [X] Go, @ryukinix - [X] CommonLisp, @ryukinix - [X] [Problem046](https://projecteuler.net/problem=46) - [X] Python, @ryukinix - [X] [Problem047](https://projecteuler.net/problem=47) - [X] Swift, @luizperes - [X] Python, @ryukinix - [X] [Problem048](https://projecteuler.net/problem=48) - [X] Haskell, @tkovs - [X] Python, @ryukinix - [X] CommonLisp, @ryukinix - [X] Clojure, @ryukinix - [X] Go, @ryukinix - [X] C, @ryukinix - [X] [Problem049](https://projecteuler.net/problem=49) - [X] Python, @ryukinix - [ ] [Problem050](https://projecteuler.net/problem=50) ================================================ FILE: add ================================================ #!/bin/bash # # # Copyright @ DestructHub Authors # # # usage: add if [ -x "$(command -v md5)" ]; then alias md5sum='xargs md5 -s' elif [ ! -x "$(command -v md5sum)" ]; then echo "None of 'md5' and 'md5sum' cmd line are not found" echo "Try install coretuils before using this script" exit 1 fi num=$(expr $1 + 0) dir="Problem"$(printf "%03d" $num) readme="[The original source of problem](https://projecteuler.net/problem=$num)" hash=$(printf $2 | md5sum) mkdir -p $dir echo "Created folder $dir." echo $hash > $dir/.hash echo "$dir/.hash => $hash" echo $readme > $dir/README.md echo "Created file $dir/README.md" echo "Added solution template for problem $num of ProjectEuler" ================================================ FILE: docker-compose.yml ================================================ version: "2" services: async: image: destructhub/project_euler entrypoint: elixir --no-halt stats.exs -s python -s commonlisp -s ruby -s haskell -s go -s php -s elixir -s lua -s c++ -s bash -s clojure -s c -s ocaml environment: STATS_POOL_SIZE: #{STATS_POOL_SIZE} volumes: - .:/code security_opt: - seccomp:unconfined sync: image: destructhub/project_euler command: python3 stats.py --build -s python -s commonlisp -s ruby -s haskell -s go -s php -s elixir -s lua -s c++ -s bash -s clojure -s c -s ocaml volumes: - .:/code security_opt: - seccomp:unconfined diff-sync: image: destructhub/project_euler command: ./test volumes: - .:/code security_opt: - seccomp:unconfined ================================================ FILE: requirements.txt ================================================ pandas numpy sympy ================================================ FILE: stats.exs ================================================ defmodule Settings do def start_link do Agent.start_link &initial_state/0, name: __MODULE__ end defp initial_state do env = System.get_env("STATS_POOL_SIZE") parsed = env && case Integer.parse(env) do {int, _} -> int :error -> false end pool_size = parsed || 2 * :erlang.system_info(:schedulers_online) %{pool_size: pool_size} end def get(key) do Agent.get __MODULE__, &(&1[key]) end def set(key, value) do Agent.update __MODULE__, & Map.put(&1, key, value) end end defmodule CLI do @parse_opts [ strict: [ help: :boolean, search: [:string, :keep], pool_size: :integer, all: :boolean, quiet: :boolean ], aliases: [ h: :help, s: :search, p: :pool_size, a: :all, q: :quiet ] ] def run do OptionParser.parse(System.argv(), @parse_opts) |> process end def process({[help: true], _, _}) do help() end def process({parsed, _, _}) do all_languages? = Keyword.get parsed, :all, false quiet? = Keyword.get parsed, :quiet, false languages = Keyword.get_values(parsed, :search) pool_size = Keyword.get parsed, :pool_size, Settings.get(:pool_size) Settings.set(:pool_size, pool_size) if not all_languages? and Enum.empty?(languages) do help() else languages |> Enum.map(& String.downcase(&1)) |> Producer.start_link(all_languages?) Consumer.start_link() Renderer.start_link(quiet?) Manager.start_link() Manager.start_workers() end end defp help do IO.puts """ TODO: help """ System.halt(0) end end defmodule Producer do use GenServer def start_link(languages, all_languages?) do GenServer.start_link __MODULE__, problems(languages, all_languages?), name: __MODULE__ end def init(problems) do {:ok, problems} end def pop do GenServer.call __MODULE__, :pop end def handle_call(:pop, _from, [h | t]) do {:reply, {:ok, h}, t} end def handle_call(:pop, _from, []) do {:reply, :error, []} end defp problems(languages, all_languages?) do language_filter = if all_languages? do fn _ -> true end else fn language -> Enum.member?(languages, String.downcase(language)) end end File.ls!(".") |> Enum.filter(& Regex.match?(~r/Problem\d{1,3}/, &1)) |> Enum.flat_map(fn problem -> File.ls!(problem) |> Enum.filter(& problem |> Path.join(&1) |> File.dir?) |> Enum.filter(language_filter) |> Enum.map(fn lang -> File.ls!(Path.join(problem, lang)) |> Enum.reject(& Regex.match?(~r/(.+)\.out$/, &1)) |> Enum.filter(& Regex.match?(~r/^solution_\d+/, &1)) |> Enum.map(fn solution -> {lang, solution} end) end) |> Enum.flat_map(fn solutions -> solutions |> Enum.map(fn {lang, solution} -> {problem, lang, solution} end) end) end) end end defmodule Manager do use GenServer def start_link do workers = span_workers(Settings.get(:pool_size)) GenServer.start_link __MODULE__, workers, name: __MODULE__ end def init(workers) do state = workers |> Enum.reduce({[], %{}}, fn ({id, worker}, {xs, map}) -> {[id | xs], Map.put(map, id, worker)} end) {:ok, state} end def start_workers do :ok = GenServer.cast __MODULE__, :start_workers end def next do :ok = GenServer.cast __MODULE__, :next end def finished(id, solution, time) do :ok = GenServer.cast __MODULE__, {:finished, id, solution, time} end def handle_cast(:start_workers, {workers, _} = state) do for _ <- workers, do: Manager.next() {:noreply, state} end def handle_cast(:next, {[id | available], workers}) do worker = workers[id] case Producer.pop() do {:ok, {problem, _, file} = solution} -> Worker.run(worker, solution) Renderer.set_label(id, problem <> "/" <> file) {:noreply, {available, workers}} _ -> Renderer.set_label(id, "Finishing last jobs") workers = Map.delete(workers, id) if workers == %{} do Consumer.output() end {:noreply, {available, workers}} end end def handle_cast({:finished, id, solution, time}, {available, workers}) do Renderer.delete_label(id) Consumer.consume(solution, time) next() {:noreply, {[id | available], workers}} end defp span_workers(n) do for id <- 1..n do {:ok, pid} = Worker.start_link(id) {id, pid} end end end defmodule Worker do use GenServer def start_link(id) do GenServer.start_link __MODULE__, id end def init(id) do {:ok, id} end def run(worker, solution) do :ok = GenServer.cast worker, {:run, solution} end def handle_cast({:run, solution}, id) do {time, _} = :timer.tc(fn -> Runner.run(solution) end) Manager.finished(id, solution, time) {:noreply, id} end end defmodule Runner do @build_machine %{ "Python" => %{ cmd: "python3", builder: :execute }, "Elixir" => %{ cmd: "elixir", builder: :execute }, "Go" => %{ cmd: "go run", builder: :execute }, "Clojure" => %{ cmd: "clojure", builder: :execute }, "CommonLisp" => %{ cmd: "sbcl --script", builder: :execute }, "Scheme" => %{ cmd: "racket --script", builder: :execute }, "Racket" => %{ cmd: "racket --script", builder: :execute }, "Haskell" => %{ cmd: "runhaskell", builder: :execute }, "C" => %{ cmd: "gcc -std=c99 -lm", builder: :build }, "C++" => %{ cmd: "g++ -std=c++0x", builder: :build }, "Lua" => %{ cmd: "lua", builder: :execute }, "Ruby" => %{ cmd: "ruby", builder: :execute }, "Bash" => %{ cmd: "bash", builder: :execute }, "Objective-C" => %{ cmd: "gcc -Wall -lm -lobjc", builder: :build }, "PHP" => %{ cmd: "php", builder: :execute }, "Swift" => %{ cmd: "swift", builder: :execute } } def run({problem, lang, file}) do %{cmd: cmd, builder: builder} = @build_machine[lang] run(builder, cmd, {problem, lang, file}) end defp run(:build, cmd, {problem, lang, file}) do cd = Path.join([".", problem, lang]) [cmd | flags] = separate_command_from_flags(cmd) %{"name" => name} = Regex.named_captures(~r/(?.+)\.(.+)$/, file) outfile = name <> ".out" System.cmd(cmd, [file, "-o", outfile] ++ flags, cd: cd, stderr_to_stdout: true) run(:execute, "bash -c", {problem, lang, outfile}) end defp run(:execute, cmd, {problem, lang, file}) do cd = Path.join([".", problem, lang]) [cmd | flags] = separate_command_from_flags(cmd) # Compiled files when error if not File.exists?(Path.join(cd, file)) do IO.puts "\n#{Path.join(cd, file)} does not exists" System.halt(1) end System.cmd cmd, flags ++ [file], cd: cd, stderr_to_stdout: true end # Some commands are like "sbcl --script" and I need to split those defp separate_command_from_flags(cmd) do String.split(cmd, " ") end end defmodule Consumer do use GenServer def start_link do GenServer.start_link __MODULE__, %{}, name: __MODULE__ end def consume({problem, language, file}, time) do GenServer.cast __MODULE__, {problem, language, file, time} end def output do GenServer.cast __MODULE__, :output end def handle_cast({problem, language, file, time}, state) do nested = Map.put(state[problem] || %{}, language, {file, time}) state = Map.put(state, problem, nested) {:noreply, state} end def handle_cast(:output, state) do Renderer.stop() IO.puts "Finished all tasks" IO.puts "" rows = state |> Map.to_list |> Enum.flat_map(fn {problem, languages} -> languages |> Map.to_list |> Enum.map(fn {lang, {solution, time}} -> {problem, lang, solution, time} end) end) |> Enum.sort_by(&(elem(&1, 3)), &>=/2) slow = Enum.take_while(rows, & elem(&1, 3) >= 60_000_000) # 1 min if not Enum.empty?(slow) do IO.puts "The following solutions past our time tolerance of one minute:" for {problem, lang, solution, time} <- slow do time = time / 1_000_000 |> Float.round(2) |> Float.to_string IO.puts "\t#{problem}/#{lang}/#{solution} (#{time}s)" end System.halt(1) end rows = rows |> Enum.map(fn {problem, lang, solution, time} -> time = time / 1_000_000 |> Float.round(2) |> Float.to_string [problem, lang, solution, (time) <> "s"] end) rows = [["Problem", "Language", "File", "Timing"] | rows] col_sizes = rows |> Enum.reduce([0, 0, 0, 0], fn (row, acc) -> row |> Enum.map(&String.length/1) |> Zipper.zip_with(acc, &max/2) end) rows |> Enum.map(fn row -> row |> Zipper.zip_with(col_sizes, & String.pad_leading(&1, &2)) |> Enum.join(" | ") end) |> Enum.join("\n") |> IO.puts System.halt(0) {:noreply, state} end end defmodule Zipper do def zip_with(as, bs, _f) when length(as) == 0 or length(bs) == 0 do [] end def zip_with([a|as], [b|bs], f) do [f.(a, b) | zip_with(as, bs, f)] end end defmodule Renderer do @spinner_frames [ ". ", ".. ", "...", " ..", " ." ] use GenServer def start_link(quiet?) do if quiet? do GenServer.start_link RendererQuiet, nil, name: __MODULE__ else pool_size = Settings.get(:pool_size) labels = for _ <- 1..pool_size, do: nil GenServer.start_link __MODULE__, labels, name: __MODULE__ end end def init(labels) do {rendered, labels} = render_labels(labels) IO.write rendered {:ok, labels} end def render do :ok = GenServer.cast __MODULE__, :render end def set_label(id, label) do :ok = GenServer.cast __MODULE__, {:set_label, id, label} end def delete_label(id) do :ok = GenServer.cast __MODULE__, {:delete_label, id} end def stop do :ok = GenServer.cast __MODULE__, :stop end def handle_info(:timeout, state) do render() {:noreply, state} end def handle_cast(:render, labels) do IO.write Spinner.erase_lines(Enum.count(labels) - 1) {rendered, labels} = render_labels(labels) IO.write rendered {:noreply, labels, 100} end def handle_cast({:set_label, id, label}, labels) do render() {:noreply, List.update_at(labels, id - 1, fn _ -> {@spinner_frames, label} end)} end def handle_cast({:delete_label, id}, labels) do render() {:noreply, List.update_at(labels, id - 1, fn _ -> nil end)} end def handle_cast(:stop, labels) do IO.write Spinner.erase_lines(Enum.count(labels) - 1) {:stop, "Done", labels} end defp render_labels(labels) do {lines, labels} = labels |> Enum.map_reduce([], fn (nil, acc) -> {"Waiting", acc ++ [nil]} ({[], label}, acc) -> frame = hd @spinner_frames text = "#{frame} #{label}" {text, acc ++ [{tl(@spinner_frames), label}]} ({[frame | frames], label}, acc) -> text = "#{frame} #{label}" {text, acc ++ [{frames, label}]} end) {Enum.join(lines, "\n"), labels} end end defmodule RendererQuiet do use GenServer def init(_) do {:ok, nil} end def handle_cast(_, _) do {:noreply, nil} end end defmodule Spinner do @esc "\u001B[" @erase_line @esc <> "2K" @cursor_left @esc <> "G" def cursor_up, do: cursor_up(1) def cursor_up(count) do @esc <> Integer.to_string(count) <> "A" end def erase_lines(count) do ups = 0..count |> Enum.map(fn _ -> @erase_line end) |> Enum.intersperse(cursor_up()) |> Enum.join("") ups <> @cursor_left end end Settings.start_link() CLI.run() ================================================ FILE: stats.py ================================================ #!/usr/bin/env python3 # coding=utf-8 # # Python Script # # Copyleft © Manoel Vilela # # import pandas as pd # sudo pip install pandas import numpy as np # sudo pip install numpy from distutils.spawn import find_executable from optparse import OptionParser from os import path import os import time import itertools import threading import subprocess import re import sys import hashlib import fileinput import signal # # # Bulding classes # # SOLUTION_TIMEOUT_VALUE = 60 class TimeOutController: class TimeOut(Exception): pass def __init__(self, sec=SOLUTION_TIMEOUT_VALUE): signal.signal(signal.SIGALRM, self.raise_timeout) signal.alarm(sec) def cancel(self): signal.alarm(0) # disable alarm def raise_timeout(self, a, n): raise TimeOutController.TimeOut() class Checker(object): checked = [] def __init__(self, compiler, path): self.compiler = compiler.split() self.path = os.path.abspath(path) self.check() def check(self): binary = self.compiler[0] if binary not in self.checked and not find_executable(binary): raise EnvironmentError("{!r} not found. Do you have the compilers?".format(binary)) # noqa elif binary not in self.checked: self.checked += binary class Execute(Checker): """Interactive languages building""" def enter_dir(self): self.old_dir = os.getcwd() os.chdir(path.dirname(self.path)) def exit_dir(self): os.chdir(self.old_dir) def execute(self): self.enter_dir() before = time.time() args = self.compiler args += [self.path] try: toc = TimeOutController() program = subprocess.Popen(args, stdout=subprocess.PIPE) out, _ = program.communicate() except TimeOutController.TimeOut: out = b"TIMEOUT" program.kill() finally: toc.cancel() time_passed = time.time() - before self.exit_dir() return out, program.returncode, time_passed class Build(Checker): """For compiled languages: C++, C for example""" fout = "compiled.out" def compile(self): args = [self.compiler[0], self.path, "-o", self.output] + self.compiler[1:] program = subprocess.Popen(args, stdout=subprocess.PIPE) return program.wait() == 0 def execute(self): self.output = path.join(path.dirname(self.path), self.fout) if self.compile(): compiled = path.abspath(self.output) program = Execute("bash -c", "{}".format(compiled)) output = program.execute() os.remove(compiled) return output return b"compiles fails", EnvironmentError, 0 ERASE_LINE = "\x1b[2K" BUILD_SUPPORT = [ "Python", # you need python | pacman -Su python "Go", # you need golang | pacman -Su golang "Clojure", # you need clojure | pacman -Su clojure "CommonLisp", # you need clisp | pacman -Su clisp "Haskell", # you need ghc | pacman -Su ghc "Lua", # you need lua | pacman -Su lua5.3 "Ruby", # you need ruby | pacman -Su ruby "C", # you need gcc | pacman -Su gcc "C++", # you need | pacman -Su g++ "Elixir", # you need elixir | pacman -Su elixir "PHP", # you need php | pacman -Su php # "Swift", # you need swift | yaourt -Su swift # "Objective-C", # you need gcc-objc | pacman -Su gcc-objc "Scheme", "Racket", "Bash", # hmm, i think you already have this "OCaml", ] BUILD_FILES = ["stats.py", "stats.exs", "test", "add"] BUILD_MACHINE = { "Python": { "cmdline": "python3", "builder": Execute }, "Go": { "cmdline": "go run", "builder": Execute }, "Clojure": { "cmdline": "clojure", "builder": Execute }, "CommonLisp": { "cmdline": "sbcl --script", "builder": Execute }, "Racket": { "cmdline": "racket --script", "builder": Execute }, "Scheme": { "cmdline": "racket --script", "builder": Execute }, "Haskell": { "cmdline": "runhaskell", "builder": Execute }, "C": { "cmdline": "gcc -std=c99 -lm", "builder": Build }, "C++": { "cmdline": "g++ -std=c++0x", "builder": Build }, "Lua": { "cmdline": "lua", "builder": Execute }, "Ruby": { "cmdline": "ruby", "builder": Execute }, "Bash": { "cmdline": "bash", "builder": Execute }, "Elixir": { "cmdline": "elixir", "builder": Execute }, "Objective-C": { "cmdline": "gcc -Wall -lm -lobjc", "builder": Build }, "PHP": { "cmdline": "php", "builder": Execute }, "Swift": { "cmdline": "swift", "builder": Execute }, "OCaml" : { "cmdline" : "ocaml", "builder": Execute, } } # CLI INTERFACE # -l (list languages with solutions) # -c (do count solutions) # -p (print the path) # -a all languages selected # -s language (search) # -b (build) # Examples of usage: # python stats.py --list # python stats.py --list --count # python stats.py --all --path # python stats.py --all --count # python stats.py -s Python -s Haskell -c # # # Cmdline parsing definitions # # def _callback(option, opt_str, value, parser): """ Used to parse several arguments for one option, knowing that arguments never start with a `-` and `--` """ assert value is None value = [] for arg in parser.rargs: # stop on --foo like options if arg[:2] == "--" and len(arg) > 2: break if arg[:1] == "-" and len(arg) > 1: break value.append(arg) del parser.rargs[:len(value)] setattr(parser.values, option.dest, value) parser = OptionParser() parser.add_option( "-l", "--list", help="Print a list of the languages whose have solutions", dest="list", action="store_true", default=False, ) parser.add_option( "-s", "--search", help="Choose the languages for print information", dest="search", action="append", default=[], nargs=1, ) parser.add_option( "-f", "--files", help="Receive a list of file paths to build them", dest="files", action="callback", callback=_callback, ) parser.add_option( "-c", "--count", help="Print the count of each solution", dest="count", action="store_true", default=False, ) parser.add_option( "-b", "--build", help="Execute the solutions and print each solution", dest="build", action="store_true", default=False, ) parser.add_option( "-p", "--path", help="Print the path of each solution", dest="path", action="store_true", default=False, ) parser.add_option( "-a", "--all", help="Select all the languages for search", dest="all", action="store_true", default=False, ) parser.add_option( "-m", "--blame", help="Show the slowest solutions that needs help", dest="blame", action="store_true", default=False, ) parser.add_option( "-g", "--graph", help="Make a cool graph with the final DataFrame data", dest="graph", action="store_true", default=False, ) parser.usage = "%prog [-s language] [-al] [-cpb] [--blame] [--files] [-g]" def walk_problems(root="."): """ Function: walk_problems Summary: Walking for repository to get each content of ProblemXXX Examples: Uniq behavior Returns: list of 3-uples of strings """ problem = re.compile("./Problem[0-9]{3}/") problems = [] for x in os.walk(root): if problem.match(x[0]) and "pycache" not in x[0]: problems.append(x) return problems def read_hashfile(fpath): """Read .hash based on fpath and clean the weird chars""" return open(fpath).read().strip(' -\n') def get_problem_hashes(): """ Function: get_problem_hashes Summary: Walking from each problem and return a tuple (problem_name, hash_content) Returns: list of tuples """ hash_pattern = re.compile("./Problem[0-9]{3}") hashes = {} for file_tuple in os.walk("."): if hash_pattern.match(file_tuple[0]) and ".hash" in file_tuple[-1]: problem = file_tuple[0] hash_path = path.join(problem, '.hash') hash_content = read_hashfile(hash_path) hashes[problem.strip('./')] = hash_content return hashes def digest_answer(answer): clean_answer = answer.strip(' \n') return hashlib.md5(clean_answer.encode('utf-8')).hexdigest() def search_language(query, languages): """ Function: search_language Summary: Search for languages based on regex Examples: >>> search_language(["C"], ["C", "C++", "Python"]) ["C", "C++"] Attributes: @param (query): list of languages for search @param (languages): collections of languages normalized Returns: list of results as strings """ return set(query) & set(languages) def split_problem_language(path): """ Function: split_problem_language Summary: Get a path and split into problem and language Examples: >>> split_problem_language("./Problem001/Python") ["Problem001", "Python] Attributes: @param (path): path like ./Folder/Language Returns: [Problem, Language] <(string, string)> """ return path.strip("./").split("/") def is_solution(string): solution = re.compile("solution_+(?!out)") return solution.match(string) def parse_solutions(problems): """ Function: parse_solutions Summary: Organize the solutions of problems Examples: Attributes: @param (problems): os.walk functions output Returns: problem:lang -> [solutions] """ map_solutions = {} for problem_path, dirs, files in problems: problem, lang = split_problem_language(problem_path) map_solutions.setdefault(problem, {}).setdefault(lang, []) for file in files: if is_solution(file): map_solutions[problem][lang].append(file) return map_solutions def load_dataframe(): """ Function: load_dataframe Summary: Load all solutions of repository at dataframe Examples: >>> df = load_dataframe()[] >>> py = df["Python"] Python Problem001 [solution_1.py, solution_2.py] Problem002 [solution_1.py] Problem003 [solution_1.py] Problem004 [solution_1.py] If you observe: (index + column_name) <- list_solutions -> filepaths! Returns: pd.DataFrame """ return pd.DataFrame.from_dict(parse_solutions(walk_problems()), "index") def solutions_paths(df, from_files=None): """ Function: load_filepaths Summary: Get each filepath of solutions based on pd.DataFrame Examples: >>> df = load_dataframe() >>> py = df[["CommonLisp"]] >>> load_filepaths(py) ["..."] Attributes: @param (df): pd.DataFrame Returns: list of file paths """ paths = [] if from_files: for problem, lang, s in from_files: paths.append((lang, path.join(problem, lang, s))) return paths for column in df.columns: solutions = df[df[column].notnull()][column] lang = solutions.name problems = solutions.index for problem in problems: p = ((lang, path.join(problem, lang, s)) for s in solutions[problem]) paths.extend(p) return paths def count_solutions(df, solutions=True): """ Function: count_solutions Summary: Count the number of solutions of each problem and language Examples: Iam tired... Attributes: @param (df): pd.DataFrame Returns: pd.DataFrame """ df = df.dropna(axis=1, how='all') # columns all nan df = df.dropna(how='all') # rows all nan df_ = pd.DataFrame() df_ = df.applymap(lambda x: len(x) if x is not np.NAN else 0) if len(df.columns) > 1 and solutions: df_["Solutions"] = df_[df_.columns].apply(tuple, axis=1).map(sum) df_ = df_[df_.Solutions > 0] return df_ def handle_files(files): """ Analyse files to return two lists : - solutions : list of files as 3-uple of strings that are more likely solutions on the format: (ProblemXXX, 'Lang', 'solution_x.y') - build_files : list of files that are more build files (stats.py, stats.exs, ...) """ solutions = [] build_files = [] for f in files: if f.count("/") == 2: solutions.append(tuple(f.split("/"))) elif f.count("/") == 1 and f.startswith("./"): dic = parse_solutions(walk_problems(f)) problem = list(dic.keys())[0] for lang in dic[problem]: for solution in dic[problem][lang]: solutions.append((problem, lang, solution)) elif f.count("/") == 0 and f in BUILD_FILES: build_files.append(f) return list(filter(lambda x: is_solution(x[2]), solutions)), build_files # docs? def spinner(control): animation = r"⣾⣽⣻⢿⡿⣟⣯" sys.stdout.write(3 * " ") for c in itertools.cycle(animation): current_time = time.time() - control.time message = "(" + c + ")" + " t: {:.2f}".format(current_time) sys.stdout.write(message) time.sleep(0.1) sys.stdout.write(len(message) * "\010") sys.stdout.flush() if control.done: break # need docs def choose_builder(lang, fpath): try: if lang in BUILD_MACHINE: builder = BUILD_MACHINE[lang]['builder'] cmdline = BUILD_MACHINE[lang]['cmdline'] b = builder(cmdline, fpath) else: raise Exception("Builder not configured for {!r}! Call the developer".format(lang)) # noqa except Exception as e: print("\n", e) os._exit(1) finally: return b # need docs def execute_builder(b): out, err, t = b.execute() answer = out.decode("utf-8").strip("\n") if err: print(err) os._exit(1) sys.stdout.write(ERASE_LINE) building = "\rBuilt {}: Answer: {}: {:.2f}s\n".format(b.path, answer, t) sys.stdout.write(building) sys.stdout.flush() return answer, t # need docs def build_result(df, ignore_errors=False, blame=False, only=()): class Control: # to handle the spinner time at each solution time = time.time() done = False control = Control() columns = ["Problem", "Language", "Time", "Answer", "Correct"] data = [] hashes = get_problem_hashes() spin_thread = threading.Thread(target=spinner, args=(control,)) spin_thread.start() _problems = only if only else solutions_paths(df) for lang, spath in _problems: if "slow" in spath and not blame: sys.stdout.write("\rIgnored {}: bad solution (slow).\n".format(spath)) # noqa continue if lang in BUILD_SUPPORT: sys.stdout.write("@Building next {}: {}".format(spath, 12 * ' ')) b = choose_builder(lang, spath) problem = split_problem_language(spath)[0] outtimed = False correct = False control.time = time.time() answer, t = execute_builder(b) outtimed = answer == "TIMEOUT" if (not outtimed) and problem in hashes: answer_hash = digest_answer(answer) correct = answer_hash == hashes[problem] data.append([problem, lang, t, answer, correct]) elif not ignore_errors: sys.stdout.write("\r{}: Don't have support yet for {!r}!\n".format(spath, lang)) # noqa sys.stdout.write("\r\n") sys.stdout.flush() control.done = True spin_thread.join() final_df = pd.DataFrame(data, columns=columns) return final_df.sort_values("Problem") def list_by_count(df): df_ = count_solutions(df, solutions=False) count = [sum(df_[lang]) for lang in df_.columns] table = pd.DataFrame(count, index=df_.columns, columns=["Solutions"]) return table.sort_values("Solutions", ascending=False) def blame_solutions(df): df_ = df.applymap( lambda solutions: [x for x in solutions if 'slow' in x] or np.NAN if solutions is not np.NAN else np.NAN ) return df_ # Problem015 -> 15 def remove_problem(df): df_ = df df_.Problem = df.Problem.map(lambda x: x.replace("Problem", "").strip('0')) return df_ def build_per_language(df): index = df.Problem.map(int).max() languages = set(df.Language) data = {lang: np.full(index, np.nan) for lang in languages} for _, row in df.iterrows(): data[row['Language']][int(row['Problem']) - 1] = row['Time'] df_ = pd.DataFrame(data, index=range(1, index + 1)).dropna(how='all') df_.index.name = 'Problems' return df_ def header(opts): return "Command: " + ' '.join([x.capitalize() for x in opts if opts[x]]) def handle_graph(df, options): import matplotlib.pyplot as plt import matplotlib cicle_colors = itertools.cycle(['b', 'r', 'g', 'y', 'k']) my_colors = itertools.islice(cicle_colors, None, len(df)) matplotlib.style.use('ggplot') if options.build: df = build_per_language(remove_problem(df)) df.plot() elif options.list and options.count: # Make a list by cycling through the colors you care about # to match the length of your data. df.plot(kind='barh', stacked=True, color=list(my_colors)) plt.show() def handle_options(options): df = load_dataframe() langs = {x.lower(): x for x in df.columns} query = [x.lower() for x in options.search] uncommited_solutions = [] uncommited_core_files = [] tbsolutions = [] count_ws = 0 # wrong solutions langs_selected = [langs[x] for x in search_language(query, langs)] if options.files: uncommited_solutions, uncommited_core_files = handle_files(options.files) if not uncommited_solutions and uncommited_core_files: sys.stdout.write( "\rForced to exit: No solutions to build\nChanged_core_files : \n {}".format( uncommited_core_files) ) sys.exit(0) tbsolutions = solutions_paths(df, from_files=uncommited_solutions) if options.all: langs_selected = [x for x in langs.values()] if options.blame: df = blame_solutions(df) if options.list: if options.count: df = list_by_count(df) elif options.path: langs_selected = [x for x in langs.values()] else: df = '\n'.join(sorted(df.dropna(axis=1, how='all').columns)) else: df = df[langs_selected] if options.count and not options.list: df = count_solutions(df) elif options.build: try: df = build_result(df[langs_selected], options.all, options.blame, only=tbsolutions) count_ws = list(df["Correct"]).count(False) correct_ratio = 1 - count_ws/len(df) if count_ws else 1 sys.stdout.write( "Correct solutions ratio : {0}% \n".format(correct_ratio * 100) ) except(SystemExit, KeyboardInterrupt): os._exit(1) elif options.path: df = '\n'.join(path for _, path in solutions_paths(df[langs_selected])) pd.set_option("display.max_rows", len(df)) print(df) if count_ws: sys.exit(1) if options.graph: handle_graph(df, options) def main(): options, _ = parser.parse_args() if not any(options.__dict__.values()): parser.print_help() os._exit(0) print(header(options.__dict__)) handle_options(options) if __name__ == "__main__": main() ================================================ FILE: test ================================================ #!/bin/bash if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then if [ "$TRAVIS_BRANCH" = "master" ]; then elixir --no-halt stats.exs -s python \ -s commonlisp \ -s ruby \ -s haskell \ -s go \ -s php \ -s elixir \ -s lua \ -s c++ \ -s bash \ -s clojure \ -s c \ -q exit $? else # Cancel build if travis is building pushed version echo "Skipped this build" exit 0 fi fi # only return the arguments which are files that exists on the filesystem function filter_exists { while read line; do [[ -f "$line" ]] && echo $line done } function diff_files () { # Return uncommited changes file names git diff origin/master --name-only | filter_exists } function staged_files () { # Return staged file names git diff --cached --name-only | filter_exists } function build_commited () { # Build only commited changed diff_files | xargs python3 stats.py --build --files } function build_staged () { # Build only staged files #NOTE: Run before opening PR on your machine, make sure # `git add .` staged_files | xargs python3 stats.py --build --files } function main () { status=0 mode=$1 target=$2 if [ "$mode" = "" ]; then build_commited status=$? elif [ "$mode" = "async" ]; then #TODO: stats.exs --build --files echo "Not Implemented" status=1 elif [ "$mode" = "sync" ]; then if [ "$target" = "diff" ]; then build_commited status=$? elif [ "$target" = "staged" ]; then build_staged status=$? fi else echo "Usage : $0 [sync|async] [diff|staged]" status=1 fi exit $status } main $@