Robbers - square times square root

Task: Crack the scrambled code for multiplying the square root of an integer n by the square of it!

Rules:

• You may only change the order of the characters in the original source.
• Safe answers cannot be cracked anymore.
• The other rules mentioned in the cops' thread

WINNER: Emigna - 10 submissons (had some trouble counting)

Honorable mentions: Notjagan, Plannapus, TEHTMI

CJam, 8 bytes, Roman Gräf

CnR are great for testing new languages :)

ldYYW#+#

Try it online!

Explanation

ld         % double(input)
#   %              ^
Y        %               (2
+    %                 +
Y       %                  2
#     %                   ^
W      %                    -1)

HODOR, 171 bytes, wwj

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!!!

Explanation

• Increment accumulator to 5
• Divide accumulator by 2
• Save a copy of accumulator value
• Set accumulator to 0
• Raise input to the value of the stored copy (2.5)
• Output as number
• back to the drawing board
– wwj
Apr 5 '17 at 15:07

JavaScript, 39 bytes, SLuck49

x=>(l=Math).cbrt(l.exp(l.log(x)*7.5))

or similarly

x=>(l=Math).exp(l.log(l.cbrt(x))*7.5)

Test:

x=>(l=Math).cbrt(l.exp(l.log(x)*7.5))

)(prompt()));

C, 115 bytes, user4867444

New solution that works for 0.

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

Old solution that doesn't work for 0:

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

Applying Newton's method (for square root) a very large fixed number of times seems to give adequate precision for numbers in the required range. I did some character wasting in the first two for loop clauses.

• Close, but not quite, as it returns nan for 0 (not sure we care about that case, asked the OP in a comment) Apr 6 '17 at 15:37
• As specified by the OP, our programs must return 0 for 0, so I'm afraid your solution doesn't work. Apr 6 '17 at 16:59
• @user4867444: Sorry, I didn't understand that it must work for 0. I've provided a modified solution that should work for 0. Apr 6 '17 at 17:48
• 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 nice magic constant to only do a few Newton iterations as opposed to thousands - but great job! Apr 6 '17 at 18:33

05AB1E, 22 bytes, Emigna

Most probably not what was intended, but works ;)

Everything before T is just byte wasting (but which leaves the stack empty), then it does a 100 Newton iterations, which yields a good enough approximation of the square root, then pushes the input twice and returns the product of the whole stack, thus giving the desired output.

Example runs:

$echo 0 | ./05AB1E.py -e 'è›¹DDLÏ_zTnF©¹®/+;}¹DP' 0.0$ echo 4 | ./05AB1E.py -e 'è›¹DDLÏ_zTnF©¹®/+;}¹DP'
32.0
$echo 6 | ./05AB1E.py -e 'è›¹DDLÏ_zTnF©¹®/+;}¹DP' 88.18163074019441$ echo 25 | ./05AB1E.py -e 'è›¹DDLÏ_zTnF©¹®/+;}¹DP'
3125.0
$echo 7131 | ./05AB1E.py -e 'è›¹DDLÏ_zTnF©¹®/+;}¹DP' 4294138928.896773 • Nice one! Didn't think of that :P Apr 7 '17 at 16:30 05AB1E, 15 bytes, user4867444 DMžDFD¹s/+;}01P Try it online! Explanation D # duplicate input M # push the largest value on the stack (the input) žDF # 4096 times do: D # current value + # added to ¹s/ # input divided by current value ; # divide sum by 2 } # end loop 01 # push 1 P # product of the stack 05AB1E, 23 bytes, user4867444$DDžHGD¹s/+;}0@rrzz2+\P

Try it online!

Explanation

\$                        # push 1 and input
DD                      # duplicate the input twice
žHG                   # 65536 times do:
D                  # duplicate current value
¹s/               # divide input by current value
+              # add result of division to current value
;             # divide by 2
}            # end loop
0@          # get the bottom value of the stack (the 1)
rr        # reverse the stack twice (no-op)
zz      # calculate 1/(1/1), a no-op
\   # discard top of stack (the 3)
P  # product of stack

JavaScript, SIGSEGV

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

Try it online!

• You got it! Kudos for you ;) Apr 12 '17 at 11:32

Python - SparklePony

import math
f=lambda x:x*x*math.sqrt(x)
• That was very fast! Apr 3 '17 at 18:00
• Thanks @SparklePony. It was very similar to mine, done it right away Apr 3 '17 at 18:01
• @SparklePony please accept the edit... Apr 3 '17 at 18:01
• I think I have done it... first time accepting an edit! Apr 3 '17 at 19:34

Scala, corvus_192

d=>math.pow(d,5/2d)

Try it here!

Simple lambda expression

05AB1E - P. Knops

t¹n*

Was quite easy :)

float q(float b){return(b-b>0.*4*1/1)-sqrtf(b)*pow(b,2)*-1;}

Not sure what the original did; I had to discard a lot of random operators and numbers, but once the available words were clear it wasn't too hard to piece together the general idea.

• Oops; noticed I'd accidentally included an extra space than the original; fixed.
– Dave
Apr 3 '17 at 20:15
• Here's the original function: float q(float b){return-1*pow(b,(b>-12)/sqrt(4.0f))*b*b*-1;} Apr 3 '17 at 20:46

R, Flounderer

scan()**mean(1:4.5)

Try it online!

Python 3.6, c..

f=lambda x:x**2.5or'1*77*8+8/5/(((aafothipie.xml)))'

Try it online!

Stuffs all the unneeded characters into a string after the or. Since x**2.5 is nonzero and so truthy, the part after the or isn't evaluated. Any syntactically valid expression would be OK here.

Python parses 2.5 and or as separate tokens in 2.5or, though the syntax highlighter for the code doesn't recognize this.

• I think you meant x**2.5? Damn Python, I'm doing the next one without strings.
– c..
Apr 4 '17 at 5:25
• @c.. Yes, 2.5, thanks.
– xnor
Apr 4 '17 at 5:27

Ruby, G B

->a{eval''<<97<<42<<42<<50<<46<<53}
• Nice, I was expecting that, maybe not so fast. :-)
– G B
Apr 4 '17 at 8:13

C#, 135 bytes, Jan Ivan

This was a lot of fun, I particularly liked the use of using static.

using System;using static System.Math;class P{static void Main(){Console.Write(Pow(long.Parse(Console.ReadLine()),1/Round(PI-E,1)));}}

JavaScript, SIGSEGV

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

Try it online!

• Well, not the same, but well, that works too. maybeIshouldn'tuseasterisks Apr 12 '17 at 11:56
• @SIGSEGV: I'd be interested to see what the intended version was then :) Apr 12 '17 at 12:03