答:
Lithp, 362 bytes

```<code>(
    (platform v1)
    (import "lists")
    (var FL (dict))
    (def fib #N::((if (< N 2) (1) ((+ (fibFL (- N 1)) (fibFL (- N 2)))))))
    (def fibFL #N::((if (dict-present FL N) ((dict-get FL N)) ((var I (fib N)) (set FL (dict-set FL N I)) (I)))))
    (def fib-orial #N::((prod (map (seq 1 N) (scope #I::((fib I)))))))
    (each (seq 2 15) (scope #N :: ((print (fib-orial N)))))
)
</code>```

As with the JavaScript answer, rounding errors occur at orial of 16. Therefore this program prints the orial of 2 to 15.

This one was tricky, because the run time was well over 10 seconds for even a small number.
I solved this by using a dictionary to store results of calls to fib. The result is that instead of 10 seconds and over 100,000 function calls, the code often runs in under 200ms and results in only ~6700 function calls.

Title: Fibonacci-orial

Body:
Definition

Fibonacci sequence F(n), on the positive integers, are defined as such:

```<code>1. F(1) = 1
2. F(2) = 1
3. F(n) = F(n-1) + F(n-2), where n is an integer and n > 2
</code>```

The Fibonacci-orial of a positive integer is the product of [F(1), F(2), ..., F(n)].

Task

Given positive integer n, find the Fibonacci-orial of n.

Specs

The fibonacci-orial of 100 must compute in under 5 seconds on a reasonable computer.

Testcases

```<code>n   Fibonacci-orial of n
1   1
2   1
3   2
4   6
5   30
6   240
7   3120
8   65520
9   2227680
10  122522400
11  10904493600
12  1570247078400
13  365867569267200
14  137932073613734400
15  84138564904377984000
16  83044763560621070208000
17  132622487406311849122176000
18  342696507457909818131702784000
19  1432814097681520949608649339904000
20  9692987370815489224102512784450560000
100 3371601853146468125386964065447576689828006172937411310662486977801540671138589868616500834190029067583665182291701553172011082574587431382310099030394306877775647395167143332483560925112960024644459715300507481235056111434293619038347456390454209587101225261757371666449068625033999573552165524529725467628060170886602001077137613803027158648329335507728698605769992818756765633305318529965186184043999696650407246193257877568825245646129366994079739720698147440310773871269639752334356493678913424390564535389212240038895626811627949132978086070255082668392290037141141291484839596694182152062726390364094447642643912371532491388089634845995941928089653751672688740718152064107169357399466473375804972260594768969952507346694189050233823596316467570584434128052398891223730335019092974935617029638919358286124350711360361279157416837428904150054292406756317837582840596331363581207781793070936765786629772999832857257349696094416616259974304208756997835360702840912518532683324936435856348020736000000000000000000000000
</code>```

References

Obligatory OEIS A003266

OEIS A000045 - Fibonacci sequence

Body:
Lithp, 362 bytes

(
    (platform v1)
    (import "lists")
    (var FL (dict))
    (def fib #N::((if (< N 2) (1) ((+ (fibFL (- N 1)) (fibFL (- N 2)))))))
    (def fibFL #N::((if (dict-present FL N) ((dict-get FL N)) ((var I (fib N)) (set FL (dict-set FL N I)) (I)))))
    (def fib-orial #N::((prod (map (seq 1 N) (scope #I::((fib I)))))))
    (each (seq 2 15) (scope #N :: ((print (fib-orial N)))))
)

As with the JavaScript answer, rounding errors occur at orial of 16. Therefore this program prints the orial of 2 to 15.

This one was tricky, because the run time was well over 10 seconds for even a small number.
I solved this by using a dictionary to store results of calls to fib. The result is that instead of 10 seconds and over 100,000 function calls, the code often runs in under 200ms and results in only ~6700 function calls.


问:
Do n and n^3 have the same set of digits?
Given a number n (0 <= n <= 2642245), check if n and n3 have the same set of digits, and output a truthy or falsey value accordingly.

For example, let's check the number 100.

1003 is 1000000.

The set of digits in 100 is {0, 1}.

The set of digits in 1000000 is {0, 1}.

Therefore, 100 should give a truthy value.

Test cases

```<code>0 -> True
1 -> True
10 -> True
107624 -> True
251894 -> True
251895 -> False
102343 -> False
</code>```

Remember, this is code-golf, so the code with the fewest bytes wins.

OEIS A029795

答:
Jelly, 8 bytes

```<code>,3*\D‘ṬE
</code>```

Try it online! or verify all test cases.

How it works

```<code>,3*\D‘ṬE  Main link. Argument: n

,3        Pair; yield [n, 3].
  *\      Cumulative reduce by exponentation. Yields [n, n³].
    D     Decimal; yield the digit arrays of n and n³.
     ‘    Increment, mapping 0 ... 9 to 1 ... 10.
      Ṭ   Untruth (vectorizes); map digit array [a, b, c, ...] to the smallest
          of zeroes with ones at indices a, b, c, ...
       E  Test the results for equality.
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Jelly, 8 bytes

,3*\D‘ṬE

Try it online! or verify all test cases.

How it works

,3*\D‘ṬE  Main link. Argument: n

,3        Pair; yield [n, 3].
  *\      Cumulative reduce by exponentation. Yields [n, n³].
    D     Decimal; yield the digit arrays of n and n³.
     ‘    Increment, mapping 0 ... 9 to 1 ... 10.
      Ṭ   Untruth (vectorizes); map digit array [a, b, c, ...] to the smallest
          of zeroes with ones at indices a, b, c, ...
       E  Test the results for equality.


问:
Draw diagonal lines of text
Given an input of a list of words, output the words with their letters arranged
diagonally:

```<code>p
 r
  o
p  g
 u  r
  z  a
a  z  m
 n  l  m
  d  e  i
c     s  n
 o        g
  d
g  e
 o
  l
   f
</code>```

(The above should be the output for the input programming puzzles and code golf.)

To be precise, each word starts on the first column and three rows below the
previous word, and each successive letter moves one column to the right and one
row down.

The input may be provided as either a single string of words, separated by
exactly one space, or a list/array of words. The words will only be composed of
lowercase letters, a-z, and will always be at least one character long.

The output may be a single string, an array of lines, or an array of arrays of
characters. Leading or trailing whitespace is not allowed, except for a single
trailing newline.

Further test cases:

a bcd efgh i j

```<code>a

b
 c
  d
e
 f
  g
i  h

j
</code>```

x

```<code>x
</code>```

verylongword short

```<code>v
 e
  r
s  y
 h  l
  o  o
   r  n
    t  g
        w
         o
          r
           d
</code>```

Since this is code-golf, the shortest code in bytes will win!

答:
Mathematica, 146 bytes

```<code>P=PadRight;T=Transpose;R=Riffle;Select[Rest@T@P@MapIndexed[""~Table~#2~Join~#1&,T@P@R[Characters/@#~R~{},{},3]]//.{0->"",{x__,""}->{x}},#!={""}&]&
</code>```

I'm disappointed by this bytecount, but oh well.

Defines an anonymous function that takes a list of words (e.g. {"this","that","these"}) and returns a two-dimensional array of characters. To view in grid form, add a //Grid at the end.

Converts the strings to an array, adds extra lines, transposes the array, prepends the necessary shifts, then transposes again.

Example result (formatted as grid):

Title: Draw diagonal lines of text

Body:
Mathematica, 146 bytes

P=PadRight;T=Transpose;R=Riffle;Select[Rest@T@P@MapIndexed[""~Table~#2~Join~#1&,T@P@R[Characters/@#~R~{},{},3]]//.{0->"",{x__,""}->{x}},#!={""}&]&

I'm disappointed by this bytecount, but oh well.

Defines an anonymous function that takes a list of words (e.g. {"this","that","these"}) and returns a two-dimensional array of characters. To view in grid form, add a //Grid at the end.

Converts the strings to an array, adds extra lines, transposes the array, prepends the necessary shifts, then transposes again.

Example result (formatted as grid):


答:
C++14, 93 bytes

int b(auto i){int k=0;while(i)k|=1<<i%10,i/=10;return k;}int f(auto n){return b(n)-b(n*n*n);}
```

Port of my C answer, works for big numbers (call with L suffix).

Title: Do n and n^3 have the same set of digits?

Body:
Given a number n (0 <= n <= 2642245), check if n and n3 have the same set of digits, and output a truthy or falsey value accordingly.

For example, let's check the number 100.

1003 is 1000000.

The set of digits in 100 is {0, 1}.

The set of digits in 1000000 is {0, 1}.

Therefore, 100 should give a truthy value.

Test cases

```<code>0 -> True
1 -> True
10 -> True
107624 -> True
251894 -> True
251895 -> False
102343 -> False
</code>```

Remember, this is code-golf, so the code with the fewest bytes wins.

OEIS A029795

Body:
C++14, 93 bytes

int b(auto i){int k=0;while(i)k|=1<<i%10,i/=10;return k;}int f(auto n){return b(n)-b(n*n*n);}

Port of my C answer, works for big numbers (call with L suffix).


问:
Print numbers from 1 to 10
This might be a very simple challenge, but I am surprised it hasn't been done on code-golf yet:

Print all Integers from 1 to 10 inclusive in ascending order to standard output.

Your output format can be whatever your language supports. This includes arbitrary separators (commas, semicolons, newlines, combinations of those, etc., but no digits), and prefixes and postfixes (like [...]). However, you may not output any other numbers than 1 through 10. Your program may not take any input. Standard loopholes are disallowed.

This is code-golf, so shortest answer in bytes wins!

Leaderboard

var QUESTION_ID=86075,OVERRIDE_USER=42570;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

答:
DARTMOUTH BASIC,42 BYTES

EH, WHY NOT?

```<code>1 FOR I=1 TO 10
2 PRINT I
3 NEXT I
4 END
</code>```

Title: Print numbers from 1 to 10

Body:
DARTMOUTH BASIC,42 BYTES

EH, WHY NOT?

1 FOR I=1 TO 10
2 PRINT I
3 NEXT I
4 END


答:
C#6, <s>117</s> <s>118</s> 115 bytes

```<code>using System.Linq;bool A(ulong n){string s=n+"",t=n*n*n+"";return s.All(x=>t.Contains(x))&t.All(x=>s.Contains(x));}
</code>```

Praise System.Linq.Enumerable

+1 byte due to long range problem

-3 bytes by storing strings to variable

Ungolfed + explanations

```<code>bool A(ulong n)
{
    // Convert n and n^3 to strings
    string s=n+"",t=n*n*n+"";
    // Two sets are equal iff:
    // Foreach element in one set, it is also present in another set
    return s.All(x=>t.Contains(x))&t.All(x=>s.Contains(x));
}
</code>```

Body:
C#6, <s>117</s> <s>118</s> 115 bytes

using System.Linq;bool A(ulong n){string s=n+"",t=n*n*n+"";return s.All(x=>t.Contains(x))&t.All(x=>s.Contains(x));}

Praise System.Linq.Enumerable

+1 byte due to long range problem

-3 bytes by storing strings to variable

Ungolfed + explanations

bool A(ulong n)
{
    // Convert n and n^3 to strings
    string s=n+"",t=n*n*n+"";
    // Two sets are equal iff:
    // Foreach element in one set, it is also present in another set
    return s.All(x=>t.Contains(x))&t.All(x=>s.Contains(x));
}


答:
Batch, 202

```<code>@set/an=%1,c=n*n*n,e=1
@for /l %%a in (0,1,9)do @call:l %%a
@exit/b%e%
:l
@set f=1
@call set s=%%n:%1=%%
@if "%s%"=="%n%" set/af=1-f
@call set s=%%c:%1=%%
@if "%s%"=="%c%" set/af=1-f
@set/ae*=f
</code>```

Note: Only works up to 1290 due to the limited range of Batch's data type. Takes input on the command line and returns an error level of 1 if the cube uses the same set of digits, 0 otherwise. Works by looping through each digit, checking to see whether an even number of the two strings contains the digit.

Body:
Batch, 202

@set/an=%1,c=n*n*n,e=1
@for /l %%a in (0,1,9)do @call:l %%a
@exit/b%e%
:l
@set f=1
@call set s=%%n:%1=%%
@if "%s%"=="%n%" set/af=1-f
@call set s=%%c:%1=%%
@if "%s%"=="%c%" set/af=1-f
@set/ae*=f

Note: Only works up to 1290 due to the limited range of Batch's data type. Takes input on the command line and returns an error level of 1 if the cube uses the same set of digits, 0 otherwise. Works by looping through each digit, checking to see whether an even number of the two strings contains the digit.


答:
Pyth, 10 bytes

Because we don't have enough variety with Pyth answers, let's add not one, but two more!  Both are 10 bytes, and have been tested with 106239 as a sample input (which some other answers failed).

```<code>!s.++Q,`**
</code>```

Explanation:

```<code>!s.++Q,`**QQQQ   Implicit input filling
        **QQQ    Q ^ 3
       `         repr(Q^3)
      ,      Q   [repr(Q^3),Q]
    +Q           [Q,repr(Q^3),Q]
  .+             Deltas ([Digits in Q but not in Q^3, digits in Q^3 but not in Q])
!s               Are both empty?
</code>```

Try the first answer using an online test suite.

Second answer:

```<code>qFmS{`d,**
</code>```

Explanation:

```<code>qFmS{`d,**QQQQ   Implicit input filling
        **QQQ    Q ^ 3
       ,     Q   [Q^3, Q]
  m              map over each element d of [Q^3, Q]:
     `d           the element's string representation
    {             with duplicates removed
   S              and sorted
qF               Fold over equality (are the two the same?)
</code>```

Try the second answer using an online test suite.

Body:
Pyth, 10 bytes

Because we don't have enough variety with Pyth answers, let's add not one, but two more!  Both are 10 bytes, and have been tested with 106239 as a sample input (which some other answers failed).

!s.++Q,`**

Explanation:

!s.++Q,`**QQQQ   Implicit input filling
        **QQQ    Q ^ 3
       `         repr(Q^3)
      ,      Q   [repr(Q^3),Q]
    +Q           [Q,repr(Q^3),Q]
  .+             Deltas ([Digits in Q but not in Q^3, digits in Q^3 but not in Q])
!s               Are both empty?

Try the first answer using an online test suite.

Second answer:

qFmS{`d,**

Explanation:

qFmS{`d,**QQQQ   Implicit input filling
        **QQQ    Q ^ 3
       ,     Q   [Q^3, Q]
  m              map over each element d of [Q^3, Q]:
     `d           the element's string representation
    {             with duplicates removed
   S              and sorted
qF               Fold over equality (are the two the same?)

Try the second answer using an online test suite.


问:
The shortest code to invert bit-wise a binary string
Me thinks there aren't enough easy questions on here that beginners can attempt!

The challenge: Given a random input string of 1's and 0's such as:

```<code>10101110101010010100010001010110101001010
</code>```

Write the shortest code that outputs the bit-wise inverse like so:

```<code>01010001010101101011101110101001010110101
</code>```

答:
Python 3, 39 bytes

Taking input from stdin and printing to stdout:

for c in input():print(1-int(c),end="")
```

ContentLicense: CC BY-SA 4.0


Body:
Clojure, 35 bytes

#(=(set(str %))(set(str(* % % %))))


问:
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: _.

```<code>abc____i
</code>```

Leaderboard

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

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/Sites/codegolf/all.css?v=7509797c03ea">

Uncracked submissions

 Language	 Score	 User

Sort by: score creation

Safe submissions

 Language	 Score	 User

```

答:
JavaScript (ES6), 63 bytes, 10 numbers, cracked

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

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

? is a hidden character.

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

Title: Code ladder, Cops

Body:
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.


答:
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.

```<code>#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;
}
</code>```

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.

Title: Code ladder, Cops

Body:
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: _.

```<code>abc____i
</code>```

Leaderboard

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

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/Sites/codegolf/all.css?v=7509797c03ea">

Uncracked submissions

 Language	 Score	 User

Sort by: score creation

Safe submissions

 Language	 Score	 User

```

Body:
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.


问:
Smallest number of contiguous monotonic subsequences
A monotonic subsequence is a sequence of numbers \$a_1, a_2, ..., a_n\$ such that

$$a_1 \le a_2 \le ... \le a_n \\
\text{or} \\
a_1 \ge a_2 \ge ... \ge a_n$$

[1, 3, 3, 7, 9, 13, 13, 100] is a monotonic (non-decreasing) subsequence, as well as [9, 4, 4, 3, 0, -10, -12] (this one is non-increasing), but [1, 3, 6, 9, 8] is not. Given a list of integers (in any reasonable format), output the smallest number N such that the sequence of these integers can be split into N monotonic sequences.

Examples

```<code>[1, 3, 7, 5, 4, 2] -> [[1, 3, 7], [5, 4, 2]] -> 2
[1, 2, 3, 4, 5, 6] -> [1, 2, 3, 4, 5, 6]     -> 1
[3, 1, 5, 5, 6]    -> [[3, 1], [5, 5, 6]]    -> 2
[4, 6, 8, 9, 1, 6] -> [[4, 6, 8, 9], [1, 6]] -> 2
[3, 3, 3, 3]       -> [[3, 3, 3, 3]]         -> 1
[7]                -> [[7]]                  -> 1
[]                 -> []                     -> anything (you don't actually have to handle an empty list case)
[1, 3, 2, -1, 6, 9, 10, 2, 1, -12] -> [[1, 3], [2, -1], [6, 9, 10], [2, 1, -12]] -> 4
</code>```

答:
C#6, <s>297</s> 209 bytes

```<code>using System.Linq;int G(int[] a)=>a.Any()?a.SkipWhile((x,i)=>i<1||x>=a[i-1]).Count()<a.SkipWhile((x,i)=>i<1||x<=a[i-1]).Count()?G(a.Select(x=>-x).ToArray()):G(a.SkipWhile((x,i)=>i<1||x<=a[i-1]).ToArray())+1:0;
</code>```

Ungolfed with explanations

```<code>int G(int[] a)=>
    a.Any()
        ?a.SkipWhile((x,i)=>i<1||x>=a[i-1]).Count()<a.SkipWhile((x,i)=>i<1||x<=a[i-1]).Count()   // If a begins by decreasing (including whole a decreasing)...
            ?G(a.Select(x=>-x).ToArray())   // ... Then flip sign to make a begins by increasing
            :G(a.SkipWhile((x,i)=>i<1||x<=a[i-1]).ToArray())+1   // ... Else skip the increasing part, recursively find the remaining part number, then add 1
        :0;   // Return 0 if a is empty
</code>```

Body:
C#6, <s>297</s> 209 bytes

using System.Linq;int G(int[] a)=>a.Any()?a.SkipWhile((x,i)=>i<1||x>=a[i-1]).Count()<a.SkipWhile((x,i)=>i<1||x<=a[i-1]).Count()?G(a.Select(x=>-x).ToArray()):G(a.SkipWhile((x,i)=>i<1||x<=a[i-1]).ToArray())+1:0;

Ungolfed with explanations

int G(int[] a)=>
    a.Any()
        ?a.SkipWhile((x,i)=>i<1||x>=a[i-1]).Count()<a.SkipWhile((x,i)=>i<1||x<=a[i-1]).Count()   // If a begins by decreasing (including whole a decreasing)...
            ?G(a.Select(x=>-x).ToArray())   // ... Then flip sign to make a begins by increasing
            :G(a.SkipWhile((x,i)=>i<1||x<=a[i-1]).ToArray())+1   // ... Else skip the increasing part, recursively find the remaining part number, then add 1
        :0;   // Return 0 if a is empty


问:
Code ladder, Robbers
This is the robbers' thread. The cops' thread goes here.

Write a code that has the same number of bytes as the cop post and where the revealed characters are identical. The code must produce 1 in its initial state, and produce the numbers 2, 3 .. when single alterations are made.

The winner will be the robber that cracked the most posts.

Example post:

MyLang, 9 bytes, 8 numbers (including link to answer), Cop's username.

Original code:

```<code>abc1efghi
</code>```

Code that produces 1 - 8:

```<code>1: abc1efghi
2: abc2efghi
3: abc2efghij
4: kbc2efghij
5: kbc23fghij
6: kbc23fghi
7: kbc63fghi
8: kbc63fhi
</code>```

Explanations are encouraged. The exact format of the robber post is optional.

答:
QBasic, 13 bytes by DLosc

```<code>?+INT(LOG(3))  'Fixed thanks to feersome
?1+INT(LOG(3))
?2+INT(LOG(3))
?3+INT(LOG(3))
?4+INT(LOG(3))
?5+INT(LOG(3))
?6+INT(LOG(3))
?7+INT(LOG(3))
?8+INT(LOG(3))
?9+INT(LOG(3))
</code>```

Try QBasic at archive.org.

Seems like the intended solution is:

```<code>? INT(LOG(3))    '1
? INT(LOG(13))   '2
? CINT(LOG(13))   '3
</code>```

but that can't possibly work because the natural log function grows too quickly. There are no sequences of this form that get past 4.

Title: Code ladder, Robbers

Body:
QBasic, 13 bytes by DLosc

?+INT(LOG(3))  'Fixed thanks to feersome
?1+INT(LOG(3))
?2+INT(LOG(3))
?3+INT(LOG(3))
?4+INT(LOG(3))
?5+INT(LOG(3))
?6+INT(LOG(3))
?7+INT(LOG(3))
?8+INT(LOG(3))
?9+INT(LOG(3))

Try QBasic at archive.org.

Seems like the intended solution is:

? INT(LOG(3))    '1
? INT(LOG(13))   '2
? CINT(LOG(13))   '3

but that can't possibly work because the natural log function grows too quickly. There are no sequences of this form that get past 4.


答:
Haskell, 47 bytes

```<code>import Data.Set
s=fromList.show
f n=s n==s(n^3)
</code>```

Usage example: f 102343 -> False.

Uses sets from the Data.Set module. The helper function s turns a number into its string representation and than makes a set out of the characters.

Body:
Haskell, 47 bytes

import Data.Set
s=fromList.show
f n=s n==s(n^3)

Usage example: f 102343 -> False.

Uses sets from the Data.Set module. The helper function s turns a number into its string representation and than makes a set out of the characters.


答:
DASH, 33 bytes

```<code>@=(f\ss[sort I;unq;str])#0f ^#0 3
</code>```

Usage:

```<code>(@=(f\ss[sort I;unq;str])#0f ^#0 3)500
</code>```

Explanation

```<code>@
  =                       #. check if the following are equal
    (f\                   #. store the following to f:
      ss[sort I;unq;str]  #. composition of to string, unique, sort
    )
      #0                  #. apply f to the arg
    f ^ #0 3              #. apply f to arg cubed
</code>```

Body:
DASH, 33 bytes

@=(f\ss[sort I;unq;str])#0f ^#0 3

Usage:

(@=(f\ss[sort I;unq;str])#0f ^#0 3)500

Explanation

@
  =                       #. check if the following are equal
    (f\                   #. store the following to f:
      ss[sort I;unq;str]  #. composition of to string, unique, sort
    )
      #0                  #. apply f to the arg
    f ^ #0 3              #. apply f to arg cubed


答:
Python 2, 26 bytes, 10 numbers, cracked

```<code>print r___e(_______+_[___]
</code>```

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

Title: Code ladder, Cops

Body:
Python 2, 26 bytes, 10 numbers, cracked

print r___e(_______+_[___]

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


答:
Kotlin: 46/88/96 bytes

The question doesn't specify from where the input comes from, so here's the usual 3 input sources.

Function: 46 bytes

```<code>fun f(i:Long)="$i".toSet()=="${i*i*i}".toSet()
</code>```

main() using first program argument: 88 bytes

fun main(a:Array<String>){val i=a[0].toLong();println("$i".toSet()=="${i*i*i}".toSet())}

main() using standard input: 96 bytes

fun main(a:Array<String>){val i=readLine()!!.toLong();println("$i".toSet()=="${i*i*i}".toSet())}

Body:
Kotlin: 46/88/96 bytes

The question doesn't specify from where the input comes from, so here's the usual 3 input sources.

Function: 46 bytes

fun f(i:Long)="$i".toSet()=="${i*i*i}".toSet()

main() using first program argument: 88 bytes

fun main(a:Array<String>){val i=a[0].toLong();println("$i".toSet()=="${i*i*i}".toSet())}

main() using standard input: 96 bytes

fun main(a:Array<String>){val i=readLine()!!.toLong();println("$i".toSet()=="${i*i*i}".toSet())}


答:
Turtlèd, <s>28</s> 26 bytes

Oh my, I appear to be beating a language specifically designed for golfing. this is a great day.

```<code>!_4[*.[ rd+.]ul[ ul]r;_+]_
</code>```

Try it online!

Explanation

(write means writing to the cell on the grid, pointed char means char in input the string pointer points to)

```<code>!                         Take string input into variable
 _                        Normally conditional, with >1 input (there will be), write ' '
  4                       set register to 4
   [*                   ] until the current cell is *
     .                    Write pointed char, initially first char
      [     ]             Until space is written on cell
        rd+.              move right, down, string pointer++, write pointed char
             ul[ ul]      Move back up to the top of the word
                    r;    Move right, down 4 (because this is register value)
                      _+  write * if end of input, else ' ', increment string pointer
                        _ will always write ' ', since it will always point at start char
</code>```

note trailing space.

Input also needs trailing space. seeing as python can take a list, this is a lot like taking a list in Turtlèd

Title: Draw diagonal lines of text

Body:
Given an input of a list of words, output the words with their letters arranged
diagonally:

```<code>p
 r
  o
p  g
 u  r
  z  a
a  z  m
 n  l  m
  d  e  i
c     s  n
 o        g
  d
g  e
 o
  l
   f
</code>```

(The above should be the output for the input programming puzzles and code golf.)

To be precise, each word starts on the first column and three rows below the
previous word, and each successive letter moves one column to the right and one
row down.

The input may be provided as either a single string of words, separated by
exactly one space, or a list/array of words. The words will only be composed of
lowercase letters, a-z, and will always be at least one character long.

The output may be a single string, an array of lines, or an array of arrays of
characters. Leading or trailing whitespace is not allowed, except for a single
trailing newline.

Further test cases:

a bcd efgh i j

```<code>a

b
 c
  d
e
 f
  g
i  h

j
</code>```

x

```<code>x
</code>```

verylongword short

```<code>v
 e
  r
s  y
 h  l
  o  o
   r  n
    t  g
        w
         o
          r
           d
</code>```

Since this is code-golf, the shortest code in bytes will win!

Body:
Turtlèd, <s>28</s> 26 bytes

Oh my, I appear to be beating a language specifically designed for golfing. this is a great day.

!_4[*.[ rd+.]ul[ ul]r;_+]_

Try it online!

Explanation

(write means writing to the cell on the grid, pointed char means char in input the string pointer points to)

!                         Take string input into variable
 _                        Normally conditional, with >1 input (there will be), write ' '
  4                       set register to 4
   [*                   ] until the current cell is *
     .                    Write pointed char, initially first char
      [     ]             Until space is written on cell
        rd+.              move right, down, string pointer++, write pointed char
             ul[ ul]      Move back up to the top of the word
                    r;    Move right, down 4 (because this is register value)
                      _+  write * if end of input, else ' ', increment string pointer
                        _ will always write ' ', since it will always point at start char

note trailing space.

Input also needs trailing space. seeing as python can take a list, this is a lot like taking a list in Turtlèd


答:
Python 2, 26 bytes, 10 numbers, DLosc

print range(11)[1or+ [  ]]
print range(11)[2or+ [  ]]
print range(11)[3or+ [  ]]
print range(11)[4or+ [  ]]
print range(11)[5or+ [  ]]
print range(11)[-5or+ [  ]]
print range(11)[-4or+ [  ]]
print range(11)[-3or+ [  ]]
print range(11)[-2or+ [  ]]
print range(11)[-1or+ [  ]]
```

I thought I'd try this with comments or newlines or anything. Definitely not the intended solution...

Title: Code ladder, Robbers

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

Write a code that has the same number of bytes as the cop post and where the revealed characters are identical. The code must produce 1 in its initial state, and produce the numbers 2, 3 .. when single alterations are made.

The winner will be the robber that cracked the most posts.

Example post:

MyLang, 9 bytes, 8 numbers (including link to answer), Cop's username.

Original code:

```<code>abc1efghi
</code>```

Code that produces 1 - 8:

```<code>1: abc1efghi
2: abc2efghi
3: abc2efghij
4: kbc2efghij
5: kbc23fghij
6: kbc23fghi
7: kbc63fghi
8: kbc63fhi
</code>```

Explanations are encouraged. The exact format of the robber post is optional.

Body:
Python 2, 26 bytes, 10 numbers, DLosc

print range(11)[1or+ [  ]]
print range(11)[2or+ [  ]]
print range(11)[3or+ [  ]]
print range(11)[4or+ [  ]]
print range(11)[5or+ [  ]]
print range(11)[-5or+ [  ]]
print range(11)[-4or+ [  ]]
print range(11)[-3or+ [  ]]
print range(11)[-2or+ [  ]]
print range(11)[-1or+ [  ]]

I thought I'd try this with comments or newlines or anything. Definitely not the intended solution...


Title: Code ladder, Robbers

Body:
Python 2, 26 bytes, 10 numbers by DLosc, non-competing

Non-competing because Sp3000 beat me to it.

print r___e(_______+_[___]

print range(19)[1]#+_[___]
print range(19)[2]#+_[___]
print range(19)[3]#+_[___]
print range(19)[4]#+_[___]
print range(19)[5]#+_[___]
print range(19)[6]#+_[___]
print range(19)[7]#+_[___]
print range(19)[8]#+_[___]
print range(19)[9]#+_[___]
print range(19)[-9]#+_[___]


答:
Python 2, 26 bytes, 10 numbers, cracked

Let's try this again.

```<code>print r___e(3______+_[___]
</code>```

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

Title: Code ladder, Cops

Body:
Python 2, 26 bytes, 10 numbers, cracked

Let's try this again.

print r___e(3______+_[___]

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


答:
Mathematica, 111 bytes

```<code>d=#[[2]]-#[[1]]&;r=Rest;f@{n_}:=1;f@k__:=If[d@k==0,f@r@k,g[k Sign@d@k]];g@{n_}:=1;g@k__:=If[d@k>0,g@r@k,1+f@r@k]
</code>```

Named function f taking a nonempty list of numbers (integers or even reals). Works from front to back, discarding the first element repeatedly and keeping track of how many subsequences are needed. More verbose:

```<code>d = #[[2]] - #[[1]] &;         function: difference of the first two elements
r = Rest;                      function: a list with its first element dropped
f@{n_} := 1;                   f of a length-1 list equals 1
f@k__ := If[d@k == 0, f@r@k,   if the first two elements are equal, drop one
                                 element and call f again ...
            g[k Sign@d@k]];  ... otherwise call the helper function g on the
                                 list, multiplying by -1 if necessary to ensure
                                 that the list starts with an increase
g@{n_} := 1;                   g of a length-1 list equals 1
g@k__ := If[d@k > 0, g@r@k,    if the list starts with an increase, drop one
                                 element and call g again ...
            1 + f@r@k];        ... otherwise drop one element, call f on the
                                 resulting list, and add 1
</code>```

Title: Smallest number of contiguous monotonic subsequences

Body:
A monotonic subsequence is a sequence of numbers \$a_1, a_2, ..., a_n\$ such that

$$a_1 \le a_2 \le ... \le a_n \\
\text{or} \\
a_1 \ge a_2 \ge ... \ge a_n$$

[1, 3, 3, 7, 9, 13, 13, 100] is a monotonic (non-decreasing) subsequence, as well as [9, 4, 4, 3, 0, -10, -12] (this one is non-increasing), but [1, 3, 6, 9, 8] is not. Given a list of integers (in any reasonable format), output the smallest number N such that the sequence of these integers can be split into N monotonic sequences.

Examples

```<code>[1, 3, 7, 5, 4, 2] -> [[1, 3, 7], [5, 4, 2]] -> 2
[1, 2, 3, 4, 5, 6] -> [1, 2, 3, 4, 5, 6]     -> 1
[3, 1, 5, 5, 6]    -> [[3, 1], [5, 5, 6]]    -> 2
[4, 6, 8, 9, 1, 6] -> [[4, 6, 8, 9], [1, 6]] -> 2
[3, 3, 3, 3]       -> [[3, 3, 3, 3]]         -> 1
[7]                -> [[7]]                  -> 1
[]                 -> []                     -> anything (you don't actually have to handle an empty list case)
[1, 3, 2, -1, 6, 9, 10, 2, 1, -12] -> [[1, 3], [2, -1], [6, 9, 10], [2, 1, -12]] -> 4
</code>```

Body:
Mathematica, 111 bytes

d=#[[2]]-#[[1]]&;r=Rest;f@{n_}:=1;f@k__:=If[d@k==0,f@r@k,g[k Sign@d@k]];g@{n_}:=1;g@k__:=If[d@k>0,g@r@k,1+f@r@k]

Named function f taking a nonempty list of numbers (integers or even reals). Works from front to back, discarding the first element repeatedly and keeping track of how many subsequences are needed. More verbose:

d = #[[2]] - #[[1]] &;         function: difference of the first two elements
r = Rest;                      function: a list with its first element dropped
f@{n_} := 1;                   f of a length-1 list equals 1
f@k__ := If[d@k == 0, f@r@k,   if the first two elements are equal, drop one
                                 element and call f again ...
            g[k Sign@d@k]];  ... otherwise call the helper function g on the
                                 list, multiplying by -1 if necessary to ensure
                                 that the list starts with an increase
g@{n_} := 1;                   g of a length-1 list equals 1
g@k__ := If[d@k > 0, g@r@k,    if the list starts with an increase, drop one
                                 element and call g again ...
            1 + f@r@k];        ... otherwise drop one element, call f on the
                                 resulting list, and add 1


答:
Jelly, 19 bytes

```<code>IṠḟ0E
ŒṖÇ€€0e$Ðḟḅ1Ṃ
</code>```

TryItOnline! or run all tests (empty list results in 1)

How?

```<code>IṠḟ0E - Link 1, test for monotonicity: a sublist
I     - incremental differences
 Ṡ    - sign {fall:-1; same:0; rise:1}
  ḟ0  - filter out the zeros
    E - all equal?

ŒṖÇ€€0e$Ðḟḅ1Ṃ - Main link
ŒṖ            - all partitions of the input list
  Ç€€         - call last link (1) as a monad for €ach for €ach
        Ðḟ    - filter out results:
       $      -    last two links as a monad
     0e       -        contains zero?
          ḅ1  - convert from unary (vectorises)
            Ṃ - minimum
</code>```

(I'm not convinced that this is the most suitable method to minimise byte count though)

Body:
Jelly, 19 bytes

IṠḟ0E
ŒṖÇ€€0e$Ðḟḅ1Ṃ

TryItOnline! or run all tests (empty list results in 1)

How?

IṠḟ0E - Link 1, test for monotonicity: a sublist
I     - incremental differences
 Ṡ    - sign {fall:-1; same:0; rise:1}
  ḟ0  - filter out the zeros
    E - all equal?

ŒṖÇ€€0e$Ðḟḅ1Ṃ - Main link
ŒṖ            - all partitions of the input list
  Ç€€         - call last link (1) as a monad for €ach for €ach
        Ðḟ    - filter out results:
       $      -    last two links as a monad
     0e       -        contains zero?
          ḅ1  - convert from unary (vectorises)
            Ṃ - minimum

(I'm not convinced that this is the most suitable method to minimise byte count though)


答:
ASMD, 5 bytes

```<code>T(i{p
</code>```

Body must be at least 30 characters; you entered 20.

Title: Print numbers from 1 to 10

Body:
This might be a very simple challenge, but I am surprised it hasn't been done on code-golf yet:

Print all Integers from 1 to 10 inclusive in ascending order to standard output.

Your output format can be whatever your language supports. This includes arbitrary separators (commas, semicolons, newlines, combinations of those, etc., but no digits), and prefixes and postfixes (like [...]). However, you may not output any other numbers than 1 through 10. Your program may not take any input. Standard loopholes are disallowed.

This is code-golf, so shortest answer in bytes wins!

Leaderboard

var QUESTION_ID=86075,OVERRIDE_USER=42570;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

Body:
ASMD, 5 bytes

T(i{p

Body must be at least 30 characters; you entered 20.


问:
The Art of Word Shaping

The Art of Word Shaping

Given a binary matrix and a string of letters, replace all 1's in the matrix, moving from top to bottom and from left to right within each row, with the letters of the string. Once the letters have been formed into the shape of the matrix, print the matrix, replacing 0's with spaces. It's probably easier to just give an example or two.

Case: Base case...

Input One:

```<code>[0,0,1,0,0]
[0,1,0,1,0]
[1,0,0,0,1]
[0,1,0,1,0]
[0,0,1,0,0]

"PPCGPPCG"
</code>```

Output One:

```<code>  P
 P C
G   P
 P C
  G
</code>```

Case: If the input string is longer than the number of ones...

Input Two:

```<code>[1,0,0]
[0,1,0]
[1,0,1]

lambda
</code>```

Output Two:

```<code>l
 a
m b
</code>```

Case: If the input string is shorter than the number of ones...

Input Three:

```<code>[1,1,1]
[1,0,1]
[1,1,1]

PPCG
</code>```

Output Three:

```<code>PPC
G P
PCG
</code>```

Available Assumptions

You may assume the input string is never empty.

You may assume the matrix will never be empty.

You may not assume that the binary matrix will never be all zeros.

Rules

If the string is shorter than the number of ones, repeat the string; all ones must be replaced.

If the string is longer than the number of ones, only use what is needed.

You may use True/False in place of integers/bits for the input.

Trailing spaces ARE REQUIRED, all zeros must be replaced with spaces.

A single trailing newline is acceptable.

This is code-golf, lowest byte count wins.

答:
Pip, 18 bytes

17 bytes of code, +1 for -l flag.

```<code>Yb{a?y@++vs}MMa^s
</code>```

Takes the array as the first command-line argument like this: 100 010 101 (needs to be quoted in shells) and the string as the second command-line argument. Try it online!

Explanation

```<code>                   a and b are cmdline args, s is space, v is -1
Yb                 Yank b into global variable y
              a^s  Split a on space into list of rows
  {        }MM     Map this function to the items of the items of a (i.e. each character):
   a               Function argument
    ?              Ternary operator (truthy if 1, falsey if 0)
       ++v         If truthy, increment v...
     y@            ... and use it to index into y (cyclically)
                   I.e.: each time we hit a 1, replace it with the next character of y
          s        If falsey, space
                   The result is a list of lists of characters; -l concats sublists and
                   newline-separates the main list
</code>```

Title: The Art of Word Shaping

Body:
Pip, 18 bytes

17 bytes of code, +1 for -l flag.

Yb{a?y@++vs}MMa^s

Takes the array as the first command-line argument like this: 100 010 101 (needs to be quoted in shells) and the string as the second command-line argument. Try it online!

Explanation

                   a and b are cmdline args, s is space, v is -1
Yb                 Yank b into global variable y
              a^s  Split a on space into list of rows
  {        }MM     Map this function to the items of the items of a (i.e. each character):
   a               Function argument
    ?              Ternary operator (truthy if 1, falsey if 0)
       ++v         If truthy, increment v...
     y@            ... and use it to index into y (cyclically)
                   I.e.: each time we hit a 1, replace it with the next character of y
          s        If falsey, space
                   The result is a list of lists of characters; -l concats sublists and
                   newline-separates the main list


答:
Kotlin: 30?/31/49 bytes

Variable of function type: 30 bytes

```<code>val a={(1..10).map(::println)}
</code>```

This might be considered cheating.

Invokable via a() like the later function. Functions are first-class citizens in Kotlin, so they can be assigned to variables aswell. The type of ´val a´ is technically () -> List<Unit>, a function that takes nothing and returns a "list of nothing", but we wouldn't be on code golf using a language that doesn't have implicit types, would we?

Function: 31 bytes

fun a(){(1..10).map(::println)}

Executable: 49 bytes

```<code>fun main(a:Array<String>){(1..10).map(::println)}
</code>```

Title: Print numbers from 1 to 10

Body:
Kotlin: 30?/31/49 bytes

Variable of function type: 30 bytes

val a={(1..10).map(::println)}

This might be considered cheating.

Invokable via a() like the later function. Functions are first-class citizens in Kotlin, so they can be assigned to variables aswell. The type of ´val a´ is technically () -> List<Unit>, a function that takes nothing and returns a "list of nothing", but we wouldn't be on code golf using a language that doesn't have implicit types, would we?

Function: 31 bytes

fun a(){(1..10).map(::println)}

Executable: 49 bytes

fun main(a:Array<String>){(1..10).map(::println)}


答:
Dip, 2 bytes

```<code>Tl
</code>```

Body must be at least 30 characters; you entered 16.

Title: Print numbers from 1 to 10

Body:
Dip, 2 bytes

Tl

Body must be at least 30 characters; you entered 16.


答:
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.

Title: Code ladder, Cops

Body:
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: _.

```<code>abc____i
</code>```

Leaderboard

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

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/Sites/codegolf/all.css?v=7509797c03ea">

Uncracked submissions

 Language	 Score	 User

Sort by: score creation

Safe submissions

 Language	 Score	 User

```

Body:
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.


答:
ASMD, 8 bytes, Cracked!

```<code>____+++C
</code>```

Works from 1-10.

Title: Code ladder, Cops

Body:
ASMD, 8 bytes, Cracked!

____+++C

Works from 1-10.


答:
Python 2, 26 bytes, 10 numbers, DLosc

Original:

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

<p>Solve:</p>

<pre class="lang-py prettyprint-override"><code>print range(3,)[1]#+_[___]
print range(3,)[-1]#+_[___]
print range(3,4)[-1]#+_[___]
print range(3,5)[-1]#+_[___]
print range(3,6)[-1]#+_[___]
print range(3,7)[-1]#+_[___]
print range(3,8)[-1]#+_[___]
print range(3,9)[-1]#+_[___]
print range(3^9)[-1]#+_[___]
print range(2^9)[-1]#+_[___]
</code>```

Yeah, I'm fairly sure this still isn't the intended solve.

Title: Code ladder, Robbers

Body:
Python 2, 26 bytes, 10 numbers, DLosc

Original:

print r___e(3______+_[___]

Solve:

print range(3,)[1]#+_[___]
print range(3,)[-1]#+_[___]
print range(3,4)[-1]#+_[___]
print range(3,5)[-1]#+_[___]
print range(3,6)[-1]#+_[___]
print range(3,7)[-1]#+_[___]
print range(3,8)[-1]#+_[___]
print range(3,9)[-1]#+_[___]
print range(3^9)[-1]#+_[___]
print range(2^9)[-1]#+_[___]

Yeah, I'm fairly sure this still isn't the intended solve.


答:
Python 3, 16 bytes, 10 numbers, by Sp3000

This was fun.

```<code>print(?%??f?r?t)

print(1%0xfor t)
print(2%0xfor t)
...
print(8%0xfor t)
print(84%0xfor t)
print(85%0xfor t)
</code>```

Exploits the fact (which I didn't know till now) that a hex literal ends as soon as a character that isn't 0-9a-fA-F is encountered--thus 0xfor is a very sneaky way to write 15 or. After that, it was a matter of finding the right value congruent to 10 modulo 15.

Title: Code ladder, Robbers

Body:
Python 3, 16 bytes, 10 numbers, by Sp3000

This was fun.

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

print(1%0xfor t)
print(2%0xfor t)
...
print(8%0xfor t)
print(84%0xfor t)
print(85%0xfor t)

Exploits the fact (which I didn't know till now) that a hex literal ends as soon as a character that isn't 0-9a-fA-F is encountered--thus 0xfor is a very sneaky way to write 15 or. After that, it was a matter of finding the right value congruent to 10 modulo 15.


问:
Walk the words!
It is in my humble opinion that standard text is boring. Therefore I propose a new writing standard, walking words!

Walking words

Walking words are words which will respond to certain characters. For the purpose of this challenge the trigger characters are [u, d, r, l] from up down right left.

Whenever you encounter such a character when printing text, you will move the direction of the text.

For example, the text abcdef will result in:

```<code>abcd
   e
   f
</code>```

Rules

Both uppercase UDRL and lowercase udrl should change the direction, but case should be preserved in the output

Input will only contain printable characters (0-9, A-Z, a-z, !@#%^&*() etc...), no newlines!

Whenever the text will collide, it will overwrite the old character at that position

Output should be presented to the user in any fashionable matter, but it should be a single output (no array of lines)

Trailing and leading newlines are allowed

Trailing spaces are allowed

Standard loopholes apply

Test cases

```<code>empty input => empty output or a newline

u =>
u

abc =>
abc

abcd =>
abcd

abcde =>
abcd
   e

abcdde =>
abcd
   d
   e

codegolf and programming puzzles =>
   cod
     e
     g
     o
dna fl    sel
            z
p           z
rogramming pu

ABCDELFUGHI =>
 I
AHCD
 G E
 UFL

It is in my humble opinion that standard text is boring. Therefore I propose a new writing standard, walking words! =>
dnats taht noinipo el
a                   b
rd                  m
       It is in my hu
 t
 e
 x
 t

 i
 s

 b
 o
 ring. Therefore I propose a new writing stand
                                             a
                                             rd
                                              ,

                                              w
                                              a
                                      rdw gnikl
                                       s
                                       !
</code>```

This is code-golf, shortest code in bytes wins!

答:
Pyth, <s>68</s> 65 bytes

```<code>KUJ,00ImXH~+VJ=@as_BM_MBU2Kx"rdlu"rd0dzjcsm.x@Hd;*Fm=Z}hdedSMCHlZ
</code>```

Test suite

This uses a dictionary, indexed by a pair of coordinates, that is updated as the input read, then printed at the end. It also uses a ton of clever golfing tricks.

Here's how I wrote it, using the interpreter's -m flag to strip the whitespace and comments before running:

```<code>KUJ,00                 ; Initialize J to [0, 0] and K to [0, 1].
                       ; J is the current location, K is the current direction.
I                      ; If the following is truthy, which will be when the input
                       ; is nonempty,
  m                    ; Map d over z, the input.
  XH                   ; Assign to H (a hash table, initially empty)
    ~+VJ               ; At location J, then update J by adding elementwise
      =@               ; K (Next variable is implicit), which is set to
        as_BM_MBU2K    ; [0, 1], bifurcated on mapped negation, then mapped on
                       ; reversal bifuraction with the old value of K appended.
                       ; e.g. [[0, 1], [1, 0], [0, -1], [-1, 0], K]
        x"rdlu"rd0     ; indexed at location equal to the index of the lowercase
                       ; of the current character into "rdlu", -1 if missing.
    d                  ; Insert the current character with that key.
  z                    ; map over z.
jc                     ; Join on newlines the result of chopping into a rectangle
  sm                   ; the concatenation of the map
    .x@Hd;             ; Lookup the character at the given location,
                       ; if none then ' '
    *Fm                ; Locations are the cartesian product of the map
      =Z}hded          ; Inclusive range from the head of each list to
                       ; the end of each list
                       ; Saved in Z for later
      SMCH             ; Transpose the list of keys, and sort the x and y values
                       ; separately.
  lZ                   ; Width of the rectangle should equal the number of
                       ; x values, which is the length of the last entry.
</code>```

Title: Walk the words!

Body:
Pyth, <s>68</s> 65 bytes

KUJ,00ImXH~+VJ=@as_BM_MBU2Kx"rdlu"rd0dzjcsm.x@Hd;*Fm=Z}hdedSMCHlZ

Test suite

This uses a dictionary, indexed by a pair of coordinates, that is updated as the input read, then printed at the end. It also uses a ton of clever golfing tricks.

Here's how I wrote it, using the interpreter's -m flag to strip the whitespace and comments before running:

KUJ,00                 ; Initialize J to [0, 0] and K to [0, 1].
                       ; J is the current location, K is the current direction.
I                      ; If the following is truthy, which will be when the input
                       ; is nonempty,
  m                    ; Map d over z, the input.
  XH                   ; Assign to H (a hash table, initially empty)
    ~+VJ               ; At location J, then update J by adding elementwise
      =@               ; K (Next variable is implicit), which is set to
        as_BM_MBU2K    ; [0, 1], bifurcated on mapped negation, then mapped on
                       ; reversal bifuraction with the old value of K appended.
                       ; e.g. [[0, 1], [1, 0], [0, -1], [-1, 0], K]
        x"rdlu"rd0     ; indexed at location equal to the index of the lowercase
                       ; of the current character into "rdlu", -1 if missing.
    d                  ; Insert the current character with that key.
  z                    ; map over z.
jc                     ; Join on newlines the result of chopping into a rectangle
  sm                   ; the concatenation of the map
    .x@Hd;             ; Lookup the character at the given location,
                       ; if none then ' '
    *Fm                ; Locations are the cartesian product of the map
      =Z}hded          ; Inclusive range from the head of each list to
                       ; the end of each list
                       ; Saved in Z for later
      SMCH             ; Transpose the list of keys, and sort the x and y values
                       ; separately.
  lZ                   ; Width of the rectangle should equal the number of
                       ; x values, which is the length of the last entry.


答:
Logicode, 9 bytes

```<code>out ~ainp
</code>```

Try it online!

Title: The shortest code to invert bit-wise a binary string

Body:
Me thinks there aren't enough easy questions on here that beginners can attempt!

The challenge: Given a random input string of 1's and 0's such as:

```<code>10101110101010010100010001010110101001010
</code>```

Write the shortest code that outputs the bit-wise inverse like so:

```<code>01010001010101101011101110101001010110101
</code>```

Body:
Logicode, 9 bytes

out ~ainp

Try it online!


答:
Brachylog, 11 bytes

```<code>doI,?:3^doI
</code>```

Try it online!

Thanks to @DestructibleWatermelon for pointing out a problem with my original answer.

Explanation

```<code>(?)doI,           I is the Input sorted with no duplicates
       ?:3^       Compute Input^3
           doI    Input^3 sorted with no duplicates is I
</code>```

Body:
Given a number n (0 <= n <= 2642245), check if n and n3 have the same set of digits, and output a truthy or falsey value accordingly.

For example, let's check the number 100.

1003 is 1000000.

The set of digits in 100 is {0, 1}.

The set of digits in 1000000 is {0, 1}.

Therefore, 100 should give a truthy value.

Test cases

```<code>0 -> True
1 -> True
10 -> True
107624 -> True
251894 -> True
251895 -> False
102343 -> False
</code>```

Remember, this is code-golf, so the code with the fewest bytes wins.

OEIS A029795

Body:
Brachylog, 11 bytes

doI,?:3^doI

Try it online!

Thanks to @DestructibleWatermelon for pointing out a problem with my original answer.

Explanation

(?)doI,           I is the Input sorted with no duplicates
       ?:3^       Compute Input^3
           doI    Input^3 sorted with no duplicates is I


Title: Code ladder, Cops

Body:
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


答:
Brachylog, 12 bytes

```<code>~c:{<=|>=}al
</code>```

Try it online!

This returns false. for the empty list [].

Explanation

```<code>(?)~c                 Take a list of sublists which when concatenated result in the Input
     :{<=|>=}a        Each sublist must be either increasing or decreasing
              l(.)    Output is the length of that list
</code>```

This will return the smallest one because ~c will generate choice points from the smallest number of sublists to the biggest.

Body:
A monotonic subsequence is a sequence of numbers \$a_1, a_2, ..., a_n\$ such that

$$a_1 \le a_2 \le ... \le a_n \\
\text{or} \\
a_1 \ge a_2 \ge ... \ge a_n$$

[1, 3, 3, 7, 9, 13, 13, 100] is a monotonic (non-decreasing) subsequence, as well as [9, 4, 4, 3, 0, -10, -12] (this one is non-increasing), but [1, 3, 6, 9, 8] is not. Given a list of integers (in any reasonable format), output the smallest number N such that the sequence of these integers can be split into N monotonic sequences.

Examples

```<code>[1, 3, 7, 5, 4, 2] -> [[1, 3, 7], [5, 4, 2]] -> 2
[1, 2, 3, 4, 5, 6] -> [1, 2, 3, 4, 5, 6]     -> 1
[3, 1, 5, 5, 6]    -> [[3, 1], [5, 5, 6]]    -> 2
[4, 6, 8, 9, 1, 6] -> [[4, 6, 8, 9], [1, 6]] -> 2
[3, 3, 3, 3]       -> [[3, 3, 3, 3]]         -> 1
[7]                -> [[7]]                  -> 1
[]                 -> []                     -> anything (you don't actually have to handle an empty list case)
[1, 3, 2, -1, 6, 9, 10, 2, 1, -12] -> [[1, 3], [2, -1], [6, 9, 10], [2, 1, -12]] -> 4
</code>```

Body:
Brachylog, 12 bytes

~c:{<=|>=}al

Try it online!

This returns false. for the empty list [].

Explanation

(?)~c                 Take a list of sublists which when concatenated result in the Input
     :{<=|>=}a        Each sublist must be either increasing or decreasing
              l(.)    Output is the length of that list

This will return the smallest one because ~c will generate choice points from the smallest number of sublists to the biggest.


答:
Java 7, <s>185</s> 178 characters

```<code>import java.util.*;
boolean a(int n){return new HashSet(Arrays.asList((n+"").split(""))).equals(new HashSet(Arrays.asList((new java.math.BigInteger(n+"").pow(3)+"").split(""))));}
</code>```

Call as:

```<code>public static void main(String [] args) {
    System.out.println(0 + " -> " + a(0));
    System.out.println(1 + " -> " + a(1));
    System.out.println(10 + " -> " + a(10));
    System.out.println(107624 + " -> " + a(107624));
    System.out.println(2103869 + " -> " + a(2103869));
    System.out.println(251894 + " -> " + a(251894));
    System.out.println(251895 + " -> " + a(251895));
    System.out.println(102343 + " -> " + a(102343));
    System.out.println(106239 + " -> " + a(106239));
}
</code>```

Output:

```<code>0 -> true
1 -> true
10 -> true
107624 -> true
2103869 -> true
251894 -> true
251895 -> false
102343 -> false
106239 -> false
</code>```

(I'm never sure if I have to count imports and method definitions as well... I've seen either way. The code itself would be only 141 bytes long though.)

Body:
Java 7, <s>185</s> 178 characters

import java.util.*;
boolean a(int n){return new HashSet(Arrays.asList((n+"").split(""))).equals(new HashSet(Arrays.asList((new java.math.BigInteger(n+"").pow(3)+"").split(""))));}

Call as:

public static void main(String [] args) {
    System.out.println(0 + " -> " + a(0));
    System.out.println(1 + " -> " + a(1));
    System.out.println(10 + " -> " + a(10));
    System.out.println(107624 + " -> " + a(107624));
    System.out.println(2103869 + " -> " + a(2103869));
    System.out.println(251894 + " -> " + a(251894));
    System.out.println(251895 + " -> " + a(251895));
    System.out.println(102343 + " -> " + a(102343));
    System.out.println(106239 + " -> " + a(106239));
}

Output:

0 -> true
1 -> true
10 -> true
107624 -> true
2103869 -> true
251894 -> true
251895 -> false
102343 -> false
106239 -> false

(I'm never sure if I have to count imports and method definitions as well... I've seen either way. The code itself would be only 141 bytes long though.)


答:
Pyke, 12 bytes

```<code>.FdRIKQoQl%@
</code>```

Try it here!

Outputs a matrix of characters

Or 9 bytes, noncompetitive.

```<code>.FdRIKQo@
</code>```

Try it here!

Add wrapping on indexables where the index asked for is bigger than the length of the indexable.

.F        - deep_for(input)
    I     -  if ^:
      Qo@ -   Q[o++]
  dR      -  else " "

Even more noncompetitive, 8 bytes

```<code>.FIQo@(P
</code>```

Try it here!

print_grid now aligns empty strings properly

deep_for now does type-guessing on falsies of a different type to the truthies

```<code>.F    (  -  deep_for(input)
 I       -   if ^:
  Qo@    -    input[o++]
       P - pretty_print(^)
</code>```

Title: The Art of Word Shaping

Body:
The Art of Word Shaping

Given a binary matrix and a string of letters, replace all 1's in the matrix, moving from top to bottom and from left to right within each row, with the letters of the string. Once the letters have been formed into the shape of the matrix, print the matrix, replacing 0's with spaces. It's probably easier to just give an example or two.

Case: Base case...

Input One:

```<code>[0,0,1,0,0]
[0,1,0,1,0]
[1,0,0,0,1]
[0,1,0,1,0]
[0,0,1,0,0]

"PPCGPPCG"
</code>```

Output One:

```<code>  P
 P C
G   P
 P C
  G
</code>```

Case: If the input string is longer than the number of ones...

Input Two:

```<code>[1,0,0]
[0,1,0]
[1,0,1]

lambda
</code>```

Output Two:

```<code>l
 a
m b
</code>```

Case: If the input string is shorter than the number of ones...

Input Three:

```<code>[1,1,1]
[1,0,1]
[1,1,1]

PPCG
</code>```

Output Three:

```<code>PPC
G P
PCG
</code>```

Available Assumptions

You may assume the input string is never empty.

You may assume the matrix will never be empty.

You may not assume that the binary matrix will never be all zeros.

Rules

If the string is shorter than the number of ones, repeat the string; all ones must be replaced.

If the string is longer than the number of ones, only use what is needed.

You may use True/False in place of integers/bits for the input.

Trailing spaces ARE REQUIRED, all zeros must be replaced with spaces.

A single trailing newline is acceptable.

This is code-golf, lowest byte count wins.

Body:
Pyke, 12 bytes

.FdRIKQoQl%@

Try it here!

Outputs a matrix of characters

Or 9 bytes, noncompetitive.

.FdRIKQo@

Try it here!

Add wrapping on indexables where the index asked for is bigger than the length of the indexable.

.F        - deep_for(input)
    I     -  if ^:
      Qo@ -   Q[o++]
  dR      -  else " "

Even more noncompetitive, 8 bytes

.FIQo@(P

Try it here!

print_grid now aligns empty strings properly

deep_for now does type-guessing on falsies of a different type to the truthies

.F    (  -  deep_for(input)
 I       -   if ^:
  Qo@    -    input[o++]
       P - pretty_print(^)


问:
Program that creates larger versions of itself (quine-variant)
You are to write a program that will output source code that is

Larger than the original program (character wise)

Will print another program larger than itself when run (i.e. the new program is also a valid answer to this challenge) indefinitely

This is code-golf, so shortest answer wins.

答:
OIL, 83 bytes

```<code>0
0
1
1
1
4
1
11
4
1
11
1
2
2
1
12
18
10
18
1
32
22
1
18
26
4
26
8
18
11
6
17
4
26
</code>```

It first prints two lines with a zero in them, and then compares each line to line 1, if they're equal (which is the case when the file is exhausted), we print what's in cell 26. The resulting output will look the same, except with an added 33, which doesn't do anything. Next time, another line will be added, and so on.

Body:
OIL, 83 bytes

0
0
1
1
1
4
1
11
4
1
11
1
2
2
1
12
18
10
18
1
32
22
1
18
26
4
26
8
18
11
6
17
4
26

It first prints two lines with a zero in them, and then compares each line to line 1, if they're equal (which is the case when the file is exhausted), we print what's in cell 26. The resulting output will look the same, except with an added 33, which doesn't do anything. Next time, another line will be added, and so on.


Body:
ES6 (Javascript), 32, 58 bytes

Golfed

n=>(x=(a,b)=>!RegExp(`[^${a}]`).test(b))(m=n*n*n,n)&x(n,m)

Test

N=n=>(x=(a,b)=>!RegExp(`[^${a}]`).test(b))(m=n*n*n,n)&x(n,m)

N(0)
1 (true)

N(1)
1 (true)

N(10)
1 (true)

N(107624)
1 (true)

N(251894)
1 (true)

N(251895)
0 (false)

N(102343)
0 (false)

N(106239)
0 (false)


问:
Monte Carlo estimator of Pi
Happy Pi Day everyone! For no reason at all, I'm trying to construct a Monte Carlo estimator of Pi that is as short as possible. Can we construct one that can fit in a tweet?

To clarify, what I have in mind is the typical approach of drawing random points from the unit square and calculating the ratio that fall within the unit circle. The number of samples can be hard coded or not. If you hardcode them, you must use at least 1000 samples. The result may be returned or printed as a floating point, fixed point or rational number.

No trig functions or Pi constants, must be a Monte Carlo approach.

This is code golf, so the shortest submission (in bytes) wins.

答:
Haskell, <s>116</s> <s>114</s> <s>110</s> 96 bytes

```<code>d=8^9
g[a,b]=sum[4|a*a+b*b<d*d]
p n=(sum.take(floor n)$g<$>iterate((\x->mod(9*x+1)d)<$>)[0,6])/n
</code>```

Because dealing with import System.Random; r=randoms(mkStdGen 2) would take too many precious bytes, I generate an infinite list of random numbers with the linear congruential generator that some say is almost cryptographically strong: x↦x*9+1 mod 8^9, which by the Hull-Dobell Theorem has the full period of 8^9.

g yields 4 if the random number point is inside the circle for pairs of random numbers in [0..8^9-1] because this eliminates a multiplication in the formula used.

Usage:

```<code>> p 100000
3.14208
</code>```

Try it online!

Title: Monte Carlo estimator of Pi

Body:
Haskell, <s>116</s> <s>114</s> <s>110</s> 96 bytes

d=8^9
g[a,b]=sum[4|a*a+b*b<d*d]
p n=(sum.take(floor n)$g<$>iterate((\x->mod(9*x+1)d)<$>)[0,6])/n

Because dealing with import System.Random; r=randoms(mkStdGen 2) would take too many precious bytes, I generate an infinite list of random numbers with the linear congruential generator that some say is almost cryptographically strong: x↦x*9+1 mod 8^9, which by the Hull-Dobell Theorem has the full period of 8^9.

g yields 4 if the random number point is inside the circle for pairs of random numbers in [0..8^9-1] because this eliminates a multiplication in the formula used.

Usage:

> p 100000
3.14208

Try it online!


问:
Quine Anagrams! (Robbers' Thread)
This is the robbers' thread. For the cops' thread, click here.

Cops' Task

For the cops' thread, click here.

Robbers' Task

Find an uncracked submission on the cops' thread. (A submission may only be cracked once.)

Unscramble the code to find a working quine.

Post an answer on the robbers' thread. Include the language, the byte count, the user who posted the scrambled code, a link to that answer, and the unscrambled code.

Here is an example of a robber submission:

Python, 29 bytes, Oliver

```<code>_='_=%r;print _%%_';print _%_
</code>```

Scoring

The user with the most cracks will be the winner of this section.

答:
PHP, 110 bytes, Oliver

```<code><?php $x='<?php $x=0; echo strtr($x, array(chr(39).$x.chr(39)));'; echo strtr($x, array(chr(39).$x.chr(39)));
</code>```

Thanks, I had fun and the strtr([]) trick was a new one for me that I hope will save me some bytes in the future.

Title: Quine Anagrams! (Robbers' Thread)

Body:
PHP, 110 bytes, Oliver

<?php $x='<?php $x=0; echo strtr($x, array(chr(39).$x.chr(39)));'; echo strtr($x, array(chr(39).$x.chr(39)));

Thanks, I had fun and the strtr([]) trick was a new one for me that I hope will save me some bytes in the future.


问:
Downgoat-ify Animals!
My Downgoat avatar has several distinct features

These features can however also apply to any other animal.

Specification

Given an image of an animal (technically can be anything), you must apply the Downgoat properties to it.

Border pixels are the outer most pixels of the image.

The background color is defined as the most common color in the border pixels. When that color is interpreted as an (r, g, b, a) color, with each channel from [0, 256), the background is defined as the area where the every channel of the given pixels' is within 50 of the "background color".

The process:

Setting the background and all transparent pixels to #232323, RGBA(35, 35, 35, 1.00)

Set all pixels which aren't the background to #FC0D1B, RGBA(252, 13, 27, 1.00).

Vertically reflect the image

Add the text -1 in Arial font, in the center of the image. The total height of the text should be 25% of the image's smallest dimension (i.e. min(width, height) * 0.25).

Rules

Feel free to assume the fonts are already installed

Your threshold is supposed to be 50, however you can take this number as input too. You do not get any decreased byte count anything for doing this however

Refer to our image I/O defaults for any questions related to I/O formats.

Image will always be at least 3x3 in size

If there is no most common "border pixel color", it doesn't matter which border pixel color you use as the "background color", this however must be consistent.

Examples

Input:

Output:

Input:

Output:

Input:

Output:

Input:

Output:

Input:

Output:

More examples?

An online implementation is available here: vihan.org/p/downgoatify/#50

This is code-golf so shortest code in bytes wins. Good luck!

答:
C, 32-bit Windows, 987 bytes

```<code>#include <windows.h>
#define A CreateCompatibleDC(c)
#define F z=GetPixel(d,x,y);r=z;g=z>>8;b=z>>16
#define C(X,Y) (X<0||Y<0||X>=s[2]||Y>=s[3]||!GetPixel(e,X,Y))
#define D ((C(x-1,y)||C(x+1,y)||C(x,y-1)||C(x,y+1))&&!C(x,y))
#define E(X,Y) ((Z+X-Y)*(Z+X-Y)<2501)
main(int a,int*n){HDC c,d,e,f,w;int x,y,s[9],z,*o,m,t,Z;unsigned char r,g,b,R,G,B;c=GetDC(w=GetDesktopWindow());d=A;e=A;SelectObject(d,f=LoadImage(0,n[1],0,0,0,16));SelectObject(e,LoadImage(0,n[2],0,0,0,16));GetObject(f,24,s+1);o=LocalAlloc(64/*Fixed,ZeroInit*/,8*s[2]*s[3]);for(x=t=Z=s[1]=s[0]=0;x<s[2];x++)for(y=0;y<s[3];y++)if D{F;for(m=0;m<t&&o[m]!=z;m+=2);o[m]=z;o[m+1]++;t+=2*(m>=t);}for(x=y=1;x<t;x+=2)if(o[x]>o[y])y=x;z=o[y-1];R=z;G=z>>8;B=z>>16;for(x=0;x<s[2];x++)for(y=0;y<s[3];y++){F;SetPixel(c,x,s[3]-y-1,(C(x,y)||(E(r,R)&&E(g,G)&&E(b,B)))?0x232323:0x1B0DFC);}SelectObject(c,CreateFont(-(s[2]>>2),0,0,0,400,0,0,0,0,0,0,0,0,"Arial"));SetBkMode(c,1);SetTextColor(c,0xFFFFFF);DrawText(c,"-1",2,s,37);ReleaseDC(w,c);}
</code>```

The file is saved with LF as line end, not with CR+LF to save some bytes.

The program is written in a way that compiler warnings are generated to save some more bytes.

The file will probably not compile as 64-bit program because the array "s[]" is used to do some implicit castings...

The program takes two images (file names are given via command line):

The first image (first command line argument) is the R/G/B image in Windows .BMP format

The second image is the Alpha channel (black means: 0%, any other colour means: not 0%); the file is also in .BMP format and must have the same size or be larger than the first image

The output image is displayed in the left upper corner of the screen

I couldn't reproduce the boy with the yellow hair. Yellow seems to be too far away (> 50) from white!

Ungolfed version:

```<code>#include <windows.h>

/*
 * Although this line costs us 32 bytes
 * Replacing "CreateCompatibleDC(c)" we'll
 * save 42 bytes in the golfed version later
 * so we save 10 bytes using this define!
 */
#define A CreateCompatibleDC(c)

/*
 * Macro: Get a pixel value at (x,y) to z
 * Also get r, g, b
 */
#define F z=GetPixel(d,x,y); \
    r=z; \
    g=z>>8; \
    b=z>>16

/*
 * Macro checking if a pixel is a
 * transparent colour or lies outside the
 * image
 */
#define C(X,Y) (X<0 || Y<0 || X>=s[2] || Y>=s[3] || !GetPixel(e,X,Y))

/*
 * Macro checking if a pixel at (x,y) is a border pixel
 */
#define D ((C(x-1,y) || C(x+1,y) || C(x,y-1) || C(x,y+1)) && !C(x,y))

/*
 * Macro checking if the difference between X and Y is less than 50
 * The variable "Z" must be type "int" and zero. It is used to
 * perform an implicit cast from "BYTE" to "int".
 */
#define E(X,Y) ((Z+X-Y)*(Z+X-Y)<2501)

/*
 * Note that the second argument is "char **",
 * not "int *".
 * We ignore resulting compiler warnings...
 */
main(int a, int * n)
{
    HDC c, d, e, f, w;
    int x, y, s[9], z, *o, m, t, Z;
    unsigned char r, g, b, R, G, B;

    /*
     * Get the HDC handle to the
     * screen (allowing us to create HDCs
     * for accessing bitmap files as well as
     * drawing directly to the screen!)
     */
    c=GetDC(w=GetDesktopWindow());
    /*
     * Create two virtual HDCs for accessing
     * the bitmap files.
     */
    d=A; /* Macro */
    e=A; /* Macro */
    /*
     * Load the two images:
     * The first argument is the image file with
     * the R/G/B channel
     * The second argument is the image file
     * containing the mask defined by the Alpha
     * channel:
     *   Black means = Alpha=0
     *   White means = Alpha>0
     *   (Any other colour means: Alpha>0)
     *
     * Note that "f" is of the type "HBITMAP",
     * not "HDC". We save 4 bytes in the golfed
     * version using HDC instead of HBITMAP and
     * compile the C file with compiler warnings
     * switched off!
     *
     * The second image should have the same size
     * as the first one. However it may be larger
     * than the first one. It must not be smaller!
     */
    SelectObject(d,f=LoadImage(0,n[1],0,0,0,16 /* 16=LR_LOADFROMFILE */));
    SelectObject(e,LoadImage(0,n[2],0,0,0,16));
    /*
     * Get the image information (size)
     */
    GetObject(f,24,s+1);
    /*
     * Search all background colours
     */
    o=LocalAlloc(64 /* Fixed, ZeroInit */,8*s[2]*s[3]);
    for(x=t=Z=s[1]=s[0]=0;x<s[2];x++)
        for(y=0;y<s[3];y++)
            if D
    {
        F; /* Macro */
        for(m=0;m<t && o[m]!=z;m+=2);
        o[m]=z;
        o[m+1]++;
        t+=2*(m>=t);
    }
    /*
     * Search the most common one
     */
    for(x=y=1;x<t;x+=2) if(o[x]>o[y]) y=x;
    z=o[y-1];
    R=z;
    G=z>>8;
    B=z>>16;
    /*
     * Draw the image directly to the screen
     */
    for(x=0;x<s[2];x++)
        for(y=0;y<s[3];y++)
    {
        F; /* Macro */
        /* C and E are macros: */
        SetPixel(c,x,s[3]-y-1,(C(x,y) ||
            (E(r,R) && E(g,G) && E(b,B)))?
            0x232323:0x1B0DFC);
    }
    /*
     * Draw the text over the image
     */
    SelectObject(c,CreateFont(-(s[2]>>2),0,0,0,400,0,0,0,0,0,0,0,0,"Arial"));
    SetBkMode(c,1 /* TRANSPARENT */);
    SetTextColor(c,0xFFFFFF);
    DrawText(c,"-1",2,s,37 /* center, vcenter, singleline */);
    /*
     * Unfortunately DrawText() won't work
     * when not doing this!
     */
    ReleaseDC(w,c);
}
</code>```

Title: Downgoat-ify Animals!

Body:
C, 32-bit Windows, 987 bytes

#include <windows.h>
#define A CreateCompatibleDC(c)
#define F z=GetPixel(d,x,y);r=z;g=z>>8;b=z>>16
#define C(X,Y) (X<0||Y<0||X>=s[2]||Y>=s[3]||!GetPixel(e,X,Y))
#define D ((C(x-1,y)||C(x+1,y)||C(x,y-1)||C(x,y+1))&&!C(x,y))
#define E(X,Y) ((Z+X-Y)*(Z+X-Y)<2501)
main(int a,int*n){HDC c,d,e,f,w;int x,y,s[9],z,*o,m,t,Z;unsigned char r,g,b,R,G,B;c=GetDC(w=GetDesktopWindow());d=A;e=A;SelectObject(d,f=LoadImage(0,n[1],0,0,0,16));SelectObject(e,LoadImage(0,n[2],0,0,0,16));GetObject(f,24,s+1);o=LocalAlloc(64/*Fixed,ZeroInit*/,8*s[2]*s[3]);for(x=t=Z=s[1]=s[0]=0;x<s[2];x++)for(y=0;y<s[3];y++)if D{F;for(m=0;m<t&&o[m]!=z;m+=2);o[m]=z;o[m+1]++;t+=2*(m>=t);}for(x=y=1;x<t;x+=2)if(o[x]>o[y])y=x;z=o[y-1];R=z;G=z>>8;B=z>>16;for(x=0;x<s[2];x++)for(y=0;y<s[3];y++){F;SetPixel(c,x,s[3]-y-1,(C(x,y)||(E(r,R)&&E(g,G)&&E(b,B)))?0x232323:0x1B0DFC);}SelectObject(c,CreateFont(-(s[2]>>2),0,0,0,400,0,0,0,0,0,0,0,0,"Arial"));SetBkMode(c,1);SetTextColor(c,0xFFFFFF);DrawText(c,"-1",2,s,37);ReleaseDC(w,c);}

The file is saved with LF as line end, not with CR+LF to save some bytes.

The program is written in a way that compiler warnings are generated to save some more bytes.

The file will probably not compile as 64-bit program because the array "s[]" is used to do some implicit castings...

The program takes two images (file names are given via command line):

The first image (first command line argument) is the R/G/B image in Windows .BMP format

The second image is the Alpha channel (black means: 0%, any other colour means: not 0%); the file is also in .BMP format and must have the same size or be larger than the first image

The output image is displayed in the left upper corner of the screen

I couldn't reproduce the boy with the yellow hair. Yellow seems to be too far away (> 50) from white!

Ungolfed version:

#include <windows.h>

/*
 * Although this line costs us 32 bytes
 * Replacing "CreateCompatibleDC(c)" we'll
 * save 42 bytes in the golfed version later
 * so we save 10 bytes using this define!
 */
#define A CreateCompatibleDC(c)

/*
 * Macro: Get a pixel value at (x,y) to z
 * Also get r, g, b
 */
#define F z=GetPixel(d,x,y); \
    r=z; \
    g=z>>8; \
    b=z>>16

/*
 * Macro checking if a pixel is a
 * transparent colour or lies outside the
 * image
 */
#define C(X,Y) (X<0 || Y<0 || X>=s[2] || Y>=s[3] || !GetPixel(e,X,Y))

/*
 * Macro checking if a pixel at (x,y) is a border pixel
 */
#define D ((C(x-1,y) || C(x+1,y) || C(x,y-1) || C(x,y+1)) && !C(x,y))

/*
 * Macro checking if the difference between X and Y is less than 50
 * The variable "Z" must be type "int" and zero. It is used to
 * perform an implicit cast from "BYTE" to "int".
 */
#define E(X,Y) ((Z+X-Y)*(Z+X-Y)<2501)

/*
 * Note that the second argument is "char **",
 * not "int *".
 * We ignore resulting compiler warnings...
 */
main(int a, int * n)
{
    HDC c, d, e, f, w;
    int x, y, s[9], z, *o, m, t, Z;
    unsigned char r, g, b, R, G, B;

    /*
     * Get the HDC handle to the
     * screen (allowing us to create HDCs
     * for accessing bitmap files as well as
     * drawing directly to the screen!)
     */
    c=GetDC(w=GetDesktopWindow());
    /*
     * Create two virtual HDCs for accessing
     * the bitmap files.
     */
    d=A; /* Macro */
    e=A; /* Macro */
    /*
     * Load the two images:
     * The first argument is the image file with
     * the R/G/B channel
     * The second argument is the image file
     * containing the mask defined by the Alpha
     * channel:
     *   Black means = Alpha=0
     *   White means = Alpha>0
     *   (Any other colour means: Alpha>0)
     *
     * Note that "f" is of the type "HBITMAP",
     * not "HDC". We save 4 bytes in the golfed
     * version using HDC instead of HBITMAP and
     * compile the C file with compiler warnings
     * switched off!
     *
     * The second image should have the same size
     * as the first one. However it may be larger
     * than the first one. It must not be smaller!
     */
    SelectObject(d,f=LoadImage(0,n[1],0,0,0,16 /* 16=LR_LOADFROMFILE */));
    SelectObject(e,LoadImage(0,n[2],0,0,0,16));
    /*
     * Get the image information (size)
     */
    GetObject(f,24,s+1);
    /*
     * Search all background colours
     */
    o=LocalAlloc(64 /* Fixed, ZeroInit */,8*s[2]*s[3]);
    for(x=t=Z=s[1]=s[0]=0;x<s[2];x++)
        for(y=0;y<s[3];y++)
            if D
    {
        F; /* Macro */
        for(m=0;m<t && o[m]!=z;m+=2);
        o[m]=z;
        o[m+1]++;
        t+=2*(m>=t);
    }
    /*
     * Search the most common one
     */
    for(x=y=1;x<t;x+=2) if(o[x]>o[y]) y=x;
    z=o[y-1];
    R=z;
    G=z>>8;
    B=z>>16;
    /*
     * Draw the image directly to the screen
     */
    for(x=0;x<s[2];x++)
        for(y=0;y<s[3];y++)
    {
        F; /* Macro */
        /* C and E are macros: */
        SetPixel(c,x,s[3]-y-1,(C(x,y) ||
            (E(r,R) && E(g,G) && E(b,B)))?
            0x232323:0x1B0DFC);
    }
    /*
     * Draw the text over the image
     */
    SelectObject(c,CreateFont(-(s[2]>>2),0,0,0,400,0,0,0,0,0,0,0,0,"Arial"));
    SetBkMode(c,1 /* TRANSPARENT */);
    SetTextColor(c,0xFFFFFF);
    DrawText(c,"-1",2,s,37 /* center, vcenter, singleline */);
    /*
     * Unfortunately DrawText() won't work
     * when not doing this!
     */
    ReleaseDC(w,c);
}


答:
PHP, 48 bytes

```<code><?=($f=count_chars)($a=$argv[1],3)==$f($a**3,3);
</code>```

It's the first time I've assigned a function to a variable like this and I'm honestly quite surprised that it works.

Body:
PHP, 48 bytes

<?=($f=count_chars)($a=$argv[1],3)==$f($a**3,3);

It's the first time I've assigned a function to a variable like this and I'm honestly quite surprised that it works.


答:
R, 21 bytes, 10 numbers, Gregor

Cop's: __i___________i______

Rob's: write(a<-1+0,file="")

Of course there's a bunch of possibility as a can be any letter (and is not needed at all)...

Title: Code ladder, Robbers

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

Write a code that has the same number of bytes as the cop post and where the revealed characters are identical. The code must produce 1 in its initial state, and produce the numbers 2, 3 .. when single alterations are made.

The winner will be the robber that cracked the most posts.

Example post:

MyLang, 9 bytes, 8 numbers (including link to answer), Cop's username.

Original code:

```<code>abc1efghi
</code>```

Code that produces 1 - 8:

```<code>1: abc1efghi
2: abc2efghi
3: abc2efghij
4: kbc2efghij
5: kbc23fghij
6: kbc23fghi
7: kbc63fghi
8: kbc63fhi
</code>```

Explanations are encouraged. The exact format of the robber post is optional.


答:
Actually, 14 bytes

```<code>`G²G²+1>`nkæ4*
</code>```

Try it online!

The number of samples is given as input (rather than hard-coded).

Explanation:

```<code>`G²G²+1>`nkæ4*
`G²G²+1>`n      do the following N times:
 G²G²+            rand()**2 + rand()**2
      1>          is 1 greater?
          kæ    mean of results
            4*  multiply by 4
</code>```

Title: Monte Carlo estimator of Pi

Body:
Happy Pi Day everyone! For no reason at all, I'm trying to construct a Monte Carlo estimator of Pi that is as short as possible. Can we construct one that can fit in a tweet?

To clarify, what I have in mind is the typical approach of drawing random points from the unit square and calculating the ratio that fall within the unit circle. The number of samples can be hard coded or not. If you hardcode them, you must use at least 1000 samples. The result may be returned or printed as a floating point, fixed point or rational number.

No trig functions or Pi constants, must be a Monte Carlo approach.

This is code golf, so the shortest submission (in bytes) wins.

Body:
Actually, 14 bytes

`G²G²+1>`nkæ4*

Try it online!

The number of samples is given as input (rather than hard-coded).

Explanation:

`G²G²+1>`nkæ4*
`G²G²+1>`n      do the following N times:
 G²G²+            rand()**2 + rand()**2
      1>          is 1 greater?
          kæ    mean of results
            4*  multiply by 4


答:
R, 8 bytes, 10 numbers, Cracked

```<code>_a___+__
</code>```

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

 cat(1+0)

 cat(1+1)

 ...

 cat(1+8)

 cat(1+9)

Title: Code ladder, Cops

Body:
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: _.

```<code>abc____i
</code>```

Leaderboard

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

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/Sites/codegolf/all.css?v=7509797c03ea">

Uncracked submissions

 Language	 Score	 User

Sort by: score creation

Safe submissions

 Language	 Score	 User

```

Body:
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)


答:
Actually, 12 bytes

```<code>3ßⁿk`$╔S`Mi=
</code>```

Try it online!

Explanation:

```<code>3ßⁿk`$╔S`Mi=
3ßⁿ           copy of input, cubed
   k          [input, input**3]
    `$╔S`M    for each:
     $          stringify
      ╔         remove duplicate elements
       S        sort
          i=  flatten and compare equality
</code>```

Body:
Given a number n (0 <= n <= 2642245), check if n and n3 have the same set of digits, and output a truthy or falsey value accordingly.

For example, let's check the number 100.

1003 is 1000000.

The set of digits in 100 is {0, 1}.

The set of digits in 1000000 is {0, 1}.

Therefore, 100 should give a truthy value.

Test cases

```<code>0 -> True
1 -> True
10 -> True
107624 -> True
251894 -> True
251895 -> False
102343 -> False
</code>```

Remember, this is code-golf, so the code with the fewest bytes wins.

OEIS A029795

Body:
Actually, 12 bytes

3ßⁿk`$╔S`Mi=

Try it online!

Explanation:

3ßⁿk`$╔S`Mi=
3ßⁿ           copy of input, cubed
   k          [input, input**3]
    `$╔S`M    for each:
     $          stringify
      ╔         remove duplicate elements
       S        sort
          i=  flatten and compare equality


答:
Scala, 57 chars

```<code>def n(x:BigInt)=x.toString.toSet==(x*x*x).toString.toSet
</code>```

Body:
Scala, 57 chars

def n(x:BigInt)=x.toString.toSet==(x*x*x).toString.toSet