Skip to content

Commit

Permalink
Synchronise with problem specifications (#230)
Browse files Browse the repository at this point in the history
* Sync metadata with `problem-specifications`

* Sync docs with `problem-specifications`

* Update references to `x-common` in `README.md`

* Update other links in `README.md`

* Sync queen-attack instructions

* Resync with latest problem specs
  • Loading branch information
simisc authored Oct 29, 2024
1 parent 8e5f887 commit e935b5d
Show file tree
Hide file tree
Showing 46 changed files with 275 additions and 193 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ For more information see [Installation instructions](docs/INSTALLATION.md)

Thank you so much for contributing! :tada:

Please read about how to [get involved in a track](https://github.com/exercism/docs/tree/master/contributing-to-language-tracks). Be sure to read the Exercism [Code of Conduct](https://exercism.io/code-of-conduct).
Please read about how to [contribute to Exercism](https://exercism.org/docs/building). Be sure to read the Exercism [Code of Conduct](https://exercism.org/docs/using/legal/code-of-conduct).

We welcome pull requests of all kinds. No contribution is too small.

We encourage contributions that provide fixes and improvements to existing exercises. Please note that this track's exercises must conform to the standards determined in the [exercism/x-common](https://github.com/exercism/x-common) repo. Changes to the tests or documentation of a common exercise will often warrant a PR in that repo before it can be incorporated into this track's exercises. If you're unsure, then go ahead and open a GitHub issue, and we'll discuss the change.
We encourage contributions that provide fixes and improvements to existing exercises. Please note that this track's exercises must conform to the standards determined in the [exercism/problem-specifications](https://github.com/exercism/problem-specifications) repo. Changes to the tests or documentation of a common exercise will often warrant a PR in that repo before it can be incorporated into this track's exercises. If you're unsure, then go ahead and open a GitHub issue, and we'll discuss the change.

## Exercise Tests

Expand All @@ -67,7 +67,7 @@ Please keep the following in mind:

- We welcome changes to code style, and wording. Please open a separate PR for these changes if possible.

- Please open an issue before creating a PR that makes significant (breaking) changes to an existing exercise or makes changes across many exercises. It is best to discuss these changes before doing the work. Discussions related to exercises that are not track specific can be found in [exercism/discussions](https://github.com/exercism/discussions/issues).
- Please open an issue before creating a PR that makes significant (breaking) changes to an existing exercise or makes changes across many exercises. It is best to discuss these changes before doing the work. Discussions related to exercises that are not track-specific can be found in [Exercism's forum](https://forum.exercism.org/).

- Follow the coding standards for Fortran. (If there is a formatter for the track's language, add instructions for using it here.)

Expand All @@ -77,16 +77,15 @@ Please keep the following in mind:

## Contributing a New Exercise

- All Exercism exercises must be defined in [x-common](https://github.com/exercism/x-common/tree/master/exercises) before they are implemented for a specific track. Please submit a PR there if your exercise is new to Exercism.
- All Exercism exercises must be defined in [problem-specifications](https://github.com/exercism/problem-specifications/tree/main/exercises) before they are implemented for a specific track. Please submit a PR there if your exercise is new to Exercism.

- Please make sure the new exercise conforms to specifications in the [exercism/x-common](https://github.com/exercism/x-common) repo.
- Please make sure the new exercise conforms to specifications in the [exercism/problem-specifications](https://github.com/exercism/problem-specifications) repo.

- Each exercise must stand on its own. Do not reference files outside the exercise directory. They will not be included when the user fetches the exercise.

- Exercises should use only the Fortran core libraries.

- Please do not add a README or README.md file to the exercise directory. The READMEs are constructed using shared metadata, which lives in the
[exercism/x-common](https://github.com/exercism/x-common) repository. Further explanation can be found in [fixing-exercise-readmes](https://github.com/exercism/docs/blob/master/language-tracks/exercises/anatomy/readmes.md)
- Please do not add a README or README.md file to the exercise directory. The READMEs are constructed using shared metadata, which lives in the [exercism/problem-specifications](https://github.com/exercism/problem-specifications) repository. Further explanation can be found in [Exercism's docs](https://exercism.org/docs/building/tracks/practice-exercises).

- Each exercise should have a test suite, an example solution, a template file for the real implementation and ... (anything else that needs to go with each exercise for this track). The CI build expects files to be named using the following convention: (describe the Fortran convention for naming the various files that make up an exercise).

Expand Down
13 changes: 11 additions & 2 deletions exercises/practice/acronym/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,14 @@ Convert a phrase to its acronym.

Techies love their TLA (Three Letter Acronyms)!

Help generate some jargon by writing a program that converts a long name
like Portable Network Graphics to its acronym (PNG).
Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG).

Punctuation is handled as follows: hyphens are word separators (like whitespace); all other punctuation can be removed from the input.

For example:

| Input | Output |
| ------------------------- | ------ |
| As Soon As Possible | ASAP |
| Liquid-crystal display | LCD |
| Thank George It's Friday! | TGIF |
2 changes: 1 addition & 1 deletion exercises/practice/acronym/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
".meta/example.f90"
]
},
"blurb": "Convert a long phrase to its acronym",
"blurb": "Convert a long phrase to its acronym.",
"source": "Julien Vanier",
"source_url": "https://github.com/monkbroc"
}
27 changes: 12 additions & 15 deletions exercises/practice/allergies/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@

Given a person's allergy score, determine whether or not they're allergic to a given item, and their full list of allergies.

An allergy test produces a single numeric score which contains the
information about all the allergies the person has (that they were
tested for).
An allergy test produces a single numeric score which contains the information about all the allergies the person has (that they were tested for).

The list of items (and their value) that were tested are:

* eggs (1)
* peanuts (2)
* shellfish (4)
* strawberries (8)
* tomatoes (16)
* chocolate (32)
* pollen (64)
* cats (128)
- eggs (1)
- peanuts (2)
- shellfish (4)
- strawberries (8)
- tomatoes (16)
- chocolate (32)
- pollen (64)
- cats (128)

So if Tom is allergic to peanuts and chocolate, he gets a score of 34.

Expand All @@ -24,7 +22,6 @@ Now, given just that score of 34, your program should be able to say:
- Whether Tom is allergic to any one of those allergens listed above.
- All the allergens Tom is allergic to.

Note: a given score may include allergens **not** listed above (i.e.
allergens that score 256, 512, 1024, etc.). Your program should
ignore those components of the score. For example, if the allergy
score is 257, your program should only report the eggs (1) allergy.
Note: a given score may include allergens **not** listed above (i.e. allergens that score 256, 512, 1024, etc.).
Your program should ignore those components of the score.
For example, if the allergy score is 257, your program should only report the eggs (1) allergy.
4 changes: 2 additions & 2 deletions exercises/practice/allergies/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
]
},
"blurb": "Given a person's allergy score, determine whether or not they're allergic to a given item, and their full list of allergies.",
"source": "Jumpstart Lab Warm-up",
"source_url": "http://jumpstartlab.com"
"source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.",
"source_url": "https://turing.edu"
}
8 changes: 5 additions & 3 deletions exercises/practice/armstrong-numbers/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Instructions

An [Armstrong number](https://en.wikipedia.org/wiki/Narcissistic_number) is a number that is the sum of its own digits each raised to the power of the number of digits.
An [Armstrong number][armstrong-number] is a number that is the sum of its own digits each raised to the power of the number of digits.

For example:

- 9 is an Armstrong number, because `9 = 9^1 = 9`
- 10 is *not* an Armstrong number, because `10 != 1^2 + 0^2 = 1`
- 10 is _not_ an Armstrong number, because `10 != 1^2 + 0^2 = 1`
- 153 is an Armstrong number, because: `153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153`
- 154 is *not* an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190`
- 154 is _not_ an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190`

Write some code to determine whether a number is an Armstrong number.

[armstrong-number]: https://en.wikipedia.org/wiki/Narcissistic_number
27 changes: 15 additions & 12 deletions exercises/practice/bob/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Instructions

Bob is a lackadaisical teenager. In conversation, his responses are very limited.
Your task is to determine what Bob will reply to someone when they say something to him or ask him a question.

Bob answers 'Sure.' if you ask him a question, such as "How are you?".
Bob only ever answers one of five things:

He answers 'Whoa, chill out!' if you YELL AT HIM (in all capitals).

He answers 'Calm down, I know what I'm doing!' if you yell a question at him.

He says 'Fine. Be that way!' if you address him without actually saying
anything.

He answers 'Whatever.' to anything else.

Bob's conversational partner is a purist when it comes to written communication and always follows normal rules regarding sentence punctuation in English.
- **"Sure."**
This is his response if you ask him a question, such as "How are you?"
The convention used for questions is that it ends with a question mark.
- **"Whoa, chill out!"**
This is his answer if you YELL AT HIM.
The convention used for yelling is ALL CAPITAL LETTERS.
- **"Calm down, I know what I'm doing!"**
This is what he says if you yell a question at him.
- **"Fine. Be that way!"**
This is how he responds to silence.
The convention used for silence is nothing, or various combinations of whitespace characters.
- **"Whatever."**
This is what he answers to anything else.
10 changes: 10 additions & 0 deletions exercises/practice/bob/.docs/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Introduction

Bob is a [lackadaisical][] teenager.
He likes to think that he's very cool.
And he definitely doesn't get excited about things.
That wouldn't be cool.

When people talk to him, his responses are pretty limited.

[lackadaisical]: https://www.collinsdictionary.com/dictionary/english/lackadaisical
2 changes: 1 addition & 1 deletion exercises/practice/bob/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
},
"blurb": "Bob is a lackadaisical teenager. In conversation, his responses are very limited.",
"source": "Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial.",
"source_url": "http://pine.fm/LearnToProgram/?Chapter=06"
"source_url": "https://pine.fm/LearnToProgram/?Chapter=06"
}
12 changes: 7 additions & 5 deletions exercises/practice/collatz-conjecture/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

The Collatz Conjecture or 3x+1 problem can be summarized as follows:

Take any positive integer n. If n is even, divide n by 2 to get n / 2. If n is
odd, multiply n by 3 and add 1 to get 3n + 1. Repeat the process indefinitely.
The conjecture states that no matter which number you start with, you will
always reach 1 eventually.
Take any positive integer n.
If n is even, divide n by 2 to get n / 2.
If n is odd, multiply n by 3 and add 1 to get 3n + 1.
Repeat the process indefinitely.
The conjecture states that no matter which number you start with, you will always reach 1 eventually.

Given a number n, return the number of steps required to reach 1.

Expand All @@ -24,4 +25,5 @@ Starting with n = 12, the steps would be as follows:
8. 2
9. 1

Resulting in 9 steps. So for input n = 12, the return value would be 9.
Resulting in 9 steps.
So for input n = 12, the return value would be 9.
2 changes: 1 addition & 1 deletion exercises/practice/collatz-conjecture/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
".meta/example.f90"
]
},
"blurb": "Calculate the number of steps to reach 1 using the Collatz conjecture",
"blurb": "Calculate the number of steps to reach 1 using the Collatz conjecture.",
"source": "An unsolved problem in mathematics named after mathematician Lothar Collatz",
"source_url": "https://en.wikipedia.org/wiki/3x_%2B_1_problem"
}
12 changes: 10 additions & 2 deletions exercises/practice/darts/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# 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].

In our particular instance of the game, the target rewards 4 different amounts of points, depending on where the dart lands:

![Our dart scoreboard with values from a complete miss to a bullseye](https://assets.exercism.org/images/exercises/darts/darts-scoreboard.svg)

- If the dart lands outside the target, player earns no points (0 points).
- If the dart lands in the outer circle of the target, player earns 1 point.
- If the dart lands in the middle circle of the target, player earns 5 points.
Expand All @@ -14,10 +16,16 @@ 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

The scoreboard image was created by [habere-et-dispertire][habere-et-dispertire] using [Inkscape][inkscape].

[darts]: https://en.wikipedia.org/wiki/Darts
[darts-target]: https://en.wikipedia.org/wiki/Darts#/media/File:Darts_in_a_dartboard.jpg
[concentric]: https://mathworld.wolfram.com/ConcentricCircles.html
[cartesian-coordinates]: https://www.mathsisfun.com/data/cartesian-coordinates.html
[real-numbers]: https://www.mathsisfun.com/numbers/real-numbers.html
[habere-et-dispertire]: https://exercism.org/profiles/habere-et-dispertire
[inkscape]: https://en.wikipedia.org/wiki/Inkscape
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.f90"
]
},
"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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ The square of the sum of the first ten natural numbers is
The sum of the squares of the first ten natural numbers is
1² + 2² + ... + 10² = 385.

Hence the difference between the square of the sum of the first
ten natural numbers and the sum of the squares of the first ten
natural numbers is 3025 - 385 = 2640.
Hence the difference between the square of the sum of the first ten natural numbers and the sum of the squares of the first ten natural numbers is 3025 - 385 = 2640.

You are not expected to discover an efficient solution to this yourself from
first principles; research is allowed, indeed, encouraged. Finding the best
algorithm for the problem is a key skill in software engineering.
You are not expected to discover an efficient solution to this yourself from first principles; research is allowed, indeed, encouraged.
Finding the best algorithm for the problem is a key skill in software engineering.
2 changes: 1 addition & 1 deletion exercises/practice/difference-of-squares/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
},
"blurb": "Find the difference between the square of the sum and the sum of the squares of the first N natural numbers.",
"source": "Problem 6 at Project Euler",
"source_url": "http://projecteuler.net/problem=6"
"source_url": "https://projecteuler.net/problem=6"
}
2 changes: 2 additions & 0 deletions exercises/practice/grains/.docs/hints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The function for an individual square should take an integer value (`n`).
Both functions should return a double precision value.
26 changes: 6 additions & 20 deletions exercises/practice/grains/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
# Instructions

Calculate the number of grains of wheat on a chessboard given that the number
on each square doubles.
Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.

There once was a wise servant who saved the life of a prince. The king
promised to pay whatever the servant could dream up. Knowing that the
king loved chess, the servant told the king he would like to have grains
of wheat. One grain on the first square of a chess board, with the number
of grains doubling on each successive square.
There once was a wise servant who saved the life of a prince.
The king promised to pay whatever the servant could dream up.
Knowing that the king loved chess, the servant told the king he would like to have grains of wheat.
One grain on the first square of a chess board, with the number of grains doubling on each successive square.

There are 64 squares on a chessboard (where square 1 has one grain, square 2 has two grains, and so on).

Write code that shows:

- how many grains were on a given square, and
- the total number of grains on the chessboard

The function for an individual square will take an integer value (`n`) and both functions will return a double precision value.

## For bonus points

Did you get the tests passing and the code clean? If you want to, these
are some additional things you could try:

- Optimize for speed.
- Optimize for readability.

Then please share your thoughts in a comment on the submission. Did this
experiment make the code better? Worse? Did you learn anything from it?
4 changes: 2 additions & 2 deletions exercises/practice/grains/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
]
},
"blurb": "Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.",
"source": "JavaRanch Cattle Drive, exercise 6",
"source_url": "http://www.javaranch.com/grains.jsp"
"source": "The CodeRanch Cattle Drive, Assignment 6",
"source_url": "https://coderanch.com/wiki/718824/Grains"
}
Loading

0 comments on commit e935b5d

Please sign in to comment.