Halรฒ a charaid! ๐
The Spanish did NOT go home. We stayed, refactored the whole thing, and now the French border patrol is asking us for immigration advice.
Turns out this puzzle isn't about Java or C++ or even Py/TS. It's about one simple abstraction:
interface Shape {
color: string;
canMove(direction: Direction, board: Board): boolean;
blocks(other: Shape): boolean;
interactsWith(other: Shape): Interaction;
}
class UShape implements Shape {
constructor(public color: string) {}
// ... you know the rest
}
class Puzzle {
private shapes: Shape[] = [];
addShape(shape: Shape) {
this.shapes.push(shape); // โ arbitrary, baby
}
}
The French claimed "even a configurable in-memory list can't work". But that's because they were thinking in if (color === "black") blocks instead of polymorphism.
The cyclomatic complexity doesn't grow with the number of shapes. It stays at O(1) when you invert the dependency correctly.
TL;DR: List<Shape> exists. The Spanish Empire of Abstraction stands undefeated. ๐ช๐ธ
Thanks for the fun puzzle โ this is exactly the kind of thinking that separates "it works" from "it scales". Also, your Scottish Gaelic intro made my week. Tapadh leibh!
Nos vemos en el siguiente reto ๐งฉ
Top comments (6)
@francistrdev @sloan one of you, or your low quality code deleted a comment of the author.
He simply stated my name in his comment.
Guy is a newcomer.
He's solving a puzzle.
I fully understand that you guys do not value humans, but instead love llms and daredevil gifs.
But please do not eradicate humans from the platform.
Please grow up as a person, and work on your EQ, and try using less underclothed waifus please.
Also please try removing gmail/binance seller articles.
Also please try removing hidden affiliate linked articles, or at least warn the author.
Also please scan seemingly linear programming related articles, whether they lead to unsavory sites.
Please do your work, instead of letting skynet delete the comment of a well meaning and brave Spanish developer, aka the author of this very article.
Thank you!
Moderation on this platform is so bad that I have to call you out to NOT remove humans, and to REMOVE account sellers.
I mean... please... pretty please.
Stop for a second, put down that keyboard, and think about it for 5 seconds.
Do you want to live in a world like this?
Honestly?
What is this good for?
What is your end goal?
What bigger philosophy do you have?
I do not see anything else than negligence on a level which simply baffles me.
Put the daredevil nonsense and waifu pics on top, and...
Honestly I want to believe that you are good people inside...
but, oh boy, you make it hard... boy you make this really hard to imagine sometimes.
Oh nono. Nono ๐
I want to see the full code related to business logic.
That is when the problem starts surfacing.
That is when the Math starts.
@yosoyignicion The real problem is the 'business lgoic', aka:
How do you ensure over the 2D grid that the game rules are adhered.
There are a lot of cases:
There are relations.
These relations are transitive.
This game is about a transitive closure.
The hardcoding of the original game - the Java I linked from some unknown person - is said to be a 'naive solution' because it took a very specific case of this puzzle, and - instead of solving the closure - it hardcoded the actual relationships and the closure as complex forests of
ifs.This naive way only works if the count of U-shapes is low.
As the count of U-shapes increase you'll get more and more cases (think like 'edge cases').
Eventually the if forest will grow so big, that a human cannot do it.
This is the beast: cyclomatic complexity.
Some comments may only be visible to logged-in visitors. Sign in to view all comments.