Skip to content

Commit 446a2b2

Browse files
committed
Format all instructions.append.md to start with an H1 (required but ignored) and H2
1 parent 466ae4d commit 446a2b2

10 files changed

Lines changed: 78 additions & 38 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Instructions Append
22

3+
## Implementation
4+
35
You must return the anagrams in the same order as they are listed in the candidate words.
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
# Hints
2-
You may notice that some test cases seem unfair. However, they may be legitimately so. For example, it is common to give young or beginner players an extra n pieces at fixed positions on the board, so mismatched piece counts can occur in an otherwise fully legal game.
1+
# Instructions append
32

4-
In any case, this exercise cares only about determining a winner for a game that can have a variety of parameters, like board length and extra pieces. It is not interested in any other state of the game, such as who moved where, when, or whose turn it is.
3+
## Hints
4+
5+
You may notice that some test cases seem unfair.
6+
However, they may be legitimately so.
7+
For example, it is common to give young or beginner players an extra n pieces at fixed positions on the board, so mismatched piece counts can occur in an otherwise fully legal game.
8+
9+
In any case, this exercise cares only about determining a winner for a game that can have a variety of parameters, like board length and extra pieces.
10+
It is not interested in any other state of the game, such as who moved where, when, or whose turn it is.
511

612
So don't be puzzled by those seemingly unfair games.
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
# Hints
1+
# Instructions append
2+
3+
## Hints
4+
25
Note that `addGigaseconds` accepts two different types of input.
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Hints
2+
3+
## Implementation
4+
25
Try to avoid code repetition, use private helper functions if you can.
36

4-
And you might consider using a single `Boolean` expression instead of `if-else` for better readability. See [here](http://cs.wellesley.edu/~cs111/spring00/lectures/boolean-simplification.html) on how this could be done (the link is for Java, but of course the logic is valid for Scala, too).
7+
And you might consider using a single `Boolean` expression instead of `if-else` for better readability.
8+
See [here](http://cs.wellesley.edu/~cs111/spring00/lectures/boolean-simplification.html) on how this could be done (the link is for Java, but of course the logic is valid for Scala, too).
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
In Scala, a popular alternative for using Lens that is supported
2-
by Exercism is [Monocle](https://www.optics.dev/Monocle/)
1+
# Instructions append
2+
3+
## Implementation
4+
5+
In Scala, a popular alternative for using Lens that is supported by Exercism is [Monocle](https://www.optics.dev/Monocle/)
Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
1-
# Hints
2-
According to [this terminology](http://chimera.labs.oreilly.com/books/1230000000929/ch01.html#sec_terminology) you should write a *parallel* and *deterministic*
3-
program and (by all means!) let Scala deal with the *concurrency* aspect.
4-
Or else your code could quickly get messy and error-prone with all kinds of nasty
5-
concurrency bugs. In particular your program could become indeterministic
6-
which spells in practice: very (in fact, VERY) hard to debug, test and reason about.
7-
8-
Having said that it might be a good idea to first write a sequential solution (and
9-
use the test suite to verify it).
10-
Only then should you try to parallelize it while keeping the sequential and parallel
11-
portions of your code as separate as possible.
12-
13-
A first iteration could be using Scala's [parallel collections](http://docs.scala-lang.org/overviews/parallel-collections/overview.html). You might find
14-
that this is almost too simple (especially if you have followed our advice and
15-
already have a sequential solution).
16-
17-
For the second iteration we recommend you try a solution with [scala.concurrent.Future](http://www.scala-lang.org/api/current/scala/concurrent/Future$.html).
18-
You can consult [this tutorial](http://danielwestheide.com/blog/2013/01/09/the-neophytes-guide-to-scala-part-8-welcome-to-the-future.html) and [its sequel](http://danielwestheide.com/blog/2013/01/16/the-neophytes-guide-to-scala-part-9-promises-and-futures-in-practice.html) for some help.
1+
# Instructions append
2+
3+
## Hints
4+
5+
According to [this terminology][terminology] you should write a *parallel* and *deterministic* program and (by all means!) let Scala deal with the *concurrency* aspect.
6+
Or else your code could quickly get messy and error-prone with all kinds of nasty concurrency bugs.
7+
In particular your program could become indeterministic which spells in practice: very (in fact, VERY) hard to debug, test and reason about.
8+
9+
Having said that it might be a good idea to first write a sequential solution (and use the test suite to verify it).
10+
Only then should you try to parallelize it while keeping the sequential and parallel portions of your code as separate as possible.
11+
12+
A first iteration could be using Scala's [parallel collections].
13+
You might find that this is almost too simple (especially if you have followed our advice and already have a sequential solution).
14+
15+
For the second iteration we recommend you try a solution with [`scala.concurrent.Future`][Future].
16+
You can consult [this tutorial][tutorial] and [its sequel][sequel] for some help.
1917
Make sure that you
18+
2019
- have only one single blocking call to wait for the result
2120
- that it is at the very end of your program, and
2221
- that it has a timeout.
2322

24-
`scala.concurrent.Future` is used in many libraries and the doctor's advice for
25-
parallel and asynchronous programming in Scala. So it is essential for mastering
26-
the language and it should become part of your Scala armory.
23+
`scala.concurrent.Future` is used in many libraries and the doctor's advice for parallel and asynchronous programming in Scala.
24+
So it is essential for mastering the language and it should become part of your Scala armory.
25+
26+
[terminology]: http://chimera.labs.oreilly.com/books/1230000000929/ch01.html#sec_terminology
27+
[parallel collections]: http://docs.scala-lang.org/overviews/parallel-collections/overview.html
28+
[Future]: http://www.scala-lang.org/api/current/scala/concurrent/Future$.html
29+
[tutorial]: http://danielwestheide.com/blog/2013/01/09/the-neophytes-guide-to-scala-part-8-welcome-to-the-future.html
30+
[sequel]: http://danielwestheide.com/blog/2013/01/16/the-neophytes-guide-to-scala-part-9-promises-and-futures-in-practice.html
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
# Hints
2-
For simplicity and readability: Consider using the Scala collection functions instead of Java's `String` methods. Remember that in Scala a `String` is implicitly also a `Seq[Char]`, so you can call them as easily as the `String` methods.
1+
# Instructions append
2+
3+
## Hints
4+
5+
For simplicity and readability: Consider using the Scala collection functions instead of Java's `String` methods.
6+
Remember that in Scala a `String` is implicitly also a `Seq[Char]`, so you can call them as easily as the `String` methods.
37

48
Some examples:
59
- `filter` instead of `replaceAll`
610
- `take`, `takeRight`, `drop`, `head`, `tail` instead of `substring`
711

8-
Another idea worth exploring might be to change the `String` into a `List[Char]`
9-
and then use [pattern matching](http://alvinalexander.com/scala/how-to-use-lists-nil-cons-scala-match-case-expressions) with the `::` operator.
12+
Another idea worth exploring might be to change the `String` into a `List[Char]` and then use [pattern matching] with the `::` operator.
13+
14+
[pattern matching]: http://alvinalexander.com/scala/how-to-use-lists-nil-cons-scala-match-case-expressions
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
# Hints
2-
Make sure your solution is general enough to be easily scalable for longer names containing more letters and digits. This usually makes for better code quality, too.
1+
# Instructions append
2+
3+
## Hints
4+
5+
Make sure your solution is general enough to be easily scalable for longer names containing more letters and digits.
6+
This usually makes for better code quality, too.
37

48
Suggestion (this is not explicitly tested):
59
To make sure you always have a unique name you could implement your own cache or use a `Stream` with its built-in cache.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# Hints
1+
# Instructions append
2+
3+
## Hints
4+
25
For something a little different you might also try a solution with an `unfold` function.
36
You are probably already familiar with `foldLeft/Right`: "map" a whole collection into something else (usually a non-collection).
47
`unfoldLeft/Right` are the "inverse" operations: "map" something (usually a non-collection) into a collection.
@@ -7,4 +10,6 @@ So `unfold`ing is a logical addition to and part of the FP standard repertoire.
710
This exercise can be seen as a case for `unfold`ing: "map" an `Int` into a `String` (which is of course implicitly a `Seq[Char]`).
811

912
Unfortunately `unfoldLeft/Right` is not included in Scala's collection library.
10-
But you can take the implementation from [here](http://daily-scala.blogspot.de/2009/09/unfoldleft-and-right.html).
13+
But you can take the implementation from [here][unfold].
14+
15+
[unfold]: http://daily-scala.blogspot.de/2009/09/unfoldleft-and-right.html
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
# Hints
2-
Remember that in Scala there are two forms of the right shift operator. The `>>` operator preserves the sign, while `>>>` zeroes the leftmost bits.
1+
# Instructions append
2+
3+
## Hints
4+
5+
Remember that in Scala there are two forms of the right shift operator.
6+
The `>>` operator preserves the sign, while `>>>` zeroes the leftmost bits.

0 commit comments

Comments
 (0)