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*
- 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\$Kevin Cruijssen– Kevin Cruijssen2020-01-24 12:34:23 +00:00Commented 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\$Kevin Cruijssen– Kevin Cruijssen2020-01-24 12:34:51 +00:00Commented 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\$Deadcode– Deadcode2020-01-24 12:35:19 +00:00Commented 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\$Kevin Cruijssen– Kevin Cruijssen2020-01-24 12:53:07 +00:00Commented Jan 24, 2020 at 12:53
Add a comment |
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
- MathJax equations
\$\sin^2 \theta\$
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. code-golf), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you