diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-09-23 05:06:14 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-23 05:06:14 +0100 |
| commit | 1a9ba67412125870784cfbab7ca944c8d3265311 (patch) | |
| tree | d631ba5140777cb4e8a6c4e7cb2d85a077412668 | |
| parent | 8d56067468806d501778539d94136e1ed88d33d8 (diff) | |
| parent | 9fd19396bf90b0e79dbf22cfca1428dc479b6a3c (diff) | |
| download | perlweeklychallenge-club-1a9ba67412125870784cfbab7ca944c8d3265311.tar.gz perlweeklychallenge-club-1a9ba67412125870784cfbab7ca944c8d3265311.tar.bz2 perlweeklychallenge-club-1a9ba67412125870784cfbab7ca944c8d3265311.zip | |
Merge pull request #2355 from tylerw/tw/challenge-079
Challenge 079
11 files changed, 151 insertions, 14 deletions
diff --git a/challenge-079/tyler-wardhaugh/clojure/README.md b/challenge-079/tyler-wardhaugh/clojure/README.md index bf7c680763..37d274beb5 100644 --- a/challenge-079/tyler-wardhaugh/clojure/README.md +++ b/challenge-079/tyler-wardhaugh/clojure/README.md @@ -1,13 +1,13 @@ -# tw.weekly.c78 +# tw.weekly.c79 -The Weekly Challenge - #078 - Tyler Wardhaugh +The Weekly Challenge - #079 - Tyler Wardhaugh ## Usage Run the project directly (shows default output from both tasks): - $ clojure -m tw.weekly.c78.core + $ clojure -m tw.weekly.c79.core Run the project's tests (which are samples from the task descriptions): @@ -15,11 +15,22 @@ Run the project's tests (which are samples from the task descriptions): Run Task #1 with input - $ clojure -m tw.weekly.c78.t1 9 10 7 5 6 1 + $ clojure -m tw.weekly.c79.t1 N Run Task #2 with input: - $ clojure -m tw.weekly.c78.t2 "(10 20 30 40 50)" "(3 4)" + $ clojure -m tw.weekly.c79.t2 A1 A2 A3 [...] + +See SVG files in the `resources` directory for the histograms drawn for each of the tests for Task 2: + + + + + + + + + ## Project Template diff --git a/challenge-079/tyler-wardhaugh/clojure/deps.edn b/challenge-079/tyler-wardhaugh/clojure/deps.edn index ea2660b255..988d683304 100644 --- a/challenge-079/tyler-wardhaugh/clojure/deps.edn +++ b/challenge-079/tyler-wardhaugh/clojure/deps.edn @@ -1,5 +1,6 @@ {:paths ["src" "resources"] - :deps {org.clojure/clojure {:mvn/version "1.10.1"}} + :deps {org.clojure/clojure {:mvn/version "1.10.1"} + metasoarous/oz {:mvn/version "1.6.0-alpha26"}} :aliases {:test {:extra-paths ["test"] :extra-deps {org.clojure/test.check {:mvn/version "1.0.0"}}} @@ -10,5 +11,5 @@ :main-opts ["-m" "cognitect.test-runner" "-d" "test"]} :uberjar {:extra-deps {seancorfield/depstar {:mvn/version "1.0.94"}} - :main-opts ["-m" "hf.depstar.uberjar" "tw.weekly.c78.jar" - "-C" "-m" "tw.weekly.c78"]}}} + :main-opts ["-m" "hf.depstar.uberjar" "tw.weekly.c79.jar" + "-C" "-m" "tw.weekly.c79"]}}} diff --git a/challenge-079/tyler-wardhaugh/clojure/pom.xml b/challenge-079/tyler-wardhaugh/clojure/pom.xml index 05a218d4c8..a5ef0fbd29 100644 --- a/challenge-079/tyler-wardhaugh/clojure/pom.xml +++ b/challenge-079/tyler-wardhaugh/clojure/pom.xml @@ -2,11 +2,11 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>tw.weekly</groupId> - <artifactId>tw.weekly.c78</artifactId> + <artifactId>tw.weekly.c79</artifactId> <version>0.1.0-SNAPSHOT</version> - <name>tw.weekly.c78</name> + <name>tw.weekly.c79</name> <description>FIXME: my new application.</description> - <url>https://github.com/tw.weekly/tw.weekly.c78</url> + <url>https://github.com/tw.weekly/tw.weekly.c79</url> <licenses> <license> <name>Eclipse Public License</name> @@ -19,9 +19,9 @@ </developer> </developers> <scm> - <url>https://github.com/tw.weekly/tw.weekly.c78</url> - <connection>scm:git:git://github.com/tw.weekly/tw.weekly.c78.git</connection> - <developerConnection>scm:git:ssh://git@github.com/tw.weekly/tw.weekly.c78.git</developerConnection> + <url>https://github.com/tw.weekly/tw.weekly.c79</url> + <connection>scm:git:git://github.com/tw.weekly/tw.weekly.c79.git</connection> + <developerConnection>scm:git:ssh://git@github.com/tw.weekly/tw.weekly.c79.git</developerConnection> <tag>HEAD</tag> </scm> <dependencies> @@ -30,6 +30,11 @@ <artifactId>clojure</artifactId> <version>1.10.1</version> </dependency> + <dependency> + <groupId>metasoarous</groupId> + <artifactId>oz</artifactId> + <version>1.6.0-alpha26</version> + </dependency> </dependencies> <build> <sourceDirectory>src</sourceDirectory> diff --git a/challenge-079/tyler-wardhaugh/clojure/resources/t2.test1.svg b/challenge-079/tyler-wardhaugh/clojure/resources/t2.test1.svg new file mode 100644 index 0000000000..c3f51d8d13 --- /dev/null +++ b/challenge-079/tyler-wardhaugh/clojure/resources/t2.test1.svg @@ -0,0 +1 @@ +<svg class="marks" width="158" height="243" viewBox="0 0 158 243" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><rect width="158" height="243" fill="white"></rect><g fill="none" stroke-miterlimit="10" transform="translate(33,10)"><g class="mark-group role-frame root" role="graphics-object" aria-roledescription="group mark container"><g transform="translate(0,0)"><path class="background" aria-hidden="true" d="M0.5,0.5h120v200h-120Z" stroke="#ddd"></path><g><g class="mark-group role-axis" aria-hidden="true"><g transform="translate(0.5,0.5)"><path class="background" aria-hidden="true" d="M0,0h0v0h0Z" pointer-events="none"></path><g><g class="mark-rule role-axis-grid" pointer-events="none"><line transform="translate(0,200)" x2="120" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,160)" x2="120" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,120)" x2="120" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,80)" x2="120" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,40)" x2="120" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,0)" x2="120" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line></g></g><path class="foreground" aria-hidden="true" d="" pointer-events="none" display="none"></path></g></g><g class="mark-group role-axis" role="graphics-symbol" aria-roledescription="axis" aria-label="X-axis titled 'x' for a discrete scale with 6 values: 0, 1, 2, 3, 4, 5"><g transform="translate(0.5,200.5)"><path class="background" aria-hidden="true" d="M0,0h0v0h0Z" pointer-events="none"></path><g><g class="mark-rule role-axis-tick" pointer-events="none"><line transform="translate(10,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(30,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(50,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(70,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(90,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(110,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-label" pointer-events="none"><text text-anchor="end" transform="translate(9.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">0</text><text text-anchor="end" transform="translate(29.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">1</text><text text-anchor="end" transform="translate(49.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">2</text><text text-anchor="end" transform="translate(69.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">3</text><text text-anchor="end" transform="translate(89.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">4</text><text text-anchor="end" transform="translate(109.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">5</text></g><g class="mark-rule role-axis-domain" pointer-events="none"><line transform="translate(0,0)" x2="120" y2="0" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-title" pointer-events="none"><text text-anchor="middle" transform="translate(60,25.5615234375)" font-family="sans-serif" font-size="11px" font-weight="bold" fill="#000" opacity="1">x</text></g></g><path class="foreground" aria-hidden="true" d="" pointer-events="none" display="none"></path></g></g><g class="mark-group role-axis" role="graphics-symbol" aria-roledescription="axis" aria-label="Y-axis titled 'Sum of y' for a linear scale with values from 0 to 5"><g transform="translate(0.5,0.5)"><path class="background" aria-hidden="true" d="M0,0h0v0h0Z" pointer-events="none"></path><g><g class="mark-rule role-axis-tick" pointer-events="none"><line transform="translate(0,200)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,160)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,120)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,80)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,40)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,0)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-label" pointer-events="none"><text text-anchor="end" transform="translate(-7,203)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">0</text><text text-anchor="end" transform="translate(-7,163)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">1</text><text text-anchor="end" transform="translate(-7,123)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">2</text><text text-anchor="end" transform="translate(-7,83)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">3</text><text text-anchor="end" transform="translate(-7,42.99999999999999)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">4</text><text text-anchor="end" transform="translate(-7,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">5</text></g><g class="mark-rule role-axis-domain" pointer-events="none"><line transform="translate(0,200)" x2="0" y2="-200" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-title" pointer-events="none"><text text-anchor="middle" transform="translate(-16.5615234375,100) rotate(-90) translate(0,-2)" font-family="sans-serif" font-size="11px" font-weight="bold" fill="#000" opacity="1">Sum of y</text></g></g><path class="foreground" aria-hidden="true" d="" pointer-events="none" display="none"></path></g></g><g class="mark-rect role-mark marks" role="graphics-object" aria-roledescription="rect mark container"><path aria-label="x: 0; Sum of y: 2; c: green" role="graphics-symbol" aria-roledescription="bar" d="M1,120h18v80h-18Z" fill="green"></path><path aria-label="x: 0; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M1,120h18v0h-18Z" fill="blue"></path><path aria-label="x: 1; Sum of y: 1; c: green" role="graphics-symbol" aria-roledescription="bar" d="M21,160h18v40h-18Z" fill="green"></path><path aria-label="x: 1; Sum of y: 1; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M21,120h18v40h-18Z" fill="blue"></path><path aria-label="x: 2; Sum of y: 4; c: green" role="graphics-symbol" aria-roledescription="bar" d="M41,39.99999999999999h18v160h-18Z" fill="green"></path><path aria-label="x: 2; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M41,39.99999999999999h18v0h-18Z" fill="blue"></path><path aria-label="x: 3; Sum of y: 1; c: green" role="graphics-symbol" aria-roledescription="bar" d="M61,160h18v40h-18Z" fill="green"></path><path aria-label="x: 3; Sum of y: 3; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M61,39.99999999999999h18v120h-18Z" fill="blue"></path><path aria-label="x: 4; Sum of y: 2; c: green" role="graphics-symbol" aria-roledescription="bar" d="M81,120h18v80h-18Z" fill="green"></path><path aria-label="x: 4; Sum of y: 2; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M81,39.99999999999999h18v80h-18Z" fill="blue"></path><path aria-label="x: 5; Sum of y: 5; c: green" role="graphics-symbol" aria-roledescription="bar" d="M101,0h18v200h-18Z" fill="green"></path><path aria-label="x: 5; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M101,0h18v0h-18Z" fill="blue"></path></g></g><path class="foreground" aria-hidden="true" d="" display="none"></path></g></g></g></svg>
\ No newline at end of file diff --git a/challenge-079/tyler-wardhaugh/clojure/resources/t2.test2.svg b/challenge-079/tyler-wardhaugh/clojure/resources/t2.test2.svg new file mode 100644 index 0000000000..1d37ffddb2 --- /dev/null +++ b/challenge-079/tyler-wardhaugh/clojure/resources/t2.test2.svg @@ -0,0 +1 @@ +<svg class="marks" width="158" height="243" viewBox="0 0 158 243" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><rect width="158" height="243" fill="white"></rect><g fill="none" stroke-miterlimit="10" transform="translate(33,10)"><g class="mark-group role-frame root" role="graphics-object" aria-roledescription="group mark container"><g transform="translate(0,0)"><path class="background" aria-hidden="true" d="M0.5,0.5h120v200h-120Z" stroke="#ddd"></path><g><g class="mark-group role-axis" aria-hidden="true"><g transform="translate(0.5,0.5)"><path class="background" aria-hidden="true" d="M0,0h0v0h0Z" pointer-events="none"></path><g><g class="mark-rule role-axis-grid" pointer-events="none"><line transform="translate(0,200)" x2="120" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,160)" x2="120" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,120)" x2="120" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,80)" x2="120" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,40)" x2="120" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,0)" x2="120" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line></g></g><path class="foreground" aria-hidden="true" d="" pointer-events="none" display="none"></path></g></g><g class="mark-group role-axis" role="graphics-symbol" aria-roledescription="axis" aria-label="X-axis titled 'x' for a discrete scale with 6 values: 0, 1, 2, 3, 4, 5"><g transform="translate(0.5,200.5)"><path class="background" aria-hidden="true" d="M0,0h0v0h0Z" pointer-events="none"></path><g><g class="mark-rule role-axis-tick" pointer-events="none"><line transform="translate(10,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(30,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(50,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(70,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(90,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(110,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-label" pointer-events="none"><text text-anchor="end" transform="translate(9.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">0</text><text text-anchor="end" transform="translate(29.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">1</text><text text-anchor="end" transform="translate(49.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">2</text><text text-anchor="end" transform="translate(69.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">3</text><text text-anchor="end" transform="translate(89.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">4</text><text text-anchor="end" transform="translate(109.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">5</text></g><g class="mark-rule role-axis-domain" pointer-events="none"><line transform="translate(0,0)" x2="120" y2="0" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-title" pointer-events="none"><text text-anchor="middle" transform="translate(60,25.5615234375)" font-family="sans-serif" font-size="11px" font-weight="bold" fill="#000" opacity="1">x</text></g></g><path class="foreground" aria-hidden="true" d="" pointer-events="none" display="none"></path></g></g><g class="mark-group role-axis" role="graphics-symbol" aria-roledescription="axis" aria-label="Y-axis titled 'Sum of y' for a linear scale with values from 0 to 5"><g transform="translate(0.5,0.5)"><path class="background" aria-hidden="true" d="M0,0h0v0h0Z" pointer-events="none"></path><g><g class="mark-rule role-axis-tick" pointer-events="none"><line transform="translate(0,200)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,160)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,120)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,80)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,40)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,0)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-label" pointer-events="none"><text text-anchor="end" transform="translate(-7,203)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">0</text><text text-anchor="end" transform="translate(-7,163)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">1</text><text text-anchor="end" transform="translate(-7,123)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">2</text><text text-anchor="end" transform="translate(-7,83)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">3</text><text text-anchor="end" transform="translate(-7,42.99999999999999)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">4</text><text text-anchor="end" transform="translate(-7,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">5</text></g><g class="mark-rule role-axis-domain" pointer-events="none"><line transform="translate(0,200)" x2="0" y2="-200" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-title" pointer-events="none"><text text-anchor="middle" transform="translate(-16.5615234375,100) rotate(-90) translate(0,-2)" font-family="sans-serif" font-size="11px" font-weight="bold" fill="#000" opacity="1">Sum of y</text></g></g><path class="foreground" aria-hidden="true" d="" pointer-events="none" display="none"></path></g></g><g class="mark-rect role-mark marks" role="graphics-object" aria-roledescription="rect mark container"><path aria-label="x: 0; Sum of y: 3; c: green" role="graphics-symbol" aria-roledescription="bar" d="M1,80h18v120h-18Z" fill="green"></path><path aria-label="x: 0; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M1,80h18v0h-18Z" fill="blue"></path><path aria-label="x: 1; Sum of y: 1; c: green" role="graphics-symbol" aria-roledescription="bar" d="M21,160h18v40h-18Z" fill="green"></path><path aria-label="x: 1; Sum of y: 2; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M21,80h18v80h-18Z" fill="blue"></path><path aria-label="x: 2; Sum of y: 3; c: green" role="graphics-symbol" aria-roledescription="bar" d="M41,80h18v120h-18Z" fill="green"></path><path aria-label="x: 2; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M41,80h18v0h-18Z" fill="blue"></path><path aria-label="x: 3; Sum of y: 1; c: green" role="graphics-symbol" aria-roledescription="bar" d="M61,160h18v40h-18Z" fill="green"></path><path aria-label="x: 3; Sum of y: 2; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M61,80h18v80h-18Z" fill="blue"></path><path aria-label="x: 4; Sum of y: 1; c: green" role="graphics-symbol" aria-roledescription="bar" d="M81,160h18v40h-18Z" fill="green"></path><path aria-label="x: 4; Sum of y: 2; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M81,80h18v80h-18Z" fill="blue"></path><path aria-label="x: 5; Sum of y: 5; c: green" role="graphics-symbol" aria-roledescription="bar" d="M101,0h18v200h-18Z" fill="green"></path><path aria-label="x: 5; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M101,0h18v0h-18Z" fill="blue"></path></g></g><path class="foreground" aria-hidden="true" d="" display="none"></path></g></g></g></svg>
\ No newline at end of file diff --git a/challenge-079/tyler-wardhaugh/clojure/resources/t2.test3.svg b/challenge-079/tyler-wardhaugh/clojure/resources/t2.test3.svg new file mode 100644 index 0000000000..0eab4070e1 --- /dev/null +++ b/challenge-079/tyler-wardhaugh/clojure/resources/t2.test3.svg @@ -0,0 +1 @@ +<svg class="marks" width="178" height="243" viewBox="0 0 178 243" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><rect width="178" height="243" fill="white"></rect><g fill="none" stroke-miterlimit="10" transform="translate(33,10)"><g class="mark-group role-frame root" role="graphics-object" aria-roledescription="group mark container"><g transform="translate(0,0)"><path class="background" aria-hidden="true" d="M0.5,0.5h140v200h-140Z" stroke="#ddd"></path><g><g class="mark-group role-axis" aria-hidden="true"><g transform="translate(0.5,0.5)"><path class="background" aria-hidden="true" d="M0,0h0v0h0Z" pointer-events="none"></path><g><g class="mark-rule role-axis-grid" pointer-events="none"><line transform="translate(0,200)" x2="140" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,150)" x2="140" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,100)" x2="140" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,50)" x2="140" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,0)" x2="140" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line></g></g><path class="foreground" aria-hidden="true" d="" pointer-events="none" display="none"></path></g></g><g class="mark-group role-axis" role="graphics-symbol" aria-roledescription="axis" aria-label="X-axis titled 'x' for a discrete scale with 7 values: 0, 1, 2, 3, 4, 5, 6"><g transform="translate(0.5,200.5)"><path class="background" aria-hidden="true" d="M0,0h0v0h0Z" pointer-events="none"></path><g><g class="mark-rule role-axis-tick" pointer-events="none"><line transform="translate(10,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(30,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(50,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(70,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(90,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(110,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(130,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-label" pointer-events="none"><text text-anchor="end" transform="translate(9.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">0</text><text text-anchor="end" transform="translate(29.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">1</text><text text-anchor="end" transform="translate(49.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">2</text><text text-anchor="end" transform="translate(69.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">3</text><text text-anchor="end" transform="translate(89.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">4</text><text text-anchor="end" transform="translate(109.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">5</text><text text-anchor="end" transform="translate(129.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">6</text></g><g class="mark-rule role-axis-domain" pointer-events="none"><line transform="translate(0,0)" x2="140" y2="0" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-title" pointer-events="none"><text text-anchor="middle" transform="translate(70,25.5615234375)" font-family="sans-serif" font-size="11px" font-weight="bold" fill="#000" opacity="1">x</text></g></g><path class="foreground" aria-hidden="true" d="" pointer-events="none" display="none"></path></g></g><g class="mark-group role-axis" role="graphics-symbol" aria-roledescription="axis" aria-label="Y-axis titled 'Sum of y' for a linear scale with values from 0 to 4"><g transform="translate(0.5,0.5)"><path class="background" aria-hidden="true" d="M0,0h0v0h0Z" pointer-events="none"></path><g><g class="mark-rule role-axis-tick" pointer-events="none"><line transform="translate(0,200)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,150)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,100)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,50)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,0)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-label" pointer-events="none"><text text-anchor="end" transform="translate(-7,203)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">0</text><text text-anchor="end" transform="translate(-7,153)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">1</text><text text-anchor="end" transform="translate(-7,103)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">2</text><text text-anchor="end" transform="translate(-7,53)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">3</text><text text-anchor="end" transform="translate(-7,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">4</text></g><g class="mark-rule role-axis-domain" pointer-events="none"><line transform="translate(0,200)" x2="0" y2="-200" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-title" pointer-events="none"><text text-anchor="middle" transform="translate(-16.5615234375,100) rotate(-90) translate(0,-2)" font-family="sans-serif" font-size="11px" font-weight="bold" fill="#000" opacity="1">Sum of y</text></g></g><path class="foreground" aria-hidden="true" d="" pointer-events="none" display="none"></path></g></g><g class="mark-rect role-mark marks" role="graphics-object" aria-roledescription="rect mark container"><path aria-label="x: 0; Sum of y: 1; c: green" role="graphics-symbol" aria-roledescription="bar" d="M1,150h18v50h-18Z" fill="green"></path><path aria-label="x: 0; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M1,150h18v0h-18Z" fill="blue"></path><path aria-label="x: 1; Sum of y: 2; c: green" role="graphics-symbol" aria-roledescription="bar" d="M21,100h18v100h-18Z" fill="green"></path><path aria-label="x: 1; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M21,100h18v0h-18Z" fill="blue"></path><path aria-label="x: 2; Sum of y: 3; c: green" role="graphics-symbol" aria-roledescription="bar" d="M41,50h18v150h-18Z" fill="green"></path><path aria-label="x: 2; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M41,50h18v0h-18Z" fill="blue"></path><path aria-label="x: 3; Sum of y: 4; c: green" role="graphics-symbol" aria-roledescription="bar" d="M61,0h18v200h-18Z" fill="green"></path><path aria-label="x: 3; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M61,0h18v0h-18Z" fill="blue"></path><path aria-label="x: 4; Sum of y: 3; c: green" role="graphics-symbol" aria-roledescription="bar" d="M81,50h18v150h-18Z" fill="green"></path><path aria-label="x: 4; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M81,50h18v0h-18Z" fill="blue"></path><path aria-label="x: 5; Sum of y: 2; c: green" role="graphics-symbol" aria-roledescription="bar" d="M101,100h18v100h-18Z" fill="green"></path><path aria-label="x: 5; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M101,100h18v0h-18Z" fill="blue"></path><path aria-label="x: 6; Sum of y: 1; c: green" role="graphics-symbol" aria-roledescription="bar" d="M121,150h18v50h-18Z" fill="green"></path><path aria-label="x: 6; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M121,150h18v0h-18Z" fill="blue"></path></g></g><path class="foreground" aria-hidden="true" d="" display="none"></path></g></g></g></svg>
\ No newline at end of file diff --git a/challenge-079/tyler-wardhaugh/clojure/resources/t2.test4.svg b/challenge-079/tyler-wardhaugh/clojure/resources/t2.test4.svg new file mode 100644 index 0000000000..64d9cdd5e6 --- /dev/null +++ b/challenge-079/tyler-wardhaugh/clojure/resources/t2.test4.svg @@ -0,0 +1 @@ +<svg class="marks" width="224" height="243" viewBox="0 0 224 243" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><rect width="224" height="243" fill="white"></rect><g fill="none" stroke-miterlimit="10" transform="translate(39,10)"><g class="mark-group role-frame root" role="graphics-object" aria-roledescription="group mark container"><g transform="translate(0,0)"><path class="background" aria-hidden="true" d="M0.5,0.5h180v200h-180Z" stroke="#ddd"></path><g><g class="mark-group role-axis" aria-hidden="true"><g transform="translate(0.5,0.5)"><path class="background" aria-hidden="true" d="M0,0h0v0h0Z" pointer-events="none"></path><g><g class="mark-rule role-axis-grid" pointer-events="none"><line transform="translate(0,200)" x2="180" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,160)" x2="180" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,120)" x2="180" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,80)" x2="180" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,40)" x2="180" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line><line transform="translate(0,0)" x2="180" y2="0" stroke="#ddd" stroke-width="1" opacity="1"></line></g></g><path class="foreground" aria-hidden="true" d="" pointer-events="none" display="none"></path></g></g><g class="mark-group role-axis" role="graphics-symbol" aria-roledescription="axis" aria-label="X-axis titled 'x' for a discrete scale with 9 values: 0, 1, 2, 3, 4, ending with 8"><g transform="translate(0.5,200.5)"><path class="background" aria-hidden="true" d="M0,0h0v0h0Z" pointer-events="none"></path><g><g class="mark-rule role-axis-tick" pointer-events="none"><line transform="translate(10,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(30,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(50,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(70,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(90,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(110,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(130,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(150,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(170,0)" x2="0" y2="5" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-label" pointer-events="none"><text text-anchor="end" transform="translate(9.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">0</text><text text-anchor="end" transform="translate(29.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">1</text><text text-anchor="end" transform="translate(49.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">2</text><text text-anchor="end" transform="translate(69.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">3</text><text text-anchor="end" transform="translate(89.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">4</text><text text-anchor="end" transform="translate(109.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">5</text><text text-anchor="end" transform="translate(129.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">6</text><text text-anchor="end" transform="translate(149.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">7</text><text text-anchor="end" transform="translate(169.5,7) rotate(270) translate(0,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">8</text></g><g class="mark-rule role-axis-domain" pointer-events="none"><line transform="translate(0,0)" x2="180" y2="0" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-title" pointer-events="none"><text text-anchor="middle" transform="translate(90,25.5615234375)" font-family="sans-serif" font-size="11px" font-weight="bold" fill="#000" opacity="1">x</text></g></g><path class="foreground" aria-hidden="true" d="" pointer-events="none" display="none"></path></g></g><g class="mark-group role-axis" role="graphics-symbol" aria-roledescription="axis" aria-label="Y-axis titled 'Sum of y' for a linear scale with values from 0 to 10"><g transform="translate(0.5,0.5)"><path class="background" aria-hidden="true" d="M0,0h0v0h0Z" pointer-events="none"></path><g><g class="mark-rule role-axis-tick" pointer-events="none"><line transform="translate(0,200)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,160)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,120)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,80)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,40)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line><line transform="translate(0,0)" x2="-5" y2="0" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-label" pointer-events="none"><text text-anchor="end" transform="translate(-7,203)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">0</text><text text-anchor="end" transform="translate(-7,163)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">2</text><text text-anchor="end" transform="translate(-7,123)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">4</text><text text-anchor="end" transform="translate(-7,83)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">6</text><text text-anchor="end" transform="translate(-7,42.99999999999999)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">8</text><text text-anchor="end" transform="translate(-7,3)" font-family="sans-serif" font-size="10px" fill="#000" opacity="1">10</text></g><g class="mark-rule role-axis-domain" pointer-events="none"><line transform="translate(0,200)" x2="0" y2="-200" stroke="#888" stroke-width="1" opacity="1"></line></g><g class="mark-text role-axis-title" pointer-events="none"><text text-anchor="middle" transform="translate(-22.123046875,100) rotate(-90) translate(0,-2)" font-family="sans-serif" font-size="11px" font-weight="bold" fill="#000" opacity="1">Sum of y</text></g></g><path class="foreground" aria-hidden="true" d="" pointer-events="none" display="none"></path></g></g><g class="mark-rect role-mark marks" role="graphics-object" aria-roledescription="rect mark container"><path aria-label="x: 0; Sum of y: 4; c: green" role="graphics-symbol" aria-roledescription="bar" d="M1,120h18v80h-18Z" fill="green"></path><path aria-label="x: 0; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M1,120h18v0h-18Z" fill="blue"></path><path aria-label="x: 1; Sum of y: 1; c: green" role="graphics-symbol" aria-roledescription="bar" d="M21,180h18v20h-18Z" fill="green"></path><path aria-label="x: 1; Sum of y: 3; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M21,120h18v60h-18Z" fill="blue"></path><path aria-label="x: 2; Sum of y: 3; c: green" role="graphics-symbol" aria-roledescription="bar" d="M41,140h18v60h-18Z" fill="green"></path><path aria-label="x: 2; Sum of y: 1; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M41,120h18v20h-18Z" fill="blue"></path><path aria-label="x: 3; Sum of y: 1; c: green" role="graphics-symbol" aria-roledescription="bar" d="M61,180h18v20h-18Z" fill="green"></path><path aria-label="x: 3; Sum of y: 3; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M61,120h18v60h-18Z" fill="blue"></path><path aria-label="x: 4; Sum of y: 2; c: green" role="graphics-symbol" aria-roledescription="bar" d="M81,160h18v40h-18Z" fill="green"></path><path aria-label="x: 4; Sum of y: 2; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M81,120h18v40h-18Z" fill="blue"></path><path aria-label="x: 5; Sum of y: 5; c: green" role="graphics-symbol" aria-roledescription="bar" d="M101,100h18v100h-18Z" fill="green"></path><path aria-label="x: 5; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M101,100h18v0h-18Z" fill="blue"></path><path aria-label="x: 6; Sum of y: 10; c: green" role="graphics-symbol" aria-roledescription="bar" d="M121,0h18v200h-18Z" fill="green"></path><path aria-label="x: 6; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M121,0h18v0h-18Z" fill="blue"></path><path aria-label="x: 7; Sum of y: 5; c: green" role="graphics-symbol" aria-roledescription="bar" d="M141,100h18v100h-18Z" fill="green"></path><path aria-label="x: 7; Sum of y: 2; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M141,60.00000000000001h18v39.99999999999999h-18Z" fill="blue"></path><path aria-label="x: 8; Sum of y: 7; c: green" role="graphics-symbol" aria-roledescription="bar" d="M161,60.00000000000001h18v140h-18Z" fill="green"></path><path aria-label="x: 8; Sum of y: 0; c: blue" role="graphics-symbol" aria-roledescription="bar" d="M161,60.00000000000001h18v0h-18Z" fill="blue"></path></g></g><path class="foreground" aria-hidden="true" d="" display="none"></path></g></g></g></svg>
\ No newline at end of file diff --git a/challenge-079/tyler-wardhaugh/clojure/src/tw/weekly/c79/core.clj b/challenge-079/tyler-wardhaugh/clojure/src/tw/weekly/c79/core.clj new file mode 100644 index 0000000000..0327a880fc --- /dev/null +++ b/challenge-079/tyler-wardhaugh/clojure/src/tw/weekly/c79/core.clj @@ -0,0 +1,12 @@ +(ns tw.weekly.c79.core + (:require [tw.weekly.c79.t1 :as t1]) + (:require [tw.weekly.c79.t2 :as t2]) + (:gen-class)) + +(defn -main + "Run all tasks" + [& _] + (println "Task #1") + (t1/-main) + (println "\n\nTask #2") + (t2/-main)) diff --git a/challenge-079/tyler-wardhaugh/clojure/src/tw/weekly/c79/t1.clj b/challenge-079/tyler-wardhaugh/clojure/src/tw/weekly/c79/t1.clj new file mode 100644 index 0000000000..47140780d4 --- /dev/null +++ b/challenge-079/tyler-wardhaugh/clojure/src/tw/weekly/c79/t1.clj @@ -0,0 +1,29 @@ +(ns tw.weekly.c79.t1 + (:require [clojure.edn :as edn])) + +;;; Task description for TASK #1 › Count Set Bits +;You are given a positive number $N. +; +;Write a script to count the total numbrer of set bits of the binary representations of all numbers from 1 to $N and return $total_count_set_bit % 1000000007. +;;;; + +(defn count-bits-to-n + "Count the '1' bits in the binary representation of all the integers [1..n]" + [n] + (let [xf (map #(Integer/bitCount %)) + source (range 1 (inc n))] + (transduce xf + source))) + +(def big-num "The large number given in the task description to modulo against" + 1000000007N) + +(defn run + "Count the 1s and modulo" + [n] + (mod (count-bits-to-n n) big-num)) + +(defn -main + "Run Task 1 with a number N, defaulting to the first one given in the examples" + [& args] + (let [N (or (-> args first edn/read-string) 4)] + (format "%d" (biginteger (run N))))) diff --git a/challenge-079/tyler-wardhaugh/clojure/src/tw/weekly/c79/t2.clj b/challenge-079/tyler-wardhaugh/clojure/src/tw/weekly/c79/t2.clj new file mode 100644 index 0000000000..45513901c1 --- /dev/null +++ b/challenge-079/tyler-wardhaugh/clojure/src/tw/weekly/c79/t2.clj @@ -0,0 +1,59 @@ +(ns tw.weekly.c79.t2 + (:require [clojure.edn :as edn]) + (:require [oz.core :as oz])) + +;;; Task description for TASK #2 › Trapped Rain Water +; You are given an array of positive numbers @N. +; +; Write a script to represent it as Histogram Chart and find out how much water it can trap. +; +; Example 1: +; Input: @N = (2, 1, 4, 1, 2, 5) +; The histogram representation of the given array is as below. +; 5 # +; 4 # # +; 3 # # +; 2 # # # # +; 1 # # # # # # +; _ _ _ _ _ _ _ +; 2 1 4 1 2 5 +;;; + +(defn splits + "Partition the input by splitting it at each index, ensuring partitions contain at least one element." + [coll] + (map #(split-at % coll) (range 1 (dec (count coll))))) + +(defn calculate-pools + "Returns a sequence of pools, which are the amount of water 'units' that can be held at the inner elements of the coll, when viewed as a h |
