u/TotalUnlucky2814

Have you quick or merge sorted 🌻or🌵?? So far I have used the game to teach O(n^2) at school...

Have you quick or merge sorted 🌻or🌵?? So far I have used the game to teach O(n^2) at school...

Hey everyone! I’m a CS teacher, and for this new school year, I decided to change the "static" whiteboards and use The Farmer Was Replaced to teach Python and real coding logic.

The game has proven to be a fantastic sandbox for exploring sorting algorithms. So far, in my classes (and videos), we have successfully implemented both Bubble Sort and Insertion Sort from scratch to optimize the drone's cactus and sunflower harvests, mapping the data using tuples (no dictionaries just yet). You could also easily implement a Selection Sort for this task without much trouble.

However, all of these algorithms have a time complexity of O(n^2). They work perfectly fine for the small grid constraints of the game, but it got me thinking about pushing the limits for huge farms (for example via mod where you can have custom grid sizes)

So, here is my question for the community: Has anyone here managed to implement a Quick Sort or a Merge Sort within the game? If yes, was it worth it?

I'm really curious to know if the O(n \log n) efficiency actually makes a noticeable difference in the game's execution time, or if the overhead makes it impractical for the drone.

Idk if the following lines count as self promotion but.. if you are learning Python, brushing up on your data structures, or just want to see how to code an Insertion Sort purely "by hand", here is the link to the vido explanation (original audio is in spanish, but there is an english translation)

🌻 https://youtu.be/4-M9qHaSa5Q

🌵https://youtu.be/ffkjLm7jPvE

I'd love to read your experienceson the Quick Sort / Merge Sort challenge for the drone.

u/TotalUnlucky2814 — 12 days ago