We look at 7 different solutions to Exercism's Minesweeper exercise - exploring solutions using nested loops, clever use of min/max to simplify bounds checking, functional pipelines and using two-dimensional matrices in Julia, C++, F#, Rust, Ruby, Crystal, and Java.
Kick back and enjoy 30mins of learning with Jeremy and Erik, then go solve the exercise in your favourite way on Exercism.
Solve the exercise at: https://exercism.org/exercises/minesweeper
Join #48in24 at: https://exercism.org/challenges/48in24
Featured solutions:
- https://exercism.org/tracks/cpp/exercises/minesweeper/solutions/iota-dev
- https://exercism.org/tracks/java/exercises/minesweeper/solutions/sjwarner-bp
- https://exercism.org/tracks/rust/exercises/minesweeper/solutions/kstep
- https://exercism.org/tracks/crystal/exercises/minesweeper/solutions/ryanplusplus
- https://exercism.org/tracks/julia/exercises/minesweeper/solutions/jbertovic
- https://exercism.org/tracks/fsharp/exercises/minesweeper/solutions/JDiLenarda
- https://exercism.org/tracks/ruby/exercises/minesweeper/solutions/iHiD
Timestamps:
00:00:00 Introduction
00:00:45 C++: for loops and indexing
00:06:25 Java: for loops with StringBuilder and min/max for simplified bounds checking
00:10:31 Rust: functional pipeline using map, filter and neighbor deltas
00:15:51 Crystal: function pipeline and string translate method to replace chars
00:20:07 Ruby: Starting with the mines
00:24:46 Julia: convert to 2D matrix and iterate over mines and update neighbors
00:31:07 F#: use Array2D type and extra padding for easy bounds checking
00:39:26 Conclusion