title: Binary Prime-Chunks

text:
# Question
Title: Binary Prime-Chunks
# We are searching for a sequence

Take the **natural numbers**
`1,2,3,4,5,6,7,8,9,10,11,12,13,14...`

Convert to **base-2**
`1,10,11,100,101,110,111,1000,1001,1010,1011,1100,1101,1110...`

**Concatenate** the above numbers
`110111001011101111000100110101011110011011110...`

**Partition** this number in **Prime-Chunks**
(chunks containing a prime number of digits)
Primes are taken in asceding order `2,3,5,7,11,13,17...`

`[11][011][10010][1110111][10001001101][0101111001101][1110...]`

and find the **Sum of the digits of each chunk**

`Primes 2 3 5 7 11 13 17`
`Chunks [11][011][10010][1110111][10001001101][0101111001101][1110...]`
`SumOfDigits 2 2 2 6 5 8`

# The Sequence

> 2, 2, 2, 6, 5, 8, 9, 10, 14, 22, 11, 18, 25, 27, 32, 21, 28, 32, 40, 40, 49, 49, 32, 41, 49, 53, 63, 55, 63, 70, 87, 73, 51, 63, 71, 78, 78, 90, 107, 86, 96, 108, 115, 128, 138, 92, 83, 95, 102, 110, 130, 106, 122, 141, 149, 163, 130, 140, 151, 165, 181, 165, 204, 200, 234, 100, 130, 138, 167, 149, 169, 180, 209, 166, 189, 194, 222, 205, 234, 260, 216, 206, 217, 241, 240, 267, 289, 242, 274, 308, 286, 329, 338, 155, 189, 225, 197, 240, 272, 217, 254, 282, 287, 317, 281, 256, 299, 286, 331, 337, 316, 350, 354, 391, 367, 282, 327, 313, 364, 358, 348, 397, 406, 466...

# The Challenge

Find the `nth` term of the above sequence

# Input

An integer `n>0`

# Test Cases

```
1->2
3->2
6->8
36->78
60->165
160->581
260->1099
350->1345

```

This is .Shortest answer in bytes wins!

# Answer
# Husk, 8 bytes

```
Σ!CİpṁḋN

```

Try it online!

## Explanation

```
Σ!CİpṁḋN
       N   Start with the infinite list of natural numbers.
     ṁḋ    Convert each to its binary representation and join them all together. (A)
   İp      Get the infinite list of primes. (B)
  C        Split (A) into chunks of lengths (B).
 !         Retrieve the nth chunk (where n is the input).
Σ          Sum the bits in this chunk.

```
> 14 votes

# Answer
# Jelly, 12 bytes

```
RÆNµSRBFṁRṪS

```

Try it online!

### How it works

```
RÆNµSRBFṁRṪS  Main link. Argument: n

R             Range; yield [1, ..., n].
 ÆN           N-th prime; yield P := [p(1), ..., p(n)].
   µ          Begin a new, monadic chain with argument P.
    S         Take the sum of P, yielding s := p(1) + ... + p(n).
     R        Range; yield [1, ..., s].
      B       Binary; convert all integers from 1 to s to base 2.
       F      Flatten the resulting array.
         R    Range; yield [[1, ..., p(1)], ..., [1, ..., p(n)]].
        ṁ     Mold; reshape the result to the left like the result to the right.
          Ṫ   Tail; take the last chunk.
           S  Take the sum, counting the set digits.

```
> 6 votes

# Answer
# 05AB1E, 12 bytes

### Code

Can get pretty slow for large numbers:

```
ÅpDOLbJs£`SO

```

Uses the **05AB1E**-encoding. Try it online!

### Explanation

```
Åp              # Get a list of the first <input> primes
  DO            # Duplicate and sum the primes
    L           # Create the list [1, .., <sum>]
     bJ         # Convert to binary and join into a single string
       s£       # Get the slices [a[0:2], a[2:2+3], a[2+3:2+3+5], a[2+3+5:2+3+5+7], ...]
                  corresponding to the list of primes
         `SO    # Get the last one and sum up it's digits

```
> 5 votes

# Answer
# Mathematica, 71 bytes

```
(Tr/@TakeList[Join@@IntegerDigits[Range[#^2+1],2],Prime~Array~#])[[#]]&

```

Try it online!
> 4 votes

# Answer
# Jelly, 21 bytes

```
RÆNSRBF
RÆN+\‘ṬœṗÇ⁸ịS

```

Try it online!
> 2 votes

# Answer
# , ~~206~~ 200 bytes

```
function(n){a=p=j=y=2
for(i in 2:n-1){while(sum(y)<4*a){x=as.double(rev(intToBits(j)))
y=c(y,x[cumsum(x)>0])
j=j+1}
b=1:a
y=y[-b]
z=outer(k<-b+a,p,'%%')
p=c(a<-k[!apply(z<1,1,sum)][1],p)}
sum(y[1:a])}

```

Try it online!

The algorithm tries also to "save" on space by iteratively removing bits as it cycles through the primes. I feel that the decimal to bit conversion could probably be shorter, but I could not figure out other alternatives.

Saved 6 bytes thanks to Jonathan French.
> 2 votes

# Answer
# Jelly, 16 bytes

```
RBFṁ
RÆNSÇṫÆNC$S

```

Try it online!

## Explanation

```
RBFṁ  Helper link. Input: integer k
R     Range, [1, 2, ..., k]
 B    Convert each to a list of its binary digits
  F   Flatten
   ṁ  Shape it to length k

RÆNSÇṫÆNC$S  Main link. Input: integer n
R            Range, [1, 2, ..., n]
 ÆN          Get i'th prime for each
   S         Sum
    Ç        Call helper link
         $   Monadic chain
      ÆN       Get n'th prime
        C      Complement, 1 - n'th prime
     ṫ       Tail, take the last n'th prime digits
          S  Sum

```
> 2 votes

# Answer
# JavaScript (ES6), 144 bytes

```
n=>eval("s=o=j=0;for(i=p=1;n;d>p&&(n--,s+=p))for(p++,d=2;p%d++;);while(b=Math.log2(++j)+1|0,i<=s)for(x=0;x++<b&i<=s;)o+=i++>s-p&&j<<x&1<<b?1:0")

```

## Ungolfed

```
n=>{
    s=o=j=0;
    for(i=p=1;n;d>p&&(n--,s+=p))
        for(p++,d=2;p%d++;);
    while(b=Math.log2(++j)+1|0,i<=s)
        for(x=0;x++<b&i<=s;)
            o+=i++>s-p&&j<<x&1<<b?1:0
    return o
}

```

## Test Cases

```
f=
n=>eval("s=o=j=0;for(i=p=1;n;d>p&&(n--,s+=p))for(p++,d=2;p%d++;);while(b=Math.log2(++j)+1|0,i<=s)for(x=0;x++<b&i<=s;)o+=i++>s-p&&j<<x&1<<b?1:0")

;[1,3,6,36,60,160,260,350].forEach(t=>console.log(t,"->",f(t)))
```

```
.as-console-wrapper{max-height:100%!important}
```
> 2 votes

# Answer
# Perl 6, 67 bytes

```
{(1..*).map(|*.base(2).comb).rotor(grep *.is-prime,2..*)[$_-1].sum}

```

Test it

## Expanded:

```
{  # bare block lambda with implicit parameter ｢$_｣

  (

    1 .. *                # Range of all numbers starting with 1

  ).map(

    # WhateverCode lambda
    |                     # Slip each of these values into the outer list individually
      *                   # this is the parameter
      .base(2)            # convert base
      .comb               # split into digits

  ).rotor(                # split into chunks

    grep *.is-prime, 2..* # the sequence of prime numbers

  )[ $_ - 1]              # index into it using 1 based indexing

  .sum                    # find the sum
}

```
> 2 votes

# Answer
# JavaScript (ES6), ~~138~~ ~~132~~ 123 bytes

```
N=>(n=k=1,g=s=>N?g((P=n=>n%--x?P(n):x<2)(x=++n)?s[n]?s.slice(--N&&n,n/!N):s+(n--,k++).toString(2):s):s.split`1`.length-1)``

```

### Test cases

Try it online!

### Demo

*NB: Only 'safe' test cases are included here (guaranteed to work on Chrome, Firefox and Edge). You may have to increase the call stack size of your engine to pass the other ones.*

```
let f =

N=>(n=k=1,g=s=>N?g((P=n=>n%--x?P(n):x<2)(x=++n)?s[n]?s.slice(--N&&n,n/!N):s+(n--,k++).toString(2):s):s.split`1`.length-1)``

console.log(f(1))   // 2
console.log(f(3))   // 2
console.log(f(6))   // 8
console.log(f(36))  // 78
console.log(f(60))  // 165
```

### Formatted and commented

```
N => (                            // given N = index of the expected term
  n = k = 1,                      // n = current prime, k = current natural number
  g = s =>                        // g = recursive function taking s = binary string
    N ?                           //   if we haven't reached the correct chunk yet:
      g(                          //     do a recursive call to g():
        (P = n =>                 //       P() returns: true for prime
          n % --x ? P(n) : x < 2) //                    false for composite
        (x = ++n) ?               //       increment n; if n is prime:
          s[n] ?                  //         if s is long enough:
            s.slice(--N && n,     //           either remove this chunk (if N > 0)
                    n / !N)       //           or truncate it to the correct size (if N = 0)
          :                       //         else:
            s + (n--, k++)        //           append the next natural number to s
                .toString(2)      //           in binary format
        :                         //       else:
          s                       //         just look for the next prime
      )                           //     end of recursive call
    :                             //   else:
      s.split`1`.length - 1       //     return the number of 1's in the last chunk
)``                               // initial call to g() with an empty string

```
> 2 votes

# Answer
# Python 2, 114 bytes

```
n=input();k=m=1;p=[0];s=''
exec's+=bin(k)[2:];p+=m%k*[k+p[-1]];m*=k*k;k+=1;'*n*n*2
print s[p[n-1]:p[n]].count('1')

```

Try it online!
> 2 votes

# Answer
# Python 2, ~~143~~ ~~139~~ 133 bytes

*-4 bytes thanks to @ErikTheOutgolfer*

```
s='1';i=x=1
exec"s=s[i:];i+=1\nwhile~-all(i%x for x in range(2,i)):i+=1\nexec's+=bin(x)[2:];x+=1;'*i;"*input()
print s[:i].count('1')

```

Try it online!
> 1 votes

# Answer
# J, 48 bytes

```
([:+/-@{:{.+/{.[:}:[:(#:@[,])/1+[:i.1++/)@:p:@i.

```

## explained

```
(                                                         )@:p:@i.  the first n primes, passed to...
       -@{: {.                    ...                               take "nth prime" elements from the tail of...
               +/                                                   sum the first n primes and...
                  {.                                                take that number of elements from...
                     [: }:                                          all but the last element of...   <----------------<
                                          1 + [: i. 1 + +/          sum first n primes, add 1 (so we have enough      |
                                                                    for case n=1) -- make that many natural numbers   |
                           [: (#:@[ , ])/                           reduce them by turning into lists of binary       |
                                                                    digits and catting, however the rightmost number  |
                                                                    won't get reduced, hence the need for ------------^
([: +/                                                              and sum those digits

```

Try it online!
> 1 votes

# Answer
# JavaScript 1+ + substr, 135 bytes

```
for(n=prompt(s=P=0),i=n*n*n*8;--i;)s=i.toString(2)+s;for(p=1;n;e=j?s:--n?P+=p:s.substr(P,p))for(j=p++;p%j--;);eval([].join.call(e,'+'))

```
> 0 votes

---
Tags: code-golf, sequence, binary
---


title: Code ladder, Cops

text:
# Question
Title: Code ladder, Cops
> Note: This challenge is finished. Submissions are still welcome but can not win.

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

Write a code that outputs the integer `1`. If you add, remove or substitute a single character (of your choosing), the code should output the integer `2`. Change one more character (the same or another), and the code should output `3`. Continue like this as far as you can, but maximum up to 10. Default output formats such as `ans = 1` are accepted. You can ignore output to STDERR (or equivalent).

You must reveal the language, byte count of your initial code, the number of integers it works for, as well as an optional number of characters of the initial code. Note: You don't have to reveal any characters, but remember that revealing characters might make it harder for the robbers as they must use the same character in the same position. You can choose which character you use to denote unrevealed characters (for instance underscore), but make sure to specify this.

Cops can provide the uncracked code after one week and call the submission "SAFE". The winning submission will be the shortest uncracked submission that produces the number 10. If no uncracked submissions are able to print 10, the shortest code that produces 9 will win, and so on. Note that the robbers don't have to make the same changes as you do, and they don't have to reproduce the exact code (unless you reveal all characters). They must only reproduce the output.

Submissions posted later than November 24th are welcome but not eligible for the win (because there will likely be fewer robbers around).

---

**Example post:**

The following post is a submission in the language `MyLang`, it is 9 bytes long, and it works for numbers 1 - 8.

# MyLang, 9 bytes, 8 numbers

This submission works for 1 - 8. Unrevealed characters are indicated with an underscore: `_`.

```
abc____i

```

### Leaderboard

Disclaimer: The leaderboard is not tested and uncracked submissions might not appear in the list.

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><style>table th,table td{padding: 5px;}th{text-align: left;}.score{text-align: right;}table a{display: block;}.main{float: left;margin-right: 30px;}.main h3,.main div{margin: 5px;}.message{font-style: italic;}#api_error{color: red;font-weight: bold;margin: 5px;}</style> <script>QUESTION_ID=99546;var safe_list=[];var uncracked_list=[];var n=0;var bycreation=function(x,y){return (x[0][0]<y[0][0])-(x[0][0]>y[0][0]);};var byscore=function(x,y){return (x[0][1]>y[0][1])-(x[0][1]<y[0][1]);};function u(l,o){jQuery(l[1]).empty();l[0].sort(o);for(var i=0;i<l[0].length;i++) l[0][i][1].appendTo(l[1]);if(l[0].length==0) jQuery('<tr><td colspan="3" class="message">none yet.</td></tr>').appendTo(l[1]);}function m(s){if('error_message' in s) jQuery('#api_error').text('API Error: '+s.error_message);}function g(p){jQuery.getJSON('//api.stackexchange.com/2.2/questions/' + QUESTION_ID + '/answers?page=' + p + '&pagesize=100&order=desc&sort=creation&site=codegolf&filter=!.Fjs-H6J36w0DtV5A_ZMzR7bRqt1e', function(s){m(s);s.items.map(function(a){var he = jQuery('<div/>').html(a.body).children().first();he.find('strike').text('');var h = he.text();if (!/cracked/i.test(h) && (typeof a.comments == 'undefined' || a.comments.filter(function(b){var c = jQuery('<div/>').html(b.body);return /^cracked/i.test(c.text()) || c.find('a').filter(function(){return /cracked/i.test(jQuery(this).text())}).length > 0}).length == 0)){var m = /^\s*((?:[^,;(\s]|\s+[^-,;(\s])+).*(0.\d+)/.exec(h);var e = [[n++, m ? m[2]-0 : null], jQuery('<tr/>').append( jQuery('<td/>').append( jQuery('<a/>').text(m ? m[1] : h).attr('href', a.link)), jQuery('<td class="score"/>').text(m ? m[2] : '?'), jQuery('<td/>').append( jQuery('<a/>').text(a.owner.display_name).attr('href', a.owner.link)) )];if(/safe/i.test(h)) safe_list.push(e);else uncracked_list.push(e);}});if (s.items.length == 100) g(p + 1);else{var s=[[uncracked_list, '#uncracked'], [safe_list, '#safe']];for(var i=0;i<2;i++) u(s[i],byscore);jQuery('#uncracked_by_score').bind('click',function(){u(s[0],byscore);return false});jQuery('#uncracked_by_creation').bind('click',function(){u(s[0],bycreation);return false});}}).error(function(e){m(e.responseJSON);});}g(1);</script><link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/Sites/codegolf/all.css?v=7509797c03ea"><div id="api_error"></div><div class="main"><h3>Uncracked submissions</h3><table> <tr> <th>Language</th> <th class="score">Score</th> <th>User</th> </tr> <tbody id="uncracked"></tbody></table><div>Sort by: <a href="#" id="uncracked_by_score">score</a> <a href="#" id="uncracked_by_creation">creation</a></div></div><div class="main"><h3>Safe submissions</h3><table> <tr> <th>Language</th> <th class="score">Score</th> <th>User</th> </tr> <tbody id="safe"></tbody></table></div>
```

# Answer
# Hexagony, 18 Bytes, 10 numbers, SAFE

This submission works for 1 - 10. Unrevealed characters are indicated with an underscore: `_`.

```
.__{_]5[$@.;=@$!!1

```

You can try Hexagony online over here.

# My solution:

```
1:   .<[{8]5[$@.;=@$!!10
2:   .<[{8]5[$@);=@$!!10
3:   2<[{8]5[$@);=@$!!10
4:   3<[{8]5[$@);=@$!!10
5:   4<[{8]5[$@);=@$!!10
6:   5<[{8]5[$@);=@$!!10
6:   7<[{8]5[$@);=@$!!10
8:   7<[{8]5[$@);=@$!!10
9:   8<[{8]5[$@);=@$!!10
10:  9<[{8]5[$@);=@$!!10

```

---

**Hex for output 1:**

Try it Online!

```
Full Hex:
  . < [
 { 8 ] 5
[ $ @ . ;
 = @ $ !
  ! 1 0

Important parts:
  . < .
 . 8 . 5
. $ @ . ;
 . . $ .
  . 1 .

```
1. At the `<` the memory edge is `0`, so it turns up.
2. Hits `1`
3. Jumps to `5`
4. Jumps over `8`, but is reversed at `<` and gets the `8` on the way back.
5. Hits `5` again
6. Jumps over `1`
7. Hits the `<` at this point, the memory value is 1585 which, mod 256, happens to be ASCII `1`
8. Finally prints and exits with `;@`.

---

**Hex for output 2:**

Try it Online!

```
Important parts:
  . < .
 . 8 . 5
. $ @ ) ;
 . . $ .
  . 1 .

```

This follows the same path, but on the way back it hits a `)` which increments the memory edge to 1586, or `2`.

---

**Hex for output 3-9:**

Try it Online!

```
Important parts:
  2 < [
 . . ] .
. $ . ) .
 . @ . !
  . 1 .

```
1. Hits the `2`
2. Now the memory edge is positive when it gets to `<`, so it turn down.
3. The `]` changes the instruction pointer, but is immediately comes back with `[`
4. `)` increments to `3`
5. `!` Prints `3`
6. `$` is left over from the first two numbers so we jump over the end (`@`)
7. `1` changes the memory edge, but that doesn't matter now.
8. `<` reflects the pointer back.
9. Again `1` doesn't matter because we hit `@` to end the program.
> 2 votes

# Answer
## Retina, 2 bytes, 10 numbers, Cracked

```
_1

```

Works for 1 to 10, `_` is a hidden character. This shouldn't be too hard, but I hope it provides a somewhat interesting puzzle. :)

You can try Retina online over here.
> 11 votes

# Answer
# Octave, 55 bytes, 10 numbers, cracked

```
(o__(O_o_(@(__o)o__-O}_)_(0<O,{_(_o_O-1)+1_@(_1}_)(__o_

```

`_` is the unknown character.

### Solution

> `(o=@(O,o)(@(O,o)o{2-O}())(0<O,{@()o(O-1)+1,@()1}))(0,o)` %then changing the very last `0` to `1,2,3` e.t.c.
> Given `x`, this does recursively calculate `x+1`. It is mainly composed of two anonymous functions. One provides an `if` statement to anchor the recursion:
> `if_ = @( boolean, outcomes) outcomes{ 2 - boolean}();`
> This is just abusing the fact that a boolean values evaluates to `0` or `1`. This function accepts a boolean value, and a cell array of two functions, and evaluates one or the other of these two functiosn depending on the boolean value. The second part is the actual recursion:
> `plus_one = @(n,f) if_(0<n ,{@()f(n-1)+1, @()1})`
> As an anyonmous function is anonymous, you cannot directly access it from itsefl. That why we need a second argument `f` first. Later we will provide a handle to the function instelf as a second argument, so a final function would looks like so:
> `plus_one_final = @(n)plus_one(n,plus_one);`
> So in this notation my submission becomes:
> `(plus_one=@(n,f)(@(boolean,outcomes)outcomes{2-boolean}())(0<n,{@()f(n-1)+1,@()1}))(n,f)`
> I asked about recursion anchors for anonymous functions in MATLAB a while ago on stackoverflow.
> 11 votes

# Answer
## Python 2, 9 bytes, 10 numbers, cracked

```
print 8/8

```

No hidden chars. Can you crack it without brute forcing?
> 9 votes

# Answer
# Perl, 12 bytes, 10 numbers, Cracked!

Underscores represent unknown characters.

```
____;say__-9

```

Probably fairly easy, and it wouldn't surprise me if there were multiple solutions. Still, it might be fun to crack.

(The intended solution was the same as the crack. This is fundamentally just a problem about assigning 10 to a variable in four characters, which is surprisingly difficult in Perl; unlike many golfing languages, it doesn't have a variable that helpfully starts at 10.)
> 8 votes

# Answer
# Perl, 46 bytes, 10 numbers, safe

## The problem

```
__b_b_\__}_b_b_b_0_;
$b[0]=10;$b{0}=1;say$b[0]

```

The shorter problems tend to get cracked quickly, so I thought I'd try a longer one. The longer ones also tend to get cracked if people leave enough of a gap to sneak something naughty like `say` or `exit` in, so all the gaps here are short. Hidden characters are represented using `_`.

## My solution

```
sub b{\@_}*b=b$b{0};
$b[0]=10;$b{0}=1;say$b[0]

```

To print 2, 3, etc., up to 9, keep changing the number assigned to `$b{0}` in the second line (i.e. `$b{0}=2`, `$b{0}=3`, etc.). The program for 9 looks like this:

```
sub b{\@_}*b=b$b{0};
$b[0]=10;$b{0}=9;say$b[0]

```

Then to produce 10, comment out the first line by prepending a `#` character to it.

## Explanation

The first thing to note is that the solution isn't really golfed apart from removing whitespace: if we lay it out with more readable whitespace, we get this:

```
sub b { \@_ }
*b = b $b{0};
$b[0] = 10;
$b{0} = 1;
say $b[0];

```

Normally, when you access the arguments of a subroutine in Perl, you do so via copying them out of `@_`. There's a good reason for this: `@_` aliases the arguments the subroutine is given (so, for example, `(sub { $_[0] = 3 })->($x)` will assign to `$x`), something that isn't normally desirable.

Although `@_` might seem magical, it's actually just using a standard feature of the Perl internals (which is readily available from XS but only comes up in a few weird cases in pure Perl, such as `@_` itself): an array doesn't store its elements directly, but rather by reference. Thus, when we call `b` in the second line below, Perl generates an array (calling it `@_`) whose first element is a reference to the same storage that `$b{0}` uses. (Hash values are also stored by reference; $\_\[0\] and $b{0} are both referencing the same storage at this point.) Because `@_` isn't doing anything special from an internals point of view, we can take a reference to it just like we could with any other array, causing it to outlive the subroutine it's defined in.

Perl variables *also* refer to data storage by reference. A long time ago, people used to use code like `*x = *y;` to set `$x` as an alias to `$y` (via making them reference the same thing), likewise `@x` as an alias to `@y`, `%x` as an alias to `%y`, and so on. That rather breaks the invariant that variables with similar names don't have to act similarly, so modern Perl provides an alternative; assigning a reference to a typeglob overrides only the variable that matches the type of the reference (so `*x = \%y` would alias `%x` to point to the same storage as `%y` but leave, say, `$x` alone). This syntax notably doesn't care about whether the storage you're aliasing to has a name, so when we assign the return value of `b` (which is an array reference that's keeping the array formerly called `@_` alive) to `*b`, what happens is that `@b` is changed to alias the argument list to the call to `b` (while leaving `%b` unchanged). This means, notably, that `$b[0]` and `$b{0}` now point to the same storage, and assigning to one will therefore change the other. Everything from then on is completely straightforward.

The Perl documentation doesn't really talk about this sort of detail, so I'm not surprised anyone got the crack; the nature of `@_` as not quite being like other arrays isn't something that's really emphasised, and most coding styles aim to minimize the effects that this has rather than amplifying them.
> 7 votes

# Answer
# JavaScript, 30 bytes, 10 numbers, cracked

```
alert(Array(_)________.length)

```

Shouldn't be too hard, but hopefully it's just hard enough to provide a challenge. :) Unrevealed characters are marked with `_`.
> 5 votes

# Answer
## Perl, 14 bytes, 10 numbers, Cracked

```
say_!"___"%""_

```

Works for 1 to 10. `_` are hidden characters.

I think this shouldn't be too hard to crack. I have an harder one, for 22 bytes, I'll post it if this one is cracked.

---

Original code :
```
say"!"=~y"%""c

```

And replace the `"!"` by a string of the length of the number you wish to print, for instance `!`, `!!`, `!!!`, etc.

However, ais523 found another way :

```
say"!"+1#"%""r

```
> 5 votes

# Answer
## JavaScript, 22 bytes, 10 numbers, cracked

Probably rather easy to crack.

```
alert(__14_337__xc_de)

```

`_` being a hidden character
> 5 votes

# Answer
# Jelly, 7 bytes, 10 numbers, cracked

```
“1‘ỌȮḊ‘

```

No wildcards.

The crack achieved (to use an eval with an argument) was, as many seem to be in this thread, not the intended one.

The intended crack was:

```
“1‘ỌȮḊ‘ - (prints 1)
“1‘     - code page index list of characters "1": [49]
   Ọ    - cast to ordinals: ['1']
    Ȯ   - print (with no line feed) and return input: effectively prints "1"
        -     (but if left at this would then implicitly print another "1")
     Ḋ  - dequeue: []
      ‘ - increment (vectorises): []
        - implicit print: prints ""

“1‘ỌŒḊ‘ - (prints 2)
“1‘Ọ    - as above: ['1']
    ŒḊ  - depth: 1
      ‘ - increment: 2
        - implicit print: prints "2"

“1‘ỌŒḊ‘‘ - (prints 3)
“1‘ỌŒḊ‘  - as above: 2
       ‘ - increment: 3
         - implicit print: prints "3"

... keep adding an increment operator to print 4 - 10.

```
> 4 votes

# Answer
# Octave, 17 bytes, 10 numbers, Cracked

```
_od(3_13_13_7_1_)

```

Original solution

> `mod(3*1361357,10)`
> `...`
> `mod(3*1361357,17)`
> `mod(3*1361397,17)`
> `mod(9*1361397,17)`

`_` is the hidden character.
> 4 votes

# Answer
# Befunge-93, 11 bytes, 10+ numbers, Cracked

This submission works for at least 1 - 10. Unrevealed characters are indicated with .

```
□□5:**-□-.@

```

Try it online

I must say I was impressed that two people could come up with independent solutions for this, neither of which were what I was expecting. While Martin got there first, I'm giving the "win" to Sp3000 as their solution is more portable.

This was my intended solution though:

> `g45:**-2-.@`
> `g45:**-1-.@`
> `g45:**-1\.@`
> `g45:**-1\+.@`
> `g45:**-2\+.@`
> `...`
> `g45:**-7\+.@`
> Because a stack underflow in Befunge is interpreted as 0, the `g` just reads from 0,0 returning the ASCII value of 'g', namely 103. `45:**-` subtracts 100, giving you 3. Then `2-` gives you 1.
> For the third iteration, the `-` (subtract) is changed to a `\` (swap) instruction, so the 3 becomes the topmost stack entry. And in iteration four, a `+` (add) instruction is inserted, thus adding the 3 to the 1 giving 4.
> 4 votes

# Answer
# R, 21 bytes, 10 numbers Cracked

```
__i___________i______

```

Works for 10 numbers. `_` is hidden character.

Original solution:

> `which(letters%in%"a")`
> `which(letters%in%"b")`
> etc.
> 4 votes

# Answer
# Ruby, 16 bytes, 10 numbers, cracked by xsot

```
x=##/=#%#
)
###x

```

`#` is any character.
> 4 votes

# Answer
# Octave, 32 bytes, 10 numbers. Cracked

```
_n_(isprime(floor(s____i__ i____

```

`_` is a hidden character.

You can try Octave online here.

---

Original solution:

1: `nnz(isprime(floor(sqrt(i):pi')))`

2: `nnz(isprime(floor('sqrt(i):pi')))`

3: `nnz(isprime(floor('sqrt(i):pia')))`

4: `nnz(isprime(floor('sqrt(i):piaa')))`

...
> 3 votes

# Answer
# Octave, 17 bytes, 10 numbers, Cracked

```
_i_(__i__(2_5_))

```

Unrevealed characters are marked with `_`.

Intended solution:

> ```
>
>     fix(asind(2/59))
>     fix(asind(3/59))
>     fix(asind(4/59))
>     fix(asind(5/59))
>     fix(asind(6/59))
>     fix(asind(7/59))
>     fix(asind(8/59))
>     fix(asind(9/59))
>     fix(asind(9/55))
>     fix(asind(9/50))
> ```
> 3 votes

# Answer
# Octave, 19 bytes, 10 numbers, cracked

```
__sca__1_)___'-_6_'

```

`_` is the hidden character.

Intended solution:

> pascal(10)('a'-96)'
> 3 votes

# Answer
# 05AB1E, 5 bytes, 10 numbers, cracked!

Not very hard, but a fun one :)

```
_[==_

```

`_` is a random character. Uses the **CP-1252** encoding. Try it online!
> 3 votes

# Answer
## JavaScript, 22 bytes, 10 numbers, cracked

```
alert(0_6_4_>_0_2_0_7)

```

`_` is the hidden character.

### Hint about the intended solution

The character that needs to be changed to generate all numbers is always the same.
> 3 votes

# Answer
# 05AB1E, 6 bytes, 10 numbers, cracked

Attempt 2, this time without the three-char string :p.

```
_ [==_

```

`_` is a random character. Uses the **CP-1252** encoding. Try it online!
> 3 votes

# Answer
# C#, 90 bytes, 10 numbers, cracked

```
using ______________________________________________;class C{static void Main(){_______;}}

```

I honestly have no idea how hard this is to crack.

Edit: Oops, transcription error. One `_` too few after `using`.

Now cracked by Hedi, who found the intended (barring the class name) solution.
> 3 votes

# Answer
## Python 3, 19 bytes, 10 numbers, cracked

```
print(??bin()?????)

```

Unrevealed characters are marked with `?`. Tested in Python 3.5.2.
> 3 votes

# Answer
## JavaScript 21 Bytes, 10 Numbers Cracked

```
alert(b_oa_"3____1"))

```

Unrevealed characters are marked with `_`

Cracked

My Version:

```
alert(btoa|"3"&("1"))
alert(btoa|"3"^("1"))
alert(btoa|"3"^("0"))
alert(btoa|"3"^("7"))
alert(btoa|"2"^("7"))
alert(btoa|"1"^("7"))
alert(btoa|"0"^("7"))
alert(btoa|"0"^("8"))
alert(btoa|"0"^("8"))
alert(btoa|"2"^("8"))

```
> 3 votes

# Answer
## Python 3, 16 bytes, 10 numbers, cracked

```
print(?%??f?r?t)

```

Unrevealed characters are marked with `?`. This is probably a bit easy since there's only five question marks, but I'm hoping it'll be a fun one.
> 3 votes

# Answer
## JavaScript 33 Bytes, 10 Numbers Cracked x2

Oops I post posted my line for generating 10 Which Hedi cracked as though it was for 1

```
alert(_to__"_Xc0__0_B6____Zp=="))

```

Version intended to post for generating 1

```
alert(_to__"_Xc0__0_Bf____Zp=="))

```

Unrevealed characters are marked with `_`

```
alert(btoa|"0Xc0"-0xBf|!("Zp=="))
alert(btoa|"0Xc0"-0xBe|!("Zp=="))
alert(btoa|"0Xc0"-0xBd|!("Zp=="))
alert(btoa|"0Xc0"-0xBc|!("Zp=="))
alert(btoa|"0Xc0"-0xBb|!("Zp=="))
alert(btoa|"0Xc0"-0xBa|!("Zp=="))
alert(btoa|"0Xc0"-0xB9|!("Zp=="))
alert(btoa|"0Xc0"-0xB8|!("Zp=="))
alert(btoa|"0Xc0"-0xB7|!("Zp=="))
alert(btoa|"0Xc0"-0xB6|!("Zp=="))

```
> 3 votes

# Answer
# Python, 10+ numbers, 61 bytes, Cracked!

Here was the code I posted:

```
try:x
except:print(__import__('sys').??c??n??()[????b????e???

```

The original code was:

```
try:x
except:print(__import__('sys').exc_info()[2].tb_lineno)

```

Basically, it throws an error (`'x' is not defined`) and then prints the line the error was found on. So, just keep adding newlines at the beginning to increment the number.

I knew it wouldn't be hard to crack - I just wanted a funny way to print numbers - but I wasn't expecting Sp3000 to get it so fast, that's some pro skills!
> 3 votes

# Answer
## *Acc!!*, 10 bytes, 9 numbers, cracked

```
?????????_

```

Works for 1 to 9. `?` is a hidden character.
> 2 votes

# Answer
# 05AB1E, 11 bytes, Cracked!

```
3628801__0_

```

Works from 1-10. `_` is a hidden character.

### Intended Solution:

```
3628801R¬0+ # 1
3628801R¬1+ # 2
3628801R¬2+ # 3
3628801R¬3+ # 4
3628801R¬4+ # 5
3628801R¬5+ # 6
3628801R¬6+ # 7
3628801R¬7+ # 8
3628801R¬8+ # 9
3628801R¬9+ # 10

```
> 2 votes

# Answer
# Octave, 25 bytes, 9 numbers. Cracked

```
__a__repmat(__one___,__)_

```

`_` is a hidden character.
> 2 votes

# Answer
# Octave, 24 bytes, 9 numbers, cracked

```
_a__repmat(__one___,__)_

```

`_` is a hidden character.

(Inspired by @LuisMendo's challenge.)
> 2 votes

# Answer
# JavaScript, 9 bytes, 10 numbers, Cracked

```
alert(__)

```

`_` is the hidden character.
> 2 votes

# Answer
# Octave, 26 bytes, 10 numbers. Cracked

```
__a__repmat(_+one___1+__))

```

`_` is a hidden char.

New variation...

---

The intended solution was:

```
>> eval(repmat('+ones',1+''))
ans =  1

>> eval(repmat('+ones',1+2'))
ans =  3

>> eval(repmat('+ones',1+9'))
ans =  10

```
> 2 votes

# Answer
# Octave, 21 bytes, 10 numbers, Cracked

```
disp(fpr___f__e_(_'_)

```

This works for 1-10. `_` are hidden characters. This will be my last and hopefully best post.

Intended solution:

> `disp(fpr= -fopen(''))` and `disp(fpr=1-fopen(''))` for 2...10

Explanation:

> `disp(fprintf('_'))` will actually print `_1` if executed, so `fpr___f` was chosen to throw people off. The `f` was needed in `fopen` so there was only one additional space. `fopen('')` returns `-1` since it fails to open a file with an empty name. `fpr= -fopen('')` makes `fpr = 1`.
> 2 votes

# Answer
# Pyth, 4 bytes, 9 numbers - Cracked

```
.__Q

```

Not super difficult, but should hopefully be fun.
> 2 votes

# Answer
## Python 2, 17 bytes, 10 numbers, cracked

```
print len([????])

```

The hidden character is `?`.
> 2 votes

# Answer
## Hexagony, 7 bytes, 10 numbers, Cracked

```
1<@|!__

```

Works for 1 to 10, `_` are hidden characters. I hope I didn't overlook any cheap way to work around the intended solution (I'm looking forward to clever ways to work around the intended solution ;)).

You can try Hexagony online over here.
> 2 votes

# Answer
# Perl, 31 bytes - 10 numbers - Cracked by ais523

```
__e_$a__<__$_;1 while_$__;say$_

```

_ is the hidden character.

I am not posting *my* solution here, because the crack is in a completely different direction from what I did, so I'll be creating a new challenge for that one. The cracked solution is below:

```
 $e=$a+q<1_$>;1 while!$e ;say$e  #Prints 1 (note the leading space)
 $e=$a+q<1_$>+1 while!$e ;say$e  #Prints 2
 $e=$a+q<1_$>+2 while!$e ;say$e  #Prints 3
 $e=$a+q<1_$>+3 while!$e ;say$e  #Prints 4
 $e=$a+q<1_$>+4 while!$e ;say$e  #Prints 5
 $e=$a+q<1_$>+5 while!$e ;say$e  #Prints 6
 $e=$a+q<1_$>+6 while!$e ;say$e  #Prints 7
 $e=$a+q<1_$>+7 while!$e ;say$e  #Prints 8
 $e=$a+q<1_$>+8 while!$e ;say$e  #Prints 9
 $e=$a+q<1_$>+9 while!$e ;say$e  #Prints 10

```
> 2 votes

# Answer
# R, 22 bytes, 10 numbers, Cracked

```
_et_______)____is_____

```

`_` is a hidden character.

See the redux version.
> 2 votes

# Answer
## C++, Linux platform, 10 numbers, 468 bytes, Cracked

Ok so previously my puzzle played with technically undefined behavior (and the gimmick was stabilizing it) and had some transcription error. I have improved my process so I expect there aren't transcription errors. This time I am not playing with undefined behavior at all and would rather just reject invoking it. I think I can justify this as being completely defined by either the language or the platform. `$` is the replacement character as I needed real `_` characters in this puzzle.

```
#include <unistd.h>
#include <iostream>
#include <fstream>

$$$$$$$$$$$$$ {
    std::ofstream *garbalgase()
    {
        std::ofstream *golgi = new std::ofstream;
        golgi->open("/dev/null");
        return golgi;
    }

    std::ostream * const jawbone = garbalgase();
    $$$$$ int value = $_$$$$$$;
}

int main()
{
    $$$$$ $$$$$$$$/$$int vl = value;
    if (fork() == 0)
    {
        $$$$$$$$$$$<std::ostream $*>($jawbone) = &std::cout;
        vl -= 4;
        _exit(0);
    }
    (*jawbone) << (vl - 9) << std::endl;
}

```

Edit: Stock solution is based on an incorrect understanding of the rules where you may insert one character to get the 1. As it's already cracked I won't be correcting it. Good luck finding the stock solution though.
> 2 votes

# Answer
## Python 2, 26 bytes, 10 numbers, cracked

Let's try this again.

```
print r___e(3______+_[___]

```

Works for 1-10; `_` is the hidden character.
> 2 votes

# Answer
## Java, 10+ digits, 1446 bytes SAFE

Revenge of the Unicode

```
\u___9\u___D\u___0\u___F\u___2\u___4\u___0\u___A\u___1\u___6\u___1\u___E\u___9\u___F\u___E\u___A\u___B\u___3\u___C\u___1\u___3\u___3\u___0\u___D\u___B\u___0\u___5\u___2\u___C\u___9\u___3\u___0\u___3\u___4\u___1\u___4\u___9\u___3\u___0\u___6\u___F\u___9\u___4\u___0\u___D\u___1\u___9\u___E\u___8\u___3\u___4\u___2\u___9\u___E\u___7\u___B\u___D\u___1\u___9\u___4\u___8\u___2\u___F\u___7\u___3\u___0\u___5\u___8\u___3\u___5\u___0\u___4\u___9\u___F\u___E\u___B\u___6\u___9\u___C\u___5\u___4\u___5\u___3\u___3\u___2\u___9\u___0\u___4\u___F\u___2\u___0\u___6\u___4\u___0\u___D\u___0\u___E\u___5\u___7\u___0\u___6\u___9\u___C\u___5\u___4\u___5\u___3\u___3\u___2\u___9\u___0\u___4\u___F\u___2\u___8\u___9\u___B\u___3\u___5\u___E\u___E\u___D\u___9\u___3\u___3\u___E\u___3\u___8\u___1\u___2\u___5\u___4\u___3\u___5\u___3\u___2\u___5\u___4\u___3\u___E\u___7\u___5\u___4\u___A\u___1\u___6\u___1\u___9\u___F\u___6\u___9\u___C\u___5\u___4\u___5\u___3\u___3\u___2\u___9\u___0\u___4\u___F\u___2\u___1\u___3\u___3\u___5\u___3\u___3\u___8\u___9\u___E\u___3\u___5\u___4\u___8\u___6\u___4\u___C\u___1\u___9\u___B\u___E\u___5\u___7\u___0\u___0\u___2\u___9\u___E\u___4\u___3\u___4\u___2\u___5\u___1\u___D\u___8\u___E\u___5\u___7\u___0\u___6\u___9\u___C\u___5\u___F\u___5\u___4\u___0\u___5\u___4\u___3\u___4\u___2\u___5\u___1\u___D\u___8\u___6\u___4\u___9\u___9\u___E\u___0\u___2\u___9\u___E\u___4\u___8\u___7\u1__1\u___7\u___5\u___7\u___1\u___7\u___9\u___B\u___D\u___D

```

No comments this time :P and it only works on the Oracle Java :P

`_` as redaction like usual

Solution:

```
\u0069\u006D\u0070\u006F\u0072\u0074\u0020\u006A\u0061\u0076\u0061\u002E\u0069\u006F\u002E\u002A\u003B\u0063\u006C\u0061\u0073\u0073\u0020\u004D\u007B\u0070\u0075\u0062\u006C\u0069\u0063\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0076\u006F\u0069\u0064\u0020\u006D\u0061\u0069\u006E\u0028\u0053\u0074\u0072\u0069\u006E\u0067\u005B\u005D\u0061\u0029\u0074\u0068\u0072\u006F\u0077\u0073\u0020\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006F\u006E\u007B\u0046\u0069\u006C\u0065\u0044\u0065\u0073\u0063\u0072\u0069\u0070\u0074\u006F\u0072\u0020\u0066\u0064\u0020\u003D\u0020\u006E\u0065\u0077\u0020\u0046\u0069\u006C\u0065\u0044\u0065\u0073\u0063\u0072\u0069\u0070\u0074\u006F\u0072\u0028\u0029\u003B\u0073\u0075\u006E\u002E\u006D\u0069\u0073\u0063\u002E\u0053\u0068\u0061\u0072\u0065\u0064\u0053\u0065\u0063\u0072\u0065\u0074\u0073\u002E\u0067\u0065\u0074\u004A\u0061\u0076\u0061\u0049\u004F\u0046\u0069\u006C\u0065\u0044\u0065\u0073\u0063\u0072\u0069\u0070\u0074\u006F\u0072\u0041\u0063\u0063\u0065\u0073\u0073\u0028\u0029\u002E\u0073\u0065\u0074\u0028\u0066\u0064\u002C\u0031\u0029\u003B\u006E\u0065\u0077\u0020\u0050\u0072\u0069\u006E\u0074\u0053\u0074\u0072\u0065\u0061\u006D\u0028\u006E\u0065\u0077\u0020\u0046\u0069\u006C\u0065\u004F\u0075\u0074\u0070\u0075\u0074\u0053\u0074\u0072\u0065\u0061\u006D\u0028\u0066\u0064\u0029\u0029\u002E\u0070\u0072\u0069\u006E\u0074\u0028\u0027\u1111\u0027\u0025\u0027\u0111\u0027\u0029\u003B\u007D\u007D

```

Deobfuscated:

```
import java.io.*;class M{public static void main(String[]a)throws Exception{FileDescriptor fd = new FileDescriptor();sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess().set(fd,1);new PrintStream(new FileOutputStream(fd)).print('\u1111'%'\u0111');}}

```

Entire Thing relies on some dirty Oracle Java classes trickery to link a Filedescriptor object to the 1 Filedescriptor which is stdout

Got the hack from stackoverflow
> 2 votes

# Answer
# Perl, 31 bytes, 10 numbers Cracked by ais523

One more go at this, before I reveal my intended solution.

```
__e_$a,_<__$_;1 while_$a_;say$_

```

Original code:

```
open$a,"<",$0;1 while<$a>;say$.  #Prints 1

```

The code must be saved as a file and not run from the command line, but the file name is not important, as it gets stored in `$0`. This code reads the file as long as there is text left, and prints `$.` which contains the number of lines in the original code. Adding a newline pretty much anywhere not inside a word or variable will increase `$.` by 1.

```
open$a,"<",$0;
1 while<$a>;say$.   #Prints 2
------
open$a,"<",$0;

1 while<$a>;say$.   #Prints 3
------

```

et cetera
> 2 votes

# Answer
## Hexagony, 15 bytes, 10 numbers, Cracked!

```
[!?>!@!__\!?!!!

```

`_` can be replaced by any characters.

Oh my.. the code is getting angry due to cheap solutions! Will this keep standing when the wall of `!` and `?` are guarding the most hearted secret?

Last submission even if this has got any cheap solutions :)

### Intended solution

For 1 to 9, there are easy changes:

> `[!?>!@!1#\!?!!!` With 1~9 replacing the 1

However for 10,

> `1!?>!@!9#\!?!!!` Which prints the 1 and then use a numerical jump so we run in a reversed fashion, which in turn goes to `?!` prints a 0 and stops. Really wanted to make some that changes IPs. By the way, all 3 submissions are with the intention to use `#` to print an 1 and then a 0. See if I come up with other nice ideas - if yes I hope more people would find it interesting to play in hexagons!
> 2 votes

# Answer
# \>\<\> Fish 23 bytes cracked

```
"H__;v+2__?
  _  >l?!;n

```

_ is the intended missing characters. Hopefully a bit more complicated than my last one but probably still easy to bypass.
> 2 votes

# Answer
# PHP, 38 bytes, 10 numbers (cracked)

`<?php__n_p___(_n=___(__=1___echo___?>`

`_` marks hidden characters.

May be too easy, might have left too much freedom. Have fun!
> 2 votes

# Answer
## OCaml (interpreted), 51 bytes, 10 numbers (Cracked)

 By "interpreted" I mean that it should be run with the command `ocaml` rather than compiled to native code with `ocamlopt`.  The hidden character is `^`.

```
^^t^r^^^^-^^^^-^^r^^^^=^^^^^^^r^^^^r^^^^^^^(^^^0/0)

```
> 2 votes

# Answer
# 아희(Aheui), 19 bytes (6 chars + 1 newline), 10 numbers

```
봃法희
반_뭉

```

Works for 1 to 10. `_` is the hidden character. Shouldn't be that hard.

Bonus: It works for `0` too.

Try it online!
> 1 votes

# Answer
# Pyth, 3 bytes, 10 numbers (Cracked)

I think it's a very simple one, and will easily get cracked.
So, it goes like this: (hidden characters: `_`)

```
__Q

```
> 1 votes

# Answer
# Octave, 21 bytes 9 numbers, cracked

```
_a__repmat(_one___,__

```

`_` is a hidden character.

My idea:

> `a=[repmat(bone,0),9]`
> 1 votes

# Answer
# JavaScript, 15 bytes, 10 numbers, cracked

```
alert(_+"+____)

```

Another short one, this time with an unfinished string \>:-)
> 1 votes

# Answer
# JavaScript, 12 bytes, 10 numbers, Cracked

Let's play with arrays:

```
alert(_[__])

```

`_` is a hidden character.

---

I wanted robbers to think that the first hidden character was a `+`, but i didn't realize that would work.

Intended solution :

> alert(-\[~0\])
> alert(-\[~1\])
> alert(-\[~2\])
> ...
> alert(-\[~9\])
> 1 votes

# Answer
## Python 2, 49 bytes, 10 numbers, cracked

```
y=10__;s='09________';print int(s[8__________:y])

```

`_` is the hidden character.

---

### Cracked by boboquack

The initial code was

`y=10-0;s='0987654321';print int(s[8+y:]+s[y-1:y])`
> 1 votes

# Answer
## C, 10+ numbers, 216 bytes, Cracked

```
#include <stdio.h>

FILE *a, *b;

void x() { ____________ int x; x = __; ________a___d____x_;}
void y() { ____________ int x; fprintf(b,"%d\n",x);}
int main() {a=fopen("/dev/null", "w");b=stdout;x();y();return 0;}

```

If your solution doesn't work with -O1 I will reject it.

Cracked by Dada. Original file:

```
#include <stdio.h>

FILE *a, *b;

void x() { /**/volatile int x; x = 07; fprintf(a,"%d\n", x);}
void y() { /**/volatile int x; fprintf(b,"%d\n", x);}
int main() {a=fopen("/dev/null", "w");b=stdout;x();y();return 0;}

```
> 1 votes

# Answer
## PowerShell, 7 bytes, 10 numbers, Cracked

Works for 1 through 10. Hidden characters are `_`.

```
___(__0

```

Intended solution: `+!@()+0` and swap out the `0` on the end for successively larger numbers.
> 1 votes

# Answer
# Java, 70 bytes, 10 Numbers, Cracked

`__________________________ ____(_____________________________)________`

`_` is the hidden character

Edit: major flaw fixed
> 1 votes

# Answer
# \>\<\> Fish 5 bytes 10 numbers Cracked by Emigna

```
_2__;

```

It should be easy to guess but I threw in a little curve ball to make it slightly harder.
> 1 votes

# Answer
## Javascript 19 bytes 10 numbers Cracked

```
alert((_1*1_10__1_)

```

Unrevealed characters are marked with `_`

Cracked! Guess i should have blotted better

```
alert((11*1+10)%10)
alert((11*2+10)%10)
alert((11*3+10)%10)
alert((11*4+10)%10)
alert((11*5+10)%10)
alert((11*6+10)%10)
alert((11*7+10)%10)
alert((11*8+10)%10)
alert((11*9+10)%10)
alert((11*9+10)%11)

```
> 1 votes

# Answer
## QBasic, 13 bytes, 10 numbers, cracked

```
__I_T__O_(3))

```

Works for 1-10. `_` is the hidden character.
> 1 votes

# Answer
## JavaScript (ES6), 63 bytes, 10 numbers, cracked

This challenge is quite fun, so here's one last submission. :-)

```
eval([...(n=0,"l?0?a?(?x?")].sort(_=>[...????+[]][n++]).join``)

```

`?` is a hidden character.

**NB:** similarly to my two other entries, this code is supposed to *print* (not return) `1`.
> 1 votes

# Answer
# R, 8 bytes, 10 numbers, Cracked

```
_a___+__

```

Original solution (as the cracked is a little different, but works):

> cat(1+0)
> cat(1+1)
> ...
> cat(1+8)
> cat(1+9)
> 1 votes

# Answer
# Perl, 26 bytes, 10 numbers Cracked by ais523 and Sunny Pun

```
____;@a=($_..10);say$a[__]

```

I'm almost positive there's an alternate solution to this problem, but let's see if anyone else can find it because I haven't been able to see it.

Edit: It looks like two people managed to circumvent what I was trying to do!

ais523's solution:

```
____;@a=($|..10);say$a[+1]  #Prints 1
____;@a=($|..10);say$a[1+1] #Prints 2
...
____;@a=($|..10);say$a[9+1] #Prints 10

```

Sunny Pun's solution:

```
$_=0;@a=($_..10);say$a[+1]  #Prints 1
...
$_=9;@a=($_..10);say$a[+1]  #Prints 10

```

Intended solution:

```
$[=1;@a=($[..10);say$a[$[]  #Prints 1
$[=2;@a=($[..10);say$a[$[]  #Prints 2
$[=3;@a=($[..10);say$a[$[]  #Prints 3
$[=4;@a=($[..10);say$a[$[]  #Prints 4
$[=5;@a=($[..10);say$a[$[]  #Prints 5
$[=5;@a=($[..10);say$a[-$[]  #Prints 6
$[=4;@a=($[..10);say$a[-$[]  #Prints 7
$[=3;@a=($[..10);say$a[-$[]  #Prints 8
$[=2;@a=($[..10);say$a[-$[]  #Prints 9
$[=1;@a=($[..10);say$a[-$[]  #Prints 10

```

While deprecated, `$[` still allows you to modify the indexing of arrays (typically, 0-based). It prints a warning to STDERR, but OP says that any output to STDERR can be ignored.
> 1 votes

# Answer
# Perl, 31 bytes, 10 numbers Cracked by ais523

```
__e_$a__<__$_;1 while_$a_;say$_

```

My original post was cracked with a solution that wasn't even in the realm of what I was going for, so I'm adding a single extra byte that renders the previous solution (hopefully) unsalvageable.

Once again cracked in a way I haven't accounted for:

```
the;$a+=<1\$>;1 while!$a ;say$a #Prints 1
the;$a+=<1\$>+1 while!$a ;say$a #Prints 2
...
the;$a+=<1\$>+9 while!$a ;say$a #Prints 10

```
> 1 votes

# Answer
# Perl, 7 bytes, 9 numbers, Cracked!

```
say$_-_

```

Underscores represent unknown characters.

The solution (as found by feersum) was to use a literal control-F to replace the first underscore, thus finding the predefined variable that has the value 2.
> 1 votes

# Answer
## Python 2, 26 bytes, 10 numbers, cracked by feersum and Destructible Watermelon

~~Third try's the charm?~~

```
print r___e(3_4____+_[___]

```

Works for 1-10, `_` is hidden.

---

Destructible Watermelon got the general idea I was going for. Here's my solution:

> ```
> print r"10e(3246578+9["[0]
> print r"10e(3246578+9["[5]
> print r"10e(3246578+9["[4]
> print r"10e(3246578+9["[6]
> print r"10e(3246578+9["[-6]
> print r"10e(3246578+9["[-7]
> print r"10e(3246578+9["[-5]
> print r"10e(3246578+9["[-4]
> print r"10e(3246578+9["[-2]
> print r"10e(3246578+9["[:2]
> ```
> 1 votes

# Answer
# COW, 51 bytes, 10 numbers Cracked by Kritixi Lithos

```
MoO ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ OOM

```

Original code:

```
MoO Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ OOM #Prints 1
MoO MoO Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ OOM #Prints 2
...
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Mo_ Mo_ OOM #Prints 10 (the last two operations were red-herrings)

```

For a Javascript-based interpreter to use for testing, you can go here.

_ is hidden character
> 1 votes

# Answer
# Wentel x87, 36 bits/8 = 4.5 bytes, 2 numbers

```
____________0110______00____00______

```
> 1 votes

# Answer
# Python 2, 111 bytes, 10 numbers (cracked)

How about some random digits?

The hidden character is `E`.

```
print +int('''3EE5EE6EE0EE2EE5EE6EE4EE9EE1EE5EE9EE4EE6EE7EE5EE7E''')%int('''2EE0EE9EE8EE9EE2EE3EE5EE0EE3EE6''')

```
> 1 votes

# Answer
## OCaml (interpreted), 51 bytes, 10 numbers (Cracked)

By "interpreted" I mean that it should be run with the command `ocaml` rather than compiled to native code with `ocamlopt`.

The hidden character is `^`.

```
^^t^r^^^^-^^^^-^^r^^^^=^^^^^^^r^^^^r^^^^^^^(^^^^/0)

```
> 1 votes

# Answer
# Octave, 16 bytes, 10 numbers (cracked)

As a cop, it's my duty to keep this site clean and remove any explicit content. I found<sup>1</sup> a piece of code referring to a diabolical body part that I've decided to censor here using underscores, `_`.

```
ev_l('P_NIS'-2_)

```

<sup>1: Well, I found it on the screen after I wrote it.</sup>
> 1 votes

# Answer
## QBasic, 12 bytes, 10 numbers, cracked

All right, let's try this:

```
_INT(_O_(3))

```

Works for 1-10. `_` is the hidden character.

---

Finally, the crack used my intended approach. :P
> 1 votes

# Answer
# Aceto, 5 bytes, 9 numbers, safe

_ are unrevealed chars

```
__xx_

```
Try it online!
> 1 votes

# Answer
## *Acc!!*, 46 bytes, 10 numbers, cracked

```
?
Count i while ?????????????????
}
Write ????

```

Works for 1 to 10, with `?` as the hidden character.

---

Original solution:

> ```
> 1
> Count i while _/10 {
> Write 49
> 0
> }
> Write 48+_
> ```
> The initial accumulator value goes from `1` to `9` and then to `99`. Whenever it is less than 10, `_/10` is 0 and the loop doesn't execute. When it is greater than 10, the inner loop writes a `1` and sets the accumulator to 0, which breaks out of the loop and writes a `0`.
> 0 votes

# Answer
## TI-Basic, 13 tokens, 10 numbers, cracked

```
DelVar A1→θ
__>A
θ

```

`_` represents a hidden token. Hopefully this isn't too easy xD
> 0 votes

# Answer
# Python, 28 bytes, 10 numbers, cracked!

```
_____ (__________)_(_____*4)_

```

Intended solution:

```
print (ord("a"   )-(24   *4))

```
> 0 votes

# Answer
# ~~ASMD, 10 bytes~~ Cracked!

```
1_**_**_*÷

```

Hidden characters are denoted by `_`.

This should be really easy to crack.

Works from 1 to 10.
> 0 votes

# Answer
# Java 10+ numbers 126 tokens

`____00________007____________00______________________________t____o_____in_(___"___42________00____00____".___________0)___;__`

`_` is redacted
> 0 votes

# Answer
## Python 2, 26 bytes, 10 numbers, cracked

```
print r___e(_______+_[___]

```

Works for 1-10; `_` is the hidden character.
> 0 votes

# Answer
# ASMD, 8 bytes, Cracked!

```
____+++C

```

Works from 1-10.
> 0 votes

# Answer
## Hexagony, 15 bytes, 10 numbers, Cracked!

```
\!?___<3__!?_<3

```

What kind of love (`<3`) is this? This is the love of Hexagons :P

I believe this is not a hard one but a hearty one (Pun intended).
> 0 votes

# Answer
# Ruby, 81 bytes, 10 numbers, cracked by feersum

```
require'digest/md5'
p Digest::MD5.digest('########')[n=0].ord^'straYNpraq'[n].ord

```

`#` is the placeholder character. Is this a standard loophole yet? Not that it's uncrackable I don't think, I've left in some weaknesses intentionally and I'm sure unintentionally.
> 0 votes

# Answer
# Python 2, 33 bytes, 9 numbers

```
#__________________
riny
________

```

<sub>(how mysterious?)</sub>
> 0 votes

# Answer
## Hexagony, 12 bytes, 10 numbers, Cracked!

```
[!_>!_!1_@!_

```

`_` can be replaced by any characters.

Seems that love doesn't belong to here should not stay here, to keep the world more interesting :P

Spent time finding cheap alternatives. So giving out much tips so that it is harder to crack (I hope impossible) with cheap alternatives `!_!`
> 0 votes

# Answer
# Python 2, 109 bytes, 10 numbers

```
from hashlib import *
h=md5()
h.update('__[_')
if h.hexdigest()=='88f4002e27b0902c7018359da9bc5b44':print(0+1)

```
> 0 votes

# Answer
# Hexagony, 18 bytes, 10 numbers, Cracked!

This submission works for 1 - 10. Unrevealed characters are indicated with an underscore: `_`.

```
.__{_]5[$@__=@_!!1

```

You can try Hexagony online over here.

I posted a follow-up using the same indended solution, but with fewer hidden characters here.
> 0 votes

# Answer
# Python 3, 56 bytes, 6 numbers, Cracked

Quite a simple concept, should be easily crackable. The 'mystery characters' are indicated with underscores.

```
print(_______(str(ord(x))for x in ________).___________)

```
> 0 votes

# Answer
## tinylisp, 43 bytes, 10 numbers

```
((v(d f(q((n)(i n(s 1(s 0(f(___))))1)))))0)

```

Works for 1-10; `_` is hidden.
> 0 votes

# Answer
## QBasic, 12 bytes, 10 numbers, cracked

Previous version's red herring created a loophole...

```
_I_T__O_(3))

```

Works for 1-10. `_` is the hidden character.
> 0 votes

# Answer
# R, 22 bytes, 10 numbers SAFE

```
_et___e_(_)____is_1___

```

`_` is hidden character

Solution:

> `set.seed(4);rpois(1,1)`
> `set.seed(4);rpois(1,2)`
> `set.seed(4);rpois(1,3)`
> `set.seed(4);rpois(1,4)`
> `set.seed(4);rpois(1,5)`
> `set.seed(4);rpois(1,6)`
> `set.seed(4);rpois(1,7)`
> `set.seed(6);rpois(1,7)`
> `set.seed(6);rpois(1,8)`
> `set.seed(6);rpois(1,9)`
> 0 votes

---
Tags: code-golf, cops-and-robbers
---


title: Implement the Cubically Cube

text:
# Question
Title: Implement the Cubically Cube
Cubically is a fairly new esoteric language capable of creating short, golf-like answers for a very specific subset of problems. It is unique in that it stores memory in the form of a 3x3 Rubik's cube, making calculations far less trivial than in most languages. In Cubically, the programmer must rotate the internal cube in order to manipulate the values stored on the faces, then use those values in their calculations. Calculations are performed on a single 32-bit integer stored on an imaginary face known as the "notepad". Additionally, Cubically can request user input and store it in an input buffer consisting of only a single integer value.

## The Cube

The faces of the cube are **U**p, **D**own, **L**eft, **R**ight, **F**ront, and **B**ack:

```
   UUU
   UUU
   UUU
LLLFFFRRRBBB
LLLFFFRRRBBB
LLLFFFRRRBBB
   DDD
   DDD
   DDD

```

When the program starts, the cube is initialized such that each square on that face is equal to that face's 0-based index:

```
   000
   000
   000
111222333444
111222333444
111222333444
   555
   555
   555

```

Whenever a face is rotated, it is always rotated clockwise:

```
Cubically> F1

   000
   000
   111
115222033444
115222033444
115222033444
   333
   555
   555

```

The value of a face is defined as being the sum of every square on that face. For example, in the above cube, the value of face `0` is 3.

## Syntax

Commands are executed by first loading a command into memory, then passing arguments to it to execute the command. For example, the command `F1` will load the command `F` into memory, then call it with the argument `1`. Additionally, `F13` will load the command `F` into memory, then call it with the argument `1`, then call it with the argument `3`. Any non-digit character is treated as a command, and any digit is treated as an argument.

## Your task

Your task is to implement Cubically's internal memory cube in a language of your choice. Your code should be able to execute a very small subset of the language.

**Commands**

* `R` \- Rotate the right face of the cube clockwise the specified number of times.
* `L` \- Rotate the left face of the cube clockwise the specified number of times.
* `U` \- Rotate the top face of the cube clockwise the specified number of times.
* `D` \- Rotate the bottom face of the cube clockwise the specified number of times.
* `F` \- Rotate the front face of the cube clockwise the specified number of times.
* `B` \- Rotate the back face of the cube clockwise the specified number of times.
* `%` \- Outputs the value on the given face. The value of a face is defined as the sum of all squares on that face.

## Rules

* You may use any language created before or after the date this challenge was posted to write a program or function capable of solving this challenge.
* Input will be passed in either through STDIN, as a string, or as a character array (you choose, please specify).
* Output must be passed either to STDOUT or as the output of the function, and it must be either an integer, a string containing only digits, or an array of digits. If your language **requires you** to output a trailing newline, you may do so.
* The input will always be in the following format: `([UDLRFB]\d*)*%[0-5]`. There will be no whitespace characters in the input.
* The input for `%` will always use a 0-based index.

This is , so shortest answer in bytes wins.

## Test Cases

```
%0 -> 0
%1 -> 9
%2 -> 18
%3 -> 27
%4 -> 36
%5 -> 45
R1%2 -> 27
RD3F2%5 -> 32
L1R23F1B5U9D2%3 -> 17

```

For more test cases, check out the TIO interpreter. If TIO isn't working, you may use the Lua interpreter instead.

# Answer
# Python 2, 476 bytes

```
import re
c=[[i]*9for i in range(6)]
r=lambda f:[f[a+b]for a in(0,1,2)for b in(6,3,0)]
U=lambda c:[r(c[0])]+[c[j+1][:3]+c[j or 4][3:]for j in(1,2,3,0)]+[c[5]]
y=lambda c:[r(c[0])]+c[2:5]+[c[1],r(r(r(c[5])))]
z=lambda c:[c[2],r(r(r(c[1]))),c[5],r(c[3]),c[0][::-1],c[4][::-1]]
s=input()
exec("c="+"(c);c=".join("".join("zzzUz U zzUzz yyyzUzzzy zUzzz yzUzzzyyy".split()[ord(t)%11%7]*sum(map(int,n))for t,n in re.findall("([BUDLFR])(\d*)",s[:-2])))+"(c)")
print sum(c[int(s[-1])])

```

**Try it online!**

A port from my Simulate A Rubik's Cube answer. The revisit prompted me to golf that by 47 bytes.
> 8 votes

# Answer
# Cubically, 1 byte

Non-competing 'cause it's lame. Don't accept this.

```
¶  Read a line from stdin and evaluate

```

I added that this afternoon :P
> 0 votes

---
Tags: code-golf, array, rubiks-cube, cubically
---


title: Identity sequences on the Rubik's Cube

text:
# Question
Title: Identity sequences on the Rubik's Cube
A move sequence is a sequence of moves (turns) on a Rubik's Cube (for the notation look down below). Beside the empty move sequence, there are many other other move sequences, that have no effect on the cube at all. We call these move sequences identity sequences.

Some of these identity sequences are obvious to determine, like `U2 R R' U2` or `U D2 U' D2`. In the first one, two random moves are done `U2 R` and afterwards immediately undone `R' U2`. The second one is similar. First two random moves `U D2` and afterwards they are undone, but in reversed order `U' D2`. This only works, because the move `U` effects only the pieces of the upper layer and the move `D2` only effects pieces of the lower layer. You can see a visualization of these two move sequences.

Other identity sequences may be not obvious at all. For instance the sequence `R' U' R' F' U F U' R' F R F' U' R U2 R`. It pretty long, but also has no effect at the cube at all.

## Move Notation

A move describes the turn of one layer of one of the six faces of the cube. A move consist of one letter representing the face followed by an optional suffix representing the turn angle.

The letters and their corresponding faces are **U** (Up - the side facing upwards), **D** (Down - the side facing downwards), **R** (Right - the side facing to the right), **L** (Left - the side facing to the left), **F** (Front - the side facing you) and **B** (Back - the side facing away from you).

If there is no suffix, the face is turned 90-degree clockwise, the suffix **`'`** means, the face is turned 90-degree counterclockwise, and the suffix **`2`** means, the face is turned 180-degree clockwise.

It you have any problems with the notation, just use http://alg.cubing.net, where you can visualize such move sequences.

## The Challenge

Your task is to write a program, that determines if a move sequences is an identity or not.

You may write a full program or a function. It should receive a string containing a move sequence (moves are separate by spaces) as input (via STDIN, command-line argument, prompt or function argument), and output (via return value or STDOUT) a Boolean value or a corresponding integer (True - 1 - identity sequence/ False - 0 - not identity sequence).

If you suffix `'` creates problems in your programming language, you may use a different symbol, but not at digit. `R F2 U3` is not allowed.

This is codegolf, therefore the shortest code (in bytes) wins.

## Test Cases

```
"" -> True
"U2 R R' U2" -> True
"U D2 U' D2" -> True
"U2 R U2 R'" -> False
"R' U' R' F' U F U' R' F R F' U' R U2 R" -> True
"L'" -> False
"B B2 B' B2" -> True
"D D2 D'" -> False
"R F' D2 U B' F2 B' U2 D2 F2 B2 U F R'" -> True
"D2 U' R2 U F2 D2 U' R2 U' B' L2 R' B' D2 U B2 L' D' R2" -> False
"R U R' U' R' F R2 U' R' U' R U R' F' R2 U R2 U' R2 U' D R2 U' R2 U R2 D'" -> True
"R U R' U' R' F R2 U' R' U' R U R' F' R2 U' R2 U R2 U' D R2 U' R2 U R2 D'" -> False
"B2 F2 U' F2 U R2 F2 U2 B D' R' D' R2 D' F2 U' F U R2 U R B D B D2 L2 D' F2 U D' R' D B R2 D2 F2 R' F2 D2" -> True
"R U2 R' U R' U2 R U2 R U R' U' R' U R U2" -> False
"U F B' R' U F' R U' F' B L U' F L'" -> False
"R2 U' R' U' R U R U R U' R" -> False
"R' F R' B2 R F' R' B2 R2" -> False

```

# Answer
> 14 votes
# Haskell, ~~263~~ ~~261~~ ~~247~~ 243 characters

```
c[x]=[x]
c(x:"2")=[x,x]
c(x:_)=[x,x,x]
s!a@[x,y,z]=case s of
 'R'|x>0->[x,-z,y]
 'B'|y>0->[z,y,-x]
 'U'|z>0->[-y,x,z]
 'L'|x<0->[x,z,-y]
 'F'|y<0->[-z,y,x]
 'D'|z<0->[y,-x,z]
 _->a
r=[-2..2]
i=mapM id[r,r,r]
f w=i==foldr(map.(!))i(c=<<words w)

```

Rather straightworward algorithm; each cubelet is made out of 1,2,4 or 8 chunks encoding its position and orientation; 4 chunks per edge cubelet, 8 per corner cubelet, 7 cubelets are stationary.

`c` **c**homps each word of the input into a sequence of CW turns, and `!` sends each chunk according to a turn. `i` is the **i**dentity position. `f` is the main **f**unction.

I'm not too happy with the `c`homp function, but I can't seem to find a way to shorten it either (@Nimi did, however)

# Answer
> 4 votes
# Cubically, ~~6~~ 4 bytes

```
¶=8%

```

I win :P

```
¶=8%
¶     read a string, evaluate as Cubically code
 =8   set notepad to (notepad == 8th face)
   %  print notepad

```

The notepad is initialized to zero. The 8th "face" contains 1 if the cube is unsolved and 0 otherwise.

Try it online!

# Answer
> 3 votes
## J - 232, 220, 381, 315 296 bytes

This solution encodes all operations as face permutations and works based on the fact that all face twists are actually the same, under a rotation of the entire cube.

*Edit*: some more golfing

```
f=:+/~6&*
r=:4 :'y f&.>(]{^:x~)&.C.;/i.2 4'"0
t=:((r~0),_4<\44#.inv 1478253772705907911x)&C.&.
Y=:(C.(,0 2 r 4 5),;/4 f&i.8)&{^:t
X=:((,1 1 0 2 r 2 4 3 1)C.C.;/0 4 2 5 f i.8)&{^:t
61".@A."1'=: ',"#~6 3$'D0XR1YF1XU2YB3XL3Y'
T=:[:(_2".@}.'(i.48)-:'&(,,[))[:(,'^:',])/&.>@|.&.;:[:''''&=@{.`]},:&'3'

```

Other than the previous tries, this *does* take corner rotation into account.

`f` is just a helper function. `r` does the rotation of one face. a face is encoded as follows:

1. all corners in steps of 6
2. all edges in steps of six

this order facilitates the encoding of rotations and twists. `t` is an adverb that twists the face under a certain cube rotation, selecting the face.

`X` and `Y` are adverbs which take as left argument the number of in that direction of the entire cube.

The next line defines all rotations: 3 characters per rotation: the name, the number of rotations and the direction.

The last line defines the test verb `T`, converting 3 and `'` to Power notation, flipping the order of operation appending the test vector andfinally excuting the entire thing.

More details upon request.

```
tests =: (] ;. _2) 0 : 0

 U2 R R' U2
 U D2 U' D2
 U2 R2 R'
 R' U' R' F' U F U' R' F R F' U' R U2 R
 L'
 B B2 B' B2
 D D2 D'
 R F' D2 U B' F2 B' U2 D2 F2 B2 U F R'
 D2 U' R2 U F2 D2 U' R2 U' B' L2 R' B' D2 U B2 L' D' R2
 R U R' U' R' F R2 U' R' U' R U R' F' R2 U R2 U' R2 U' D R2 U' R2 U R2 D'
 R U R' U' R' F R2 U' R' U' R U R' F' R2 U' R2 U R2 U' D R2 U' R2 U R2 D'
 B2 F2 U' F2 U R2 F2 U2 B D' R' D' R2 D' F2 U' F U R2 U R B D B D2 L2 D' F2 U D' R' D B R2 D2 F2 R' F2 D2
 R U2 R' U R' U2 R U2 R U R' U' R' U R U2
 U F B' R' U F' R U' F' B L U' F L'
 R2 U' R' U' R U R U R U' R
 R' F R' B2 R F' R' B2 R2
)
res =: 1 1 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0
res ([,],:=) T"1 tests NB. passes all tests.
1 1 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0
1 1 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

NB. some handy display methods:
dispOrig=: (". ;._2) 0 :0
   _   _   _   5  29  11   _   _   _   _   _   _
   _   _   _  47  _1  35   _   _   _   _   _   _
   _   _   _  23  41  17   _   _   _   _   _   _
   3  27   9   0  24   6   1  25   7   2  26   8
  45  _3  33  42  _6  30  43  _5  31  44  _4  32
  21  39  15  18  36  12  19  37  13  20  38  14
   _   _   _   4  28  10   _   _   _   _   _   _
   _   _   _  46  _2  34   _   _   _   _   _   _
   _   _   _  22  40  16   _   _   _   _   _   _
)
ind =: dispOrig i.&, i. 48 NB. indices of i.48 in the original display

disp =: (9 12$(,dispOrig) ind}~ ])
changed =: 1 : '(u ~:&disp ]) i.48' NB. use to debug permutation verbs: L ch
vch =: 1 :'disp  ((]+_*=) u)'
NB. viewmat integration RGB
cm =: 255 * 1 0 0 , 1 1 1, 0 1 0, 1 1 0, 1 0.5 0, 0 0 1,: 0 0 0 NB. colormap
NB. use as:  "cube i. 48" for seeing a nice folded out cube.
cube =: cm viewmat (>&7 + >&15 + >&23 + >&31 + >& 39 + >&47)@|@disp@]

```

# Answer
> 2 votes
# Python 3: 280 chars

This is not a participant in the challenge. Firstly because I asked the challenge myself and secondly because it's not my code. All credits belong to Stefan Pochmann, who discovered this awesome way of simulating a Rubik's Cube. I only did some golfing and some minor changes in respect of the challenge.

```
def f(a):
 s=t="UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR".split()
 for m in a.split():q="FLBR FRBL FDBU FUBD URDL ULDR".split()['UDLRFB'.index(m[0])];n=2+"2'".find(m[-1]);s=[[p,p.translate(str.maketrans(q,q[n:]+q[:n]))][m[0]in p]for p in s]
 return s==t

```

The idea behind this is the following. `s` represents the location of the pieces of `UF`, `UR`, and so on. For instance: `s = ['DF', 'BL', ...]` means, that the piece `UF` is at the position `DF`, the piece `UR` is at the position `BL`, ...

How does the position of a piece change, when doing a move. If you do a `U`-move, all stickers (colors) of the `U`-layer, which faced the front face, move to the left face. The stickers of the left face move to the back, these to the right and these to the front face. Encoded by `FLBR`. Some examples: `UF` moves to `UL`, `UFR` moves to `ULF` and so on. Therefore, applying a move is simply translating the faces of pieces in the corresponding layer.

---
Tags: code-golf, rubiks-cube
---


# Question
Title: Find the maximum of 3 numbers without branching
This time around your goal is to find the maximum of 3 integers (from -(2^31) to 2^31 - 1 in binary 2's complement) without using branching or loops.

You are **only** allowed to use

* Inequality/Equality (`==`, `>`, `>=`, `<`, `<=`, `!=`) These count as **2** tokens.
* Arithmetic (`+`, `-`, `*`, `/`)
* Logical Operators (`!` not, `&&` and, `||` or)
* Bitwise Operators (`~` not, `&` and, `|` or, `^` xor, `<<`, `>>`, `>>>` arithmetic and logical left and right shifts)
* Constants. 0 tokens
* Variable assignment. 0 tokens

Input 3 variables as `a`, `b` and `c`. Output the maximum number.

Standard atomic code-golf rules apply. If you have any questions please leave them in the comments. One token is any of the above with the special rules.

# Answer
> 7 votes
# Javascript 10 tokens

*Edit* Using \< and * instead of bit fiddling - as pointed out in comments, bits operations may fail for input near the range limit (over 30 bits)

```
function Max(x,y,z)
{
  var d=y-x;
  x=y-d*(d<0);
  d=x-z;
  return x-d*(d<0);
}

```

# C 8 tokens

Language agnostic in fact, any C like language will do. To be picky, in standard C it's not portable because right shift may not extend the sign (but in common implementations it does).

In C (and C++, C#, and Java I think) we can easily handle overflow problems using bigger temporary values:

```
int Max(int x, int y, int z)
{
    long long X = x;
    long long Y = y;
    long long Z = z;
    long long D = Y-X;
    X=Y-((D>>63)&D);
    D=X-Z;
    return (int) (X-((D>>63)&D));
}

```

# Answer
> 11 votes
# Javascript

**6 tokens**

```
function maxOf3(a, b, c) {
    (b>a) && (a=b);
    (c>a) && (a=c);
    return a;
}

```

# Answer
> 6 votes
## C: 10 tokens

```
int max(int a, int b, int c)
{
    a += (b > a) * (b - a);
    a += (c > a) * (c - a);
    return a;
}

```

Inspired by @openorclose's answer, but converted to C and made branchless using multiplication rather than short circuit boolean operators.

# Answer
> 3 votes
# Javascript

**14 tokens**

```
function max (a, b, c)
{
    var ab = (a >= b) * a + (a < b) * b;
    return (ab >= c) * ab + (ab < c) * c;
}

```

# Answer
> 2 votes
## Many languages (Python) (10 tokens)

```
def max3(x,y,z):
    m = x ^ ((x ^ y) & -(x < y))
    return m ^ ((m ^ z) & -(m < z))

print max3(-1,-2,-3) # -1
print max3(-1,2,10) # 10

```

https://graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax

Oh, someone already posted it :)

# Answer
> 1 votes
# C++11: 15 tokens

Using only arithmetic and bitwise operators (since equality and boolean logic operators make it too easy)...

```
#include <iostream>

auto max(int32_t a, int32_t b, int32_t c)->int32_t {
  return c - ((c - (a - ((a - b) & (a - b) >> 31))) & (c - (a - ((a - b) & (a - b) >> 31))) >> 31);
}

auto main()->int {
  // test harness
  std::cout << max(9, 38, 7) << std::endl;
  return EXIT_SUCCESS;
}

```

# Answer
> 0 votes
# J (Not competing)

I was just wondering what the a solution in J would look like. This uses a `,` and a `#` though, so it won't be competing.

```
((a<b),(b<c),(c<a))#b,c,a

```

This would compete, but is way too long, with 9 tokens:

```
(b*a<:b)+(c*b<c)+(a*c<a)

```

# Answer
> 0 votes
we have the following assumptions:

* max(a;b)=(a+b + |a-b|)/2
* max(a;b;c)=max(max(a;b);c)
* abs(a)=(a + (a \>\> 31)) ^ (a \>\> 31)

we can use the pseudo-code:

> function max(a,b,c)
>
> {
>
> out1=( (a+b) + (( (a-b) + ((a-b) \>\> 31)) ^ ((a-b)\>\> 31))) div 2
>
> out2=( (out1+c) + (( (out1-c) + ((out1-c) \>\> 31)) ^ ((out1-c)\>\> 31))) div 2
>
> return out2
>
> }

# Answer
> 0 votes
## C# (2nd try)

I got it... No integrated functions...

But is it allowed to use other integrated datatypes or just plain int? If allowed I would propose:

```
int foo2(int a, int b, int c)
{
   var x = new SortedList<int,int>();

   x[a] = 1;
   x[b] = 1;
   x[c] = 1;

   return x.Keys[2];
}

```

# Answer
> 0 votes
## javascript 8 tokens

although similar to @openorclose's answer, i do actually use the logical operators for the assignment itself.

```
function max( a, b, c ) {
    x=( a > b && a) || b;
    return ( x > c && x ) || c;
}

```

fiddle

# Answer
> 0 votes
## R (10 tokens)

```
function max(a, b, c) {
  max <- a
  max <- max + (b - max) * (b > max)
  max <- max + (c - max) * (c > max)
  return(max)
}

```

# Answer
> 0 votes
## Brainfuck (Not competing)

```
>,[-<+>>>+<<]>,[-<+>>>+<<]>[>[-<->>]<<]<[-]>[-]>[-]<<<[->>>>+<<<<]>>>>[-<+>>>+<<]>,[-<+>>>+<<]>[>[-<->>]<<]<<

```

# Answer
> 0 votes
# TIS-100, 8 operations

```
MOV ACC UP #A
SUB UP     #B
SUB 999
ADD 999
ADD UP     #B
SUB UP     #C
SUB 999
ADD 999
ADD UP     #C
MOV ACC DOWN

```

The provider(UP) only do MOVs so not shown in the code Maybe not work when too near the 999 edge

# Answer
> -1 votes
VBA (6 tokens)

```
 Function max3(a As Integer, b As Integer, c As Integer)
 i = IIf(a >= b And a >= c, a, IIf(b >= c, b, c))
 max3 = i
 End Function

```

not sure if this is not branching.

# Answer
> -1 votes
## JavaScript: 4 tokens (\** based on broad interpretation of "assignment"!)

Obviously my score of 4 is extremely generous/lenient!

To arrive at that score I've assumed "assignment" (worth 0 tokens in the question) includes such things as additive assignment, subtractive assignment, multiplicative assignment, and XOR-ing (`^=`) assignment

```
function f(a, b, c) {
  d = a;
  d -= b;
  d = d >= 0;

  a *= d;  //a = a if (a>=b), else 0
  d ^= true; //invert d
  b *= d;  //b = b if (b<a), else 0

  a += b;  //a is now max(a,b)

  d = a;
  d -= c;
  d = d >= 0;

  a *= d;  //a = a if (a>=c), else 0
  d ^= true; //invert d
  c *= d;  //c = c if (c<a), else 0
  a += c;  //a is now max(max(a,b),c)

  return a;
}

```

If those assignments actually count the score is 14 :)

---
Tags: atomic-code-golf
---


# Question
Title: Fastest algorithm for decomposing a perfect power
A perfect power is a positive integer that's equal to one positive integer, to the power of another positive integer (e.g. *a**b* is a perfect power). Note that trivial solutions (e.g. *b*=1) are excluded; specifically, the definition requires *a* ≥ 2 and *b* ≥ 2.

## The task

Write a full program that takes any number of positive integers (separated by newlines) from standard input, and for each such input *n*, outputs all pairs of positive integers *a*, *b* (with *a* ≥ 2 and *b* ≥ 2) such that *a**b* = *n*. Use the syntax `a^b` for these pairs. If multiple pairs of outputs are possible for a given input, print all of them, separated by spaces.

Note the victory condition below: the aim here is to optimize the program for *speed*, not size.

## Example test cases

**Input**

```
 1745041
 1760929
 1771561
 1852321
 1868689
 1874161
 1885129
 1907161
 1953125
 113795717542678488615120001
 113795717546049421004105281

```

**Output**

```
 1745041 = 1321^2
 1760929 = 1327^2
 1771561 = 11^6 121^3 1331^2
 1852321 = 1361^2
 1868689 = 1367^2
 1874161 = 37^4 1369^2
 1885129 = 1373^2
 1907161 = 1381^2
 1953125 = 5^9 125^3
 113795717542678488615120001 = 10667507560001^2
 113795717546049421004105281 = 10667507560159^2

```

## Clarifications

* No more than 10000 inputs will be given on any single run of the program.
* Your program, as written, should be able to handle numbers up to at least 30 digits long (meaning you will likely need to use bignum support). In order for the victory condition to be meaningful, though, the underlying algorithm behind your submission must be capable of working for arbitrary perfect powers, no matter how large they are.
* Each input *n* will actually be a perfect power, i.e. there will always be at least one output corresponding to each given input.
* There are no restrictions on programming language (as long as the language has sufficient power to complete the task).

## Victory condition

The program with the fastest algorithm (i.e. with the fastest complexity) will be the winner. (Note that the fastest known perfect power decomposition algorithms can determine whether a number is a perfect power, and what the base and exponent are, without having to actually factorise the number; you may want to take this into account when choosing the algorithm for your problem.)

In the case that two programs are equally fast by this measure, the tiebreak will be to see which program runs faster in practice (on the stated testcases or, to avoid hard-coding, a similar set of test cases).

# Answer
> 4 votes
## Python, 207 chars

This takes *O(log2 N)* bigint ops. *O(log N)* different exponents to try, and *O(log N)* binary search to find each base.

```
import sys
for N in map(int,sys.stdin.readlines()):
 p,s=2,''
 while 1<<p<=N:
  i,j=2,N
  while j>i+1:
   m=(i+j)/2
   if m**p>N:j=m
   else:i=m
  if i**p==N:s+=' %d^%d'%(i,p)
  p+=1
 if s:print N,'=',s[1:]

```

# Answer
> 4 votes
# C - No bigints

My solution use a 64 bit float and a 64 bit integer in combination to produce the result without using slow bignumber arithmetic. First a possible set of values that fit the high-order bits are produced using floats, then the low order is checked using integers. Due to 64 bit floats having 53 bit mantissa the method will break for numbers around 106 bit in length, but the task was only for up to 100 bit numbers.

```
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include "math.h"
#define i64 unsigned long long
#define i32 unsigned int
#define f64 double

int main(){
    char inp[31];
    while(1==scanf("%30s",inp)){
        printf("%s =",inp);

        f64 upper=strtod(inp,NULL);
        //i64 lower=strtoull(inp,NULL,10);
        //i64 lower=atoll(inp);
        //Neither library function produce input mod 2^64 like one would expect, fantabulous!
        i64 lower=0;
        i32 c=0;
        while(inp[c]){
            lower*=10;
            lower+=inp[c]-48;
            c++;
        }
        f64 a,b;
        i64 candidate;
        f64 offvalue;
        f64 offfactor;
        i32 powleft;
        i64 product;
        i64 currentpow;
        for(a=2;a<50;a++){ //Loop for finding large bases (>3).
            b=1.0/a;
            b=pow(upper,b);
            candidate=(i64)(b+.5);
            if(candidate<4){
                break;
            }
            offvalue=b-(f64)candidate;
            offfactor=fabs(offvalue/b);
            if(offfactor<(f64)1e-14){
                product=1;
                powleft=(i32)a;
                currentpow=candidate;
                while(powleft){ //Integer exponentation loop.
                    if(powleft&1){
                        product*=currentpow;
                    }
                    currentpow*=currentpow;
                    powleft=powleft>>1;
                }
                if(product==lower){
                    printf(" %I64u^%.0lf",candidate,a);
                }
            }
        }
        for(candidate=3;candidate>1;candidate--){ //Loop for finding small bases (<4), 2 cycles of this saves 50 cycles of the previous loop.
            b=log(upper)/log(candidate);
            a=round(b);
            offfactor=fabs(a-b);
            if((offfactor<(f64)1e-14) && (a>1)){
                product=1;
                powleft=(i32)a;
                currentpow=candidate;
                while(powleft){ //Integer exponentation loop.
                    if(powleft&1){
                        product*=currentpow;
                    }
                    currentpow*=currentpow;
                    powleft=powleft>>1;
                }
                if(product==lower){
                    printf(" %I64u^%.0lf",candidate,a);
                }
            }
        }
        printf("\n");
        if(inp[0]==113){ //My keyboard lacks an EOF character, so q will have to do.
            return 0;
        }
    }
    return 0;
}

```

As for runtime, ideone produce a clean 0 http://www.ideone.com/HJl2f this should be a pretty superior method, but any attempt to verify this will drown in I/O.

# Answer
> 0 votes
## Ruby

Non-golfed, not-really-optimized solution. I hope I didn't mess up my math.

Roots are calculated first using core `sqrt` and `cbrt` methods, then using dumb approximation (binary search).

On my PC, 10000 long random inputs (not necessarily actually having non-trivial representations) take ~30 seconds (see the `bench` method).

```
def root start, exp, startapprox=nil
    if exp==1
        return start
    elsif exp==2
        return Math.sqrt(start).round
    elsif exp==3 and Math.respond_to? :cbrt # 1.9 only
        return Math.cbrt(start).round
    else
        lower=0
        upper=startapprox||Math.sqrt(start).ceil

        until upper-lower<=1
            res=(lower+upper)/2

            if res**exp<start
                lower=res+1
            else
                upper=res
            end
        end

        distlow=(start - lower**exp).abs
        distupp=(start - upper**exp).abs

        if distlow<distupp
            return lower
        else
            return upper
        end
    end
end

def powers number
    ret=[]
    skip=[]

    maxexp=(Math.log2 number).floor
    prev=nil

    2.upto(maxexp) do |exp|
        next if skip[exp]

        rt=root number, exp, prev
        if number==rt**exp
            ret<<"#{rt}^#{exp}"
        else
            (exp..maxexp).step(exp){|i| skip[i]=true} # if it's not 2nd power, it cant be 4th power etc
        end

        prev=rt
    end

    "#{number} = #{ret.reverse.join ' '}"
end

def bench n=10
    require 'benchmark'

    Array.new(n){Benchmark.realtime{powers rand 1e30}}.inject(:+)
end

# read input, output powers
if __FILE__==$0
    while (a=gets.strip).length>0
        puts powers a.to_i
    end
end

```

# Answer
> 0 votes
# C++, not sure if it's correct

```
#include <iostream>
#include<iomanip>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
long double x;
char s[120];
ios::sync_with_stdio(false);
//cout << setprecision(20);
while (cin >> s) {
    cout << s << " =";
    //sscanf (s, "%Lf", &x);
    x = 0;
    for (char*p=s; *p; p++) {
        x = 10*x + (*p-48);
    }
    for (int i=2; ; i++) {
        long double tmp = pow(x, 1./i);
        if (tmp<1.98) break;
        long long inty = tmp + 0.5;
        tmp = powl(inty, i) - x;
        //cout << "[" << i << ' ' << inty << ' ' << tmp << "]\n";
        if (abs(tmp * 1e19) < x)
            cout << ' ' << inty << '^' << i;
    }
    cout << '\n';
}
}

```

If `Each input n will actually be a perfect power`, numbers may needn't be not so accurate/precise. Here my `long double` is `TBYTE` type, though `sizeof(x)` is 12

---
Tags: math, fastest-algorithm
---


# Question
Title: 128 years? Hypothetical leap year reform
The solar year is 365 days, 5 hours, 48 minutes, 45 seconds, and 138 milliseconds, according to this video. With the current Gregorian calendar, the rules for leap years are as follows:

```
if      year is divisible by 400, LEAP YEAR
else if year is divisible by 100, COMMON YEAR
else if year is divisible by 4,   LEAP YEAR
else,                             COMMON YEAR

```

Unfortunately, this method is off by one day every 3216 years.

One possible method of reforming the calendar is the following rule:

```
if      year is divisible by 128, COMMON YEAR
else if year is divisible by 4,   LEAP YEAR
else,                             COMMON YEAR

```

This has the benefit of not requiring us to change our calendars again for another 625,000 years, give or take.

Say the entire world decides that, starting now, we use this system of every fourth year is a leap year except every 128th year, changing our calendars as follows:

```
YEAR    GREGORIAN    128-YEAR
2044    LEAP         LEAP
2048    LEAP         COMMON
2052    LEAP         LEAP
 ...
2096    LEAP         LEAP
2100    COMMON       LEAP
2104    LEAP         LEAP
 ...
2296    LEAP         LEAP
2300    COMMON       LEAP
2304    LEAP         COMMON
2308    LEAP         LEAP

```

How would this affect our day of the week algorithms?

**The challenge**

* Given a date from the year 2000 to the year 100000, find the day of the week under this new calendar.
* Any input and output format is allowed as long as you clearly specify which formats you are using.
* This is code golf so try to make your solutions as golfy as possible!

**Test cases**

```
"28 February 2048" -> "Friday"
"March 1, 2048"    -> "Sat"
(2100, 2, 29)      -> 0           # 0-indexed with Sunday as 0
"2100-02-29"       -> 7           # 1-indexed with Sunday as 7
"28 Feb. 2176"     -> "Wednesday"
"1-Mar-2176"       -> "Th"
"28/02/100000"     -> "F"         # DD/MM/YYYYYY
"Feb. 29, 100000"  -> 6           # 1-indexed with Sunday as 7
"03/01/100000"     -> 1          # MM/DD/YYYYYY and 1-indexed with Sunday as 1

```

Suggestions and feedback on the challenge are welcome. Good luck and good golfing!

# Answer
> 8 votes
# C (gcc), 60 bytes

```
f(m,d,y){y-=m<3;return(y+y/4-y/128+"-bed=pen+mad."[m]+d)%7;}

```

Try it online!

Simple modification of Sakamoto's method. Takes input as integer arguments in the order `month, day, year`, and outputs the number of the day (0-indexed on Sunday).

# Answer
> 6 votes
# Wolfram Language (Mathematica), ~~57~~ ~~55~~ 53 bytes

```
DayName@{m=#~Mod~128;6+Mod[(9#-m)/8-6Clip@m,28],##2}&

```

Try it online!

Takes three inputs: the year, the month, and the day, in that order. For example, if you save the above function as `fun`, then `fun[2048,2,28]` tells you the day of week of February 28, 2048.

## How it works

The formula `m=#~Mod~128;6+Mod[(9#-m)/8-6Clip@m,28]` converts the year into an equivalent year (a year with exactly the same days of week) between 6 AD and 33 AD. To do this, we subtract an offset and then take the year mod 28; but the offset changes every 128 years, and for years divisible by 128, we have to make a further adjustment because the equivalent year shouldn't be a leap year.

Anyway, once that's done, we look up the month and day in that equivalent year using the built-in `DayName`.

# Answer
> 3 votes
# JavaScript, ~~65~~ 59 bytes

```
(d,m,y)=>(y-=m<3,(+"0032503514624"[m]+y+(y>>2)-(y>>7)+d)%7)

```
~~```
(d,m,y)=>(y-=m<3,(+"0032503514624"[m]+~~y+~~(y/4)-~~(y/128)+d)%7)

```~~

Uses Sakamoto's method. Gives `0=Sunday, 1=Monday, 2=Tuesday...`

*-2 bytes thanks to Misha Lavrov<br>-4 bytes thanks to Arnauld*

# Answer
> 3 votes
# Python 2, 67 bytes

```
def f(m,d,y):y-=m<3;return(y+y/4-y/128+int("0032503514624"[m])+d)%7

```

Try it online!

`int("..."[m])` can be replaced by `ord("-bed=pen+mad."[m])`.

# Answer
> 2 votes
# Actually, 37 bytes

This is a port of notjagan's modification of Sakamoto's algorithm, but with a few stack-based tricks as described below. Input format is `day, year, month`. Output format is `0-indexed with Sunday as 0`. Golfing suggestions welcome! Try it online!

```
;"0032503514624"Ei)3>±+;¼L;¼¼½L±kΣ7@%

```

**Explanation**

```
                     Implicit input: day, year, month (month is at TOS)
;"0032503514624"Ei)  Get the month code, convert to float, rotate to bottom of the stack
3>±+                 If 3>month, add -1 to year
;¼L                  Push floor(year/4) to stack
;¼¼½L±               Push floor(year/4) and append -floor(year/128) to stack.
kΣ                   Wrap the stack (y/128, y/4, y, month_code, d) in a list and sum
7@%                  Get the sum modulo 7
                     Implicit return

```

# Answer
> 2 votes
# Jelly, ~~32~~ ~~31~~ ~~30~~ 28 bytes

Another port of notjagan's modification of Sakamoto's algorithm but with a base-250 number in place of `032503514624` (don't need the extra `0` because Jelly is 1-indexed). Input format is `month, year, day`. Output format is `0-based with Sunday as 0`. Golfing suggestion are very welcome as the way the links were tough to arrange and may still be golfable. Try it online!

**Edit:** -1 byte from using bit shift instead of integer division. -1 byte from rearranging the beginning and the input format. -2 bytes thanks to Erik the Outgolfer and caird coinheringaahing.

```
3>_@µæ»7,2I+µ“Ṿ⁵Ḥ9{’D³ị+⁵+%7

```

**Explanation**

```
         Three arguments: month, year, day
3>_@     Subtract (month<3) from year. Call it y.
µ        Start a new monadic chain.
æ»7,2    Bit shift y by both 7 and 2 (equivalent to integer division by 128 and by 4).
I+       y + y/4 - y/128
µ        Start a new monadic chain.
“Ṿ⁵Ḥ9{’  The number 732573514624 in base 250.
D        The list [7, 3, 2, 5, 7, 3, 5, 1, 4, 6, 2, 4].
³ị       Get the month code from the list (1-based indexing).
+⁵+      Add y, our month code, and day together.
%7       Modulus 7.

```

---
Tags: code-golf, date, algorithm
---


title: Őőőőőőő, are you there?

text:
# Question
Title: Őőőőőőő, are you there?
## Description

While support is getting better and better for people to write in various scripts around the world using unicode, and now you can even write in emojis as well, unfortunately most fonts<sup>\[citation needed\]</sup> are still missing Latin characters based on the double acute accent, which is required to write properly in Hungarian.

These characters are the following four:

* U+0150 LATIN CAPITAL LETTER O WITH DOUBLE ACUTE (Ő)
* U+0151 LATIN SMALL LETTER O WITH DOUBLE ACUTE (ő)
* U+0170 LATIN CAPITAL LETTER U WITH DOUBLE ACUTE (Ű)
* U+0171 LATIN SMALL LETTER U WITH DOUBLE ACUTE (ű)

## Task

Your task is to write a program / script / function, that given a font or a font's name gives out a truthy value in case the font contains **all** of the four glyphs described above, or a falsey value if at least one of them is missing from the font.

## Scoring

This is code-golf, so lowest byte-count wins

## Test cases

These fonts are from Google Fonts. Note that some fonts on Google Fonts (for example Lato) have an updated version on other sites which already contain the missing glyphs, if you have the updated ones then obviously your results might be different from the test cases below.

Truthy values:

```
Roboto
Open Sans
Lalezar
Source Sans Pro
Arial
Times New Roman
Cinzel

```

Falsey values:

```
Voltaire
Rosario
Heebo
Bitter
Arvo
Lato (see note above)
Molengo (contains ű and Ű, but not ő or Ő)
Sue Ellen Francisco (contains only the uppercase variants)
Germania One (contains only the lowercase variants)
Garamond (the one installed on OSX by Office for Mac)

```

## Notes

* It's up to you if your program requires a font's name as a parameter or the actual font (or the font's location on the system)
* If it's a font's name the program should check the system font registered at that name (for example if you specify `"Arial"` it should use the Arial font in your system's font registry)
* If it's a location the program should use that specific font, even if there is a system font registered with that same name (for example if you specify `"/home/user/Arial.ttf"` it should use that font even if there's an Arial registered in the system's store)
* Google Fonts above is just a convenient place you can download fonts for testing purposes, but your code doesn't need to use those fonts
* It is enough if your program works with only one specific font type, e.g. TTF, OTF, WOFF, SVG font, Type 1, Metafont, etc. However you should support a font format that has generic support for the four glyphs and for signalling missing glyphs mentioned above, e.g. you cannot chose a font format where the answer will always be falsey or truthy
* Some fonts might have the above glyphs incorrectly hardcoded to a fake value (e.g. the replacement box) instead of not specifying in the font file at all. Your code doesn't need to be able to differentiate between a fake glyph and a real glyph, but it's also acceptable if it does the check based on that.

Please specify in your answer how you have to pass in the font, and what kind of fonts it works with.

# Answer
> 12 votes
# Scala, 56 bytes

```
s=>new java.awt.Font(s,0,0).canDisplayUpTo("ŐőŰű")<0

```

`canDisplayUpTo` is a method of the Font object that returns the index of the first charater that cannot be displayed by the font. It return -1 if all characters can be displayed. javadoc

# Answer
> 9 votes
# Mathematica, ~~80~~ ~~72~~ 76 bytes

```
xFreeQ[f=Rasterize@Style[#,FontFamily->x]&;f/@("Ő""ő""Ű""ű"),f@"�"]

```

Takes the name of a font as a string. For each of the characters in question, generates an image of the character in the given font, and checks if they're all different from a similar image of the replacement character "�".

(The other weird character, , is `\[Function]`.)

In almost all cases, the following **67-byte** solution works instead:

```
xLength[Rasterize@Style[#,FontFamily->x]&/@("Ő""ő""Ű""ű")]>3

```

Here, we just check if all four images are different, which is valid under several assumptions about the fonts:

* If the font can actually represent these characters, the results are all different.
* If it fails to represent one of them, it fails on at least two (both the lowercase ones, or maybe "Ő" and "ő" but not "Ű" and "ű") replacing them both by the same "�"-looking character.

Unfortunately, the first assumption fails in very rare cases. For example, maybe the font doesn't distinguish between uppercase and lowercase characters. One example of this is a variant of EB Garamond, "EB Garamond 12 All SC". (On my laptop, there are 360 fonts installed, and this is the only one of them that the second solution fails on.)

Neither solution can be tried on Try It Online because the script version of Mathematica, unsurprisingly, has no support for different fonts. If you have Mathematica installed and want to try this, the system variable `$FontFamilies` lists the valid inputs (the fonts you have installed).

---

*-4 bytes thanks to Martin Ender*

# Answer
> 8 votes
# C# (Visual C# Compiler), ~~107~~ 100 + 23 bytes

*-7 bytes thanks to briantist, whose Powershell answer helped me realise I'm a dummy and can shave off some bytes.*

```
s=>"ŐőŰű".All(x=>new Windows.Media.GlyphTypeface(new Uri(s)).CharacterToGlyphMap.ContainsKey(x))

```

+23 bytes from

```
namespace System.Linq{}

```

It takes path to a font file (local or internet uri), and only supports OpenType fonts. Unfortunately doesn't work on TIO because it needs reference to PresentationCore.dll, but here's the full program code anyway: LINK

Explanation:
GlyphTypeface class loads font from provided uri, CharacterToGlyphMap loads all possible characters to a map, in which the characters are the keys. So we just take every tested character and check if the keys exist (which means the font supports them).

# Answer
> 5 votes
# PowerShell, 86 bytes

```
([Windows.Media.GlyphTypeface]::new("$args")|% C*p|? K* -in 336,337,368,369).Count-eq4

```

This is a shameless port of Grzegorz Puławski's Answer in PowerShell, using some golfing tricks.

I'm confident this could be golfed further but I have run out of time at the moment.

---
Tags: code-golf, unicode
---