Synced practice exercise docs to problem specificatons. (#3573)
This commit is contained in:
@@ -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
|
||||
## Perfect
|
||||
|
||||
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**.
|
||||
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
|
||||
|
||||
@@ -11,12 +11,14 @@ The first three digits of the local number represent the _exchange code_, follow
|
||||
The format is usually represented as
|
||||
|
||||
```text
|
||||
(NXX)-NXX-XXXX
|
||||
NXX NXX-XXXX
|
||||
```
|
||||
|
||||
where `N` is any digit from 2 through 9 and `X` is any digit from 0 through 9.
|
||||
|
||||
Your task is to clean up differently formatted telephone numbers by removing punctuation and the country code (1) if present.
|
||||
Sometimes they also have the country code (represented as `1` or `+1`) prefixed.
|
||||
|
||||
Your task is to clean up differently formatted telephone numbers by removing punctuation and the country code if present.
|
||||
|
||||
For example, the inputs
|
||||
|
||||
|
||||
@@ -8,18 +8,14 @@ A chessboard can be represented by an 8 by 8 array.
|
||||
|
||||
So if you are told the white queen is at `c5` (zero-indexed at column 2, row 3) and the black queen at `f2` (zero-indexed at column 5, row 6), then you know that the set-up is like so:
|
||||
|
||||
```text
|
||||
a b c d e f g h
|
||||
8 _ _ _ _ _ _ _ _ 8
|
||||
7 _ _ _ _ _ _ _ _ 7
|
||||
6 _ _ _ _ _ _ _ _ 6
|
||||
5 _ _ W _ _ _ _ _ 5
|
||||
4 _ _ _ _ _ _ _ _ 4
|
||||
3 _ _ _ _ _ _ _ _ 3
|
||||
2 _ _ _ _ _ B _ _ 2
|
||||
1 _ _ _ _ _ _ _ _ 1
|
||||
a b c d e f g h
|
||||
```
|
||||

|
||||
|
||||
You are also able to answer whether the queens can attack each other.
|
||||
In this case, that answer would be yes, they can, because both pieces share a diagonal.
|
||||
|
||||
## Credit
|
||||
|
||||
The chessboard image was made by [habere-et-dispertire][habere-et-dispertire] using LaTeX and the [chessboard package][chessboard-package] by Ulrike Fischer.
|
||||
|
||||
[habere-et-dispertire]: https://exercism.org/profiles/habere-et-dispertire
|
||||
[chessboard-package]: https://github.com/u-fischer/chessboard
|
||||
|
||||
@@ -44,5 +44,5 @@ Your task is to implement a simple [RESTful API][restful-wikipedia] that receive
|
||||
[restful-wikipedia]: https://en.wikipedia.org/wiki/Representational_state_transfer
|
||||
[iou]: https://en.wikipedia.org/wiki/IOU
|
||||
[github-rest]: https://developer.github.com/v3/
|
||||
[reddit-rest]: https://www.reddit.com/dev/api/
|
||||
[reddit-rest]: https://web.archive.org/web/20231202231149/https://www.reddit.com/dev/api/
|
||||
[restfulapi]: https://restfulapi.net/
|
||||
|
||||
Reference in New Issue
Block a user