TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

40 点作者 andersource超过 3 年前

9 条评论

k_超过 3 年前
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 未加载
mozz100超过 3 年前
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 未加载
ghbakir超过 3 年前
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 未加载
Tronchenbiais超过 3 年前
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 未加载
mgdlbp超过 3 年前
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.
nitrogen超过 3 年前
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?
pandatigox超过 3 年前
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 未加载
pizzabearman超过 3 年前
Cool idea. Was having issues with phone
评论 #28625556 未加载
milanj超过 3 年前
I&#x27;d love to see some solutions so I can learn how you&#x27;re intended to solve these.
评论 #28629048 未加载