Who would have thought the meme is poorly thought out. Regardless, it doesn't add all of the complexity you implied. The fix is one more Boolean and updating the diagonal check
let isLowerHalf = y > maxY / 2;
let isDiagonal = x == y + isLowerHalf || x == maxX - y - isLowerHalf;
I typed it in 20 seconds on my phone on JS fiddle then had to retype it because the copy+paste doesn't work on jsfiddled mobile site and OCR are ligatures.
Chained conditionals CAN be a code smell, but when used sparingly they can help reduce cognitive complexity.
The version a beginner would make is a version with 7 or 8 separate booleans and multiple print statements which is besides the point. Logically it is the same.
Ignoring that, the person I was replying to didn't know how to do it and explicitly said it needed a bunch of extra nonsense that it did not need. They were trying to be clever and failed.
View all comments
Show parent comment
4
u/AlwaysHopelesslyLost 13h ago
If you consider booleans or an if as more than a for loop then sure? It takes 2 loops, 1 if, and 6 Boolean checks for the simple version.