From 890b3634bc8b2048421f2200f90c56d9d09442ab Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Thu, 30 May 2024 11:41:23 +0200 Subject: [PATCH 01/11] pascals-triangle: split into instructions and introduction --- exercises/pascals-triangle/description.md | 14 -------------- exercises/pascals-triangle/instructions.md | 3 +++ exercises/pascals-triangle/introduction.md | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 14 deletions(-) delete mode 100644 exercises/pascals-triangle/description.md create mode 100644 exercises/pascals-triangle/instructions.md create mode 100644 exercises/pascals-triangle/introduction.md diff --git a/exercises/pascals-triangle/description.md b/exercises/pascals-triangle/description.md deleted file mode 100644 index 352263abd2..0000000000 --- a/exercises/pascals-triangle/description.md +++ /dev/null @@ -1,14 +0,0 @@ -# Description - -Compute Pascal's triangle up to a given number of rows. - -In Pascal's Triangle each number is computed by adding the numbers to the right and left of the current position in the previous row. - -```text - 1 - 1 1 - 1 2 1 - 1 3 3 1 -1 4 6 4 1 -# ... etc -``` diff --git a/exercises/pascals-triangle/instructions.md b/exercises/pascals-triangle/instructions.md new file mode 100644 index 0000000000..69d1ee9aac --- /dev/null +++ b/exercises/pascals-triangle/instructions.md @@ -0,0 +1,3 @@ +# Instructions + +Your task is to output the first N rows of Pascal's Triangle. diff --git a/exercises/pascals-triangle/introduction.md b/exercises/pascals-triangle/introduction.md new file mode 100644 index 0000000000..11f9f69a6b --- /dev/null +++ b/exercises/pascals-triangle/introduction.md @@ -0,0 +1,16 @@ +# Introduction + +[Pascal's triangle][wikipedia] is a triangular array of positive integers. +The first (topmost) row contains a single number: one. +The numbers in subsequent rows are computed by adding the numbers to the right and left of the current position in the previous row. + +```text + 1 + 1 1 + 1 2 1 + 1 3 3 1 +1 4 6 4 1 +# ... etc +``` + +[wikipedia]: https://en.wikipedia.org/wiki/Pascal%27s_triangle From daa647095a71d5d73a5a7ebbba104e13414bcba2 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Sat, 1 Jun 2024 07:28:44 +0200 Subject: [PATCH 02/11] Update instructions.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: András B Nagy <20251272+BNAndras@users.noreply.github.com> --- exercises/pascals-triangle/instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/pascals-triangle/instructions.md b/exercises/pascals-triangle/instructions.md index 69d1ee9aac..58a1fed9f3 100644 --- a/exercises/pascals-triangle/instructions.md +++ b/exercises/pascals-triangle/instructions.md @@ -1,3 +1,3 @@ # Instructions -Your task is to output the first N rows of Pascal's Triangle. +Your task is to output the first N rows of Pascal's triangle. From e8bb50d1e4f6b9de92a4aaf34e00a61d02881d04 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Tue, 4 Jun 2024 15:19:26 +0200 Subject: [PATCH 03/11] Add a bit more text --- exercises/pascals-triangle/introduction.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/exercises/pascals-triangle/introduction.md b/exercises/pascals-triangle/introduction.md index 11f9f69a6b..33f59dd161 100644 --- a/exercises/pascals-triangle/introduction.md +++ b/exercises/pascals-triangle/introduction.md @@ -1,8 +1,18 @@ # Introduction [Pascal's triangle][wikipedia] is a triangular array of positive integers. -The first (topmost) row contains a single number: one. -The numbers in subsequent rows are computed by adding the numbers to the right and left of the current position in the previous row. + +Each row has N values, where N is the row number (starting at one). +Therefore, the first row has one value, the second row has two values, and so on. + +The values in rows are computed by adding the numbers directly to the right and left of the current position in the previous row. +If the previous row does not have a value to the left or right of the current position, treat that value as zero. + +The one exception is the first (topmost) row (as it does not have a previous row) and which contains a single one. + +## Example + +Let's look at the first 5 rows of Pascal's Triangle: ```text 1 @@ -10,7 +20,6 @@ The numbers in subsequent rows are computed by adding the numbers to the right a 1 2 1 1 3 3 1 1 4 6 4 1 -# ... etc ``` [wikipedia]: https://en.wikipedia.org/wiki/Pascal%27s_triangle From 409f60151e3a221ab765428efd2719aee1bbc21c Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Wed, 5 Jun 2024 14:13:58 +0200 Subject: [PATCH 04/11] Improve instructions and introduction --- exercises/pascals-triangle/instructions.md | 32 ++++++++++++++++++++++ exercises/pascals-triangle/introduction.md | 31 ++++++++++----------- 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/exercises/pascals-triangle/instructions.md b/exercises/pascals-triangle/instructions.md index 58a1fed9f3..0f58f00696 100644 --- a/exercises/pascals-triangle/instructions.md +++ b/exercises/pascals-triangle/instructions.md @@ -1,3 +1,35 @@ # Instructions Your task is to output the first N rows of Pascal's triangle. + +[Pascal's triangle][wikipedia] is a triangular array of positive integers. + +In Pascal's triangle, the number of values in a row is equal to its row number (which starts at one). +Therefore, the first row has one value, the second row has two values, and so on. + +The first (topmost) row has a single value: `1`. +Subsequent rows' values are computed by adding the numbers directly to the right and left of the current position in the previous row. + +If the previous row does _not_ have a value to the left or right of the current position (which only happens for the leftmost and rightmost positions), treat that position's value as zero (effectively "ignoring" it in the summation). + +## Example + +Let's look at the first 5 rows of Pascal's Triangle: + +```text + 1 + 1 1 + 1 2 1 + 1 3 3 1 +1 4 6 4 1 +``` + +The topmost row has one value, which is `1`. + +The leftmost and rightmost values have only one preceding position to consider, which is the position to its right respectively to its left. +With the topmost value being `1`, it follows from this that all the leftmost and rightmost values are also `1`. + +The other values all have two positions to consider. +For example, the fifth row's (`1 4 6 4 1`) middle value is `6`, as the values to its left and right in the preceding row are `3` and `3`: + +[wikipedia]: https://en.wikipedia.org/wiki/Pascal%27s_triangle diff --git a/exercises/pascals-triangle/introduction.md b/exercises/pascals-triangle/introduction.md index 33f59dd161..5c88cec0d9 100644 --- a/exercises/pascals-triangle/introduction.md +++ b/exercises/pascals-triangle/introduction.md @@ -1,25 +1,24 @@ # Introduction -[Pascal's triangle][wikipedia] is a triangular array of positive integers. +With the weather being great, you're not looking forward to spending an hour in a classroom doing math. +Annoyed, you enter the class room, where you notice a strangely satisfying triangle shape on the blackboard. +Whilst waiting for your math teacher to arrive, you can't help but notice some patterns in the triangle: the outer values are all ones, each subsequent row has one more value than its previous row and the triangle is symmetrical. +Weird! -Each row has N values, where N is the row number (starting at one). -Therefore, the first row has one value, the second row has two values, and so on. +Not long after you sit down, your teacher enters the room and explains that this triangle is the famous +[Pascal's triangle][wikipedia]. -The values in rows are computed by adding the numbers directly to the right and left of the current position in the previous row. -If the previous row does not have a value to the left or right of the current position, treat that value as zero. +Over the next hour, your teacher reveals some amazing things hidden in this triangle: -The one exception is the first (topmost) row (as it does not have a previous row) and which contains a single one. +- It can be used to compute how many ways you can pick K elements from N values. +- It contains the Fibonacci sequence. +- If you color odd and even number differently, you get a beautiful pattern called the [Sierpiński triangle][wikipedia-sierpinski-triangle] -## Example +The teacher implores you and your classmates to lookup other other uses, and assures you that there are lots more! +At that moment, the school bell rings. +You realize that for the past hour, you were completely absorbed in learning about Pascal's triangle. Math is definitely not as boring as you thought it was! -Let's look at the first 5 rows of Pascal's Triangle: - -```text - 1 - 1 1 - 1 2 1 - 1 3 3 1 -1 4 6 4 1 -``` +You quickly grab your laptop from your bag and go outside, ready to enjoy both the sunshine _and_ the wonders of Pascal's triangle. [wikipedia]: https://en.wikipedia.org/wiki/Pascal%27s_triangle +[wikipedia-sierpinski-triangle]: https://en.wikipedia.org/wiki/Sierpi%C5%84ski_triangle From e5b2dce04a0782323c92d9166fc7f124b2513f14 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Wed, 5 Jun 2024 21:40:14 +0200 Subject: [PATCH 05/11] Update exercises/pascals-triangle/introduction.md Co-authored-by: BethanyG --- exercises/pascals-triangle/introduction.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exercises/pascals-triangle/introduction.md b/exercises/pascals-triangle/introduction.md index 5c88cec0d9..e69a478971 100644 --- a/exercises/pascals-triangle/introduction.md +++ b/exercises/pascals-triangle/introduction.md @@ -16,7 +16,8 @@ Over the next hour, your teacher reveals some amazing things hidden in this tria The teacher implores you and your classmates to lookup other other uses, and assures you that there are lots more! At that moment, the school bell rings. -You realize that for the past hour, you were completely absorbed in learning about Pascal's triangle. Math is definitely not as boring as you thought it was! +You realize that for the past hour, you were completely absorbed in learning about Pascal's triangle. +Math is definitely not as boring as you thought it was! You quickly grab your laptop from your bag and go outside, ready to enjoy both the sunshine _and_ the wonders of Pascal's triangle. From 568ea25b21f457470c3f4b2b237c5e8ce233010d Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Wed, 5 Jun 2024 21:40:20 +0200 Subject: [PATCH 06/11] Update exercises/pascals-triangle/introduction.md Co-authored-by: BethanyG --- exercises/pascals-triangle/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/pascals-triangle/introduction.md b/exercises/pascals-triangle/introduction.md index e69a478971..10d910b74c 100644 --- a/exercises/pascals-triangle/introduction.md +++ b/exercises/pascals-triangle/introduction.md @@ -12,7 +12,7 @@ Over the next hour, your teacher reveals some amazing things hidden in this tria - It can be used to compute how many ways you can pick K elements from N values. - It contains the Fibonacci sequence. -- If you color odd and even number differently, you get a beautiful pattern called the [Sierpiński triangle][wikipedia-sierpinski-triangle] +- If you color odd and even numbers differently, you get a beautiful pattern called the [Sierpiński triangle][wikipedia-sierpinski-triangle] The teacher implores you and your classmates to lookup other other uses, and assures you that there are lots more! At that moment, the school bell rings. From 1746fe35c7ddad0ed5bfaf6c5015ecb4ba29d4c9 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Wed, 5 Jun 2024 21:41:03 +0200 Subject: [PATCH 07/11] Update exercises/pascals-triangle/introduction.md --- exercises/pascals-triangle/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/pascals-triangle/introduction.md b/exercises/pascals-triangle/introduction.md index 10d910b74c..eae552e84a 100644 --- a/exercises/pascals-triangle/introduction.md +++ b/exercises/pascals-triangle/introduction.md @@ -14,7 +14,7 @@ Over the next hour, your teacher reveals some amazing things hidden in this tria - It contains the Fibonacci sequence. - If you color odd and even numbers differently, you get a beautiful pattern called the [Sierpiński triangle][wikipedia-sierpinski-triangle] -The teacher implores you and your classmates to lookup other other uses, and assures you that there are lots more! +The teacher implores you and your classmates to lookup other uses, and assures you that there are lots more! At that moment, the school bell rings. You realize that for the past hour, you were completely absorbed in learning about Pascal's triangle. Math is definitely not as boring as you thought it was! From 3193643866a6d5b3b11660d1b15e6fd730babf85 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Thu, 6 Jun 2024 08:32:32 +0200 Subject: [PATCH 08/11] Remove boring part --- exercises/pascals-triangle/introduction.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/exercises/pascals-triangle/introduction.md b/exercises/pascals-triangle/introduction.md index eae552e84a..43668744e8 100644 --- a/exercises/pascals-triangle/introduction.md +++ b/exercises/pascals-triangle/introduction.md @@ -17,8 +17,6 @@ Over the next hour, your teacher reveals some amazing things hidden in this tria The teacher implores you and your classmates to lookup other uses, and assures you that there are lots more! At that moment, the school bell rings. You realize that for the past hour, you were completely absorbed in learning about Pascal's triangle. -Math is definitely not as boring as you thought it was! - You quickly grab your laptop from your bag and go outside, ready to enjoy both the sunshine _and_ the wonders of Pascal's triangle. [wikipedia]: https://en.wikipedia.org/wiki/Pascal%27s_triangle From 56e0b16d8e9c09a6dfd902eecd540ea3c5fc6131 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Thu, 6 Jun 2024 11:29:35 +0200 Subject: [PATCH 09/11] Update exercises/pascals-triangle/introduction.md Co-authored-by: Jie --- exercises/pascals-triangle/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/pascals-triangle/introduction.md b/exercises/pascals-triangle/introduction.md index 43668744e8..24b3803202 100644 --- a/exercises/pascals-triangle/introduction.md +++ b/exercises/pascals-triangle/introduction.md @@ -12,7 +12,7 @@ Over the next hour, your teacher reveals some amazing things hidden in this tria - It can be used to compute how many ways you can pick K elements from N values. - It contains the Fibonacci sequence. -- If you color odd and even numbers differently, you get a beautiful pattern called the [Sierpiński triangle][wikipedia-sierpinski-triangle] +- If you color odd and even numbers differently, you get a beautiful pattern called the [Sierpiński triangle][wikipedia-sierpinski-triangle]. The teacher implores you and your classmates to lookup other uses, and assures you that there are lots more! At that moment, the school bell rings. From 8ff07c320a8599b2500900aee88ff238ebc18bf2 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Tue, 25 Jun 2024 07:29:01 +0100 Subject: [PATCH 10/11] Update introduction.md --- exercises/pascals-triangle/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/pascals-triangle/introduction.md b/exercises/pascals-triangle/introduction.md index 24b3803202..e013a4ecf6 100644 --- a/exercises/pascals-triangle/introduction.md +++ b/exercises/pascals-triangle/introduction.md @@ -1,6 +1,6 @@ # Introduction -With the weather being great, you're not looking forward to spending an hour in a classroom doing math. +With the weather being great, you're not looking forward to spending an hour in a classroom. Annoyed, you enter the class room, where you notice a strangely satisfying triangle shape on the blackboard. Whilst waiting for your math teacher to arrive, you can't help but notice some patterns in the triangle: the outer values are all ones, each subsequent row has one more value than its previous row and the triangle is symmetrical. Weird! From 80d7132e4a6070d9f89a5cce1a4e4a2688ce7d1e Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Tue, 25 Jun 2024 07:29:24 +0100 Subject: [PATCH 11/11] Update introduction.md Co-authored-by: Victor Goff --- exercises/pascals-triangle/introduction.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exercises/pascals-triangle/introduction.md b/exercises/pascals-triangle/introduction.md index e013a4ecf6..60b8ec30dc 100644 --- a/exercises/pascals-triangle/introduction.md +++ b/exercises/pascals-triangle/introduction.md @@ -5,8 +5,7 @@ Annoyed, you enter the class room, where you notice a strangely satisfying trian Whilst waiting for your math teacher to arrive, you can't help but notice some patterns in the triangle: the outer values are all ones, each subsequent row has one more value than its previous row and the triangle is symmetrical. Weird! -Not long after you sit down, your teacher enters the room and explains that this triangle is the famous -[Pascal's triangle][wikipedia]. +Not long after you sit down, your teacher enters the room and explains that this triangle is the famous [Pascal's triangle][wikipedia]. Over the next hour, your teacher reveals some amazing things hidden in this triangle: