Note: This is the cops' thread, where one should post the scrambled code. Here is the robbers' thread where the cracked source should be posted and linked to the cop's answer.


Task: Write the shortest safe program which multiplies the square root of an integer n by the square of n

This is , so the rules are:

  • In your answer, post a scrambled version of your source code (the characters should be written in any order). The scrambled version should not work!
  • You can take input in any standard way, the same goes for output. Hardcoding is forbidden
  • After the code is cracked by the robbers (if this happens), you must mention that your code has been cracked in your title and add a spoiler to your answer's body with your exact code
  • The same applies to safe answers (mention that it's safe and add the spoiler)
  • The code is considered safe if nobody has cracked it in 5 days after posting it and you can optionally specify that in the title
  • You must specify your programming language
  • You should specify your byte count
  • You must state the rounding mechanism in your answer (see below)

You can assume that the result is lower than 232 and n is always positive. If the result is an integer, you must return the exact value with or without a decimal point; otherwise the minimum decimal precision will be 3 decimal places with any rounding mechanism of your choice, but can include more. You must state the rounding mechanism in your answer. You are not allowed to return as fractions (numerator, denominator pairs - sorry, Bash!)

Examples:

In -> Out

4 -> 32.0 (or 32)
6 -> 88.18163074019441 (or 88.182 following the rules above)
9 -> 243.0
25 -> 3125.0

The shortest safe answer by the end of April will be considered the winner.

share|improve this question
1  
Related. (Same CnR rules, different task.) – Martin Ender 21 hours ago
1  
@MartinEnder If the task is the only thing differing, then isn't it a duplicate? – Nathan Merrill 19 hours ago
1  
@NathanMerrill I don't know, I don't think we have any established duplicate guidelines for cops and robbers challenge, but if I ask a new code-golf challenge, where the "only" thing that's different from a previous code golf is the task, it's usually not considered a duplicate. ;) (That said, I agree that CnRs are probably more interesting if we change up the CnR-part of the challenge, not the underlying task.) – Martin Ender 19 hours ago
1  
@fəˈnɛtɪk a) only if you change the input to a hardcoded value, because the other challenge doesn't allow taking input, b) we also don't close every random challenge as a duplicate of codegolf.stackexchange.com/q/101638/8478. – Martin Ender 18 hours ago
2  
I had written my code to work for an input up to 2^32... Which is why I asked about rounding errors, got rather off the mark at that point – fəˈnɛtɪk 17 hours ago

33 Answers 33

Röda, 28 bytes

 (),.025^^cdfhnnnopprstuu{|}

Note the space at the beginning. No rounding, but it uses floating point numbers so precision is limited.

share|improve this answer
    
Is this an anonymous function, or a "full" function? – Kritixi Lithos 17 hours ago
    
@KritixiLithos if the cop does not want to give clues, it is not supposed to – Mr. Xcoder 17 hours ago

Perl, 42 bytes

There are 41 bytes of code and -p flag (no other flags).

/"/4~~r..rso4r<_$4va=eg1de|i/h0-&$c={}l+"

The result isn't rounded (or rather rounded up to the same point Perl would have round up by doing $_ = (sqrt $_) * ($_ ** 2)).

share|improve this answer
    
True. I was trying to edit quickly because I saw 4 reopen votes and hoped to get the question fixed before the 5th was cast. If the question had been left in the sandbox until it was ready, it would have been better for all involved. – Peter Taylor 18 hours ago
    
@PeterTaylor Sure, no problem, and anyway it was bold so fairly visible (I wasn't blaming anyone, but merely pointing a minor flow (that I corrected right away (introducing typos in the process))). And I couldn't agree more about the sandbox part. – Dada 18 hours ago

MATL, 12 bytes

'Un&0P'/^:+1

No rounding; uses floating point.

EDIT Sorry everyone, there was a mistake. Former O should be 0. Corrected now. (I would downvote myself for this if I could).

share|improve this answer

Octave, 43 bytes

$'()*+,-/23579:[]aelnouv'*,-23:[]lu',-23]',

This is a script that requires input from the command line (it's not a function). It's floating point accuracy (so no rounding).

share|improve this answer

Swift - 64 bytes

prot Fdnufi;nooitamunc xetgru(->atl)Ior:n{tFn pg,F(ao.o25t)(w)l}

No rounding, and displays a .0 even if the result is an integer.

share|improve this answer

Mathematica, 131 bytes, non-competing?, cracked

This has been cracked by @lanlock4! However, I still have internet points to bestow on someone who finds the original solution, where all the characters are actually needed....

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

This is intended as a puzzle. Although you may use the above characters however you want, I certainly intend for the answer to follow the form

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

where the first and third lines are just a wrapper to make the rounding and display legal (it writes every output to exactly three decimal places, rounded), and the second line is the scrambled version of the guts of the code. Sample outputs:

6 -> 88.182
9 -> 243.000
9999 -> 9997500187.497

(Mathematica is non-free software, but there is a Wolfram sandbox where it is possible to test modest amounts of code. For example, cutting and pasting the code

f[y_]:=With[{x=
    y^2.5
},Print[#,".",IntegerString[Round@#2,10,3]]&@@QuotientRemainder[1000x,1000]]

defines a function, which you can subsequently call like f@6 or f[9], that does the same thing as the unscrambled version of the code above. So does this really have to be non-competing?)

share|improve this answer
    
Cracked it! – lanlock4 9 hours ago

Haskell, 16 bytes (Cracked by @nimi)

()*...25=eglopxx

No particular rounding

share|improve this answer

R, 28 bytes (Cracked by @Flounderer)

funny(p1)-tio(^*^)/pc(2)<p2;

Standard R floating-point accuracy.

share|improve this answer
    
    
@Flounderer Yes, it is. – Steadybox 11 hours ago

C#, 172 bytes

       (((((())))))***,,,,......1225;;;;;;<====>CFLMMMMMPPPRSSSSSWaaaaaaabbbbcccddddddeeeeeeeeeeegghiiiiiiiillllllmmnnnnnnnooooooooqqqqrrrssssssssstttttttttuuuuuuuvvwyy{{}}

This code is a full program.

There are seven space characters at the start.

The input is read form STDIN and printed to STDOUT. The result is in double, no rounding done.

share|improve this answer

Inform 7, 71 bytes

""()**-..:[]
                 RT
aaaabeeeffilmmnnnnnooooooqrrrrrssstuuy

The code includes 17 spaces and 2 new lines. This is a full Infrom 7 program defining a function that prints the result with a precision of 5 decimal places.

share|improve this answer
    
Cracked. – Ilmari Karonen 11 hours ago

OCaml, 13 bytes (Cracked by @Dada)

2*fn-5f>f*u .

No rounding (within IEEE 754 scope).

share|improve this answer
3  
cracked. – Dada 16 hours ago

C, 50 bytes

%(())   ,-12225;>\\aaabbdddeeefffllnoooprrttuuuuw{

Uses standard IEEE754 rounding.

share|improve this answer
    
Cracked? – fergusq 1 hour ago

JavaScript (ES7), 20 bytes (Cracked by @IlmariKaronen)

****..22255666=>____

Standard JavaScript precision.

share|improve this answer
    
Cracked. (Oops, posted in the wrong thread at first.) – Ilmari Karonen 10 hours ago
    
Yeah, that's what I get for having way too many tabs open. Fixed. – Ilmari Karonen 10 hours ago

Python 2, 60 Bytes (Cracked by @notjagan)

 3n0)4  5)594p3(p5*5i9t4542)0/*((8(t.84- 90945 u)i*48/95n8r8

No rounding involved. Accurate up to 10 decimal digits.

share|improve this answer
    
Cracked! – notjagan 10 hours ago

Python 3.6 - 15 bytes (Cracked by Kritixi Lithos)

axx 2*d:b.*5mal

Standard rounding precision of Python

share|improve this answer
2  
Cracked! – Kritixi Lithos 17 hours ago
    
@KritixiLithos well done +1 – Mr. Xcoder 17 hours ago

C++, 100 bytes (Cracked by @fergusq)

#.leiha2dm"
tuchn"crmueie<linaatt#dso
fameng pcae sli;t>dt nnsiuno;s mnpti;ouic(<){n(a;>w<n>n)co.,5}

Standard C++ rounding precision

share|improve this answer
1  
Cracked! – fergusq 16 hours ago

Python 2, 44 Bytes (Cracked by @fəˈnɛtɪk)

np5w***i0(0(0r0n0t+iarn00p0)_(0tu00i50.0)) t

Has accuracy up to 10 decimal digits (I think). No rounding involved and there is a space involved.

share|improve this answer
1  
Cracked! – fəˈnɛtɪk 16 hours ago
    
@fəˈnɛtɪk you should edit the answer you've cracked. Well done! – Mr. Xcoder 16 hours ago

Excel VBA, 59 bytes

?(())*..//11124AAAAFPSW[[]]^acceehiiiiklnnnnoooppqrrstttttu

No particular rounding.
Uses the Immediate Window.

share|improve this answer

Scala, 19 bytes (Cracked by @math_junkie)

)>,/2(=addd.hmoptw5

This is a function of type Int=>Double.

share|improve this answer
    
Cracked! – math_junkie 14 hours ago

05AB1E, 4 bytes (Cracked by @Mr. Xcoder)

Must be really easy to crack, but I'll still post it here

n*t¹

Normal rounding

share|improve this answer

C, 60 bytes (Cracked by @Dave)

1(root, flat*fat bern**lotr);pw(f{bus(--q.b4/q0*1-2)})(b>1)b

Standard C float accuracy.

share|improve this answer
    
Cracked: codegolf.stackexchange.com/a/115113/8927 – Dave 14 hours ago

Javascript, 123 bytes, Cracked by notjagan

 """"""((((((((()))))))))********,--.....//2;;======>>Seeeeeeegggggggggggghhhhhhhhhhhilllllnnnnnnnnnnorrrsstttttttttttttu{}

This code is a full function

There is one space character at the very start of the list of characters

The rounding of this answer is the floating point precision for Javascript, accuracy is within 10^-6 for every answer.

Got shorter because the precision didn't need to be maintained quite as high as I thought it did.

I had realized that it would be much easier to solve than I initially had made it but it was already there :P

Initial code:

g=t=>t-(t*t-n)/("le".length*t);e=h=>{n=h*h*h*h*h,s=2**(n.toString("ng".length).length/"th".length);return g(g(g(g(g(s)))))}

Newtons method, applied 5 times from the closest power of 2

share|improve this answer

RProgN 2, 6 Bytes

š2]^+\

No rounding, displays many decimal places. Does not display any for an integer solution.

share|improve this answer

Haskell, 64 bytes

$$$$$$(((((())))))**,...0<<<>>>[]cccccdddeffiiiiilloopppprrsstuu

Standard Haskell floating point operations.

share|improve this answer

R, 19 bytes (Cracked by @Steadybox)

mensana(4*5*c(.1)):

Standard rounding

R, 33 bytes

(rofl(17)^coins(2*e)/pisan(10))--
share|improve this answer
    
Cracked the 19-byte answer. – Steadybox 10 hours ago

Python 3.6 - 52 bytes (Cracked by @xnor)

f=lambda x:x**125*77*8+8/5/((('aafoort.hipie.xml')))

Standard Python rounding

share|improve this answer
    
Cracked – xnor 4 hours ago

C#, 112 bytes (cracked by Emigna)

     ((((())))),.....25;;;=CCLMMPPPRSWaaaaaaabbbccdddeeeeeeeeghiiiiiillllmnnnnnooooooorrrsssssssstttttuuvvwy{{}}

no rounding done

using System;
class P
{
    static void Main()
    {
        var b=double.Parse(Console.ReadLine());
        Console.Write(Math.Pow(b,2.5));
    }
}
share|improve this answer
    
Cracked – Emigna 1 hour ago

Octave, 30 bytes

(((((())))))**++/:@eeeiiijmsu~

A bit simpler than my first one. Shouldn't be too hard, but it's hopefully a fun puzzle.

share|improve this answer
1  
No ^? Hmmm... – Luis Mendo 13 mins ago

Python 2, 39 bytes (cracked by @Mr. Xcoder)

q=a(lxt)mh*mprf.hr
ax tttaixxmb :m*asod

Standard Python float rounding.

share|improve this answer
    
Cracked. – Mr. Xcoder 16 hours ago

Octave, 42 bytes

((((()))))+,,,-//01111111@[]^mnooorrssst~~

No rounding. Floating point accuracy.

share|improve this answer
    
I think I'm quite close, but I don't have any more time. This one should be a bit simpler than my first one, in case you want to give it a go :) – Stewie Griffin 15 mins ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.