Cops and Robbers: Redacted Primality (Cops' Thread)

19

3

This challenge was originally sandboxed by Magic Octopus Urn; I adopted and posted it with his permission.

This is the cops' thread. The robbers' thread is here.

The challenge

  • Step One: Write a piece of code (function or full program) which checks for primality.
  • Step Two: Remove pieces of your code by replacing characters with the symbol .
  • Step Three: Post the redacted code on the cops thread.
  • Step Four: Wait for your code to be cracked and try to crack other's code.

For example, the Groovy code {it.isPrime()} could become {██.is█████()}. (This one would be stupidly easy to crack; also, I know, .isPrime() is not a Groovy method.)


Scoring

You must include your program's score in its submission. The score is defined as the ratio of redacted characters to characters. So if your program had 20 characters and 5 were redacted, your score would be 0.25. The Groovy code above would have a score of 0.5.


Rules

  • Your program only needs to handle positive integers. It should output a truthy value if the number is prime and a falsy value otherwise. Please specify in your answer what it outputs.
  • Your code may not contain any comments or unnecessary whitespace.
  • No hashing or cryptographic obfuscation.
  • Your code may be no more than 50% redacted (at least 1/2 the characters must be shown). This means that the highest possible score is 0.5.
  • If your answer is not cracked within a week you may mark it safe and edit in the intended crack.

Winning

The winner will be the lowest-scoring uncracked answer within two weeks of posting. In the case of a tie, whichever has the most votes will win. This thread is always open to more submissions, but the winner chosen after two weeks will be permanent.

MD XF

Posted 2018-02-03T04:29:14.897

Reputation: 11 605

What is the domain of the input? (i.e. is it all n >= 1 or all integers?) – Conor O'Brien – 2018-02-03T04:50:07.343

1@FryAmTheEggman [tag:status-completed] – MD XF – 2018-02-03T05:11:23.357

It may be a good idea, given a conversation that has already happened in the comments of an answer, to discuss the spirit of your rule about comments. Generally, the code should be "golfed," in that it should not contain arbitrarily long variable names, etc, to achieve lower scores. This can't really be a rule (at least afaik) but I think it will be alright since the community can discourage obviously lame answers. I'm not certain, and definitely thought that this might make the challenge unclear, but I think that is the best way to go. – FryAmTheEggman – 2018-02-03T05:48:08.213

1Again, if a scoring method is easily exploitable, it's broken. – user202729 – 2018-02-03T07:33:13.210

1Related :) – DLosc – 2018-02-03T09:25:26.660

You should had characters at prime number positions are redacted. This would have encouraged shorter solutions because primes get less common as the numbers get larger – Jo King – 2018-02-04T06:06:39.427

1Snippet please? – user202729 – 2018-02-04T10:21:11.360

Define "unnecessary whitespace" – Destructible Lemon – 2018-02-06T22:36:24.320

Answers

3

Functoid, score = 14 / 223 ≈ 0.062780 [safe]

Y(yG(BK██)(B(S(BS(C(BC(C(BB(B(v
S(CB█)(█C█B>vK  BSBB())█K(BS(S?
>(KZ)(C(C(Bv>██        >   v██<
█)Sg3I)$; @>B(BS(b(C(BBI)Iv>(█g
())I)))I)IBB(C(b(CB(C())))<v)█C
I))I))0)))(C(BC(B(BB)(C(BBv>)))
]I))))I))>    >)█   $;@   >I)(B

Takes input as command-line argument and outputs True (prime) or False, try it online!

Hint (added 4 days after posting):

The first and 4th are a red herring: The intended (and most likely every) solution's IP will follow the first line and reach the ? character.

Solution

Y(yG(BKL2)(B(S(BS(C(BC(C(BB(B(v
S(CBO)( C B>vK  BSBB())OK(BS(S?
>(KZ)(C(C(Bv>O)        >   vY <
^)Sg3I)$; @>B(BS(b(C(BBI)Iv>(yg
())I)))I)IBB(C(b(CB(C())))<v)-C
I))I))0)))(C(BC(B(BB)(C(BBv>)))
]I))))I))>    >)2   $;@   >I)(B

Try it online!

Explanation

Due to the randomness that comes from ? it's not possible to flatten the program. Here's the flat program with a question mark where a random expression will be:

Y(yG(BKL2)(B(S(BS(C(BC(C(BB(B(?(yg(KZ)(C(C(BB(BS(b(C(BBI)I))))(C(BC(b(C(BBI)I)))I))(C-))))I))I))0)))(C(BC(B(BB)(C(BBI)(B]I))))I)))2$;@

Full program:

Y{trial_division}      --  fix-point of {trial_division}
                 2     --  apply 2 (begin division with 2)
                  $    --  apply argument (work with the supplied input)
                   ;   --  print result as boolean
                    @  --  terminate program

The {trial_division}:

y                         -- recursive function with two arguments x,y
 G                        -- | base predicate: x >= y
  (BKL2)                  -- | base function:  BKL2 x y
                             |  ->             K(L2) x y
                             |  ->             L2 y
                             |  ->             2 <= y
        {recursive_call}  -- | recursive call

{recursive_call}, taking arguments f (self-reference), x and y (note 0 is the same as False)

  B (S(BS(C(BC(C(BB(B{divides}I))I))0))) (C(BC(B(BB)(C(BBI)(B]I))))I) f x y
->       (C(BC(C(BB(B{divides}I))I))0) x y (BC(B(BB)(C(BBI)(B]I)))) f I x y)
->       (C(BC(C(BB(B{divides}I))I))0) x y (BC(B(BB)(C(BBI)(B]I)))) f I x y)
->            (C(BB(B{divides}I))I) x y 0  (BC(B(BB)(C(BBI)(B]I)))) f I x y)
->            (C(BB(B{divides}I))I) x y 0  (   B(BB)(C(BBI)(B]I))   f x I y)
->                   {divides}      x y 0  (         C(BBI)(B]I)    f x y  )
->              if x `divides` y then 0 else         C(BBI)(B]I)    f x y
->                                                    f (B]I x)  y
->                                                    f (] x) y
->                                                    f (x+1) y

{divides} is ?(yg(KZ)(C(C(BB(BS(b(C(BBI)I))))(C(BC(b(C(BBI)I)))I))(C-))) where ? is randomly chosen (depending on the random direction) from:

  • Y
  • S(CBO)(CBO)
  • S(SB(KO))(BBSBKO)

These are all equivalent to each other, so {divides} becomes the fix-point of:

y                       -- recursive function with two arguments x,y
 g                      -- | base predicate: x > y
  (KZ)                  -- | base function:  KZ x y
                        -- |  ->              0 == y
      {recursive_call}  -- | recursive call

{recursive_call} is a pretty obfuscated expression that basically just does f x (y-x)

ბიმო

Posted 2018-02-03T04:29:14.897

Reputation: 15 345

5

8086 DOS COM, 87 bytes, score 19/87 ~= 0.2183

Cracked by NieDzejkob

1└╣██1█╛ü ¼<█t<< u≈¼<█t█,0|/<██+ô≈ßô☺├δδâ√█|█╞█S█Y╣██9┘t█ë╪1╥≈±○╥t█Aδ∩╞█S█N┤█║S█═!├A
$

This is a COM program; expects number as a command line argument, outputs Y or N. Limit: 65535 because 16 bit processor (sizeof(int) would be 2). Newline is 0x0D 0x0A on this platform. Yes you count 20 █ instead of 19 █. One of them's a real █ and has not been substituted. Muhahaha.

The space in position 10 is actually a NUL byte. The symbol for NUL is the same as space in the old VGA font.

Joshua

Posted 2018-02-03T04:29:14.897

Reputation: 3 043

1

Will take forever to crack because there are about 0 relation between assembly (opcode) and machine code. / Is this Code page 437?

– user202729 – 2018-02-05T05:23:47.983

@user202729: Correct code page. DOS is CP437 unless stated otherwise. – Joshua – 2018-02-05T15:40:50.293

Are you using an obscure DOS quirk to read the commandline parameters from $5881 instead of $0081, or is it a mistake? Do I need a true DOS installation? – NieDzejkob – 2018-02-05T22:36:15.200

@NieDzejkob: Wait what? I'm pretty sure it reads its command line from DS:0081. I'll double-check the hexdump when I get home but I don't expect to find anything. – Joshua – 2018-02-05T23:14:18.567

@Joshua well, the ╛üX at the very beginning is mov si, 0x5881. – NieDzejkob – 2018-02-05T23:36:52.777

@NieDzejkob: Ah. Upload problem. I added a note to it. – Joshua – 2018-02-05T23:45:30.840

Well, I don't even need these bytes. Cracked! – NieDzejkob – 2018-02-06T02:15:13.713

5

Swift 4, score 26 / 170 ≈ 0.153, safe

func p(n:Int)->Bool{func █(_ █:Int,_ █:Int)->Int{var h=(1...l).map{$0██m██
while(m=h.count,m██).1{h=[Int](h[█...])};return m}
return █>██&(█.███).index█j█n██0)>=█0}█=██l}

Try it online!

Intended Crack

func p(n:Int)->Bool{func j(_ l:Int,_ k:Int)->Int{var h=(1...l).map{$0},m=l
while(m=h.count,m>k).1{h=[Int](h[k...])};return m}
return n>1&&(2..<n).index{j(n,$0)>=$0}==nil}

Ungolfed

func p(n:Int)->Bool{
  func j(_ l:Int,_ k:Int)->Int{    // Modulus function (l mod k)
    var h=(1...l).map{$0},m=l      //  Create an array h of size l
    while(m=h.count,m>k).1{        //  While h has more than k elements:
      h=[Int](h[k...])             //   Remove k elements from h
    }
    return m                       //  Return the length of h (equal to k if l divides k)
  }
  return n>1&&                     // Test if n > 1
  (2..<n).index{j(n, $0)>=$0}==nil //  and no number from 2 to n-1 divides n
}

Herman L

Posted 2018-02-03T04:29:14.897

Reputation: 3 611

4

brainfuck, 37/540 bytes (score: 0.06851) (Cracked by Nitrodon)

>>>>>+>,[>++++++[-<-------->]<+>,]<[-[█<█<]++++++++++<]>[-]>>██[>█>>█>]+[<]<<[<]>█<<+>>[>]█>[>]█+[<]<<[<]>-█>]>>[->]<[-[[<]<]++++++++++<]>[-]>[<█]>]>[>]<[[█]<]<<<<<[<]<<██>>[>]<█[->+<]<█>>[>]<[-[[<]<]++++++++++<]>███>[<<]>[[[>]>████[<]<[-[[<]<]++++++++++<]>[-]>[█<]>]>[>]<[[-]>+[>]<-<[<]<]+<<<<<[<]>[[>]+[[>]>]>[>]>[-<+>]<[<]<[>+[<]>>-<<<<<[[<]<]>>███████>[[█]>]<]<[[<]<]<[█]>]>>>[[>]<->>]]>[[>]>]<<[[[█]<]<]<<<[█]<<█>>>[>]█[-[[<]<]++++++++++<]>>[[>]+[------->++<]>.+.+++++.[---->+<]>+++.>>]>[>]+[------->++<]>++.++.---------.++++.--------.

Try it online!

Prints "prime" if prime, "not prime" if composite. Technically works for arbitrary integers but times out on TIO for numbers above 6000

Jo King

Posted 2018-02-03T04:29:14.897

Reputation: 38 234

2Cracked after working on this for several days. – Nitrodon – 2018-02-08T13:54:29.273

3

Python 3, 388 bytes, .155, Cracked

Last-minute crack. Yes, this is the Miller-Rabin test.

I suppose probabilistic tests are allowed, uncertainty 2^-100

Well, a great hint in the previous sentence though

Made return value 0 as COMPOSITE and 1 as PROBABLY PRIME

*368 > 388 : Fixed the problem when z<4

import ██████
def f(z):
 if z<4:return z>>1
 d,s,n,e,c=██z,0,z,0,50
 while not ██1:d//=2;s+=1
 while n>0:n//=2;e+=1
 ███████████()
 while c>0:
  a=0
  while a<2or a>z-█:
   a,b=0,e
   while b>0:a=a*2+██████████████(0,1);b-=█
  x,r=███(█,█,z),██s
  if ██x and x!=██z:
   while r>0:
    x,r=███(█,█,z),██r
    if not ██x:return 0
    elif x==██z:break
   else:return 0
  c-=█
 else:return 1

Solution:

import random
def f(z):
 if z<4:return z>>1
 d,s,n,e,c=~-z,0,z,0,50
 while not d&1:d//=2;s+=1
 while n>0:n//=2;e+=1
 random.seed()
 while c>0:
  a=0
  while a<2or a>z-1:
   a,b=0,e
   while b>0:a=a*2+random.randint(0,1);b-=1
  x,r=pow(a,d,z),~-s
  if ~-x and x!=~-z:
   while r>0:
    x,r=pow(x,2,z),~-r
    if not ~-x:return 0
    elif x==~-z:break
   else:return 0
  c-=1
 else:return 1

Shieru Asakoto

Posted 2018-02-03T04:29:14.897

Reputation: 4 445

1I think having long strings like "COMPOSITE" violates the spirit of the rule "Your code may not contain any comments or unnecessary whitespace." – Pavel – 2018-02-03T05:29:20.647

@Pavel Edited. Well I don't think the return values are comments or unnecessary whitespace though – Shieru Asakoto – 2018-02-03T05:37:57.640

1It was technically valid. It was just cheap. – Pavel – 2018-02-03T05:41:30.087

I don't think this terminates when z=2. – Nitrodon – 2018-02-03T06:28:56.407

@Nitrodon Oops, it didn't terminate when z=3 either. Fixed – Shieru Asakoto – 2018-02-03T06:44:55.077

Cracked. I didn't realize earlier that Miller-Rabin has a 3/4 probability of detecting composite numbers. – Nitrodon – 2018-02-10T07:47:47.847

3

Mathematica, 97 bytes, score 0.2989690722 (Cracked)

f[x_]:=(██ToString███████████████;StringMatchQ[████Infinity,RegularExpression@"█\█\█{█\█+, ███"])

Strings! Regex! Primes?

There is such a thing as a primality checking regex, but that's not whats happening here.

This has been cracked, but the way I intended was quite different, so I won't reveal the intended solution yet.

Pavel

Posted 2018-02-03T04:29:14.897

Reputation: 8 585

1Cracked. – user202729 – 2018-02-03T08:23:53.560

3

Jelly, score 0.(142857) (cracked)

25██26█966836897364918299█0█1█65849159233270█02█837903312854349029387313█ị██v

Try it online!

Repost of my other answer, this time with a few more bytes revealed to avoid unintended cheats.

Erik the Outgolfer

Posted 2018-02-03T04:29:14.897

Reputation: 38 134

I can character-wise OR your two answers to get some bytes... probably I won't. – user202729 – 2018-02-03T13:57:44.527

@user202729 Uh, something weird happened, I didn't intend to cover more chars... – Erik the Outgolfer – 2018-02-03T14:20:43.433

Cracked. – user202729 – 2018-02-04T10:14:04.970

3

095, score 0.20512820512 [Safe]

1id#█#=(DD#█#█{d_█%(█D0█]D}██s]D1.=[1s]

Prints 1 if prime, 0 if composite

Solution:

1id#2#=(DD#2#-{d_.%(rD0R]D}drs]D1.=[1s]

nosekill

Posted 2018-02-03T04:29:14.897

Reputation: 81

3

Octave, Score: 0.15 (86 bytes)

I revealed several more characters. I thought the winning criterion was highest score, not lowest.

@(x)eval([(str2num(cell2mat([cellstr(reshape('0█1███1█0█0█00',████))])')█'█')','(x)'])

Try it online!

Good luck =)

Stewie Griffin

Posted 2018-02-03T04:29:14.897

Reputation: 43 471

1Cracked! This was a fun one. – Giuseppe – 2018-02-08T20:23:15.937

2

Node JavaScript, score: 0.4

Here's where it works. Full program that takes input from first command line argument, and outputs to stdout.

Hopefully, a not-so-difficult solution to start this off.

Using this snippet to calculate score.

require███████████2<<2██>n█████rin█(b████████x)█████(9211█6830)██(a,c)=>a[c[0]██████████(c)]███████);d=███+n;q=████27775██9564,[502█59,█6])[█]);a=██q>0████r(n=q█a█&█-q-██)a██n%q?██0██(137152█8270,22288)(a)

Conor O'Brien

Posted 2018-02-03T04:29:14.897

Reputation: 36 228

2

Japt, 19 bytes, 0.315789... score, Safe

I don't know if I obscured more of this than I needed to, costing myself a better score.

█h8575¥█
█UâÊ█Ê█ █2

View solution (Explanation coming soon)

Shaggy

Posted 2018-02-03T04:29:14.897

Reputation: 24 623

2

Jelly, score 0.(142857)

25██26█9668368973649182992051██5849159233270202█837903312854349029387313█████

Try it online!

Takes a command-line argument.

False = 0
True = 1

Erik the Outgolfer

Posted 2018-02-03T04:29:14.897

Reputation: 38 134

1Certainly unintended crack. – user202729 – 2018-02-03T13:28:39.960

@user202729 Eh, I should've revealed more, I'll repost. But I can't add that it was cracked until you post on the robbers thread. :P – Erik the Outgolfer – 2018-02-03T13:31:56.067

2

JavaScript, 103 bytes, score 0.1923

x=>{if(x<4)return(!0);for(y=x>>>Math.log10(p=████;--y-1;(p=x/y%1)████if(██&&(███))break████return(███)}

Returns a boolean.

Unintended crack

iovoid

Posted 2018-02-03T04:29:14.897

Reputation: 411

Cracked! – MegaTom – 2018-02-04T02:52:10.907

2

Brain-Flak, Score: 35/134 = 0.2612 (cracked!)

(({████){██[████)█>(({}))<>}<>{}███{}((██({}))█████{}]██)({}(<>))<>{(({})){({}[()])<>}{}}{}<>([{}()]{})██[██()██(()█[()]██{}██}{}<>{})

Returns 1 for prime, 0 for composite.

This is a very hard language to try this challenge in, as the formatting is so restricted that it takes effort not to make it obvious what the missing character is.

This is a very hard language to solve this challenge in, as it is ridiculously hard to read.

MegaTom

Posted 2018-02-03T04:29:14.897

Reputation: 3 787

Cracked – Nitrodon – 2018-02-04T06:39:25.433

2

Javascript, score 0.1894093686354379

let t=[2,3,3,3,3,3,3,5,7,5,7,5,7,7,11,12,13,11,13,13,1,2,17,13,2,3,17,19,23,29,19,19,41,23,23,29,23,"","",29,7,31,31,524,31,37,33,34,41]; function r(a, b) {█████████████████████████████████████████████████████████████};function l(t){let a=0;let b=[];while(true){b.push(t[a]);█████████████;if(!t[a]){return█████};function p(v) {let i=0;let a=r(2,v██);for (i in a){if(v%(█████████a█i██)==0){return false;}};return true;};function f(v){if(l(t).indexOf(v)!=-1){return true;}else{return p(v)};};

Good luck. :p

call f with the prime you want to check.

moonheart08

Posted 2018-02-03T04:29:14.897

Reputation: 693

Unintended crack within less than 30 minutes. Not even use the array t. – user202729 – 2018-02-05T15:55:26.143

Hum. I guess i didn't think about that one. This is just a preliminary warmup anyways :p Nice job. – moonheart08 – 2018-02-05T16:01:35.273

2

><>, score 0.096, cracked by Jo King

:1@v>~~:?1n;█$-1<█?=2:}*{█@:$@:

Intended crack:

:1@v>~~:?1n;
$-1<^?=2:}*{%@:$@:

Esolanging Fruit

Posted 2018-02-03T04:29:14.897

Reputation: 13 542

I don't know ><> really well, but isn't the first v an unconditional infinite loop? – NieDzejkob – 2018-02-05T22:31:15.767

@NieDzejkob If you run the program as it is, yes, it will loop forever. – Esolanging Fruit – 2018-02-05T22:44:26.220

oh, I see it now... – NieDzejkob – 2018-02-05T22:57:44.713

Cracked – Jo King – 2018-02-06T02:06:37.220

2

Java 1.4+, 24/145 (0.16551724137)

class X{public static void main(String[]args){System.out.println(new String(████████[Integer.parseInt(args[0])]).matches("█████████████")?███);}}

Try it online!


Weirdest way I've seen to prime check in Java by far lol.

Magic Octopus Urn

Posted 2018-02-03T04:29:14.897

Reputation: 19 422

cracked – ovs – 2018-02-08T14:33:22.797

2

C, 34/76 = 0.447368, Safe

int p(int n){int r███████2;██r███r++)███+███n;████&███r));return███████n██;}

Having this many blanks means that I will be much more likely to get an unintended crack than the intended one.

Solution:

int p(int n){int r=1,e=n%2;for(;(r++)*(r++)<n;e=e&&(n%r));return e?n>1:n<3;}

explanation:

e holds a boolean value of whether or not the number is not prime (with a few special case exceptions). r iterates through the odd numbers less than or equal to the square root of n. return e?n>1:n<3; handles the special cases when n is 1 or 2.

MegaTom

Posted 2018-02-03T04:29:14.897

Reputation: 3 787

2

M, score: 4/22 = .1818..., cracked by Dennis

███“;;█»VOḣ2S⁵++3Ọ;”Pv

This may end up with an unintended crack, we'll have to see. It did.

Dennis' solutions is

ÆPø“;;“»VOḣ2S⁵++3Ọ;”Pv

Try it online!

I will leave my solution hidden for someone to crack. My hint to Dennis on his robber submission was the word "zoo".

dylnan

Posted 2018-02-03T04:29:14.897

Reputation: 4 993

@user202729 I think you may be able to crack this – dylnan – 2018-02-20T16:55:11.503

Cracked. – Dennis – 2018-02-21T18:17:21.057

1

Pyth, score: ~0.(461538) (13 bytes) (Cracked)

█]█Q ██Q{█M█P

Try to crack it here!

Mr. Xcoder

Posted 2018-02-03T04:29:14.897

Reputation: 39 774

Cracked. – MD XF – 2018-02-04T02:49:46.860

I knew it was easily brute forceable... – Mr. Xcoder – 2018-02-04T06:02:27.467

1

Pyt, score: 0.288288... [Safe]

Đ2⇹█ŘĐĐŁ███⇹ʀĐ↔Đ5Ș↔⇹██=█ŕĐ↔Đ5Ș↔Đř█⇹█████↔Đ4Ș5Ș⇹██⇹3Ș°04Ș↔█3ȘĐŁ█3Ș05Ș↔█⇹04Ș0↔⇹██=█ŕ↔ŕĐĐŁ██↔██↔ŕŕŕŕ█↔████↔ŕŕŕ██¬¬


Outputs "True" if prime, "False" if not

Forgot to mention that it is a probabilistic test.

Solution:

Đ2⇹⁻ŘĐĐŁ₂`⁻⇹ʀĐ↔Đ5Ș↔⇹Ǥ1=?ŕĐ↔Đ5Ș↔Đř²⇹%∈2*⁻↔Đ4Ș5Ș⇹⁻₂⇹3Ș°04Ș↔+3ȘĐŁ⁺3Ș05Ș↔+⇹04Ș0↔⇹%+=?ŕ↔ŕĐĐŁ⁺⁺↔ł:↔ŕŕŕŕ;↔⁺⁻±?↔ŕŕŕ:;¬¬

This implements the Solovay-Strassen primality test.

Try it online here!

mudkip201

Posted 2018-02-03T04:29:14.897

Reputation: 833

1

C, 66 bytes, 29 redacted, score 0.439

i;p(n){█████2███████ 0███████2;███;███)if(████)return 0;return 1;}

Just a simple C submission; I'll see how long this one takes before I post a really evil one.

MD XF

Posted 2018-02-03T04:29:14.897

Reputation: 11 605

Are you sure that the last block is supposed to be 4 characters long? – NieDzejkob – 2018-02-05T17:02:36.840

@NieDzejkob Yes. – MD XF – 2018-02-05T18:27:02.977

1

sh + coreutils, score 19 / 143 ~= 0.1328

cracked

e█ec█s█ █c "██████WyAkKHNoIC1jICJg█WNobyBabUZqZEc5eWZIUnlJQ2█2SnlBblhHNG5m██JoYVd3Z0t6SjhkMk1nTFhjSyB8YmFzZTY0IC1kYCIpIC1lcSAxIF0K█b█se6███d`"

TIO

Joshua

Posted 2018-02-03T04:29:14.897

Reputation: 3 043

1@MDXF: Base64 is encoding, not encryption. There's no key to crack. – Joshua – 2018-02-04T02:21:48.730

Can you include a TIO link? (probably bash) – user202729 – 2018-02-04T10:19:57.990

Cracked (3 hours ago). – user202729 – 2018-02-05T15:46:20.553

1

Brain-Flak, score 29 / 140 = 0.207

({}██()██<>){██({}[()])██{}{}███({<({}[()])><>({})<>}{}██████{}██){(({})){({}[()])<>}{}}<>([{}()]{}<>{})<>}(<>██{}({}████)((){[()]██{}██}{})

Try it online!

Outputs 1 for prime and 0 for non-prime.

Nitrodon

Posted 2018-02-03T04:29:14.897

Reputation: 9 181

1

Tampio (imperative), score: 24/51 = 0.5

Luku on alkuluku,jos ████████████e███████ on █████.

This is an obvious solution, I hope no one here understands Finnish.

fergusq

Posted 2018-02-03T04:29:14.897

Reputation: 4 867

1

Tampio (imperative), score: 26/223 = 0.11659...

Luvun kokonaislukuarvot ovat riippuen siitä,onko se yksi,joko listan,jonka alkioita ovat yksi █████████████████████,alkiot tai █████ liitettynä sen alkutekijöihin.Luku on alkuluku,jos sen kokonaislukuarvojen summa on nolla.

fergusq

Posted 2018-02-03T04:29:14.897

Reputation: 4 867

1

Python 3, score: 0.386363, cracked

p=lambda x,i=2:█████or(x%i and ████████)████

Going for the really low hanging fruit at first. I'll come up with a cheeky answer soon.

user71546 made it "work" with

p=lambda x,i=2:i>=x or(x%i and p(x,i+1))or 0

...but that was unintended. Original code was

p=lambda x,i=2:i>x/2or(x%i and p(x,i+1))or 0

Neither work for x<2, turns out. Oops.

osuka_

Posted 2018-02-03T04:29:14.897

Reputation: 391

1Cracked? Not working when x<2 though. – Shieru Asakoto – 2018-02-20T04:19:38.140

1

Ruby, 27/73 = 0.369863

def p n;███████(██n.times████a[2..-1].map{|s|█.██n████s}██.█*█|██})█);end

This should be fun.

MegaTom

Posted 2018-02-03T04:29:14.897

Reputation: 3 787

0

JavaScript (ES7), 297 bytes, 103 redacted, .347

M=(N,X=N,F=(n,a=█████)=>a>1e-20?█████+F(n,█████████):1,G=(n,a=█████)=>a>1e-20?█████+G(n,███████):n==2?0:G(n-1),H=(n,a=█████)=>a>1e-20?█████-H(n,███████):0,I=n=>████████I(████),J=n=>I(n)*████+H(█████████-1),K=(n,l=n|0)=>(n-l>=.5)+l,L=(a,b)=>██████████(a)+█(b)████,Z=L(--N,N)██)=>L(Z,████M(N,X)██)██

My previous Python answer was too straightforward, so here's an evil one ;)

The logic behind is straightforward though.

Shieru Asakoto

Posted 2018-02-03T04:29:14.897

Reputation: 4 445