Coding Challenges: 4Clojureλ︎
The website is self-contained with nothing to install, simply paste in the missing code and run the tests. One piece of code should solve all the tests for that challenge.
The Problem List shows the challenges categorized by experience level required, (Elementary, Easy, Medium, Hard) to solve them. Start with the easiest problem or work your way through the challenges in any order you wish. The Status column tracks your progress thorugh the challenges.
Select the name of a challenge to see the description and one or more code tests that must pass.
Enter the code that should be inserted where the
__ double underscore characters are.
Press the Run button to see if the code satisfies the tests
A dialog box is displayed showing how many tests have passed and failed
Start learning the Clojure API
There are over 600 functions in the
clojure.core namespace alone, with additional functions in many other namespaces that make up the https://clojure.github.io/clojure/. It is not required to learn all these functions to be productive in Clojure.
4ever-clojure replaces 4Clojure
4Ever-Clojure is a new implementation of 4Clojure.com which has now been decommissioned
Help completing the challengesλ︎
Search directly in ClojureDocs for functions. Each function has a page that describes the function, shows the arguments it takes and provides many examples of its use. At the end of the page are related functions too.
Practicalli Code walk-through and solution journal
practicalli/four-clojure code journals for the first 60 challenges contains a design journal showing how each challenge was solved and additional refactor or alternative approaches to the solution.
Practicalli 4Clojure guides playlist provides video walk-through of the first 64 challenges, again with alternative solutions where relevant.
An Internet search of
clojure topic, where
topic is a name of the thing you want to do, should return many examples of functions that could be useful to solving the challenge. Or
Help from the community
Clojure community - getting help covers several sources of help from the Clojure community.
Using let and anonymous functionsλ︎
The solution submitted should be a single form, which is inserted in the test code where the
__ underscore placeholder is. It is therefore not possible to define data with
def or a separate function with
defn to support the submitted solution.
Use the anonymous function,
(fn ), to define behaviour.
Use let to bind a name to a value, so that value can be re-used throughout the expression.
let is also useful for breaking the algorithm into smaller pieces, making it easier to solve the challenge.
It is common to combine
let to solve the challenges as they grow in complexity
My function is not workingλ︎
- Clojure Cheatsheet - Clojure.org
- Clojure API - Clojure.org
- practicalli/four-clojure code journals for the first 60 challenges
- 4Clojure video guides by Practicalli
- Clojure Core Library - ClojureDocs
- Clojure, The Essential Reference - Renzo Bogatti - Manning book published in 2020