From b1718caa66010810aa5901465c5d3befc5528d2c Mon Sep 17 00:00:00 2001 From: Denis Fuenzalida Date: Sun, 21 Jul 2019 18:37:39 -0700 Subject: [PATCH] First import --- .gitignore | 5 +++ README.md | 50 ++++++++++++++++++++++++ deps.edn | 33 ++++++++++++++++ script/new | 3 ++ script/rescore | 20 ++++++++++ script/test | 44 ++++++++++++++++++++++ script/test-one | 52 +++++++++++++++++++++++++ test/euler/new.clj | 94 ++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 301 insertions(+) create mode 100755 .gitignore create mode 100755 README.md create mode 100755 deps.edn create mode 100755 script/new create mode 100755 script/rescore create mode 100755 script/test create mode 100755 script/test-one create mode 100755 test/euler/new.clj diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..4d72b2a --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/.cpcache +/out +/.nrepl-port +/cljs-test-runner-out +*~ diff --git a/README.md b/README.md new file mode 100755 index 0000000..1a3da0b --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# Euler CLJC + +Cross platform Project Euler solutions. + +This project is based on from the [Advent of CLJC](https://github.com/borkdude/advent-of-cljc) project. + +## Contribute + +PRs welcome. Make a new solution file with the `new` script: + + script/new 012 username + +where `username` is your Github or Bitbucket username. Then fill in the solution in the file. If the input and answers are still empty you will have to provide it in `data.cljc`. + +This repo does not accept multiple inputs and answers. + +## Dev + +Read [here](https://nrepl.xyz/nrepl/usage/server.html) how to get an nREPL for this project. + +## Tests + +Make sure the tests for your solution pass with the `test-one` script. + +Please do not run calculations outside the tests. Memoized functions are permitted. Top-level lazy sequences are fine as long as they are not realized outside the tests. + +Tests support the following metadata: + + - `:skip-cljs`: used for skipping Node tests. Used in `.circle/test-diff`, + `script/test` and `script/test-one`. + - `:slow`: used for skipping long running tests. Only used in `script/test`. + +Run all tests: + + script/test + +Run one test: + + script/test-one 012 username + +Run with instrumentation: + + INSTRUMENT=true script/test + INSTRUMENT=true script/test-one euler.012.username + +Skip Clojure or ClojureScript: + + SKIP_CLJ=true script/test + SKIP_CLJS=true script/test + diff --git a/deps.edn b/deps.edn new file mode 100755 index 0000000..47ec40a --- /dev/null +++ b/deps.edn @@ -0,0 +1,33 @@ +{:deps {net.cgrand/xforms {:mvn/version "0.18.2"} + com.rpl/specter {:mvn/version "1.1.2"} + binaryage/oops {:mvn/version "0.6.4"}} + :aliases + {:test {:extra-paths ["test"] + :extra-deps {org.clojure/clojure {:mvn/version "1.10.0-RC5"} + ;; org.clojure/clojurescript {:mvn/version "1.10.439"} + org.clojure/clojurescript {:git/url "https://github.com/clojure/clojurescript" + :sha "d6f8896452b531a273f99f2716aaa08f09600063"} + org.clojure/test.check {:mvn/version "RELEASE"} + ;;org.clojure/spec.alpha {:local/root "/Users/Borkdude/git/spec.alpha"} + chivorcam {:mvn/version "1.0.0"} + speculative {:mvn/version "0.0.3-SNAPSHOT"} + ;; workarounds-1.10.439 {:git/url "https://github.com/mfikes/workarounds-1.10.439" + ;; :sha "a559201602fc6a21701479b83086d76bd5ed09eb"} + }} + :test-clj + {:extra-paths ["test"] + :extra-deps {com.cognitect/test-runner + {:git/url "https://github.com/cognitect-labs/test-runner.git" + :sha "028a6d41ac9ac5d5c405dfc38e4da6b4cc1255d5"}} + :jvm-opts ["-Xss2m"] + :main-opts ["-m" "cognitect.test-runner"]} + :test-cljs + {:extra-paths ["test" "cljs-test-runner-out/gen"] + :extra-deps {olical/cljs-test-runner {;;:mvn/version "3.2.1" + :git/url "https://github.com/borkdude/cljs-test-runner" + :sha "c04e52ba1f9b2c646710b532a0c3ca5cab429491"}} + :main-opts ["-m" "cljs-test-runner.main"]} + :new + {:extra-paths ["test"] + :extra-deps {org.clojure/tools.cli {:mvn/version "0.4.1"}} + :main-opts ["-m" "aoc.new"]}}} diff --git a/script/new b/script/new new file mode 100755 index 0000000..beab5ff --- /dev/null +++ b/script/new @@ -0,0 +1,3 @@ +#!/bin/sh + +clj -A:new $@ diff --git a/script/rescore b/script/rescore new file mode 100755 index 0000000..f6483b9 --- /dev/null +++ b/script/rescore @@ -0,0 +1,20 @@ +#!/bin/bash + +set -eu + +if [ ! $YEAR ]; then + YEAR=2018 +fi + +branch="rescore-$YEAR-$1" +git checkout -b "$branch" +cd "src/aoc/y$YEAR/$1" + +for i in $(ls *.cljc); do + echo -e ";; trigger scoring, this comment may be removed next time\n" >> $i +done +git commit -am "$branch" +git push origin "$branch" + +git checkout master +git branch -D "$branch" diff --git a/script/test b/script/test new file mode 100755 index 0000000..ab7ace3 --- /dev/null +++ b/script/test @@ -0,0 +1,44 @@ +#!/bin/bash + +exit_code=0 + +if [ ! $INSTRUMENT ]; then + regex="euler\.p.*(?