Skip to content

Commit

Permalink
Add advance exercise fibonacci
Browse files Browse the repository at this point in the history
  • Loading branch information
Chemaclass committed Apr 19, 2024
1 parent 91386ad commit bcbec35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions content/tutorials/exercises/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,24 @@ title = "Advanced"
weight = 4
+++

{% question() %}
Implement a `fibonacci` function.
{% end %}
{% solution() %}
```phel
(defn fib [n]
(loop [fib-nums [0 1]]
(if (>= (count fib-nums) n)
(slice fib-nums 0 n)
(let [[n1 n2] (reverse fib-nums)]
(recur (push fib-nums (+ n1 n2)))))))
```
{% end %}

{% question() %}
Print the five most used words from a book. For better results it is useful to remove the most common
words in the language the book was written in (these are called "[stop words](https://en.wikipedia.org/wiki/Stop_word)").
Print the five most used words from a book.

> For better results, it is useful to remove the most common words in the language the book was written in (these are called "[stop words](https://en.wikipedia.org/wiki/Stop_word)").
Some tips:
1) Save the book content in a variable
Expand Down
2 changes: 1 addition & 1 deletion templates/shortcodes/question.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="question" id="number-{{ nth }}">
{% set questionNumber = '<b>Question ' ~ nth ~ ': </b>' %}
{% set questionNumber = '<b>Exercise ' ~ nth ~ ': </b>' %}

{{ questionNumber ~ body | markdown | safe }}
</div>

0 comments on commit bcbec35

Please sign in to comment.