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
187 changes: 180 additions & 7 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,47 @@
],
"difficulty": 2
},
{
"slug": "high-scores",
"name": "High Scores",
"uuid": "81e1ea19-1c58-4b34-b3c4-d05e029032aa",
"practices": [
"tuples"
],
"prerequisites": [
"sequences",
"higher-order-sequences",
"tuples"
],
"difficulty": 2
},
{
"slug": "micro-blog",
"name": "Micro Blog",
"uuid": "5cef0fa1-06b4-4212-9a07-3b9ecb1c4249",
"practices": [
"unicode"
],
"prerequisites": [
"strings",
"unicode"
],
"difficulty": 2
},
{
"slug": "nucleotide-count",
"name": "Nucleotide Count",
"uuid": "23b64c13-1b0e-4179-bbed-71369c70a7c1",
"practices": [
"assocs"
],
"prerequisites": [
"strings",
"errors",
"assocs"
],
"difficulty": 2
},
{
"slug": "pangram",
"name": "Pangram",
Expand Down Expand Up @@ -434,7 +475,10 @@
],
"prerequisites": [
"conditionals",
"booleans"
"booleans",
"combinators",
"tuples",
"sequences"
],
"difficulty": 2
},
Expand Down Expand Up @@ -478,6 +522,21 @@
],
"difficulty": 3
},
{
"slug": "binary-search",
"name": "Binary Search",
"uuid": "ea3a619c-0d03-4688-821a-22379470d7e1",
"practices": [
"recursion"
],
"prerequisites": [
"sequences",
"conditionals",
"locals",
"recursion"
],
"difficulty": 3
},
{
"slug": "bob",
"name": "Bob",
Expand Down Expand Up @@ -516,7 +575,8 @@
"prerequisites": [
"strings",
"numbers",
"unicode"
"unicode",
"sequences"
],
"difficulty": 3
},
Expand Down Expand Up @@ -545,6 +605,21 @@
],
"difficulty": 3
},
{
"slug": "phone-number",
"name": "Phone Number",
"uuid": "7fa72ba9-5942-47aa-ae62-eba877d18905",
"practices": [
"strings"
],
"prerequisites": [
"strings",
"conditionals",
"higher-order-sequences",
"errors"
],
"difficulty": 3
},
{
"slug": "prime-factors",
"name": "Prime Factors",
Expand All @@ -567,7 +642,8 @@
],
"prerequisites": [
"conditionals",
"strings"
"strings",
"higher-order-sequences"
],
"difficulty": 3
},
Expand Down Expand Up @@ -599,6 +675,21 @@
],
"difficulty": 3
},
{
"slug": "scrabble-score",
"name": "Scrabble Score",
"uuid": "9fafa9b3-2ca6-44ac-af1c-f202572f94c8",
"practices": [
"assocs"
],
"prerequisites": [
"strings",
"unicode",
"higher-order-sequences",
"assocs"
],
"difficulty": 3
},
{
"slug": "sum-of-multiples",
"name": "Sum of Multiples",
Expand Down Expand Up @@ -629,6 +720,35 @@
],
"difficulty": 4
},
{
"slug": "flatten-array",
"name": "Flatten Array",
"uuid": "27cb8df3-ed88-4b60-990e-eb0422123260",
"practices": [
"recursion"
],
"prerequisites": [
"sequences",
"conditionals",
"recursion"
],
"difficulty": 4
},
{
"slug": "largest-series-product",
"name": "Largest Series Product",
"uuid": "d6d49ae0-5999-435c-902f-beb35e72aac9",
"practices": [
"higher-order-sequences"
],
"prerequisites": [
"strings",
"numbers",
"higher-order-sequences",
"errors"
],
"difficulty": 4
},
{
"slug": "luhn",
"name": "Luhn",
Expand All @@ -638,7 +758,23 @@
],
"prerequisites": [
"strings",
"numbers"
"numbers",
"higher-order-sequences",
"unicode",
"locals"
],
"difficulty": 4
},
{
"slug": "pascals-triangle",
"name": "Pascal's Triangle",
"uuid": "95dc30b1-af57-4c4c-af4d-64c53cfea619",
"practices": [
"higher-order-sequences"
],
"prerequisites": [
"sequences",
"higher-order-sequences"
],
"difficulty": 4
},
Expand All @@ -653,7 +789,8 @@
"case",
"combinators",
"sequences",
"dynamic-variables"
"dynamic-variables",
"tuples"
],
"difficulty": 4
},
Expand All @@ -679,7 +816,8 @@
],
"prerequisites": [
"numbers",
"tuples"
"case",
"dynamic-variables"
],
"difficulty": 4
},
Expand Down Expand Up @@ -758,7 +896,26 @@
"strings"
],
"prerequisites": [
"strings"
"strings",
"higher-order-sequences",
"unicode",
"locals"
],
"difficulty": 5
},
{
"slug": "knapsack",
"name": "Knapsack",
"uuid": "0c991751-e9a9-4291-a0fd-65af4263a65e",
"practices": [
"recursion"
],
"prerequisites": [
"tuples",
"sequences",
"conditionals",
"locals",
"recursion"
],
"difficulty": 5
},
Expand Down Expand Up @@ -943,6 +1100,22 @@
],
"difficulty": 7
},
{
"slug": "satellite",
"name": "Satellite",
"uuid": "65d091e3-0d2f-4f69-a088-069f799d0109",
"practices": [
"recursion"
],
"prerequisites": [
"sequences",
"errors",
"tuples",
"locals",
"recursion"
],
"difficulty": 7
},
{
"slug": "nth-prime",
"name": "Nth Prime",
Expand Down
12 changes: 6 additions & 6 deletions exercises/concept/character-study/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Instructions

Lewis, a young Lisp Alien, needs to get some work done on their
Human alphabets project and asks if you can help them program some
words they will need.
Heidi, a young Forth Alien, needs to get some work done on her
Human alphabets project and asks if you can help her program some
words she will need.

## 1. Compare two characters

Expand All @@ -20,7 +20,7 @@ CHAR: A CHAR: a compare-chars . ! => less

## 2. Determine the size of a character

Lewis needs to know whether a character is "big" (uppercase),
Heidi needs to know whether a character is "big" (uppercase),
"small" (lowercase), or has no size. Define `size-of-char` to
return `big`, `small`, or `no-size`.

Expand All @@ -33,7 +33,7 @@ CHAR: space size-of-char . ! => no-size

## 3. Change the size of a character

Lewis sometimes needs to flip a character to a different size.
Heidi sometimes needs to flip a character to a different size.
Define `change-size-of-char` to take a character and a desired
size (`big` or `small`) and return the corresponding-case
character.
Expand All @@ -45,7 +45,7 @@ CHAR: A small change-size-of-char . ! => 97 (CHAR: a)

## 4. Determine the type of a character

Lewis also needs to know what *kind* of character it is. Define
Heidi also needs to know what *kind* of character it is. Define
`type-of-char` to return:

- `alpha` for any letter (upper or lower)
Expand Down
19 changes: 19 additions & 0 deletions exercises/concept/character-study/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,23 @@ CHAR: space . ! => 32
CHAR: \n . ! => 10
```

## Symbols

When a word needs to return a tag rather than a value — say,
`yes`/`no`/`maybe` instead of a boolean — declare each tag as a
*symbol*. A symbol is a word that pushes itself when called, and
two symbols compare equal only when they are the same name.

```factor
USING: kernel ;

SYMBOLS: yes no maybe ;

yes . ! => yes
yes yes = . ! => t
yes no = . ! => f
```

`SYMBOL: name` declares one; `SYMBOLS: a b c ;` declares several.

[unicode]: https://docs.factorcode.org/content/vocab-unicode.html
2 changes: 1 addition & 1 deletion exercises/concept/character-study/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"forked_from": [
"common-lisp/character-study"
],
"blurb": "Learn about Unicode-aware character handling by helping a Lisp Alien with their alphabets project."
"blurb": "Learn about Unicode-aware character handling by helping a Forth Alien with her alphabets project."
}
29 changes: 29 additions & 0 deletions exercises/practice/binary-search/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Instructions

Your task is to implement a binary search algorithm.

A binary search algorithm finds an item in a list by repeatedly splitting it in half, only keeping the half which contains the item we're looking for.
It allows us to quickly narrow down the possible locations of our item until we find it, or until we've eliminated all possible locations.

~~~~exercism/caution
Binary search only works when a list has been sorted.
~~~~

The algorithm looks like this:

- Find the middle element of a _sorted_ list and compare it with the item we're looking for.
- If the middle element is our item, then we're done!
- If the middle element is greater than our item, we can eliminate that element and all the elements **after** it.
- If the middle element is less than our item, we can eliminate that element and all the elements **before** it.
- If every element of the list has been eliminated then the item is not in the list.
- Otherwise, repeat the process on the part of the list that has not been eliminated.

Here's an example:

Let's say we're looking for the number 23 in the following sorted list: `[4, 8, 12, 16, 23, 28, 32]`.

- We start by comparing 23 with the middle element, 16.
- Since 23 is greater than 16, we can eliminate the left half of the list, leaving us with `[23, 28, 32]`.
- We then compare 23 with the new middle element, 28.
- Since 23 is less than 28, we can eliminate the right half of the list: `[23]`.
- We've found our item.
13 changes: 13 additions & 0 deletions exercises/practice/binary-search/.docs/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Introduction

You have stumbled upon a group of mathematicians who are also singer-songwriters.
They have written a song for each of their favorite numbers, and, as you can imagine, they have a lot of favorite numbers (like [0][zero] or [73][seventy-three] or [6174][kaprekars-constant]).

You are curious to hear the song for your favorite number, but with so many songs to wade through, finding the right song could take a while.
Fortunately, they have organized their songs in a playlist sorted by the title — which is simply the number that the song is about.

You realize that you can use a binary search algorithm to quickly find a song given the title.

[zero]: https://en.wikipedia.org/wiki/0
[seventy-three]: https://en.wikipedia.org/wiki/73_(number)
[kaprekars-constant]: https://en.wikipedia.org/wiki/6174_(number)
Loading