@@ -37,6 +37,12 @@ there are no difference - apart from this very cell - between the teacher and th
3737
3838## problem statement
3939
40+ ``` {image} media/puzzle8-solving.gif
41+ :align: right
42+ :width: 250px
43+ ```
44+
45+
4046the puzzle is a 3x3 board with 8 tiles numbered from 1 to 8, and a hole (that we
4147note ` 0 ` or ` - ` depending on the context).
4248the hole is free to swap with any of the up to 4 adjacent tiles (no diagonal move); here's an example
@@ -383,8 +389,16 @@ one common mistake by first-timers is to
383389
384390# ## page.update()
385391
386- also, as explained in the library documentation, dont' forget to add `page.update()` whenever necessary
387- without a call to this function, your changes will remain in memory and won' t be reflected on the actual screen !
392+ also, as explained in the library documentation, don' t forget to add `page.update()` whenever necessary
393+ (you can also call update() on an inner widget if that' s more convenient)
394+ but without a call to this function, your changes will remain in memory and won' t be reflected on the actual screen !
395+
396+ ```{admonition} do not overuse
397+ :class : dropdown
398+
399+ because this function actually involves updating the display, this is a relatively slow operation,
400+ so make sure to not call it too often either !
401+ ```
388402
389403++ +
390404
@@ -442,6 +456,7 @@ with our convention that the goal is "1 2 3 4 5 6 7 8 0", here's a sample of
442456boards with their respective shortest distance; the last one is unreachable
443457
444458```python
459+ # here are a few solvable problems, with their minimal distance to the goal
445460problems = []
446461problems.append((" 1 2 3 4 5 6 7 0 8" , 1 ))
447462problems.append((" 1 2 3 4 5 6 0 7 8" , 2 ))
@@ -455,7 +470,7 @@ problems.append(("6 1 8 3 4 5 7 0 2", 21))
455470problems.append((" 6 1 5 7 0 8 4 2 3" , 24 ))
456471problems.append((" 6 1 4 5 3 0 8 2 7" , 27 ))
457472problems.append((" 8 6 7 5 0 1 3 2 4" , 30 ))
458- # not reachable
473+ # this one is not reachable
459474problems.append((" 6 1 7 4 5 2 3 8 0" , float (' inf' )))
460475```
461476
@@ -612,5 +627,5 @@ the full documentation is here:
612627 first lines)
613628
614629using this information, you can identify the bottleneck functions, and then focus on optimizing them
615- this is how for example how I was able to discard numpy arrays as a possible representation for the boards,
630+ this is how for example how I was able to discard numpy arrays as a possible representation for the boards,
616631as profiling showed that they were incurring a significant overhead - the way I was using them at least
0 commit comments