Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions exercises/practice/anagram/.docs/instructions.append.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Instructions Append

## Track specific instructions

You must return the anagrams in the same order as they are listed in the candidate words.
12 changes: 9 additions & 3 deletions exercises/practice/connect/.docs/instructions.append.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Hints
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.
# Instructions append

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.
## Track specific instructions

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.

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.

So don't be puzzled by those seemingly unfair games.
5 changes: 4 additions & 1 deletion exercises/practice/gigasecond/.docs/instructions.append.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Hints
# Instructions append

## Track specific instructions

Note that `addGigaseconds` accepts two different types of input.
6 changes: 5 additions & 1 deletion exercises/practice/leap/.docs/instructions.append.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Hints

## Track specific instructions

Try to avoid code repetition, use private helper functions if you can.

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).
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 changes: 5 additions & 2 deletions exercises/practice/lens-person/.docs/instructions.append.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
In Scala, a popular alternative for using Lens that is supported
by Exercism is [Monocle](https://www.optics.dev/Monocle/)
# Instructions append

## Track specific instructions

In Scala, a popular alternative for using Lens that is supported by Exercism is [Monocle](https://www.optics.dev/Monocle/)
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
# Hints
According to [this terminology](http://chimera.labs.oreilly.com/books/1230000000929/ch01.html#sec_terminology) you should write a *parallel* and *deterministic*
program and (by all means!) let Scala deal with the *concurrency* aspect.
Or else your code could quickly get messy and error-prone with all kinds of nasty
concurrency bugs. In particular your program could become indeterministic
which spells in practice: very (in fact, VERY) hard to debug, test and reason about.

Having said that it might be a good idea to first write a sequential solution (and
use the test suite to verify it).
Only then should you try to parallelize it while keeping the sequential and parallel
portions of your code as separate as possible.

A first iteration could be using Scala's [parallel collections](http://docs.scala-lang.org/overviews/parallel-collections/overview.html). You might find
that this is almost too simple (especially if you have followed our advice and
already have a sequential solution).

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).
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.
# Instructions append

## Track specific instructions

According to [this terminology][terminology] you should write a *parallel* and *deterministic* program and (by all means!) let Scala deal with the *concurrency* aspect.
Or else your code could quickly get messy and error-prone with all kinds of nasty concurrency bugs.
In particular your program could become indeterministic which spells in practice: very (in fact, VERY) hard to debug, test and reason about.

Having said that it might be a good idea to first write a sequential solution (and use the test suite to verify it).
Only then should you try to parallelize it while keeping the sequential and parallel portions of your code as separate as possible.

A first iteration could be using Scala's [parallel collections].
You might find that this is almost too simple (especially if you have followed our advice and already have a sequential solution).

For the second iteration we recommend you try a solution with [`scala.concurrent.Future`][Future].
You can consult [this tutorial][tutorial] and [its sequel][sequel] for some help.
Make sure that you

- have only one single blocking call to wait for the result
- that it is at the very end of your program, and
- that it has a timeout.

`scala.concurrent.Future` is used in many libraries and the doctor's advice for
parallel and asynchronous programming in Scala. So it is essential for mastering
the language and it should become part of your Scala armory.
`scala.concurrent.Future` is used in many libraries and the doctor's advice for parallel and asynchronous programming in Scala.
So it is essential for mastering the language and it should become part of your Scala armory.

[terminology]: http://chimera.labs.oreilly.com/books/1230000000929/ch01.html#sec_terminology
[parallel collections]: http://docs.scala-lang.org/overviews/parallel-collections/overview.html
[Future]: http://www.scala-lang.org/api/current/scala/concurrent/Future$.html
[tutorial]: http://danielwestheide.com/blog/2013/01/09/the-neophytes-guide-to-scala-part-8-welcome-to-the-future.html
[sequel]: http://danielwestheide.com/blog/2013/01/16/the-neophytes-guide-to-scala-part-9-promises-and-futures-in-practice.html
13 changes: 9 additions & 4 deletions exercises/practice/phone-number/.docs/instructions.append.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Hints
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.
# Instructions append

## Track specific instructions

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.

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

Another idea worth exploring might be to change the `String` into a `List[Char]`
and then use [pattern matching](http://alvinalexander.com/scala/how-to-use-lists-nil-cons-scala-match-case-expressions) with the `::` operator.
Another idea worth exploring might be to change the `String` into a `List[Char]` and then use [pattern matching] with the `::` operator.

[pattern matching]: http://alvinalexander.com/scala/how-to-use-lists-nil-cons-scala-match-case-expressions
8 changes: 6 additions & 2 deletions exercises/practice/robot-name/.docs/instructions.append.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Hints
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.
# Instructions append

## Track specific instructions

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.

Suggestion (this is not explicitly tested):
To make sure you always have a unique name you could implement your own cache or use a `Stream` with its built-in cache.
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Hints
# Instructions append

## Track specific instructions

For something a little different you might also try a solution with an `unfold` function.
You are probably already familiar with `foldLeft/Right`: "map" a whole collection into something else (usually a non-collection).
`unfoldLeft/Right` are the "inverse" operations: "map" something (usually a non-collection) into a collection.
Expand All @@ -7,4 +10,6 @@ So `unfold`ing is a logical addition to and part of the FP standard repertoire.
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]`).

Unfortunately `unfoldLeft/Right` is not included in Scala's collection library.
But you can take the implementation from [here](http://daily-scala.blogspot.de/2009/09/unfoldleft-and-right.html).
But you can take the implementation from [here][unfold].

[unfold]: http://daily-scala.blogspot.de/2009/09/unfoldleft-and-right.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Hints
Remember that in Scala there are two forms of the right shift operator. The `>>` operator preserves the sign, while `>>>` zeroes the leftmost bits.
# Instructions append

## Track specific instructions

Remember that in Scala there are two forms of the right shift operator.
The `>>` operator preserves the sign, while `>>>` zeroes the leftmost bits.