TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Checkerboard Programming – write code to match checkerboard patterns

40 pointsby andersourceover 3 years ago

9 comments

k_over 3 years ago
Cool! I think I would have liked it more with shorter names by default, but that&#x27;s nothing really.<p>Ended up with a quick solution to all problems so I can go back to work. Please forgive me<p>function draw_checkerboard(board) { var res = document.querySelectorAll(&#x27;#goal-checkers-group rect&#x27;); var len = Math.sqrt(res.length); for (var row = 0; row &lt; len; row++) { for (var col = 0; col &lt; len; col++) { board[row][col] = res[col + row * len].className.baseVal; } } }<p>Edit: forgot that col&#x2F;row size wasn&#x27;t fixed<p>Edit 2: &gt; Well, that&#x27;s the end of this small journey.<p>Not that small of a journey actually, quite a lot of interesting puzzles. Good job!
评论 #28627500 未加载
mozz100over 3 years ago
Really fun idea and a great implementation. I have been trying to come up with programming puzzles for my own project <a href="https:&#x2F;&#x2F;www.dev-esc.com" rel="nofollow">https:&#x2F;&#x2F;www.dev-esc.com</a> - an escape room for devs<p>My own “Show HN” is at <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=28579191" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=28579191</a><p>andersource would you be willing to consider letting me incorporate something like a checkerboard puzzle?<p>Have you any metrics on average completion times etc? Striking the right balance between fun vs difficult has proved tricky for me.
评论 #28626275 未加载
ghbakirover 3 years ago
Love it! It reminds a bit on this mehanical programming game <a href="https:&#x2F;&#x2F;www.turingtumble.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.turingtumble.com&#x2F;</a><p>where you have to reconstruct a marble pattern with logical gates controlling how the marbles flow.<p>Will try this with my daughter next time.
评论 #28625721 未加载
Tronchenbiaisover 3 years ago
I just finished solving the puzzles. Overall I really enjoyed the game.<p>The only thing I did not like was that for certain puzzles, such as the Ying-Yang one, coming up with an idea that will solve the puzzle is quite straight forward, but figuring out the parameters you used for some of the curves can take a long time.<p>The Ying-Yang problem has no hints and I had to use two different sine waves for the upper half and the bottom half of the screen, just because I couldn&#x27;t guess which one you used. I also tried solving the &quot;spiraling into control&quot; one without looking at the hints, and was unable to.
评论 #28628998 未加载
mgdlbpover 3 years ago
Indeed, when attempting to use the initial nested loop as much as possible, its body essentially becomes a pixel shader.<p>I was reminded of one of my earliest side projects, a Mandelbrot set renderer; amusing that the last exercise is exactly that.
nitrogenover 3 years ago
Nice, this looks like a good way to practice basic looping and operators. Has anyone just hard-coded the target board and copied the values instead of calculating?
pandatigoxover 3 years ago
On a side note, I&#x27;m curious how the sandbox was implemented. For security issues, how does one make sure that the sandbox is not just a javascript eval?
评论 #28625710 未加载
评论 #28625620 未加载
pizzabearmanover 3 years ago
Cool idea. Was having issues with phone
评论 #28625556 未加载
milanjover 3 years ago
I&#x27;d love to see some solutions so I can learn how you&#x27;re intended to solve these.
评论 #28629048 未加载