Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 1
    \$\begingroup\$ @Deadcode Primarily because I would have to do an \$-1\$ after we've found \$N+1\$. So where your answer outputs \$N\$, mine outputs \$N+1\$ (excluding edge case \$0\$). \$\endgroup\$ Commented Jan 24, 2020 at 12:34
  • 1
    \$\begingroup\$ @Deadcode Also, Whitespace only has labels and jumps to labels to create loops and if-statements. The only jumps available are: jump unconditional; jump if 0; and jump it negative. Jump if positive is unfortunately not available (not really necessary, since one could use \$×-1\$ and then use the jump if neg. as alternative). Because of this I currently check whether \$(N+1)^2 - 2M^2 < 0\$ is truthy. If it is: continue the loop; if not: print \$N+1\$. \$\endgroup\$ Commented Jan 24, 2020 at 12:34
  • 1
    \$\begingroup\$ Wow, very cool that the same (or very similar) algorithm is quite fitting in both regex and Whitespace. And ≤ vs. < is of course purely a golf optimization :) If it made a difference which you used, sqrt(2) would be rational. FWIW I mis-typed the LaTeX explanation – it really is ≤ in the regex. Oh, and if this is using the same algorithm as the regex, how come this rounds up and the regex rounds down? [Edit: Oops, rewrote this comment not realizing you'd already replied to it.] \$\endgroup\$ Commented Jan 24, 2020 at 12:35
  • \$\begingroup\$ @Deadcode Ah, of course, \$<\$ vs \$\leq\$ is irrelevant, otherwise \$\sqrt{2}\$ would have been rational. Edited my answer. \$<\$ certainly saves bytes in my answer though, since I'd otherwise have to add a Duplicate, Jump if 0, and additional label which discards the duplicate before continuing with the loop (what I had in my initial 122 byter). \$\endgroup\$ Commented Jan 24, 2020 at 12:53