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
49 Answers 49
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...)
-
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\$Ilmari Karonen– Ilmari Karonen2017年04月04日 17:39:16 +00:00Commented Apr 4, 2017 at 17:39
-
\$\begingroup\$ How does this work? \$\endgroup\$Arjun– Arjun2017年04月05日 07:30:29 +00:00Commented 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**asMath.pow()to raise the input to the power of 2.5 (6.25 power 0.5). \$\endgroup\$Joe– Joe2017年04月05日 09:24:13 +00:00Commented 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– Arjun2017年04月05日 10:01:13 +00:00Commented Apr 5, 2017 at 10:01
Python, 15 bytes, Mr. Xcoder
lambda x:x**2.5
Pretty simple. Just takes x and raises it to the 2.5th power.
-
\$\begingroup\$ I was posting it right now! Cannot believe it! Good job! \$\endgroup\$Mr. Xcoder– Mr. Xcoder2017年04月03日 17:39:39 +00:00Commented Apr 3, 2017 at 17:39
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.
-
\$\begingroup\$ You got me, nicely done! \$\endgroup\$Kyle G– Kyle G2017年04月12日 14:58:15 +00:00Commented Apr 12, 2017 at 14:58
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);}
-
\$\begingroup\$ Well done! Please edit the answer you crack, because I cannot do it now! \$\endgroup\$Mr. Xcoder– Mr. Xcoder2017年04月03日 17:15:24 +00:00Commented Apr 3, 2017 at 17:15
-
\$\begingroup\$ An anonymous user suggested an edit to save 8 bytes by removing the
usingand just doingint main(){float n;std::cin>>n;std::cout<<pow(n,2.5);}\$\endgroup\$Martin Ender– Martin Ender2017年04月03日 20:27:10 +00:00Commented Apr 3, 2017 at 20:27 -
\$\begingroup\$ Save another byte #including <cmath> instead of math.h.:) \$\endgroup\$zyndor– zyndor2017年05月04日 05:18:18 +00:00Commented May 4, 2017 at 5:18
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". :)
-
\$\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– Flounderer2017年04月03日 23:19:46 +00:00Commented 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\$Ilmari Karonen– Ilmari Karonen2017年04月03日 23:37:26 +00:00Commented Apr 3, 2017 at 23:37
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.
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.
-
\$\begingroup\$ Really? Well at least I got my language known. \$\endgroup\$2017年04月05日 21:29:59 +00:00Commented Apr 5, 2017 at 21:29
-
\$\begingroup\$ @ThisGuy: You've made some fun languages :) Not terribly useful in general though ;) \$\endgroup\$Emigna– Emigna2017年04月05日 21:30:54 +00:00Commented Apr 5, 2017 at 21:30
-
\$\begingroup\$ Look at the 2nd paragraph \$\endgroup\$2017年04月05日 21:33:56 +00:00Commented Apr 5, 2017 at 21:33
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).
C, 50 bytes, Dave
double b(float \ufa2d){return pow(\ufa2d,25e-1);%>
This requires -lm compiler flag, but I don't know how it would be possible to solve this without it.
-
\$\begingroup\$ correct, and almost exactly what I had (variable was named
\uad2fon mine). Well done; I thought I'd left enough red-herrings in there to keep people busy a lot longer! Also the-lmflag wasn't needed for me using Clang (I'd have mentioned it!) but you're correct that strictly speaking it's required. \$\endgroup\$Dave– Dave2017年04月04日 11:59:09 +00:00Commented Apr 4, 2017 at 11:59
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
-
\$\begingroup\$ Yes, this is not the intended solution which involved
sin(pi), but unfortunately it does work! +1 \$\endgroup\$Flounderer– Flounderer2017年04月04日 21:13:42 +00:00Commented Apr 4, 2017 at 21:13 -
\$\begingroup\$ It was
scan()^(-floor(-sin(pi)*2e17)/10)\$\endgroup\$Flounderer– Flounderer2017年04月05日 21:38:09 +00:00Commented Apr 5, 2017 at 21:38
-
\$\begingroup\$ My solution was
]š2円^*, but they both work the same way. \$\endgroup\$ATaco– ATaco2017年04月04日 23:21:21 +00:00Commented Apr 4, 2017 at 23:21
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
-
\$\begingroup\$ Almost there. Had to change a mistake in my code so yours ins't quite right. \$\endgroup\$2017年04月05日 14:10:56 +00:00Commented Apr 5, 2017 at 14:10
-
\$\begingroup\$ fixed the start command \$\endgroup\$wwj– wwj2017年04月05日 14:24:27 +00:00Commented 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\$2017年04月05日 14:26:59 +00:00Commented 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– wwj2017年04月05日 14:51:09 +00:00Commented 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\$2017年04月05日 14:52:10 +00:00Commented Apr 5, 2017 at 14:52
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);}}
-
\$\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– Emigna2017年04月05日 15:07:38 +00:00Commented Apr 5, 2017 at 15:07
-
\$\begingroup\$ +1 Not what I had intended, but very nice solution. ;) \$\endgroup\$raznagul– raznagul2017年04月05日 15:16:41 +00:00Commented Apr 5, 2017 at 15:16
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))
-
\$\begingroup\$ Is second input allowed in such challenge? \$\endgroup\$pajonk– pajonk2017年04月05日 15:11:49 +00:00Commented 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\$Jörg Hülsermann– Jörg Hülsermann2017年04月05日 15:30:13 +00:00Commented Apr 5, 2017 at 15:30
-
\$\begingroup\$ @pajonk I have improve my post it could been that you have make a little mistake \$\endgroup\$Jörg Hülsermann– Jörg Hülsermann2017年04月05日 16:12:29 +00:00Commented 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– pajonk2017年04月06日 18:59:46 +00:00Commented 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\$Jörg Hülsermann– Jörg Hülsermann2017年04月06日 20:42:23 +00:00Commented Apr 6, 2017 at 20:42
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!
-
\$\begingroup\$ @Mr. Xcoder , as said above, can't comment on your post in the cops' thread, sorry about that :) \$\endgroup\$user4867444– user48674442017年04月05日 23:58:24 +00:00Commented 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)/1just 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– Kyle G2017年04月06日 01:43:00 +00:00Commented Apr 6, 2017 at 1:43
Python 2.7, Koishore Roy
s=e=x=y=input()**0.5
print'%.3f'%(y**(5.0))
-
\$\begingroup\$ Or
y=x=e=s, both work :)) Good job anyways! \$\endgroup\$Mr. Xcoder– Mr. Xcoder2017年04月08日 14:46:34 +00:00Commented Apr 8, 2017 at 14:46 -
\$\begingroup\$ Good job. :P Now I need to work on a new code. Darn! \$\endgroup\$Koishore Roy– Koishore Roy2017年04月09日 08:47:00 +00:00Commented Apr 9, 2017 at 8:47
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
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
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.
Python 3.6, c..
f=lambda x:x**2.5or'1*77*8+8/5/(((aafothipie.xml)))'
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.
-
\$\begingroup\$ I think you meant
x**2.5? Damn Python, I'm doing the next one without strings. \$\endgroup\$c..– c..2017年04月04日 05:25:00 +00:00Commented Apr 4, 2017 at 5:25
-
\$\begingroup\$ Ah, I knew there would be a workaround the method I used to 'secure' the code. Well done! \$\endgroup\$Okx– Okx2017年04月04日 11:21:14 +00:00Commented Apr 4, 2017 at 11:21
-
\$\begingroup\$ @Okx: Yeah, 05AB1E is very tricky to pad with extra code without making it bypassable. \$\endgroup\$Emigna– Emigna2017年04月04日 11:27:34 +00:00Commented Apr 4, 2017 at 11:27
-
\$\begingroup\$ I'll see if I can make you a trickier one ;) \$\endgroup\$Okx– Okx2017年04月04日 11:29:52 +00:00Commented 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– Emigna2017年04月04日 11:31:51 +00:00Commented Apr 4, 2017 at 11:31
Fireball, 8 bytes, Okx
♥2♥1Z/^*
Explanation:
♥2♥1Z/^*
♥2 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. :(
-
\$\begingroup\$ I don't think that will work. Easy fix though, so I'll give you the answer. You just need to swap the
Z1into1Z. \$\endgroup\$Okx– Okx2017年04月04日 11:21:58 +00:00Commented Apr 4, 2017 at 11:21 -
\$\begingroup\$ I was sure I did a mistake there. Updated. \$\endgroup\$Linnea Gräf– Linnea Gräf2017年04月04日 11:22:53 +00:00Commented Apr 4, 2017 at 11:22
Haskell, 64 bytes, @nimi
product.(<$>(($(succ.cos0ドル))<$>[(flip<$>flip)id$id,recip])).(**)
Try it online! That was a fun one. I first found product.(<$>(($succ(cos0ドル))<$>[id,recip])).(**) which behaves correctly and than had to fit flip flip <$> () $ id . somewhere into it.
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
-
\$\begingroup\$ Original:
a=function(s)s**2*s**(0.125*2*2)\$\endgroup\$Steadybox– Steadybox2017年04月04日 14:47:14 +00:00Commented Apr 4, 2017 at 14:47
Explore related questions
See similar questions with these tags.