Skip to content

Commit

Permalink
Sync exercise instructions
Browse files Browse the repository at this point in the history
- alphametics
- darts
- hello-world
- pascals-triangle
- perfect-numbers
- pig-latin
- pythagorean-triplet
- raindrops
- strain
- two-bucket
- yacht
  • Loading branch information
keiravillekode committed Sep 28, 2024
1 parent 9d54fb7 commit 8297f9a
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 32 deletions.
4 changes: 1 addition & 3 deletions exercises/practice/alphametics/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Instructions

Write a function to solve alphametics puzzles.
Given an alphametics puzzle, find the correct solution.

[Alphametics][alphametics] is a puzzle where letters in words are replaced with numbers.

Expand All @@ -26,6 +26,4 @@ This is correct because every letter is replaced by a different number and the w

Each letter must represent a different digit, and the leading digit of a multi-digit number must not be zero.

Write a function to solve alphametics puzzles.

[alphametics]: https://en.wikipedia.org/wiki/Alphametics
2 changes: 1 addition & 1 deletion exercises/practice/alphametics/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
".meta/example.lua"
]
},
"blurb": "Write a function to solve alphametics puzzles."
"blurb": "Given an alphametics puzzle, find the correct solution."
}
4 changes: 2 additions & 2 deletions exercises/practice/darts/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Instructions

Write a function that returns the earned points in a single toss of a Darts game.
Calculate the points scored in a single toss of a Darts game.

[Darts][darts] is a game where players throw darts at a [target][darts-target].

Expand All @@ -16,7 +16,7 @@ In our particular instance of the game, the target rewards 4 different amounts o
The outer circle has a radius of 10 units (this is equivalent to the total radius for the entire target), the middle circle a radius of 5 units, and the inner circle a radius of 1.
Of course, they are all centered at the same point — that is, the circles are [concentric][] defined by the coordinates (0, 0).

Write a function that given a point in the target (defined by its [Cartesian coordinates][cartesian-coordinates] `x` and `y`, where `x` and `y` are [real][real-numbers]), returns the correct amount earned by a dart landing at that point.
Given a point in the target (defined by its [Cartesian coordinates][cartesian-coordinates] `x` and `y`, where `x` and `y` are [real][real-numbers]), calculate the correct score earned by a dart landing at that point.

## Credit

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/darts/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
".meta/example.lua"
]
},
"blurb": "Write a function that returns the earned points in a single toss of a Darts game.",
"blurb": "Calculate the points scored in a single toss of a Darts game.",
"source": "Inspired by an exercise created by a professor Della Paolera in Argentina"
}
2 changes: 1 addition & 1 deletion exercises/practice/hello-world/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
".meta/example.lua"
]
},
"blurb": "The classical introductory exercise. Just say \"Hello, World!\".",
"blurb": "Exercism's classic introductory exercise. Just say \"Hello, World!\".",
"source": "This is an exercise to introduce users to using Exercism",
"source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program"
}
27 changes: 24 additions & 3 deletions exercises/practice/pascals-triangle/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
# Instructions

Compute Pascal's triangle up to a given number of rows.
Your task is to output the first N rows of Pascal's triangle.

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.
[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
# ... etc
```

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
22 changes: 22 additions & 0 deletions exercises/practice/pascals-triangle/.docs/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Introduction

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!

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:

- 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].

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.
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
44 changes: 30 additions & 14 deletions exercises/practice/perfect-numbers/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,38 @@

Determine if a number is perfect, abundant, or deficient based on Nicomachus' (60 - 120 CE) classification scheme for positive integers.

The Greek mathematician [Nicomachus][nicomachus] devised a classification scheme for positive integers, identifying each as belonging uniquely to the categories of **perfect**, **abundant**, or **deficient** based on their [aliquot sum][aliquot-sum].
The aliquot sum is defined as the sum of the factors of a number not including the number itself.
The Greek mathematician [Nicomachus][nicomachus] devised a classification scheme for positive integers, identifying each as belonging uniquely to the categories of [perfect](#perfect), [abundant](#abundant), or [deficient](#deficient) based on their [aliquot sum][aliquot-sum].
The _aliquot sum_ is defined as the sum of the factors of a number not including the number itself.
For example, the aliquot sum of `15` is `1 + 3 + 5 = 9`.

- **Perfect**: aliquot sum = number
- 6 is a perfect number because (1 + 2 + 3) = 6
- 28 is a perfect number because (1 + 2 + 4 + 7 + 14) = 28
- **Abundant**: aliquot sum > number
- 12 is an abundant number because (1 + 2 + 3 + 4 + 6) = 16
- 24 is an abundant number because (1 + 2 + 3 + 4 + 6 + 8 + 12) = 36
- **Deficient**: aliquot sum < number
- 8 is a deficient number because (1 + 2 + 4) = 7
- Prime numbers are deficient

Implement a way to determine whether a given number is **perfect**.
Depending on your language track, you may also need to implement a way to determine whether a given number is **abundant** or **deficient**.
## Perfect

A number is perfect when it equals its aliquot sum.
For example:

- `6` is a perfect number because `1 + 2 + 3 = 6`
- `28` is a perfect number because `1 + 2 + 4 + 7 + 14 = 28`

## Abundant

A number is abundant when it is less than its aliquot sum.
For example:

- `12` is an abundant number because `1 + 2 + 3 + 4 + 6 = 16`
- `24` is an abundant number because `1 + 2 + 3 + 4 + 6 + 8 + 12 = 36`

## Deficient

A number is deficient when it is greater than its aliquot sum.
For example:

- `8` is a deficient number because `1 + 2 + 4 = 7`
- Prime numbers are deficient

## Task

Implement a way to determine whether a given number is [perfect](#perfect).
Depending on your language track, you may also need to implement a way to determine whether a given number is [abundant](#abundant) or [deficient](#deficient).

[nicomachus]: https://en.wikipedia.org/wiki/Nicomachus
[aliquot-sum]: https://en.wikipedia.org/wiki/Aliquot_sum
4 changes: 2 additions & 2 deletions exercises/practice/pig-latin/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ For example:

## Rule 2

If a word begins with a one or more consonants, first move those consonants to the end of the word and then add an `"ay"` sound to the end of the word.
If a word begins with one or more consonants, first move those consonants to the end of the word and then add an `"ay"` sound to the end of the word.

For example:

Expand All @@ -33,7 +33,7 @@ If a word starts with zero or more consonants followed by `"qu"`, first move tho

For example:

- `"quick"` -> `"ickqu"` -> `"ay"` (starts with `"qu"`, no preceding consonants)
- `"quick"` -> `"ickqu"` -> `"ickquay"` (starts with `"qu"`, no preceding consonants)
- `"square"` -> `"aresqu"` -> `"aresquay"` (starts with one consonant followed by `"qu`")

## Rule 4
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/pythagorean-triplet/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
".meta/example.lua"
]
},
"blurb": "There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product a * b * c.",
"blurb": "There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the triplet.",
"source": "Problem 9 at Project Euler",
"source_url": "https://projecteuler.net/problem=9"
}
2 changes: 1 addition & 1 deletion exercises/practice/raindrops/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
".meta/example.lua"
]
},
"blurb": "Convert a number to a string, the content of which depends on the number's factors.",
"blurb": "Convert a number into its corresponding raindrop sounds - Pling, Plang and Plong.",
"source": "A variation on FizzBuzz, a famous technical interview question that is intended to weed out potential candidates. That question is itself derived from Fizz Buzz, a popular children's game for teaching division.",
"source_url": "https://en.wikipedia.org/wiki/Fizz_buzz"
}
2 changes: 1 addition & 1 deletion exercises/practice/strain/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
".meta/example.lua"
]
},
"blurb": "Implement the `keep` and `discard` operation on collections. Given a collection and a predicate on the collection's elements, `keep` returns a new collection containing those elements where the predicate is true, while `discard` returns a new collection containing those elements where the predicate is false.",
"blurb": "Implement the `keep` and `discard` operation on collections.",
"source": "Conversation with James Edward Gray II",
"source_url": "http://graysoftinc.com/"
}
2 changes: 1 addition & 1 deletion exercises/practice/two-bucket/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ There are some rules that your solution must follow:
b) the second bucket is full
2. Emptying a bucket and doing nothing to the other.
3. Filling a bucket and doing nothing to the other.
- After an action, you may not arrive at a state where the starting bucket is empty and the other bucket is full.
- After an action, you may not arrive at a state where the initial starting bucket is empty and the other bucket is full.

Your program will take as input:

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/yacht/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
]
},
"blurb": "Score a single throw of dice in the game Yacht.",
"source": "James Kilfiger, using wikipedia",
"source": "James Kilfiger, using Wikipedia",
"source_url": "https://en.wikipedia.org/wiki/Yacht_(dice_game)"
}

0 comments on commit 8297f9a

Please sign in to comment.