{
  "workbooktitle": "Recursion with the monks of Mons Komputarius",
  "storytitle": "1a · The monks of Mons Komputarius",
  "sortingtitle": "1b–1g · Understanding recursion",
  "countingtitle": "2 · Applying recursion",
  "dialoguelabel": "Dialogue",
  "introduction": "A traveller is looking for a solution to his unsorted cards. The monks show him an approach in which the problem gets smaller and smaller, and the solution takes shape on the way back.\n\nThis digital version is based on the workbook dated **29 April 2025**. Read the story one picture at a time; use **Back** and **Next** to revisit each individual conversation and action. At most one person speaks in each picture: their mouth is open. **R** stands for the traveller, **M** for the head monk and **K** for the child. **...** accompanies silent actions and pauses for thought.\n\nThe cards are inserted on the left on the way back, so the finished row is sorted in **descending** order. In the sequel, the traveller counts a tower of three stones. Afterwards, you will practise a recursive drawing algorithm yourself.",
  "task1a": "Watch the computing play **“The monks of Mons Komputarius”**. Pay particular attention to what the monks do with the tray and their cards.",
  "task1b": "The monks’ work has two phases: before and after the traveller returns the tray. Describe how the problem (cards to be sorted) and the solution (sorted cards) change in each phase.",
  "recursionexplanation": "**Recursion** is a programming technique that takes a problem as a parameter. The function first simplifies the problem. It then calls itself with the simplified problem.\n\nThe general structure from the workbook can be written as follows (pseudocode):\n\n```text\nfunction solve_problem(problem):\n    if problem is already solved:                 # Base case\n        return the known solution\n    else:\n        simplification, smaller_problem =\n            simplify_problem(problem)             # Simplification\n        partial_solution = solve_problem(smaller_problem)  # Recursive call\n        solution = combine(simplification, partial_solution)\n                                                  # Combining results\n        return solution\n```\n\nObserve the code **before** and **after** the recursive call. The calling monk waits for the partial solution before he can continue.",
  "task1c": "Describe where the following elements occur in the story: **simplification**, **recursive call**, **base case**, **combining results**.",
  "task1d": "Explain why each monk has to do something at two different moments. Explain how the code shows what happens in the first phase and what happens in the second.",
  "task1e": "Using the cards as an example, describe what would happen if the base case were not at the beginning of the code.",
  "task1f": "Write the **pseudocode for the sorting algorithm**. Use the same sorting direction as in the story and mark the four components of a recursive function.",
  "task1g": "Explain why the traveller can also carry out the algorithm alone and what he means by **“I may not have enough hands … but there is plenty of room on my table.”**",
  "task2a": "Read the sequel to the play. The traveller is now back home.",
  "task2b": "Describe how the traveller proceeds, using the terms **simplification**, **recursive call**, **base case** and **combining results**.",
  "task2c": "At the start of execution, there is an empty tally sheet at the top of the table. There is nothing in the lower area. Sketch the situation with the traveller holding a tower of **3 stones**.\n\nYou can draw your sketch on paper. In the answer field, record what can be seen **at the top**, **at the bottom** and **in his hand**.",
  "task2d": "Sketch the situation that exists **immediately before each recursive call** during execution. Start with the tower of 3 stones.\n\nAdd your sketches on paper. For each call, describe in the answer field: **remaining tower | stones put down | tally sheet**.",
  "task2e": "Describe how the tally sheet can be implemented in code.",
  "task2f": "Write the **pseudocode for the traveller’s counting algorithm**.",
  "task2g": "The monks would take a different approach: rather than keeping a tally sheet beside the table, each monk would put one stone on the tray before returning it. Describe how this way of counting can be implemented in code.",
  "task2h": "**Recursive functions** are easy to write. Their execution is often harder to follow, however, because a function is rarely executed “in one go”: from its beginning to its return, without jumping elsewhere.\n\nA recursive function is usually executed “in one go” in exactly one situation. **Which situation, and why?**",
  "functionalexplanation": "A function’s implementation is called **functional** if it has no mutable state stored outside the function, such as a tally sheet.",
  "task2i": "Explain whether the monks’ and the traveller’s approaches to counting are **functional**.",
  "task2j": "Explain why implementing recursive algorithms **functionally** is often recommended.",
  "task1atitle": "Exercise 1a)",
  "task1btitle": "Exercise 1b)",
  "task1ctitle": "Exercise 1c)",
  "task1dtitle": "Exercise 1d)",
  "task1etitle": "Exercise 1e)",
  "task1ftitle": "Exercise 1f)",
  "task1gtitle": "Exercise 1g)",
  "task2atitle": "Exercise 2a)",
  "task2btitle": "Exercise 2b)",
  "task2ctitle": "Exercise 2c)",
  "task2dtitle": "Exercise 2d)",
  "task2etitle": "Exercise 2e)",
  "task2ftitle": "Exercise 2f)",
  "task2gtitle": "Exercise 2g)",
  "task2htitle": "Exercise 2h)",
  "task2ititle": "Exercise 2i)",
  "task2jtitle": "Exercise 2j)",
  "silence": "...",
  "entrancedialogue": "**R:** “Master … I seek solutions!”",
  "warningdialogue": "**M:** “That does not surprise me … anyone who rushes into action so quickly will inevitably run past every solution.”",
  "shoutdialogue": "**R:** “MASTER!”",
  "cards-demanddialogue": "**R:** “My cards! They need to be sorted!”",
  "in-deed-onedialogue": "**M:** “Indeed!”",
  "help-uncertaindialogue": "**R:** “Master, I do not know how.”",
  "help-questiondialogue": "**R:** “Could … could you help me?”",
  "help-insistentdialogue": "**R:** “Then help me!”",
  "journey-questiondialogue": "**M:** “My dear stranger … how long did you travel to get here?”",
  "journey-answerdialogue": "**R:** “By plane … 20 hours!”",
  "return-questiondialogue": "**M:** “And how long will your return journey take?”",
  "return-answerdialogue": "**R:** “… presumably 20 hours as well?”",
  "patiencedialogue": "**M:** “My dear stranger … I can show you our ways. But whether you will understand them … that I cannot promise. They are not difficult … but they require a calmness you seem to lack …”",
  "tray-instructiondialogue": "**M:** “Put the cards on the tray.”",
  "watchdialogue": "**M:** “Watch carefully and learn!”",
  "emptydialogue": "**M:** “My dear stranger … you seek solutions, yet you fail to see a solution even when it is right in front of you …”",
  "givebackdialogue": "**M:** “Stranger … give him back the tray!”",
  "sorteddialogue": "**M:** “My dear stranger. You now know our ways. Go out and use our knowledge whenever you need it. And do not worry: it does not take a temple full of monks to complete the task. Discipline and calm are quite enough!”",
  "understooddialogue": "**R:** “I understand completely! I know I can do this on my own. I may not have enough hands … but there is plenty of room on my table. Thank you, great master!”",
  "farewelldialogue": "**M:** “I see you have understood. Go now … and approach things a little more calmly in future!”",
  "familydialogue": "**K:** “Mum, Dad, look what I built!”",
  "family-father-replydialogue": "**R:** “Yes, very nice, sweetheart.”",
  "family-child-questiondialogue": "**K:** “Do you know how big it is?”",
  "family-father-hurrydialogue": "**R:** “No, but we also have to …”",
  "count-explanationdialogue": "**R:** “No, sweetheart … but I know how we can find out!”",
  "kochtitle": "3 · Programming recursion yourself: the Koch curve",
  "kochintroduction": "Now you will program your own recursive algorithm. The **Koch curve** is created by replacing each line segment with four shorter segments: the middle third becomes a triangular peak. The distance from start to finish remains **270 steps**.\n\nOpen the editor. You can work in **Python** or with your own **Snap blocks**. Use a function with the parameters **length** and **depth**, and carry it over from one exercise to the next. The preview shows the target drawing and your result. The red arrows in the template indicate directions; they are not part of the drawing.",
  "koch0title": "3a · The simple line — depth 0",
  "koch0": "Draw a horizontal line **270 steps** to the right. Write a function `koch(length, depth)`. When `depth == 0`, it draws a segment with `forward(length)` and finishes. First call it with length **270** and depth **0**. This is the **base case** of your recursive function.",
  "koch1title": "3b · A triangular peak — depth 1",
  "koch1": "Extend the same function: for a greater depth, divide the length by **3** and call `koch` **four times** with the shorter length and a depth reduced by **1**. Between calls, turn **60° left**, **120° right** and **60° left**. Draw the target curve with length **270** and depth **1**. Each of its four segments is **90 steps** long. The turtle faces right again at the end. Use recursive calls rather than four hard-coded `forward` commands.",
  "koch2title": "3c · Replacing each segment again — depth 2",
  "koch2": "Reuse your function from exercise 3b. Change only the depth of the initial call to **2**. Each of the four segments is now replaced by the same pattern again: this produces **16 segments**, each **30 steps** long. Compare your drawing with the target. Check whether you can use the same function for depths **0**, **1** and **2**. As you trace execution, ask yourself: what is simplified, when does a call end, and how do the four partial drawings form the next curve?"
}
