19
\$\begingroup\$

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

You must post a comment in the cops' thread with a link to your working source, mentioning clearly that you have Cracked it. In your answer's title, you must include the link to the original answer.

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
  • Please edit the answer you crack

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

Honorable mentions: Notjagan, Plannapus, TEHTMI

\$\endgroup\$
0

49 Answers 49

1
2
2
\$\begingroup\$

05AB1E, 22 bytes, P. Knops

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

Try it online!

Explanation

n # square of input * # times ¹t # square root of input q # end program 

The rest of the operations never get executed.
We could have done it without the q as well by having ? after the calculation and escaping the equality sign for example with '=.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Was just doing it for fun :D \$\endgroup\$ Commented Apr 4, 2017 at 18:12
  • \$\begingroup\$ @P.Knops: That's the best reason :) \$\endgroup\$ Commented Apr 4, 2017 at 18:56
2
\$\begingroup\$

CJam, 8 bytes, Roman Gräf

My First ever CJam answer.
CnR are great for testing new languages :)

ldYYW#+# 

Try it online!

Explanation

ld % double(input) # % ^ Y % (2 + % + Y % 2 # % ^ W % -1) 
\$\endgroup\$
0
2
\$\begingroup\$

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
  • Read input
  • Raise input to the value of the stored copy (2.5)
  • Output as number
\$\endgroup\$
1
  • \$\begingroup\$ back to the drawing board \$\endgroup\$ Commented Apr 5, 2017 at 15:07
2
\$\begingroup\$

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:

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

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

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.

\$\endgroup\$
4
  • \$\begingroup\$ Close, but not quite, as it returns nan for 0 (not sure we care about that case, asked the OP in a comment) \$\endgroup\$ Commented Apr 6, 2017 at 15:37
  • \$\begingroup\$ As specified by the OP, our programs must return 0 for 0, so I'm afraid your solution doesn't work. \$\endgroup\$ Commented Apr 6, 2017 at 16:59
  • \$\begingroup\$ @user4867444: Sorry, I didn't understand that it must work for 0. I've provided a modified solution that should work for 0. \$\endgroup\$ Commented Apr 6, 2017 at 17:48
  • 1
    \$\begingroup\$ 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! \$\endgroup\$ Commented Apr 6, 2017 at 18:33
2
\$\begingroup\$

05AB1E, 22 bytes, Emigna

蛹DDLÏ_zTnF©¹®/+;}¹DP 

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 
\$\endgroup\$
1
  • \$\begingroup\$ Nice one! Didn't think of that :P \$\endgroup\$ Commented Apr 7, 2017 at 16:30
2
\$\begingroup\$

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 
\$\endgroup\$
2
\$\begingroup\$

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 2+ # add 2 \ # discard top of stack (the 3) P # product of stack 
\$\endgroup\$
2
\$\begingroup\$

JavaScript, SIGSEGV

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

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ You got it! Kudos for you ;) \$\endgroup\$ Commented Apr 12, 2017 at 11:32
1
\$\begingroup\$

Python - SparklePony

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

Scala, corvus_192

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

Try it here!

Simple lambda expression

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

05AB1E - P. Knops

t¹n* 

Was quite easy :)

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

C, Steadybox

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.

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

R, Flounderer

scan()**mean(1:4.5) 

Try it online!

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

Ruby, G B

->a{eval''<<97<<42<<42<<50<<46<<53} 
\$\endgroup\$
1
  • \$\begingroup\$ Nice, I was expecting that, maybe not so fast. :-) \$\endgroup\$ Commented Apr 4, 2017 at 8:13
1
\$\begingroup\$

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)));}} 
\$\endgroup\$
1
\$\begingroup\$

JavaScript, SIGSEGV

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

Try it online!

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

Python 2, 174 bytes, cracks penalosa

print str(input()**(5. * .5))or ()/22*2444599.9.HHHWWW_______________aaaaabbbcccccccccddddddeeeeeeeeeeeefffgghhhhiiiiiiikkkkkkkkkllllllllmmnnnooooooooprrrrrrrrrrrt.tttuuuuuu; 

Try it online!

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

Vyxal, cracks emanresuA's answer

5|2/en[(`ĖĖ: 

Try it Online!

Easy. I came up with the solution in the shower that's how easy it is.

\$\endgroup\$
1
  • \$\begingroup\$ So you have, thanks to an oversight of mine. On to round 2 \$\endgroup\$ Commented Nov 25, 2021 at 7:47
1
2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.