18
\$\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

48 Answers 48

9
\$\begingroup\$

JavaScript (ES7), Neil

_26_=>_26_**6.25**.5

The hard part, of course, was figuring out what to do with all the extra characters. (And also not posting this solution in the wrong thread, like I accidentally did at first. Oopsie...)

\$\endgroup\$
4
  • 1
    \$\begingroup\$ @SethWhite: I had to use all the characters that Neil used in his scrambled code, otherwise this wouldn't have been a valid crack. \$\endgroup\$ Apr 4, 2017 at 17:39
  • \$\begingroup\$ How does this work? \$\endgroup\$
    – Arjun
    Apr 5, 2017 at 7:30
  • \$\begingroup\$ @Arjun _26_=> defines an anonymous function taking one parameter called _26_ (variables may start with an underscore but not a number). Then the remainder is just using ** as Math.pow() to raise the input to the power of 2.5 (6.25 power 0.5). \$\endgroup\$
    – Joe
    Apr 5, 2017 at 9:24
  • \$\begingroup\$ Ah! I was thinking that _26_ was something ES7 specific. Didn't know that variables can be in this form too! (I have never seen a variable without an alphabet). That was a very clever approach by @Neil. And you were very clever too in cracking it! Have your well-deserved +1! :) \$\endgroup\$
    – Arjun
    Apr 5, 2017 at 10:01
6
\$\begingroup\$

Python, 15 bytes, Mr. Xcoder

lambda x:x**2.5

Pretty simple. Just takes x and raises it to the 2.5th power.

\$\endgroup\$
6
\$\begingroup\$

OCaml, 13 bytes, shooqie

fun f->f**2.5

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ I was posting it right now! Cannot believe it! Good job! \$\endgroup\$
    – Mr. Xcoder
    Apr 3, 2017 at 17:39
5
\$\begingroup\$

Python 3, 44 bytes, Kyle Gullion

Those *s were quite misleading. Very clever!

lambda i:i**(lambda o,r:o/r)(*map(ord,'i*'))

Due to the quite limited character set I would be very surprised if there were any other valid solutions beyond trivial renaming or reordering of arguments.

\$\endgroup\$
1
  • \$\begingroup\$ You got me, nicely done! \$\endgroup\$
    – Kyle G
    Apr 12, 2017 at 14:58
4
\$\begingroup\$

C++ (gcc), 100 bytes, Mr. Xcoder

#include<math.h>
#include"iostream"
using namespace std;int main(){float n;cin>>n;cout<<pow(n,2.5);}

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ Well done! Please edit the answer you crack, because I cannot do it now! \$\endgroup\$
    – Mr. Xcoder
    Apr 3, 2017 at 17:15
  • \$\begingroup\$ An anonymous user suggested an edit to save 8 bytes by removing the using and just doing int main(){float n;std::cin>>n;std::cout<<pow(n,2.5);} \$\endgroup\$ Apr 3, 2017 at 20:27
  • \$\begingroup\$ Save another byte #including <cmath> instead of math.h.:) \$\endgroup\$
    – zyndor
    May 4, 2017 at 5:18
4
\$\begingroup\$

Haskell, Leo

x=exp.(2.5*).log

A pointfree function named x. Usage: x 4 -> 32.0

\$\endgroup\$
4
\$\begingroup\$

Inform 7, corvus_192

Cool, an Inform7 entry. :) I just had to give this one a try.

I'm pretty sure this is the intended solution:

R is a room.

To f (n - number): say "[n * n * real square root of n]".

Note that this solution only works if compiled with the Glulx back-end, due to the use of the real square root of function.


BTW, the double quotes and square brackets are actually unnecessary; just say n * n * real square root of n would work just as well. The periods at the end of the commands could be omitted, too; or we could keep the first period and get rid of the newlines instead. Other parts of the code we could trim away include the article "a" before "room" and the spaces before the parentheses and after the colon. Fortunately, since we've got a spare pair of brackets, we can always use them to comment out all these extra characters. ;) So this is a valid solution, too:

R is room.To f(n - number):say n * n * real square root of n[
" a . "
]

To test this solution interactively, it's convenient to append something like the following test harness to the code:

Effing is an action applying to one number.
Understand "f [number]" as effing.
Carry out effing: f the number understood.

After compiling and running the program, you can type e.g. f 4. f 6. f 9. f 25 at the > prompt and receive something like the following output:

Welcome
An Interactive Fiction
Release 1 / Serial number 170404 / Inform 7 build 6L38 (I6/v6.33 lib 6/12N) SD

R

>f 4. f 6. f 9. f 25
32.0
88.18164
243.0
3125.0
>

BTW, I just noticed that Inform (or presumably, rather, Glulx) rounds the last decimal place of f 6 wrong: the correct value is much closer to 88.18163 than to 88.18164. Fortunately, I don't think this affects the correctness of the solution(s), especially since the challenge specified "any rounding mechanism of your choice". :)

\$\endgroup\$
2
  • \$\begingroup\$ I'm sure I found an Inform 7 fiddle a while ago, but I can't find it when I search. Do you know if there is an online interpreter anywhere? \$\endgroup\$
    – Flounderer
    Apr 3, 2017 at 23:19
  • \$\begingroup\$ @Flounderer: I don't really know of any. There are certainly online (even JS-based) players for the Glulx / Z-machine bytecode produced by the Inform 7 compiler, but I'm not aware of anything that would directly take plain Inform 7 source code and compile and run it online. The compiler / IDE is pretty easy to install, though; on Ubuntu Linux, it's as easy as apt-get install gnome-inform7. \$\endgroup\$ Apr 3, 2017 at 23:37
4
\$\begingroup\$

Mathematica, Greg Martin

f[y_]:=With[{x=
    #&@@{#(#)#^(1/(1+1))&@y,#&@@@{1^(1),-1}}
},Print[#,".",IntegerString[Round@#2,10,3]]&@@QuotientRemainder[1000x,1000]]

Thanks for leaving the rounding stuff intact!

Explanation: #(#)#^(1/(1+1))&@y does the main work of multiplying y squared, aka y(y), and y's square root, y^(1/(1+1)). The #&@@@{1^(1),-1} bit is just junk to use up the other letters, and #&@@ picks out the useful bit from the junk.

\$\endgroup\$
4
\$\begingroup\$

MATL, 12 bytes, Luis Mendo

10'U&+:'n/^P

Calculate 10/4 = 2.5 with 4 coming from string length. Use this as an exponent. P is a no-op here.

\$\endgroup\$
3
\$\begingroup\$

NO, 41 bytes, This Guy

NOOOOOO?NOOOOOOOOOOO!nnOOOOO
NOOOOOOOO?no
\$\endgroup\$
3
  • \$\begingroup\$ Really? Well at least I got my language known. \$\endgroup\$ Apr 5, 2017 at 21:29
  • \$\begingroup\$ @ThisGuy: You've made some fun languages :) Not terribly useful in general though ;) \$\endgroup\$
    – Emigna
    Apr 5, 2017 at 21:30
  • \$\begingroup\$ Look at the 2nd paragraph \$\endgroup\$ Apr 5, 2017 at 21:33
3
\$\begingroup\$

R, Steadybox

y<-function(p)(p^(1/2)*p^2);

seems to be an anagram of funny(p1)-tio(^*^)/pc(2)<p2;

\$\endgroup\$
3
\$\begingroup\$

Python 2, 60 bytes, Anthony Pham

print    (input()**(5.0/(2*5554448893999/5554448893840))-0)

Based on discarding characters through Python 2's float division (the default for / between integers).

\$\endgroup\$
3
\$\begingroup\$

C, 50 bytes, Dave

double b(float \ufa2d){return pow(\ufa2d,25e-1);%>

Try it online!

This requires -lm compiler flag, but I don't know how it would be possible to solve this without it.

\$\endgroup\$
1
  • \$\begingroup\$ correct, and almost exactly what I had (variable was named \uad2f on mine). Well done; I thought I'd left enough red-herrings in there to keep people busy a lot longer! Also the -lm flag wasn't needed for me using Clang (I'd have mentioned it!) but you're correct that strictly speaking it's required. \$\endgroup\$
    – Dave
    Apr 4, 2017 at 11:59
3
\$\begingroup\$

R, Flounderer

This is a crack of the 33 bytes solution of @Flounderer

scan()^(floor(pi)-1/2)-sin(7*0e1)

Usage:

> scan()^(floor(pi)-1/2)-sin(7*0e1)
1: 4
2: 
Read 1 item
[1] 32
> scan()^(floor(pi)-1/2)-sin(7*0e1)
1: 6
2: 
Read 1 item
[1] 88.18163
> scan()^(floor(pi)-1/2)-sin(7*0e1)
1: 9
2: 
Read 1 item
[1] 243
> scan()^(floor(pi)-1/2)-sin(7*0e1)
1: 25
2: 
Read 1 item
[1] 3125
\$\endgroup\$
2
  • \$\begingroup\$ Yes, this is not the intended solution which involved sin(pi), but unfortunately it does work! +1 \$\endgroup\$
    – Flounderer
    Apr 4, 2017 at 21:13
  • \$\begingroup\$ It was scan()^(-floor(-sin(pi)*2e17)/10) \$\endgroup\$
    – Flounderer
    Apr 5, 2017 at 21:38
3
\$\begingroup\$

RProgN 2, ATaco

]2^\š*

Apparently StackExchange needs extra characters, so here you go.

\$\endgroup\$
1
  • \$\begingroup\$ My solution was ]š\2^*, but they both work the same way. \$\endgroup\$
    – ATaco
    Apr 4, 2017 at 23:21
3
\$\begingroup\$

HODOR, 198, This Guy

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 Hodor, hodor!,
HODOR!!
HODOR!!!

Explanation:

Start
read input into accumulator
copy accumulator to storage
Do math, option 7(nth root), n=2
swap storage and accumulator
Do math, option 6(nth power), n=2
Do math, option 3(times), storage
output accumulator as a number
end

note: I had to make some modifications to the get interpreter to run on my machine (the one you have posted doesn't seem to accept lowercase h, among some other things)

Also, I don't seem to have enough rep to comment, so if someone could let @This Guy know, I would be grateful

I think this fixed the error, the code now starts with Walder instead of Wylis, which adds the extra byte

\$\endgroup\$
8
  • \$\begingroup\$ Almost there. Had to change a mistake in my code so yours ins't quite right. \$\endgroup\$ Apr 5, 2017 at 14:10
  • \$\begingroup\$ fixed the start command \$\endgroup\$
    – wwj
    Apr 5, 2017 at 14:24
  • \$\begingroup\$ Though that you had it but you went for a different method than me that uses the same number of bytes. Your answer would do what you wanted it to do but it isn't the same as mine. Also I had to change the name because of this so I made an edit to your posts. \$\endgroup\$ Apr 5, 2017 at 14:26
  • \$\begingroup\$ for clarification, does this still count as a crack, or do I need to match up exactly? \$\endgroup\$
    – wwj
    Apr 5, 2017 at 14:51
  • \$\begingroup\$ I'm not exactly sure. I'm going to ask in the comments. +1 your solution is making me think really hard! \$\endgroup\$ Apr 5, 2017 at 14:52
3
\$\begingroup\$

C#, 172 bytes, raznagul

Hardest part was figuring out what to do with all the leftovers.

using System;using S=System.Console;class PMabddellorttuuv{static void Main(){S.Write(Math.Pow(double.Parse(S.ReadLine()),2.5));Func<double> o;int q=1,M=q*2,b,e;q*=(q*M);}}
\$\endgroup\$
2
  • \$\begingroup\$ Nice! I got stuck on the leftovers as well. Didn't think to add them to the class name, doh!. Good job! \$\endgroup\$
    – Emigna
    Apr 5, 2017 at 15:07
  • \$\begingroup\$ +1 Not what I had intended, but very nice solution. ;) \$\endgroup\$
    – raznagul
    Apr 5, 2017 at 15:16
3
\$\begingroup\$

EXCEL, 26 Bytes pajonk

=SQRT(A1)*A1^2/1/ISNA(IP2)

A1 as input IP2 contain a second input with a #N/A Error in this case ISNA(IP2) belongs to 1

For an additional () we can do this

=SQRT(A1)*A1^2/ISNA(PI(1/2))
\$\endgroup\$
5
  • \$\begingroup\$ Is second input allowed in such challenge? \$\endgroup\$
    – pajonk
    Apr 5, 2017 at 15:11
  • \$\begingroup\$ @pajonk The rules say "You can take input in any standard way" so I have assume that you make this trick with a second input \$\endgroup\$ Apr 5, 2017 at 15:30
  • \$\begingroup\$ @pajonk I have improve my post it could been that you have make a little mistake \$\endgroup\$ Apr 5, 2017 at 16:12
  • \$\begingroup\$ The standard way for taking one number is (I think) taking one input. In my opinion the second input would be unfair and against the rules. PS There's no mistake in number of brackets. \$\endgroup\$
    – pajonk
    Apr 6, 2017 at 18:59
  • \$\begingroup\$ @pajonk I can not use combinations with SIN and PI cause there are not enough brackets. =SQRT(A1)*A1^2/SIN(PI()/2) If you set the #NA Error through formating or something else I would see it as additional second input. SQRT and ISNA are the only two functions that make a little sense. But please ask the man who had developed the question \$\endgroup\$ Apr 6, 2017 at 20:42
3
\$\begingroup\$

Python 3.6, 64 bytes, Mr. Xcoder

php38af4r2aoot2srm0itpfpmm0726991i=     (lambda x:x**2.5*1*1/1);

Maybe not what was intended, but works ;)

$ python3
Python 3.6.1 (default, Apr  4 2017, 09:36:47) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> php38af4r2aoot2srm0itpfpmm0726991i=     (lambda x:x**2.5*1*1/1);
>>> php38af4r2aoot2srm0itpfpmm0726991i(6)
88.18163074019441
>>> php38af4r2aoot2srm0itpfpmm0726991i(4)
32.0
>>> php38af4r2aoot2srm0itpfpmm0726991i(25)
3125.0

Not enough rep to comment on the cops' thread's answer yet, sorry... Would appreciate if someone could do it for me, thanks!

\$\endgroup\$
2
  • \$\begingroup\$ @Mr. Xcoder , as said above, can't comment on your post in the cops' thread, sorry about that :) \$\endgroup\$ Apr 5, 2017 at 23:58
  • \$\begingroup\$ Came to post a similar solution from math import pi as pp0012223467899;f=lambda x:x**2.5*1*(1)/1 just to see I've been beaten to the punch. I've added a link to this post on the cops thread for you. \$\endgroup\$
    – Kyle G
    Apr 6, 2017 at 1:43
3
\$\begingroup\$

Röda, 28 bytes, fergusq

f(n){push n^0.5,n^2|product}
\$\endgroup\$
3
\$\begingroup\$

Python 2.7, Koishore Roy

s=e=x=y=input()**0.5
print'%.3f'%(y**(5.0))
\$\endgroup\$
2
  • \$\begingroup\$ Or y=x=e=s, both work :)) Good job anyways! \$\endgroup\$
    – Mr. Xcoder
    Apr 8, 2017 at 14:46
  • \$\begingroup\$ Good job. :P Now I need to work on a new code. Darn! \$\endgroup\$ Apr 9, 2017 at 8:47
3
\$\begingroup\$

R, Flounderer

This is a crack of @Flounderer's 31-byte solution:

`[.`=function(`]`)`]`^`[`(lh,9)

Ok that was a tough one. It creates a function called `[.`. The argument to the function is called `]` which is elevated to power 2.5 by using the 9th element of the built-in time-serie lh ("a regular time series giving the luteinizing hormone in blood samples at 10 mins intervals from a human female, 48 samples." that is used as example in one of R's base packages). lh[9] is here on top of it replaced by its equivalent `[`(lh, 9). De-obfuscated by substituting f for the function name and n for the argument name, the function then becomes f=function(n)n^lh[9].

Usage:

> `[.`=function(`]`)`]`^`[`(lh,9)
> `[.`(4)
[1] 32
> `[.`(6)
[1] 88.18163
> `[.`(9)
[1] 243
> `[.`(25)
[1] 3125
\$\endgroup\$
2
\$\begingroup\$

Python 2, 44 bytes, Anthony Pham

print int(raw_input())**(0+000000000000.5*5)

Takes input from raw_input, converts to int and raises to power 2.5

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

JavaScript, fəˈnɛtɪk

n=>n**("ggggg".length*2**(-"g".length))// ""((((((()))))))***,-...;;=====>Seeeeegggghhhhhhhhhilllnnnnnnorrrsstttttttttttu{}

Gets 5/2 through 5 times 2 to the negative first power, where 5 and 1 were received from the length of strings. Took the easy way out in a sense by commenting out the extraneous characters.

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

C#, 112 bytes, Jan Ivan

using System;class P{static void Main(){var b=Math.Pow(double.Parse(Console.ReadLine()),2.5);Console.Write(b);}}
\$\endgroup\$
2
\$\begingroup\$

05AB1E, 47 bytes, Okx

).2555BFHIJJKKKPQRS``„cg…ghi…lsw…x}T…Áöž«‚¹n¹t*

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ Ah, I knew there would be a workaround the method I used to 'secure' the code. Well done! \$\endgroup\$
    – Okx
    Apr 4, 2017 at 11:21
  • \$\begingroup\$ @Okx: Yeah, 05AB1E is very tricky to pad with extra code without making it bypassable. \$\endgroup\$
    – Emigna
    Apr 4, 2017 at 11:27
  • \$\begingroup\$ I'll see if I can make you a trickier one ;) \$\endgroup\$
    – Okx
    Apr 4, 2017 at 11:29
  • \$\begingroup\$ @Okx: Looking forward to it :) I have an idea as well that I may try to implement after work ;) \$\endgroup\$
    – Emigna
    Apr 4, 2017 at 11:31
2
\$\begingroup\$

Fireball, 8 bytes, Okx

♥²♥1Z/^*

Explanation:

♥²♥1Z/^*
♥²       Push first input squared.
  ♥      Push first input again.
   1Z/   Push 1/2
      ^  First input to the 1/2th
       * Multiply square and root

Not sure if it works. I have currently no java on my laptop. :(

\$\endgroup\$
2
  • \$\begingroup\$ I don't think that will work. Easy fix though, so I'll give you the answer. You just need to swap the Z1 into 1Z. \$\endgroup\$
    – Okx
    Apr 4, 2017 at 11:21
  • \$\begingroup\$ I was sure I did a mistake there. Updated. \$\endgroup\$ Apr 4, 2017 at 11:22
2
\$\begingroup\$

Haskell, 64 bytes, @nimi

product.(<$>(($(succ.cos$0))<$>[(flip<$>flip)id$id,recip])).(**)

Try it online! That was a fun one. I first found product.(<$>(($succ(cos$0))<$>[id,recip])).(**) which behaves correctly and than had to fit flip flip <$> () $ id . somewhere into it.

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

R, steadybox

a222=function(s)(s**0.5)*s**2**1

Usage:

> a222=function(s)(s**0.5)*s**2**1
> a222(4)
[1] 32
> a222(6)
[1] 88.18163
> a222(9)
[1] 243
> a222(25)
[1] 3125
\$\endgroup\$
1
  • \$\begingroup\$ Original: a=function(s)s**2*s**(0.125*2*2) \$\endgroup\$
    – Steadybox
    Apr 4, 2017 at 14:47
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\$
    – P. Knops
    Apr 4, 2017 at 18:12
  • \$\begingroup\$ @P.Knops: That's the best reason :) \$\endgroup\$
    – Emigna
    Apr 4, 2017 at 18:56

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.