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

asked Apr 3, 2017 at 12:45
\$\endgroup\$
0

49 Answers 49

1
2
2
\$\begingroup\$

05AB1E, 22 bytes, P. Knops

n1t*qA9\="'?:@->%#[{!.

Try it online!

Explanation

n # square of input
 * # times
 1t # 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 '=.

answered Apr 4, 2017 at 17:10
\$\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)
answered Apr 4, 2017 at 11:25
\$\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
answered Apr 5, 2017 at 15:01
\$\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()));

answered Apr 5, 2017 at 19:27
\$\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.

answered Apr 6, 2017 at 8:24
\$\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

è›1DDLÏ_zTnF©1®/+;}1DP

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 'è›1DDLÏ_zTnF©1®/+;}1DP'
0.0
$ echo 4 | ./05AB1E.py -e 'è›1DDLÏ_zTnF©1®/+;}1DP'
32.0
$ echo 6 | ./05AB1E.py -e 'è›1DDLÏ_zTnF©1®/+;}1DP'
88.18163074019441
$ echo 25 | ./05AB1E.py -e 'è›1DDLÏ_zTnF©1®/+;}1DP'
3125.0
$ echo 7131 | ./05AB1E.py -e 'è›1DDLÏ_zTnF©1®/+;}1DP'
4294138928.896773
answered Apr 7, 2017 at 16:14
\$\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žDFD1s/+;}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
 1s/ # input divided by current value
 ; # divide sum by 2
 } # end loop
 01 # push 1
 P # product of the stack
answered Apr 7, 2017 at 16:37
\$\endgroup\$
2
\$\begingroup\$

05AB1E, 23 bytes, user4867444

$DDžHGD1s/+;}0@rrzz2+\P

Try it online!

Explanation

$ # push 1 and input
 DD # duplicate the input twice
 žHG # 65536 times do:
 D # duplicate current value
 1s/ # 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
answered Apr 7, 2017 at 16:50
\$\endgroup\$
2
\$\begingroup\$

JavaScript, SIGSEGV

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

Try it online!

answered Apr 12, 2017 at 11:30
\$\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)
answered Apr 3, 2017 at 17:59
\$\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

answered Apr 3, 2017 at 19:06
\$\endgroup\$
1
\$\begingroup\$

05AB1E - P. Knops

t1n*

Was quite easy :)

answered Apr 3, 2017 at 19:28
\$\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.

answered Apr 3, 2017 at 20:04
\$\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!

answered Apr 3, 2017 at 23:15
\$\endgroup\$
1
\$\begingroup\$

Ruby, G B

->a{eval''<<97<<42<<42<<50<<46<<53}
answered Apr 4, 2017 at 7:52
\$\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)));}}
answered Apr 7, 2017 at 20:31
\$\endgroup\$
1
\$\begingroup\$

JavaScript, SIGSEGV

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

Try it online!

answered Apr 12, 2017 at 11:52
\$\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!

answered May 28 at 1:19
\$\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.

answered Nov 25, 2021 at 6:55
\$\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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.