Yesterday, I wrote an algorithm
Yesterday, I wrote an algorithm. It made me realise that I don't do so often. Most of the time, coding is about neatly joining together technologies. If you can understand how to use $.getJSON then you're away.
In this case, I wanted to break up a 10x10 grid, extracting four blocks of different areas, the total area being less than 100. Like this:
I wanted the blocks to be as square as possible, and to each start from a corner. I'd had a go previously, but wrote an algorithm which failed, using a particular square twice. Yesterday's version, using a different approach (and less code, fewer classes) is, I believe, robust.
Have a go, if you fancy a challenge!
<< Home