37
\$\begingroup\$

Note: This is the cops' thread, where one should post the scrambled code. Here is the robbers' thread where the cracked source should be posted and linked to the cop's answer.


Task: Write the shortest safe program which multiplies the square root of an integer n by the square of n

This is , so the rules are:

  • In your answer, post a scrambled version of your source code (the characters should be written in any order). The scrambled version should not work!
  • You can take input in any standard way, the same goes for output. Hardcoding is forbidden
  • After the code is cracked by the robbers (if this happens), you must mention that your code has been cracked in your title and add a spoiler to your answer's body with your exact code
  • The same applies to safe answers (mention that it's safe and add the spoiler)
  • The code is considered safe if nobody has cracked it in 5 days after posting it and you can optionally specify that in the title
  • You must specify your programming language
  • You should specify your byte count
  • You must state the rounding mechanism in your answer (see below)

You can assume that the result is lower than 232 and n is always positive. If the result is an integer, you must return the exact value with or without a decimal point; otherwise the minimum decimal precision will be 3 decimal places with any rounding mechanism of your choice, but can include more. You must state the rounding mechanism in your answer. You are not allowed to return as fractions (numerator, denominator pairs - sorry, Bash!)

Examples:

In -> Out

4 -> 32.0 (or 32)
6 -> 88.18163074019441 (or 88.182 following the rules above)
9 -> 243.0
25 -> 3125.0

The shortest safe answer by the end of April will be considered the winner.

\$\endgroup\$
26
  • 2
    \$\begingroup\$ Related. (Same CnR rules, different task.) \$\endgroup\$ Commented Apr 3, 2017 at 12:57
  • 3
    \$\begingroup\$ @MartinEnder If the task is the only thing differing, then isn't it a duplicate? \$\endgroup\$ Commented Apr 3, 2017 at 14:48
  • 1
    \$\begingroup\$ @NathanMerrill I don't know, I don't think we have any established duplicate guidelines for cops and robbers challenge, but if I ask a new code-golf challenge, where the "only" thing that's different from a previous code golf is the task, it's usually not considered a duplicate. ;) (That said, I agree that CnRs are probably more interesting if we change up the CnR-part of the challenge, not the underlying task.) \$\endgroup\$ Commented Apr 3, 2017 at 14:50
  • 1
    \$\begingroup\$ Good luck everyone! I am really glad that you have decided to reopen this. Looking forward to see interesting answers! \$\endgroup\$
    – Mr. Xcoder
    Commented Apr 3, 2017 at 15:23
  • 2
    \$\begingroup\$ I had written my code to work for an input up to 2^32... Which is why I asked about rounding errors, got rather off the mark at that point \$\endgroup\$ Commented Apr 3, 2017 at 16:19

68 Answers 68

2
\$\begingroup\$

05AB1E, 35 bytes

ö£=s‰sr2xöR+RM0`.T"YVBYCDž„¨¨"6£H-L

This one took me a while to make.

There's some double quotes in there, so you can surround as much of the code as you want in them.

No rounding, decimal point precision.

\$\endgroup\$
2
\$\begingroup\$

Fireball, 8 bytes (Cracked by Roman Gräf)

♥1Z*^²/♥

Does not round, uses floating point precision.

Code surrounded with hearts ;)

Should pretty easy to crack, once you have a look into Fireball.

\$\endgroup\$
1
2
\$\begingroup\$

C#, 112 bytes (cracked by Emigna)

     ((((())))),.....25;;;=CCLMMPPPRSWaaaaaaabbbccdddeeeeeeeeghiiiiiillllmnnnnnooooooorrrsssssssstttttuuvvwy{{}}

no rounding done

using System;
class P
{
    static void Main()
    {
        var b=double.Parse(Console.ReadLine());
        Console.Write(Math.Pow(b,2.5));
    }
}
\$\endgroup\$
3
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Emigna
    Commented Apr 4, 2017 at 8:48
  • \$\begingroup\$ You are free to add more cops if you have more ideas, but you should post them in separate answers instead of adding to an existing one. \$\endgroup\$
    – Emigna
    Commented Apr 6, 2017 at 9:31
  • \$\begingroup\$ Ok: codegolf.stackexchange.com/a/115492/67504 \$\endgroup\$
    – Jan Ivan
    Commented Apr 6, 2017 at 9:40
2
\$\begingroup\$

NO!, 41 bytes (Cracked by Emigna)

NOOO! NO! can finally compete! Although no-one will be bothered to crack this anyway :(

Anyway sigh here's the code:

NNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO??
nnno!

Full list of commands here. Coded in Python so uses Python rounding.

NOOOOOOOOO!!!!!!!! Someone cracked it. (Curse you Emigna!) (just kidding!)

\$\endgroup\$
8
  • \$\begingroup\$ Introducing a new language will be fun ... Cannot wait ro strugle to crack it😂 \$\endgroup\$
    – Mr. Xcoder
    Commented Apr 4, 2017 at 18:04
  • \$\begingroup\$ Post another answer to NOT! mess up the two @ThisGuy \$\endgroup\$
    – Mr. Xcoder
    Commented Apr 4, 2017 at 18:58
  • \$\begingroup\$ I think you mean "consonants" in your documentation (not constants). \$\endgroup\$
    – Dave
    Commented Apr 5, 2017 at 19:37
  • \$\begingroup\$ @Dave D'oh! 🙃☺️ \$\endgroup\$ Commented Apr 5, 2017 at 19:41
  • \$\begingroup\$ hmm, what's the canonical version of your interpreter for this challenge? Current master doesn't compile due to a typo on line 162 (there's also a typo on line 163 and missing self. on 149). \$\endgroup\$
    – Dave
    Commented Apr 5, 2017 at 20:03
2
\$\begingroup\$

C, 115 bytes, (Cracked by @tehtmi)

""%&&((((((()))))))******++++,..//01122233388;;;;;;<====>>   bbbdddeeeefffggillllllllllnnnnnnnnoooooooooooprrtuuu{}

Notice that it does include 3 spaces.

Always outputs 3 exact decimals, rounded to the closest thousandth.

Should be rather fun to crack as it doesn't involve any built-in to compute powers or square roots, as opposed to most (cracked) solutions so far.

Example run (which also gives you a few small hints):

int main() {
  int n[] = {4, 6, 9, 25};
  for (int i = 0; i < 4; i++) {
    printf("%i => ", n[i]);
    o(n[i]);
    printf("\n");
  }
}

outputs:

4 => 32.000
6 => 88.182
9 => 243.000
25 => 3125.000

Tested with both gcc and clang, with no compilation flag needed.


It's been cracked; the original solution was

o(double n){long o=2.303e18+(*(long*)&n>>1);double l=*(double*)&o;for(o=2;o++<8;)l=(l+n/l)/2;printf("%.3f",l*n*n);}

which uses a magic constant in the same spirit as the infamous fast inverse square root algorithm to do just a handful of Newton iterations (as opposed to several thousands in the cracked solution)

\$\endgroup\$
3
  • \$\begingroup\$ It could actually be 3 bytes shorter, at a cost of completely sacrificing performance though :) (as in, becomes really, really slow) \$\endgroup\$ Commented Apr 5, 2017 at 1:58
  • \$\begingroup\$ Crack? Probably not exactly what you're going for, but maybe similar and I think it is okay. \$\endgroup\$
    – tehtmi
    Commented Apr 6, 2017 at 8:25
  • \$\begingroup\$ @tehtmi not quite, see my comment there (your solution does not return correctly for input 0) \$\endgroup\$ Commented Apr 6, 2017 at 17:00
2
\$\begingroup\$

05AB1E, 23 bytes (Cracked by Emigna)

A totally different approach than my previous answers :)

$++/02;@DDDGHP\rrszz}¹ž

No rounding.

Example runs

In   -> Out
0    -> 0
4    -> 32.0
6    -> 88.18163074019441
25   -> 3125.0
7131 -> 4294138928.8967724
\$\endgroup\$
4
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Emigna
    Commented Apr 7, 2017 at 16:51
  • \$\begingroup\$ Dammit :-D ! This wasn't the intended solution, mine was $žHGDzrDz0@+2s/r+;}\¹DP, using the convergent sequences u_0 = 1, v_0 = x, u_(n+1) = 2 / (1/u_n + 1/v_n), v_(n+1) = (u_n + v_n) /2 to compute the square root. But very well done! \$\endgroup\$ Commented Apr 7, 2017 at 17:14
  • \$\begingroup\$ The thing is, it's hard to come up with an approximation method that can't be tweaked back into Newtons' iterations, mmh... \$\endgroup\$ Commented Apr 7, 2017 at 17:15
  • \$\begingroup\$ Oooh, that was a cool implementation. I figured my crack wasn't the intended :) \$\endgroup\$
    – Emigna
    Commented Apr 7, 2017 at 17:19
2
\$\begingroup\$

Excel VBA, 59 bytes (Safe)

?(())*..//11124AAAAFPSW[[]]^acceehiiiiklnnnnoooppqrrstttttu

No particular rounding.
Uses the Immediate Window.

\$\endgroup\$
2
\$\begingroup\$

Octave, 42 bytes (Safe)

((((()))))+,,,-//01111111@[]^mnooorrssst~~

No rounding. Floating point accuracy.

Intended solution

@(s)norm(roots([-1,~1,s^(10/(1+1))]),1/~1)

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Was this close? f=@(s)s^norm(roots([1,2.5,1]),1)? I didn't find a way to make those remaining numbers and +-~~ become 2.5. I had some other attempts that were quite similar (changed the numbers a bit), but I couldn't get it correct. \$\endgroup\$ Commented Apr 8, 2017 at 17:56
  • \$\begingroup\$ @StewieGriffin It was! I have posted the intended solution \$\endgroup\$
    – Luis Mendo
    Commented Apr 9, 2017 at 2:07
2
\$\begingroup\$

Lua 5.3, 110 bytes (safe)

((((()))))**,,,,,-....=====>~             aaaaaaaaacddddeeeffhhhiiiiiiilllmmnnnnnnooopppppprrrrrrrsssssssstttt

Calculations are standard using Lua numbers (ie double in common implementations). Tested using PUC-Rio interpreter. (I hope I didn't do anything bad, but I think it is reasonable...)

This is a full program with input from the command line.

Original solution:

for a,r in pairs(math)do l,s=pcall(r,-math.pi)if s~=s and a>=(i or a)then i,p=a,r end end s=...print(s*s*p(s))

Explanation:

math.sqrt is retrieved from the math library by looping through the math table and looking for functions that return NaN (and don't throw an error) when applied to negative pi. There are only a few functions like this, and sqrt is alphabetically last.

\$\endgroup\$
2
\$\begingroup\$

Javascript, 15 17 bytes, Cracked by @Emigna

(x=>x****-125*10)

Solution:

x=>x**(25*10**-1)

Javascript, 18 bytes, Again, Cracked.

x=>x**-(!3.5++)[];

Solution:

x=>x**(3-!+[]+.5);

\$\endgroup\$
2
  • \$\begingroup\$ Cracked. I was really wondering how to do it without the parenthesis ;) \$\endgroup\$
    – Emigna
    Commented Apr 12, 2017 at 11:31
  • \$\begingroup\$ Cracked 2nd \$\endgroup\$
    – Emigna
    Commented Apr 12, 2017 at 11:52
2
\$\begingroup\$

JavaScript + paper.js, 210 bytes (safe)

This one's fun. No comments for you, and no strings either.

paper.js is a vector graphics framework. This is a full program that takes input via a prompt and outputs graphically, because it's possible. There is no rounding and floating-point accuracy (I think).
Reference
Try code here

Math.tan(prompt(a,0));
leg Rave, ew(0,0),ectoPlasm = Real new qrt(;
marvin atTax M(en) in vr;tent * hat.o = Mat
nottet near(0a,a) w cgee;
brown.cern(lantern) ;( w 0,0.art;vict.o brace
r=v=,h.c.)an=.flClr= Cor0)

Edit: Just noticed (my fault for not reading properly)

The shortest safe answer by the end of April will be considered the winner.

Well, oops.

Original solution:

var a = prompt(0,0);
var r = new Rectangle(0,0,a,a).area;
var t = new Rectangle(0,0,Math.cbrt(a),Math.sqrt(Math.cbrt(a))).area;
var n = new PointText(view.center);
n.content = r * t;
n.fillColor = new Color(0);

Try code here

\$\endgroup\$
0
2
\$\begingroup\$

HODOR, 172 bytes, Cracked by Emigna

Walder
Hodor Hodor Hodor Hodor Hodor Hodor
Hodor Hodor Hodor Hodor Hodor
Hodor Hodor Hodor Hodor
Hodor Hodor Hodor
Hodor Hodor
Hodor
hodor hodor
HODOR HODOR!!!!!!!,,,,,,..?

let me know if I missed anything

\$\endgroup\$
4
  • \$\begingroup\$ Nope, this is scrambled \$\endgroup\$
    – wwj
    Commented Apr 5, 2017 at 14:26
  • \$\begingroup\$ just approved your edit, I wrote this up last night... I think the interpreter I was using might have been out of date... I will need to check to make sure the code still works when I get home \$\endgroup\$
    – wwj
    Commented Apr 5, 2017 at 14:32
  • \$\begingroup\$ I'm checking it now. See if I can crack it \$\endgroup\$ Commented Apr 5, 2017 at 14:33
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Emigna
    Commented Apr 5, 2017 at 15:01
1
\$\begingroup\$

Python 3.6 - 15 bytes (Cracked by Kritixi Lithos)

axx 2*d:b.*5mal

Standard rounding precision of Python

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Cracked! \$\endgroup\$
    – user41805
    Commented Apr 3, 2017 at 16:20
  • \$\begingroup\$ @KritixiLithos well done +1 \$\endgroup\$
    – Mr. Xcoder
    Commented Apr 3, 2017 at 16:21
1
\$\begingroup\$

C++, 100 bytes (Cracked by @fergusq)

#.leiha2dm"
tuchn"crmueie<linaatt#dso
fameng pcae sli;t>dt nnsiuno;s mnpti;ouic(<){n(a;>w<n>n)co.,5}

Standard C++ rounding precision

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Cracked! \$\endgroup\$
    – fergusq
    Commented Apr 3, 2017 at 17:15
1
\$\begingroup\$

Python 2, 44 Bytes (Cracked by @fəˈnɛtɪk)

np5w***i0(0(0r0n0t+iarn00p0)_(0tu00i50.0)) t

Has accuracy up to 10 decimal digits (I think). No rounding involved and there is a space involved.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Cracked! \$\endgroup\$ Commented Apr 3, 2017 at 17:38
  • \$\begingroup\$ @fəˈnɛtɪk you should edit the answer you've cracked. Well done! \$\endgroup\$
    – Mr. Xcoder
    Commented Apr 3, 2017 at 17:45
1
\$\begingroup\$

Scala, 19 bytes (Cracked by @math_junkie)

)>,/2(=addd.hmoptw5

This is a function of type Int=>Double.

\$\endgroup\$
1
1
\$\begingroup\$

05AB1E, 4 bytes (Cracked by @Mr. Xcoder)

Must be really easy to crack, but I'll still post it here

n*t¹

Normal rounding

\$\endgroup\$
1
\$\begingroup\$

C, 60 bytes (Cracked by @Dave)

1(root, flat*fat bern**lotr);pw(f{bus(--q.b4/q0*1-2)})(b>1)b

Standard C float accuracy.

\$\endgroup\$
1
1
\$\begingroup\$

05AB1E, 23 bytes (Cracked by Emigna)

Another try

A9n*¥="'q?:@->%t#[{¹!.

Normal rounding

\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Emigna
    Commented Apr 4, 2017 at 17:11
1
\$\begingroup\$

HODOR, 198 bytes (Cracked by wwj)

NB: Had to correct the code!

Uses the brand-new hodor command (Updated Saturday)! Yes, I know I'm not supposed to say but it's pretty obvious anyway and (as far as I know) I'm the only person who can code in Hodor so worth some help :)

This is the code: and the full list of commands is here

H!HDHrlrHrhoooo!h, oo!do ordoH!oHHd
dodHrodorooooHdddoooOOo ddro roorrro.r,H
ooO ooHr,
HdHo oo H!O?Hd, oo,, Hdodhd oor, dd!HHrDo aod
rdroHdH,HrRr
 o o RHrdHoo,oro Hr
oo
oHoer o r oddodo,rr
rdd!WrH d
\$\endgroup\$
8
  • \$\begingroup\$ How do I run the Hodor interpreter? \$\endgroup\$
    – Emigna
    Commented Apr 5, 2017 at 12:59
  • 1
    \$\begingroup\$ @Emigna working on a file that will run from command line but for now will add a note in README (English version) \$\endgroup\$ Commented Apr 5, 2017 at 13:20
  • \$\begingroup\$ Is there perhaps a bug on row 118 in the interpreter? I can't get my program to work without changing that. Also, h should be in VALID_CHARS right? \$\endgroup\$
    – Emigna
    Commented Apr 5, 2017 at 14:17
  • \$\begingroup\$ @Enigma What version of Python are you using. I've fixed it btw \$\endgroup\$ Commented Apr 5, 2017 at 14:19
  • \$\begingroup\$ I was using python 3. \$\endgroup\$
    – Emigna
    Commented Apr 5, 2017 at 14:19
1
\$\begingroup\$

Stacked, 64 bytes

:u#{`E2t#tv',lnp~.iuP#2qr+t,'3m3em`,#9''.::mluls on\ts r:a\:+.S0

Good luck.

Result for 6: 88.181630740194411535.

\$\endgroup\$
4
  • \$\begingroup\$ Maybe linking to github.com/ConorOBrien-Foxx/stacked would be more helpful. \$\endgroup\$ Commented Apr 7, 2017 at 1:22
  • \$\begingroup\$ @user4867444 If you click on "stacked" in the link above it gets your there anyhow. \$\endgroup\$ Commented Apr 7, 2017 at 1:22
  • \$\begingroup\$ Takes me to tio.run/nexus/stacked rather, which is not super helpful to learn about the language? \$\endgroup\$ Commented Apr 7, 2017 at 1:24
  • \$\begingroup\$ @user4867444 Perhaps my wording is confusing. On the tio.run page, clicking on "stacked" gets you to the github. Shown in this image Admittedly, it's a tad convoluted. \$\endgroup\$ Commented Apr 7, 2017 at 1:35
1
\$\begingroup\$

Javascript (ES6), 39 bytes (Cracked)

(((())))*....57===>Mabcefghlllloprttxxx

The rounding is normal floating point precision for Javascript.

\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – GOTO 0
    Commented Apr 5, 2017 at 19:29
1
\$\begingroup\$

bash, 158 bytes

This program requires a 64 bit processor to function. Pass input number as argument; result on stdout. I believe rounding is floor function. This program actually does decimal output. If you got integer only keep trying.

^=======|       -!
///////......
''(((((((((((())))))))))))
[]$$$$$$$$$****
\\\\\\
#++
000000000000
111111222
bcdddeeeehhhiill
nn
NNNNNNoooOOOOOOO
sssSSSS
tw
\$\endgroup\$
1
\$\begingroup\$

Python 2.7, 174 bytes

_cc*gnta(dkree_rtrto._i9kuc_ l5_r_cctbimWka(Wihlkeu_5_eur_rri_keeluc4clrp ..u_)(HohhH)ap5o(trbnord_ir9/*in)_clrikroap.ie.tg_obkfkseeeel*in2Hkdu*ffmo4lWlrncde_22);doodt a49 hu
\$\endgroup\$
1
\$\begingroup\$

05AB1E, 15 bytes, (Cracked by Emigna)

+/01;DDDFMPs}¹ž

Normal rounding

Example runs

In   -> Out
0    -> 0
4    -> 32.0
6    -> 88.18163074019441
25   -> 3125.0
7131 -> 4294138928.896773
\$\endgroup\$
2
  • \$\begingroup\$ Cracked, right back at ya :P \$\endgroup\$
    – Emigna
    Commented Apr 7, 2017 at 16:37
  • \$\begingroup\$ @Emigna: eh, I figured it was only a question of time, same method ;) good job! \$\endgroup\$ Commented Apr 7, 2017 at 17:11
1
\$\begingroup\$

C#, 135 bytes (cracked by SLuck49)

      (((((()))))),,-..../11;;;CCEILMMMPPPRRSSWaaaaaaacccdddeeeeeeeeggghiiiiiiiillllmmnnnnnnnnoooooooorrsssssssssssttttttttuuuvwyy{{}}

no rounding done
(First try)

\$\endgroup\$
1
  • \$\begingroup\$ Cracked This was fun. \$\endgroup\$
    – SLuck49
    Commented Apr 7, 2017 at 20:32
1
\$\begingroup\$

05AB1E, 22 bytes, Cracked by user4867444

+/;DDDFLPT_nz}©®¹¹¹Ïè›

Example runs

In -> Out
0  -> 0
4  -> 32.0
6  -> 88.18163074019441

Original solution

LnD¹›_Ï®©èTFD¹/z+;}¹DP

\$\endgroup\$
1
1
\$\begingroup\$

JavaScript (ES7), 24 bytes (Safe)

()+01488M``aabeiijlooqtv

Standard 64 bit floating point rounding.


Solution

eval(atob`8j0+8ioqMi41`)

Tests

console.log(eval(atob`8j0+8ioqMi41`)(0));    // 0
console.log(eval(atob`8j0+8ioqMi41`)(1));    // 1
console.log(eval(atob`8j0+8ioqMi41`)(2));    // 5.656854249492381
console.log(eval(atob`8j0+8ioqMi41`)(4));    // 32
console.log(eval(atob`8j0+8ioqMi41`)(10));   // 316.22776601683796

\$\endgroup\$
0
1
\$\begingroup\$

Javascript (ES7), 53 bytes (safe)

(((())))*++++,,,/0233346=====>>[[]]aaaabbbccelootttuv

The rounding is normal floating point precision for Javascript.

Tested this in the latest Chrome and FF.


Solution

u=>(o=(t,c,a=o+c,b=a[t])=>eval(a[42]+b+b+3*30/t))(36)

This works because a=o+c is '(t,c,a=o+c,b=a[t])=>eval(a[42]+b+b+3*30/t)undefined'.
So a[42]='u', a[36]='*', 3*30/36=2.5, making eval('u**2.5').

Tests

var f=u=>(o=(t,c,a=o+c,b=a[t])=>eval(a[42]+b+b+3*30/t))(36);
console.log(f(0));    // 0
console.log(f(1));    // 1
console.log(f(2));    // 5.656854249492381
console.log(f(4));    // 32
console.log(f(10));   // 316.22776601683796

\$\endgroup\$
1
\$\begingroup\$

05AB1E, 27 bytes - safe

Yet another totally different approach from my previous answers.

(/1DFFOOPT`ins}}©®¹¹Ðèëž‚‚‹

No rounding.

Example runs

In   -> Out
0    -> 0
4    -> 32.0
6    -> 88.18163074019441
25   -> 3125.0
7131 -> 4294138928.896773

Solution

Ð(‚žFFDO©n¹‹i`T/ë1è®s}‚}O¹P

This is simply computing the square root with a trivial (and very dumb) trial-and-error strategy...

Detailed explanation

Ð(‚žFFDO©n¹‹i`T/ë1è®s}‚}O¹P
Ð(‚                         # triplicate the input, reverse the sign of the last copy, and wrap the last 2 items in a list, which going forward is going to be the list of our current sqrt approximation and of the next decrement in our dumb search (so it starts at [x, -x])
   žFF                      # 16384(!) times, do
      D                     # duplicate the current [value, decrement] list
       O©                   # compute the sum value + decrement, and also save it in the register
         n                  # compute the square of that potential new approximation of the square root
          ¹‹                # and compare it with the input
            i               # if our new approximation is smaller than the actual square root, then
             `              # push the flattened [value, decrement] list to the stack as value, decrement
              T/            # and divide our decrement by 10
                ë           # else (our new approximation is still bigger than the actual square root, then)
                 1è         # extract the current decrement from the list
                   ®        # retrieve the new approximation from the register
                    s       # and switch them to again have them in the value, decrement order
                     }      # end of the if
                      ‚     # no matter which branch of the if we went into, the last 2 items of the stack are now the new approximation and the new decrement, in order: wrap them in a list for the next loop iteration
                       }    # end of the loop
                        O   # replaces the output of the loop (the final [value, decrement] list) by its sum, which given the very small value of the decrement at that point is pretty much the same as our final approximation of sqrt(x)
                         ¹  # push another copy of x; the stack is now [x, sqrt(x), x] (where the first x comes from the very first copy of the initial Ð)
                          P # computes the product of the whole stack

Try it online!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.