Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

difference-of-squares: Sync tests #696

Merged
merged 5 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion exercises/practice/difference-of-squares/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"mathias",
"rubysolo",
"Scientifica96",
"yurrriq"
"yurrriq",
"tasxatzial"
],
"files": {
"solution": [
Expand Down
31 changes: 19 additions & 12 deletions exercises/practice/difference-of-squares/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[e46c542b-31fc-4506-bcae-6b62b3268537]
description = "square of sum 1"
description = "Square the sum of the numbers up to the given number -> square of sum 1"

[9b3f96cb-638d-41ee-99b7-b4f9c0622948]
description = "square of sum 5"
description = "Square the sum of the numbers up to the given number -> square of sum 5"

[54ba043f-3c35-4d43-86ff-3a41625d5e86]
description = "square of sum 100"
description = "Square the sum of the numbers up to the given number -> square of sum 100"

[01d84507-b03e-4238-9395-dd61d03074b5]
description = "sum of squares 1"
description = "Sum the squares of the numbers up to the given number -> sum of squares 1"

[c93900cd-8cc2-4ca4-917b-dd3027023499]
description = "sum of squares 5"
description = "Sum the squares of the numbers up to the given number -> sum of squares 5"

[94807386-73e4-4d9e-8dec-69eb135b19e4]
description = "sum of squares 100"
description = "Sum the squares of the numbers up to the given number -> sum of squares 100"

[44f72ae6-31a7-437f-858d-2c0837adabb6]
description = "difference of squares 1"
description = "Subtract sum of squares from square of sums -> difference of squares 1"

[005cb2bf-a0c8-46f3-ae25-924029f8b00b]
description = "difference of squares 5"
description = "Subtract sum of squares from square of sums -> difference of squares 5"

[b1bf19de-9a16-41c0-a62b-1f02ecc0b036]
description = "difference of squares 100"
description = "Subtract sum of squares from square of sums -> difference of squares 100"
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
(ns difference-of-squares)

(defn difference [] ;; <- arglist goes here
;; your code goes here
)
(defn square-of-sum
"Returns the square of the sum of the numbers up to the given number"
[n]
;; function body
)

(defn sum-of-squares [] ;; <- arglist goes here
;; your code goes here
)
(defn sum-of-squares
"Returns the sum of the squares of the numbers up to the given number"
[n]
;; function body
)

(defn square-of-sum [] ;; <- arglist goes here
;; your code goes here
)
(defn difference
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love that you moved this to the bottom

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love that you also did the same 😄

"Returns the difference between the square of the sum of numbers up to a given number and the sum of the squares of those numbers"
[n]
;; function body
)
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
(ns difference-of-squares-test
(:require [clojure.test :refer [deftest is]]
[difference-of-squares :as dos]))
(:require [clojure.test :refer [deftest testing is]]
difference-of-squares))

(deftest square-of-sum-to-5
(is (= 225 (dos/square-of-sum 5))))
(deftest square-of-sum_test_1
(testing "Square the sum of the numbers up to the given number -> square of sum 1"
(is (= 1 (difference-of-squares/square-of-sum 1)))))

(deftest sum-of-squares-to-5
(is (= 55 (dos/sum-of-squares 5))))
(deftest square-of-sum_test_2
(testing "Square the sum of the numbers up to the given number -> square of sum 5"
(is (= 225 (difference-of-squares/square-of-sum 5)))))

(deftest difference-of-squares-to-5
(is (= 170 (dos/difference 5))))
(deftest square-of-sum_test_3
(testing "Square the sum of the numbers up to the given number -> square of sum 100"
(is (= 25502500 (difference-of-squares/square-of-sum 100)))))

(deftest square-of-sum-to-10
(is (= 3025 (dos/square-of-sum 10))))
(deftest sum-of-squares_test_1
(testing "Sum the squares of the numbers up to the given number -> sum of squares 1"
(is (= 1 (difference-of-squares/sum-of-squares 1)))))

(deftest sum-of-squares-to-10
(is (= 385 (dos/sum-of-squares 10))))
(deftest sum-of-squares_test_2
(testing "Sum the squares of the numbers up to the given number -> sum of squares 5"
(is (= 55 (difference-of-squares/sum-of-squares 5)))))

(deftest difference-of-squares-to-10
(is (= 2640 (dos/difference 10))))
(deftest sum-of-squares_test_3
(testing "Sum the squares of the numbers up to the given number -> sum of squares 100"
(is (= 338350 (difference-of-squares/sum-of-squares 100)))))

(deftest square-of-sum-to-100
(is (= 25502500 (dos/square-of-sum 100))))
(deftest difference_test_1
(testing "Subtract sum of squares from square of sums -> difference of squares 1"
(is (= 0 (difference-of-squares/difference 1)))))

(deftest sum-of-squares-to-100
(is (= 338350 (dos/sum-of-squares 100))))
(deftest difference_test_2
(testing "Subtract sum of squares from square of sums -> difference of squares 5"
(is (= 170 (difference-of-squares/difference 5)))))

(deftest difference-of-squares-to-100
(is (= 25164150 (dos/difference 100))))
(deftest difference_test_3
(testing "Subtract sum of squares from square of sums -> difference of squares 100"
(is (= 25164150 (difference-of-squares/difference 100)))))