Skip to main content
added 63 characters in body
Source Link
Kosatka
  • 121
  • 4

Brainlove, 73 70 74 6161 35 bytes

Because brainfuck is too hard

-3 bytes by myself, rearranging the memory and fixing some bugs

+4 bytes by myself, fixing an error

-13 bytes by myself

-26 bytes by myself, actually using the Brainlove features properly.

[[->+>+<<]>[<+>-]<-]>+>>+[<<[>(>[$[-<~)>+<]!-<<+>]+>[<$[>[-]<[>+<~]<-]>++>>>+<]>]!++>>+<]>- 

Try it onlineTry it online

First computes the sum $$ S = \sum_{i=1}^n i = \frac{n(n+1)}{2} $$ and then the square root by finding the largest n for which $$ \sum_{i=1}^n 2i-1 = n^2 < S $$ The error is always $$ E= \sqrt{\frac{n(n+1)}{2}}- \frac{n}{\sqrt{2}} < \sqrt{\frac{(n+\frac{1}{2})^2}{2}} - \frac{n}{\sqrt{2}} = \frac{n+\frac{1}{2}-n}{\sqrt{2}} = \frac{\sqrt{2}}{4} $$ and it is counteracted by rounding down. It is not very golfed, since I'm not very familiar with golfing in Brainlove/brainfuck, any improvements welcome (or a bf version). It should theoretically work for unbound cells (arbitrary precision), but I didn't have an option to test that. The input and output are on position 0 and 42 on tape, respectively.

Brainlove, 73 70 74 61 bytes

Because brainfuck is too hard

-3 bytes by myself, rearranging the memory and fixing some bugs

+4 bytes by myself, fixing an error

-13 bytes by myself

[[->+>+<<]>[<+>-]<-]>+>>+[<<[>(>-<~)-<<+>-]<[>+<-]>++>>>+<]>- 

Try it online

First computes the sum $$ S = \sum_{i=1}^n i = \frac{n(n+1)}{2} $$ and then the square root by finding the largest n for which $$ \sum_{i=1}^n 2i-1 = n^2 < S $$ The error is always $$ E= \sqrt{\frac{n(n+1)}{2}}- \frac{n}{\sqrt{2}} < \sqrt{\frac{(n+\frac{1}{2})^2}{2}} - \frac{n}{\sqrt{2}} = \frac{n+\frac{1}{2}-n}{\sqrt{2}} = \frac{\sqrt{2}}{4} $$ and it is counteracted by rounding down. It is not very golfed, since I'm not very familiar with golfing in Brainlove/brainfuck, any improvements welcome (or a bf version). It should theoretically work for unbound cells (arbitrary precision), but I didn't have an option to test that. The input and output are on position 0 and 4 on tape, respectively.

Brainlove, 73 70 74 61 35 bytes

Because brainfuck is too hard

-3 bytes by myself, rearranging the memory and fixing some bugs

+4 bytes by myself, fixing an error

-13 bytes by myself

-26 bytes by myself, actually using the Brainlove features properly.

[$[->+<]!-]+>[<$[>[-~]<-]!++>>+<]>- 

Try it online

First computes the sum $$ S = \sum_{i=1}^n i = \frac{n(n+1)}{2} $$ and then the square root by finding the largest n for which $$ \sum_{i=1}^n 2i-1 = n^2 < S $$ The error is always $$ E= \sqrt{\frac{n(n+1)}{2}}- \frac{n}{\sqrt{2}} < \sqrt{\frac{(n+\frac{1}{2})^2}{2}} - \frac{n}{\sqrt{2}} = \frac{n+\frac{1}{2}-n}{\sqrt{2}} = \frac{\sqrt{2}}{4} $$ and it is counteracted by rounding down. It is not very golfed, since I'm not very familiar with golfing in Brainlove/brainfuck, any improvements welcome (or a bf version). It should theoretically work for unbound cells (arbitrary precision), but I didn't have an option to test that. The input and output are on position 0 and 2 on tape, respectively.

deleted 153 characters in body
Source Link
Kosatka
  • 121
  • 4

Brainlove, 73 70 74 61 bytes

Because brainfuck is too hard

-3 bytes by myself, rearranging the memory and fixing some bugs

+4 bytes by myself, fixing an error

-13 bytes by myself

[[->+>+<<]>[<+>-]<-]>+>>+[<<[>(>-<~)-<<+>-]<[>+<-]>++>>>+<]>- 

Try it onlineTry it online

First computes the sum $$ S = \sum_{i=1}^n i = \frac{n(n+1)}{2} $$ and then the square root by finding the largest n for which $$ \sum_{i=1}^n 2i-1 = n^2 < S $$ The error is always $$ E= \sqrt{\frac{n(n+1)}{2}}- \frac{n}{\sqrt{2}} < \sqrt{\frac{(n+\frac{1}{2})^2}{2}} - \frac{n}{\sqrt{2}} = \frac{n+\frac{1}{2}-n}{\sqrt{2}} = \frac{\sqrt{2}}{4} $$ and it is counteracted by rounding down. It is not very golfed, since I'm not very familiar with golfing in Brainlove/brainfuck, any improvements welcome (or a bf version). It should theoretically work for unbound cells (arbitrary precision), but I didn't have an option to test that. The input and output are on position 0 and 4 on tape, respectively.

Unary output version, can handle printing numbers bigger than 10

Brainlove, 73 70 74 61 bytes

Because brainfuck is too hard

-3 bytes by myself, rearranging the memory and fixing some bugs

+4 bytes by myself, fixing an error

-13 bytes by myself

[[->+>+<<]>[<+>-]<-]>+>>+[<<[>(>-<~)-<<+>-]<[>+<-]>++>>>+<]>- 

Try it online

First computes the sum $$ S = \sum_{i=1}^n i = \frac{n(n+1)}{2} $$ and then the square root by finding the largest n for which $$ \sum_{i=1}^n 2i-1 = n^2 < S $$ The error is always $$ E= \sqrt{\frac{n(n+1)}{2}}- \frac{n}{\sqrt{2}} < \sqrt{\frac{(n+\frac{1}{2})^2}{2}} - \frac{n}{\sqrt{2}} = \frac{n+\frac{1}{2}-n}{\sqrt{2}} = \frac{\sqrt{2}}{4} $$ and it is counteracted by rounding down. It is not very golfed, since I'm not very familiar with golfing in Brainlove/brainfuck, any improvements welcome (or a bf version). It should theoretically work for unbound cells (arbitrary precision), but I didn't have an option to test that. The input and output are on position 0 and 4 on tape, respectively.

Unary output version, can handle printing numbers bigger than 10

Brainlove, 73 70 74 61 bytes

Because brainfuck is too hard

-3 bytes by myself, rearranging the memory and fixing some bugs

+4 bytes by myself, fixing an error

-13 bytes by myself

[[->+>+<<]>[<+>-]<-]>+>>+[<<[>(>-<~)-<<+>-]<[>+<-]>++>>>+<]>- 

Try it online

First computes the sum $$ S = \sum_{i=1}^n i = \frac{n(n+1)}{2} $$ and then the square root by finding the largest n for which $$ \sum_{i=1}^n 2i-1 = n^2 < S $$ The error is always $$ E= \sqrt{\frac{n(n+1)}{2}}- \frac{n}{\sqrt{2}} < \sqrt{\frac{(n+\frac{1}{2})^2}{2}} - \frac{n}{\sqrt{2}} = \frac{n+\frac{1}{2}-n}{\sqrt{2}} = \frac{\sqrt{2}}{4} $$ and it is counteracted by rounding down. It is not very golfed, since I'm not very familiar with golfing in Brainlove/brainfuck, any improvements welcome (or a bf version). It should theoretically work for unbound cells (arbitrary precision), but I didn't have an option to test that. The input and output are on position 0 and 4 on tape, respectively.

added 15 characters in body
Source Link
Kosatka
  • 121
  • 4

Brainlove, 73 70 7474 61 bytes

Because brainfuck is too hard

-3 bytes by myself, rearranging the memory and fixing some bugs

+4 bytes by myself, fixing an error

-13 bytes by myself

(>>>-<<<~)[[->+>+<<]>[<+>-]<-]>+>>+[<<[>-(>-<~)-<<+>-]<[>+<-]>++>>>+<]>[]>++>>>+<]>-~] 

Try it onlineTry it online

First computes the sum $$ S = \sum_{i=1}^n i = \frac{n(n+1)}{2} $$ and then the square root by finding the largest n for which $$ \sum_{i=1}^n 2i-1 = n^2 < S $$ The error is always $$ E= \sqrt{\frac{n(n+1)}{2}}- \frac{n}{\sqrt{2}} < \sqrt{\frac{(n+\frac{1}{2})^2}{2}} - \frac{n}{\sqrt{2}} = \frac{n+\frac{1}{2}-n}{\sqrt{2}} = \frac{\sqrt{2}}{4} $$ and it is counteracted by rounding down. It is not very golfed, since I'm not very familiar with golfing in Brainlove/brainfuck, any improvements welcome (or a bf version). It should theoretically work for unbound cells (arbitrary precision), but I didn't have an option to test that. The input and output are on position 0 and 4 on tape, respectively.

Unary output version, can handle printing numbers bigger than 10Unary output version, can handle printing numbers bigger than 10

Brainlove, 73 70 74 bytes

Because brainfuck is too hard

-3 bytes by myself, rearranging the memory and fixing some bugs

+4 bytes by myself, fixing an error

(>>>-<<<~)[[->+>+<<]>[<+>-]<-]>+>>+[<<[>-(>-<~)<<+>-]<[>+<-]>++>>>+<]>[-~] 

Try it online

First computes the sum $$ S = \sum_{i=1}^n i = \frac{n(n+1)}{2} $$ and then the square root by finding the largest n for which $$ \sum_{i=1}^n 2i-1 = n^2 < S $$ The error is always $$ E= \sqrt{\frac{n(n+1)}{2}}- \frac{n}{\sqrt{2}} < \sqrt{\frac{(n+\frac{1}{2})^2}{2}} - \frac{n}{\sqrt{2}} = \frac{n+\frac{1}{2}-n}{\sqrt{2}} = \frac{\sqrt{2}}{4} $$ and it is counteracted by rounding down. It is not very golfed, since I'm not very familiar with golfing in Brainlove/brainfuck, any improvements welcome (or a bf version). It should theoretically work for unbound cells (arbitrary precision), but I didn't have an option to test that.

Unary output version, can handle printing numbers bigger than 10

Brainlove, 73 70 74 61 bytes

Because brainfuck is too hard

-3 bytes by myself, rearranging the memory and fixing some bugs

+4 bytes by myself, fixing an error

-13 bytes by myself

[[->+>+<<]>[<+>-]<-]>+>>+[<<[>(>-<~)-<<+>-]<[>+<-]>++>>>+<]>- 

Try it online

First computes the sum $$ S = \sum_{i=1}^n i = \frac{n(n+1)}{2} $$ and then the square root by finding the largest n for which $$ \sum_{i=1}^n 2i-1 = n^2 < S $$ The error is always $$ E= \sqrt{\frac{n(n+1)}{2}}- \frac{n}{\sqrt{2}} < \sqrt{\frac{(n+\frac{1}{2})^2}{2}} - \frac{n}{\sqrt{2}} = \frac{n+\frac{1}{2}-n}{\sqrt{2}} = \frac{\sqrt{2}}{4} $$ and it is counteracted by rounding down. It is not very golfed, since I'm not very familiar with golfing in Brainlove/brainfuck, any improvements welcome (or a bf version). It should theoretically work for unbound cells (arbitrary precision), but I didn't have an option to test that. The input and output are on position 0 and 4 on tape, respectively.

Unary output version, can handle printing numbers bigger than 10

added 66 characters in body
Source Link
Kosatka
  • 121
  • 4
Loading
added 84 characters in body
Source Link
Kosatka
  • 121
  • 4
Loading
added 22 characters in body
Source Link
Kosatka
  • 121
  • 4
Loading
added 210 characters in body
Source Link
Kosatka
  • 121
  • 4
Loading
added 151 characters in body
Source Link
Kosatka
  • 121
  • 4
Loading
edited body
Source Link
Kosatka
  • 121
  • 4
Loading
Source Link
Kosatka
  • 121
  • 4
Loading