In this post, I’m going to explain to you how I solved the dividing a plot problem using Scala.
The description.
You’re a farmer, and you want to divide a farm plot into smaller plots. Then, you must follow the next conditions.
- All the smaller plots must be squares.
- All the smaller plots must have the same size.
- The new plots must have an area greater than zero.
This exercise is mentioned in the book Grokking Algorithms of Aditya y. Bhargava.
About the solution.
- I’m using Scala.
- I added many comments, you can disable them, by changing the value in UtilsObject.
- There are some sanity checks, there aren’t part of the solutions. They are small tests, just to make sure everything is running properly.
- You can track every recursive step in the comments.
- If you’re learning recursion, I also mentioned when the program is running a base step.
- I tried to make the code very descriptive.
- I used IntelliJ for running, a scratch file.
Últimas entradas de Gustavo Sánchez (ver todo)
- NVL in SQL Server - 2023-11-01
- ¿Que es Cake Build? - 2023-02-22
- #How to fix error: MSB4019: The imported project «Microsoft.Data.Tools.Schema.SqlTasks.targets» was not found - 2023-02-20