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

```

Title: Code ladder, Cops

Body:
Java, 70 bytes, 10 Numbers, Cracked

__________________________ ____(_____________________________)________

_ is the hidden character

Edit: major flaw fixed


问:
Golfing Flower of Life
The challenge here is to accurately depict the flower of life (which is a sacred geometrical figure according to some) in the language of your choice.

The design consists an arrangement of circles and partial circles of radius 1 as shown whose centres arranged on a triangular grid of pitch 1, plus one larger circle of radius 3 surrounding them.

The design can be scaled as you like, but a max error of 2% from mathematically correct is permitted. If using raster graphics, this effectively limits the diameter of the small circles to at least about 100 pixels.

Since this is code-golf, shortest code (bytes) wins.

答:
Mathematica, <s>177</s> <s>173</s> <s>128</s> <s>124</s> 120 bytes

```<code>c=Circle;Graphics@{{0,0}~c~3,Rotate[Table[If[-3<x-y<4,c[{√3x,-x+2y}/2,1,Pi/{6,2}]],{x,-3,2},{y,-4,2}],Pi/3#]&~Array~6}
</code>```

The main idea is to compose the result from six rotated versions of this:

This in turn is a rectangular table of identical circle arcs with two corners cut off. If we remove the shearing and represent each circle center with a #, we basically want to distribute the circles in this pattern:

```<code>####
#####
######
######
 #####
  ####
</code>```

These edges are cut off by imposing the condition -3 < x-y < 4 on the 2D indices (since the value of x-y is constant along diagonals) and the shearing comes from multiplying these x and y by non-orthogonal basis vectors which span the grid we're looking for.

This particular orientation of the unrotated arcs turns out to be the shortest since both ends of the arc evenly divide Pi so that the arc can be expressed as Pi/{6,2} (all other arcs would either require and additional minus sign or integers in the numerator).

ContentLicense: CC BY-SA 4.0

Title: Golfing Flower of Life

Body:
Mathematica, <s>177</s> <s>173</s> <s>128</s> <s>124</s> 120 bytes

c=Circle;Graphics@{{0,0}~c~3,Rotate[Table[If[-3<x-y<4,c[{√3x,-x+2y}/2,1,Pi/{6,2}]],{x,-3,2},{y,-4,2}],Pi/3#]&~Array~6}

The main idea is to compose the result from six rotated versions of this:

This in turn is a rectangular table of identical circle arcs with two corners cut off. If we remove the shearing and represent each circle center with a #, we basically want to distribute the circles in this pattern:

####
#####
######
######
 #####
  ####

These edges are cut off by imposing the condition -3 < x-y < 4 on the 2D indices (since the value of x-y is constant along diagonals) and the shearing comes from multiplying these x and y by non-orthogonal basis vectors which span the grid we're looking for.

This particular orientation of the unrotated arcs turns out to be the shortest since both ends of the arc evenly divide Pi so that the arc can be expressed as Pi/{6,2} (all other arcs would either require and additional minus sign or integers in the numerator).

ContentLicense: CC BY-SA 3.0


问:
Iterated partial sums
The partial sums of a list of integers [a1, a2, a3, ..., an] are

s1 = a1

s2 = a1 + a2

s3 = a1 + a2 + a3

...

sn = a1 + a2 + ... + an

We can then take the list of partial sums [s1, s2, s3, ..., sn] and compute its partial sums again to produce a new list, and so on.

Related: Iterated forward differences

Input:

A non-empty list of integers

A positive number of iterations,

Output: Print or return the list of integers that results from taking the partial sums that many times.

Fewest bytes wins. Built-ins are OK even if they outright solve the problem.

Test cases:

```<code>f([-3, 4, 7, -1, 15], 1) == [-3, 1, 8, 7, 22]
f([-3, 4, 7, -1, 15], 3) == [-3, -5, 1, 14, 49]
</code>```

Leaderboard:

var QUESTION_ID=59192,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/61321/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

```

答:
C++14, 67 bytes

As unnamed lambda modifying its input, requiring c as a random-access-container like vector<int>.

[](auto&c,int n){while(n--)for(int i=0;i++<c.size();c[i]+=c[i-1]);}
```

Title: Iterated partial sums


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

```

答:
k, 5 bytes

```<code>1+!10
</code>```

Explanation:

```<code>1+ //Projection of +, add 1 to the argument
!10 // "til" 10 - i.e. generate a list of numbers from 0 to n-1
</code>```

Output:

```<code>1 2 3 4 5 6 7 8 9 10
</code>```

Title: Print numbers from 1 to 10

Body:
k, 5 bytes

1+!10

Explanation:

1+ //Projection of +, add 1 to the argument
!10 // "til" 10 - i.e. generate a list of numbers from 0 to n-1

Output:

1 2 3 4 5 6 7 8 9 10


问:
Calculating waves
I've been scrolling around this site for a while, but just recently got really interested in actually trying out some of the challenges. I was intending to try my hand at some of the existing code-golf topics, but I didn't have Internet access for a while yesterday, and in the meantime, I thought up my own challenge.

Your task is to create a program or function that takes an array of Floats a and an integer n, then sets each value in a to the average of the two beside it, n times. When repeatedly used with increasing values of n, this generates a wave-like motion:

Specifics:

If there happens to be only one item in a, or if n is 0 or less, the program should return the original array.

Inputs and outputs can be in any format you desire, as long as they are visibly separated.

For each step:

The first item in a should become the average of itself and the next item.

The last item in a should become the average of itself and the previous item.

Any other item in a should become the average of the previous item and the next item.

Make sure you are calculating off the previous step's array and not the current one!

Test cases: NOTE: Your inputs/outputs do not have to be in this format!

```<code>[0, 0, 1, 0, 0], 1          -> [0, 0.5, 0, 0.5, 0]
[0, 0, 1, 0, 0], 2          -> [0.25, 0, 0.5, 0, 0.25]
[0, 0, 1, 0, 0], 0          -> [0, 0, 1, 0, 0]
[0, 0, 1, 0, 0], -39        -> [0, 0, 1, 0, 0]
[0, 16, 32, 16, 0], 1       -> [8, 16, 16, 16, 8]
[0, 1, 2, 3, 4, 5], 1       -> [0.5, 1, 2, 3, 4, 4.5]
[0, 64], 1                  -> [32, 32]
[0], 482                    -> [0]
[32, 32, 32, 16, 64, 16, 32, 32, 32], 4 -> [33, 27, 40, 22, 44, 22, 40, 27, 33]
</code>```

This is code-golf, so shortest answer in bytes wins. The winner will be chosen in one week (on August 1). Good luck!

Edit: Congrats to the winner, @issacg, with a whopping 18 bytes!

Title: Calculating waves

Body:
Racket 223 bytes

(let p((l l)(m 0)(g list-ref))(cond[(> n m)(let*((j(length l))(k(for/list((i j))(cond[(= i 0)(/(+(g l 0)(g l 1))2)]
[(= i(- j 1))(/(+(g l(- j 2))(g l(- j 1)))2)][else(/(+(g l(+ i 1))(g l(- i 1)))2)]))))(p k(+ 1 m) g))][l]))

Ungolfed:

(define(f l n)
  (let loop ((l l)
             (m 0)
             (lr list-ref))
    (cond
      [(> n m)
       (let* ((j (length l))
              (k (for/list ((i j))
                   (cond
                     [(= i 0)       (/ (+ (lr l 0)
                                          (lr l 1))
                                       2)]
                     [(= i (- j 1)) (/ (+ (lr l (- j 2))
                                          (lr l (- j 1)))
                                        2)]
                     [else          (/ (+ (lr l (+ i 1))
                                          (lr l (- i 1)))
                                       2)])
                   )))
         (loop k
               (+ 1 m)
               lr))]
      [else l]
      )))

Testing:

(f '[32 32 32 16 64 16 32 32 32] 4)

Output:

'(33 27 40 22 44 22 40 27 33)


答:
><> (Fish) 10 bytes

```<code>1l:naoa=?;
</code>```

This is my first submission and I know their is already a Fish answer but I don't have the reputation to comment.

The main difference is using the l to place the length of the stack onto the stack allowing us to bypass 'adding one' saving a byte.

Using l also means we don't need to preserve the stack value (just the length) so we do not need to duplicate the top of the stack to preserve our values, saving another 2 bytes (one for the duplication of the stack value and another as we do not need to skip any instructions for preserving the stack).

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:
><> (Fish) 10 bytes

1l:naoa=?;

This is my first submission and I know their is already a Fish answer but I don't have the reputation to comment.

The main difference is using the l to place the length of the stack onto the stack allowing us to bypass 'adding one' saving a byte.

Using l also means we don't need to preserve the stack value (just the length) so we do not need to duplicate the top of the stack to preserve our values, saving another 2 bytes (one for the duplication of the stack value and another as we do not need to skip any instructions for preserving the stack).


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

答:
Java, 70 bytes, 10(+) numbers, by masterX244

```<code>//Submission v
__________________________ ____(_____________________________)________
//Original code v
class A{public static void main(String[]a){System.out.print(')'-40);}}//1
</code>```

This makes use of the character codes for numbers. The char ) is 41. So when you subtract 40 from it, it evaluates to 1. By incrementing the char by 1, we effectively increase the output by 1 too.

Try it online in Ideone!. Note: in Ideone, you need to have public before class and the name of the class should be HelloWorld

Other numbers:

```<code>class A{public static void main(String[]a){System.out.print('*'-40);}}//2
class A{public static void main(String[]a){System.out.print('+'-40);}}//3
class A{public static void main(String[]a){System.out.print(','-40);}}//4
class A{public static void main(String[]a){System.out.print('-'-40);}}//5
class A{public static void main(String[]a){System.out.print('.'-40);}}//6
class A{public static void main(String[]a){System.out.print('/'-40);}}//7
class A{public static void main(String[]a){System.out.print('0'-40);}}//8
class A{public static void main(String[]a){System.out.print('1'-40);}}//9
class A{public static void main(String[]a){System.out.print('2'-40);}}//10
...
class A{public static void main(String[]a){System.out.print('~'-40);}}//86
</code>```

Edit: fixed mistake

Edit 2: Yes, this can go upto 86 and maybe even more!

Title: Code ladder, Robbers

Body:
Java, 70 bytes, 10(+) numbers, by masterX244

//Submission v
__________________________ ____(_____________________________)________
//Original code v
class A{public static void main(String[]a){System.out.print(')'-40);}}//1

This makes use of the character codes for numbers. The char ) is 41. So when you subtract 40 from it, it evaluates to 1. By incrementing the char by 1, we effectively increase the output by 1 too.

Try it online in Ideone!. Note: in Ideone, you need to have public before class and the name of the class should be HelloWorld

Other numbers:

class A{public static void main(String[]a){System.out.print('*'-40);}}//2
class A{public static void main(String[]a){System.out.print('+'-40);}}//3
class A{public static void main(String[]a){System.out.print(','-40);}}//4
class A{public static void main(String[]a){System.out.print('-'-40);}}//5
class A{public static void main(String[]a){System.out.print('.'-40);}}//6
class A{public static void main(String[]a){System.out.print('/'-40);}}//7
class A{public static void main(String[]a){System.out.print('0'-40);}}//8
class A{public static void main(String[]a){System.out.print('1'-40);}}//9
class A{public static void main(String[]a){System.out.print('2'-40);}}//10
...
class A{public static void main(String[]a){System.out.print('~'-40);}}//86

Edit: fixed mistake

Edit 2: Yes, this can go upto 86 and maybe even more!


问:
Score a hand of Hearts
Hearts is a trick-taking card game for 4 players. Each trick is taken by the player who played the highest card of the leading suit. At the end of each hand, the players incur a penalty score depending on the penalty cards they have taken; the task is to determine the scores under Microsoft Hearts rules.

Input

Input is 4 lists (or delimited string, array, etc.) showing the penalty cards taken by each of the 4 players. The penalty cards are

```<code>2♥, 3♥, 4♥, 5♥, 6♥, 7♥, 8♥, 9♥, 10♥, J♥, Q♥, K♥, A♥, Q♠
</code>```

which we shall represent as

```<code>2,  3,  4,   5,  6,  7,  8,  9,  10,  11, 12,  13,  1,  0
</code>```

respectively.

Output

Output is the 4 penalty points incurred by the 4 players (list, string, array etc.). Scoring is as follows:

Each heart (♥, represented by integers 1 to 13 inclusive) incurs 1 point

The queen of spades (Q♠, represented by 0) incurs 13 points

Exception: if a player has taken all of the penalty cards (called shooting the moon), then he incurs 0 points, while all other players incur 26 points.

Test cases

```<code>[2, 8, 7, 1], [3, 4], [], [9, 5, 6, 0, 10, 11, 12, 13]     -->  4,  2,  0, 20
[0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [], [], [1]   --> 25,  0,  0,  1
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0], [], [], [] -->  0, 26, 26, 26
</code>```

Shortest code in bytes wins.

答:
C++14, 158 bytes

As unnamed Lambda:

[](auto c){typename decltype(c)::value_type r;int b=0;for(auto d:c){int q=0;for(auto i:d)q+=i?1:13;r.push_back(q);b+=q==26;}if(b)for(int&x:r)x=26-x;return r;}
```
<p>Requires a <code>vector<vector<int>></code> and returns <code>vector<int></code></p>
<p>Ungolfed:</p>
<pre class="lang-c++ prettyprint-override"><code>[](auto c){
 typename decltype(c)::value_type r;   //result vector
 int b=0;                              //flag if one has all cards
 for(auto d:c){                        //over all decks
  int q=0;                             //count points
  for(auto i:d) q+=i?1:13;             //+13 for queen, +1 else
  r.push_back(q);                      //add to result
  b+=q==26;                            //possibly activate flag
 }
 if(b) for(int&x:r) x=26-x;            //if flag is set, mirror the results
 return r;
}
</code>```

Few testcases for you:

 auto r = std::vector<std::vector<int>>{{2,8,7,1},{3,4},{},{9,5,6,0,10,11,12,13}};
 auto s = std::vector<std::vector<int>>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0},{},{},{}};
 auto t = std::vector<std::vector<int>>{{},{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0},{},{1}};
```

Title: Score a hand of Hearts

Body:
C++14, 158 bytes

As unnamed Lambda:

[](auto c){typename decltype(c)::value_type r;int b=0;for(auto d:c){int q=0;for(auto i:d)q+=i?1:13;r.push_back(q);b+=q==26;}if(b)for(int&x:r)x=26-x;return r;}

Requires a vector<vector<int>> and returns vector<int>

Ungolfed:

[](auto c){
 typename decltype(c)::value_type r;   //result vector
 int b=0;                              //flag if one has all cards
 for(auto d:c){                        //over all decks
  int q=0;                             //count points
  for(auto i:d) q+=i?1:13;             //+13 for queen, +1 else
  r.push_back(q);                      //add to result
  b+=q==26;                            //possibly activate flag
 }
 if(b) for(int&x:r) x=26-x;            //if flag is set, mirror the results
 return r;
}

Few testcases for you:

 auto r = std::vector<std::vector<int>>{{2,8,7,1},{3,4},{},{9,5,6,0,10,11,12,13}};
 auto s = std::vector<std::vector<int>>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0},{},{},{}};
 auto t = std::vector<std::vector<int>>{{},{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0},{},{1}};


Title: Score a hand of Hearts

Body:
Hearts is a trick-taking card game for 4 players. Each trick is taken by the player who played the highest card of the leading suit. At the end of each hand, the players incur a penalty score depending on the penalty cards they have taken; the task is to determine the scores under Microsoft Hearts rules.

Input

Input is 4 lists (or delimited string, array, etc.) showing the penalty cards taken by each of the 4 players. The penalty cards are

```<code>2♥, 3♥, 4♥, 5♥, 6♥, 7♥, 8♥, 9♥, 10♥, J♥, Q♥, K♥, A♥, Q♠
</code>```

which we shall represent as

```<code>2,  3,  4,   5,  6,  7,  8,  9,  10,  11, 12,  13,  1,  0
</code>```

respectively.

Output

Output is the 4 penalty points incurred by the 4 players (list, string, array etc.). Scoring is as follows:

Each heart (♥, represented by integers 1 to 13 inclusive) incurs 1 point

The queen of spades (Q♠, represented by 0) incurs 13 points

Exception: if a player has taken all of the penalty cards (called shooting the moon), then he incurs 0 points, while all other players incur 26 points.

Test cases

```<code>[2, 8, 7, 1], [3, 4], [], [9, 5, 6, 0, 10, 11, 12, 13]     -->  4,  2,  0, 20
[0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [], [], [1]   --> 25,  0,  0,  1
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0], [], [], [] -->  0, 26, 26, 26
</code>```

Shortest code in bytes wins.

Body:
Python 2, <s>75</s> <s>72</s> 71 bytes

i=[len(a)+12*(0in a)for a in input()]
print[[x,26-x][26in i]for x in i]

Takes input as [2, 8, 7, 1], [3, 4], [], [9, 5, 6, 0, 10, 11, 12, 13]


Title: Score a hand of Hearts

Body:
JavaScript (ES6), <s>82</s> <s>80</s> <s>77</s> <s>72</s> <s>70</s> <s>69</s> 67 bytes

Saved 2 bytes thanks to @Neil

f =
s=>s.map(c=>c.map(t=>r+=t?1:13,r=0)|(b|=r>25,r),b=0).map(c=>b*26^c)

console.log(f.toString().length)
console.log(f([[2, 8, 7, 1], [3, 4], [], [9, 5, 6, 0, 10, 11, 12, 13]]));
console.log(f([[0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [], [], [1] ]));
console.log(f([[0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [], [1], [] ]));
console.log(f([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0], [], [], []]));
console.log(f([[],[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0], [], []]));

Breakdown

s=>s.map(                              // for each hand
 c=>c.map(                             // for each card
  t=>r+=t?1:13,                        // add value of card
 r=0)|(
  b=b|r>25,r                           // set flag if any hand scores 26 points
 ),
 b=0)
.map(c=>b?                             // for every card if a hand scored 26
  c?0:26                               // set every 0 hand to 26 and the 26 hand to 0
:c)                                    // otherwise do nothing


问:
Manoeuvre the grid!

Briefing

You are a bot, in a 2D grid that extends infinitely in all four directions, north, south, east and west. When given a number, you must move the bot so that you get to the target number.

Here's how the grid works:

You can move in 4 directions: north, south, east or west. Once you move off a cell, you are not allowed to go back to that cell again (so effectively, it's been wiped off the map).

There is a "counter", which goes 1234567890 (so it goes from 1 to 2... all the way to 9, then to 0, then back to 1 again), which changes every time you move.

You also have a "value", which starts off at 0.

Once you move in any direction, a mathematical operation occurs, depending on what direction you move:

North: Your value is increased by counter (value += counter).

East: Your value is decremented by counter (value -= counter).

South: Your value is multiplied by counter (value *= counter).

West: Your value is divided by counter (value /= counter).

Division is integer division, so 5/2 -> 2.

You are not allowed to divide by 0.

Example:

If the bot moves north 3 times:

The first "north" move increments the counter to 1, and adds that to the value (which is now 1).

The second "north" move increments the counter to 2, and adds that to the value (which is now 3).

The third "north" move increments the counter to 3, and adds that to the value (which is now 6).

The final value is 6.

Move north, then south again:

The first "north" move increments the counter to 1, and adds that to the value (which is now 1).

The second "south" move errors, because the cell the bot is trying to move on is removed (from the first move).

There is no final value, because the bot errored.

Challenge

Your challenge is to write a program when, given a number, produce the suitable directions for the bot to go in so that the final value of the bot is equal to that number.

So if the number is 6, a valid solution to that would be:

```<code>nnn
</code>```

(The bot moves north 3 times in a row).

Your test values are:

```<code>49445094, 71259604, 78284689, 163586986, 171769219, 211267178, 222235492, 249062828, 252588742, 263068669, 265657839, 328787447, 344081398, 363100288, 363644732, 372642304, 374776630, 377945535, 407245889, 467229432, 480714605, 491955034, 522126455, 532351066, 542740616, 560336635, 563636122, 606291383, 621761054, 648274119, 738259135, 738287367, 748624287, 753996071, 788868538, 801184363, 807723631, 824127368, 824182796, 833123975, 849666906, 854952292, 879834610, 890418072, 917604533, 932425141, 956158605, 957816726, 981534928, 987717553
</code>```

(These are 50 random numbers from 1 to 1 billion.)

Your score is the total amount of moves made for all 50 numbers - the fewer moves, the better. In case of a tie, the person who submitted their code earlier wins.

Specs

You are guaranteed receive a positive integer for input.

Your value variable must not go above 2^31-1 or below -2^31 at any point for your generated paths.

Your final program must fit in an answer (so, < 30,000 bytes).

You may only hard-code 10 numbers.

Your program must run within 5 minutes on a reasonable laptop for any test case.

The results MUST be the same every time the program is run for each number.

答:
Python, Score = 56068747912

```<code>def move(n):
    print("n" + "en" * (n - 1))
</code>```

Just prints nenenenenenenen... for every number.

Will add an explanation later.

Title: Manoeuvre the grid!

Body:
Python, Score = 56068747912

def move(n):
    print("n" + "en" * (n - 1))

Just prints nenenenenenenen... for every number.

Will add an explanation later.


答:
CJam, <s>22</s> 20 bytes

Thanks to jimmy23013 for saving 2 bytes.

```<code>{{XD?}f%1fb_26&1bf^}
</code>```

An unnamed block (function), which takes a list of 4 lists as input and returns the list of scores.

Try it online!

Explanation

```<code>{      e# For each card...
  XD?  e#   Choose 1 if it's positive and 13 if it's zero.
}f%
1fb    e# Sum each hand.
_26&   e# Get the set intersection of the scores with 26. This gives [26]
       e# if someone shot the moon, and [] otherwise.
1b     e# Treat as base-1 digits, which gives 26 if someone shot the moon
       e# and zero otherwise.
f^     e# XOR each result with this number. This swaps zeros and 26s when
       e# someone shot the moon and does nothing otherwise.
</code>```

Title: Score a hand of Hearts

Body:
CJam, <s>22</s> 20 bytes

Thanks to jimmy23013 for saving 2 bytes.

{{XD?}f%1fb_26&1bf^}

An unnamed block (function), which takes a list of 4 lists as input and returns the list of scores.

Try it online!

Explanation

{      e# For each card...
  XD?  e#   Choose 1 if it's positive and 13 if it's zero.
}f%
1fb    e# Sum each hand.
_26&   e# Get the set intersection of the scores with 26. This gives [26]
       e# if someone shot the moon, and [] otherwise.
1b     e# Treat as base-1 digits, which gives 26 if someone shot the moon
       e# and zero otherwise.
f^     e# XOR each result with this number. This swaps zeros and 26s when
       e# someone shot the moon and does nothing otherwise.


答:
C#, 90 bytes, 10 numbers, cracked

```<code>using ______________________________________________;class C{static void Main(){_______;}}
</code>```

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

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

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

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#, 90 bytes, 10 numbers, cracked

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

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

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

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


答:
C++: score = 453,324,048

OK, needed some time to rework this, but here's the way I solved it.

After studying the solution space, I decided that my strategy would be:

Uses the south steps to get as close to the target number

if the target is positive, follow this path: nnnesssssessssssss

if the target is negative, follow this path: esssssssseessssss
c. if the target is between 0 and 20, solve it "the old fashion way" (trail and error over every possible path til we reach it).

Once we have our "best place" (get as close to the target, without going "over"), we may be able to get closer by multiplying by 2 or 3; so take between 0 to 9 steps east, and then one step south.  keep the path that gets us the closest to the target.

"Run" north, or east til we are within 45 points of the target (every 10 steps north, add 45 points to the score, like wise, every 10 steps east, reduces the score by 45).

Take a few more steps in the same direction, til we are within 10 points of the target

Do "the old fashion way" from this point, it shouldn't be that hard now.

Here's my result: total score is 453324048

And the paths:

```<code>  0) to reach   49445094, it takes   1311037 steps, by doing: nnnesssssesssssseeeeese(n *     1311010)enen
  1) to reach   71259604, it takes   1320313 steps, by doing: nnnesssssesssssseeeeeese(n *     1320280)nnnnnneee
  2) to reach   78284689, it takes   1956998 steps, by doing: nnnesssssesssssseeeeeees(e *     1956970)eeee
  3) to reach  163586986, it takes   2483885 steps, by doing: nnnesssssessssssse(n *     2483860)nnnnnnn
  4) to reach  171769219, it takes   4302163 steps, by doing: nnnesssssessssssse(n *     4302130)nnnnnnnnnnennnn
  5) to reach  211267178, it takes  13079485 steps, by doing: nnnesssssessssssse(n *    13079460)nnnnnen
  6) to reach  222235492, it takes  15516886 steps, by doing: nnnesssssessssssse(n *    15516860)nnnnnnnn
  7) to reach  249062828, it takes  12390325 steps, by doing: nnnesssssessssssseeees(e *    12390290)eeeeenenneene
  8) to reach  252588742, it takes  11606785 steps, by doing: nnnesssssessssssseeees(e *    11606760)een
  9) to reach  263068669, it takes   9277915 steps, by doing: nnnesssssessssssseeees(e *     9277880)eeeeenennneee
 10) to reach  265657839, it takes   8702543 steps, by doing: nnnesssssessssssseeees(e *     8702510)eeeeenennee
 11) to reach  328787447, it takes   5326312 steps, by doing: nnnesssssessssssseeeese(n *     5326280)nnnnennnn
 12) to reach  344081398, it takes   8724966 steps, by doing: nnnesssssessssssseeeese(n *     8724940)enn
 13) to reach  363100288, it takes  12951386 steps, by doing: nnnesssssessssssseeeese(n *    12951360)enn
 14) to reach  363644732, it takes  13072373 steps, by doing: nnnesssssessssssseeeese(n *    13072340)nnnnnnnnen
 15) to reach  372642304, it takes  15071833 steps, by doing: nnnesssssessssssseeeese(n *    15071800)nnnnnnnenn
 16) to reach  374776630, it takes  15546133 steps, by doing: nnnesssssessssssseeeese(n *    15546100)nnnnnenene
 17) to reach  377945535, it takes  16250331 steps, by doing: nnnesssssessssssseeeese(n *    16250300)nnnnennn
 18) to reach  407245889, it takes  11107325 steps, by doing: nnnesssssessssssseeeees(e *    11107300)ne
 19) to reach  467229432, it takes   2222403 steps, by doing: nnnesssssessssssseeeeese(n *     2222370)nnnnnnnee
 20) to reach  480714605, it takes   5219109 steps, by doing: nnnesssssessssssseeeeese(n *     5219080)neenn
 21) to reach  491955034, it takes   7716983 steps, by doing: nnnesssssessssssseeeeese(n *     7716950)nnnnennnn
 22) to reach  522126455, it takes  14421745 steps, by doing: nnnesssssessssssseeeeese(n *    14421710)nnnnnneneee
 23) to reach  532351066, it takes  16693875 steps, by doing: nnnesssssessssssseeeeese(n *    16693850)n
 24) to reach  542740616, it takes  14866179 steps, by doing: nnnesssssessssssseeeeees(e *    14866150)eeeen
 25) to reach  560336635, it takes  10955953 steps, by doing: nnnesssssessssssseeeeees(e *    10955920)eeeeennen
 26) to reach  563636122, it takes  10222731 steps, by doing: nnnesssssessssssseeeeees(e *    10222700)eeeeene
 27) to reach  606291383, it takes    743785 steps, by doing: nnnesssssessssssseeeeees(e *      743760)e
 28) to reach  621761054, it takes   2693968 steps, by doing: nnnesssssessssssseeeeeese(n *     2693940)nnn
 29) to reach  648274119, it takes   8585761 steps, by doing: nnnesssssessssssseeeeeese(n *     8585730)nnnnnn
 30) to reach  738259135, it takes   5286413 steps, by doing: nnnesssssessssssseeeeeees(e *     5286380)eeneneee
 31) to reach  738287367, it takes   5280141 steps, by doing: nnnesssssessssssseeeeeees(e *     5280110)nneenn
 32) to reach  748624287, it takes   2983042 steps, by doing: nnnesssssessssssseeeeeees(e *     2983010)eeeenee
 33) to reach  753996071, it takes   1789313 steps, by doing: nnnesssssessssssseeeeeees(e *     1789280)eeeennee
 34) to reach  788868538, it takes   5960183 steps, by doing: nnnesssssessssssseeeeeeese(n *     5960150)nnenene
 35) to reach  801184363, it takes   8697033 steps, by doing: nnnesssssessssssseeeeeeese(n *     8697000)nnenene
 36) to reach  807723631, it takes  10150197 steps, by doing: nnnesssssessssssseeeeeeese(n *    10150170)n
 37) to reach  824127368, it takes  13795475 steps, by doing: nnnesssssessssssseeeeeeese(n *    13795440)nnnnnnnne
 38) to reach  824182796, it takes  13807795 steps, by doing: nnnesssssessssssseeeeeeese(n *    13807760)nnnnnenee
 39) to reach  833123975, it takes  15794722 steps, by doing: nnnesssssessssssseeeeeeese(n *    15794690)nennnn
 40) to reach  849666906, it takes  14397917 steps, by doing: nnnesssssessssssseeeeeeees(e *    14397880)eeeeeeeenee
 41) to reach  854952292, it takes  13223389 steps, by doing: nnnesssssessssssseeeeeeees(e *    13223350)eeeeeeeeneeen
 42) to reach  879834610, it takes   7693981 steps, by doing: nnnesssssessssssseeeeeeees(e *     7693950)eeenn
 43) to reach  890418072, it takes   5342102 steps, by doing: nnnesssssessssssseeeeeeees(e *     5342070)eeennn
 44) to reach  917604533, it takes    699395 steps, by doing: nnnesssssessssssseeeeeeeese(n *      699360)nnnneene
 45) to reach  932425141, it takes   3992863 steps, by doing: nnnesssssessssssseeeeeeeese(n *     3992830)nennnn
 46) to reach  956158605, it takes   9266963 steps, by doing: nnnesssssessssssseeeeeeeese(n *     9266930)nnnnen
 47) to reach  957816726, it takes   9635434 steps, by doing: nnnesssssessssssseeeeeeeese(n *     9635400)nnnennn
 48) to reach  981534928, it takes  14906145 steps, by doing: nnnesssssessssssseeeeeeeese(n *    14906110)nnnnnnnn
 49) to reach  987717553, it takes  16280059 steps, by doing: nnnesssssessssssseeeeeeeese(n *    16280030)nn
</code>```

I'm sure there's a way to improve on this by doing some cleaver "south/west" moves (dividing by 4 and multiplying by 5; for example); but coding it, and making sure you don't over lap or get trapped, is tricky.

Another solution path, may be to try to go back down from the target, to a "reasonable" number, and then, just find a path to that smaller number; but you'll have to "aim" it right, so that the step number will match.  tricky, but might be the best way to solve this.

Anyway, here is my code code:

#include <stdio.h>
#include <vector>
#include <queue>;

using namespace std;

long long upperLimit;
long long lowerLimit;
bool bDebugInfo = false;
//bool bDebugInfo = true;

//  a point struct (x and y)
struct point
{
    int x;
    int y;

    point():x(0),y(0)
    {
    }

    bool operator ==(const point& other)
    {
        return (x==other.x) && (y==other.y);
    }

    void ApplyDirection(char direction)
    {
        switch (direction)
        {
        case 'n':
            y++;
            break;
        case 'w':
            x--;
            break;
        case 'e':
            x++;
            break;
        case 's':
            y--;
            break;
        }
    }
};

// each state is of this formate
struct botState
{
    int nStep;
    long long number;
    vector<char> path;

    botState()
        :nStep(0),
        number(0)
    {
    }

    botState* clone()
    {
        botState* tmp = new botState();
        tmp->nStep = nStep;
        tmp->number = number;
        tmp->path = path;
        return tmp;
    }

    void clone(botState* other)
    {
        nStep = other->nStep;
        number = other->number;
        path = other->path;
    }

};

bool changeNumberWithDirection(long long &number, char direction, int step)
{
    switch (direction)
    {
    case 'n':
        number += (step%10);
        break;
    case 'w':
        if (step%10)
            number /= (step%10);
        else
            return false;
        break;
    case 'e':
        number -= (step%10);
        break;
    case 's':
        number *= (step%10);
        break;

    default:
        return false;
    }

    return true;
}

bool tryToAddStep(queue<botState*>& queueOfStates, const botState* pState, char direction, char cStarDirection)
{
    botState* pTmpState;
    long long newNumber;
    int newStep = pState->nStep+1;

    newNumber = pState->number;
    if (!changeNumberWithDirection(newNumber, direction, newStep))
        return false;

    if (newNumber > upperLimit)
        return false;

    if (newNumber < lowerLimit)
        return false;

    if ((newNumber == 0) && (newStep%10 == 0))
        return false;                // no need to return back to 0 after 10 or more steps, we already have better ways to do this.

    // build the x,y points of the path up to this point
    point tmpPoint;
    vector<point> pointsInPath;
    pointsInPath.push_back(tmpPoint);

    for (int i=0; i<pState->path.size(); i++)
    {
        if (pState->path.at(i) == '*')
        {
            for (int j=0; j<100; j++)
            {
                tmpPoint.ApplyDirection(cStarDirection);
                pointsInPath.push_back(tmpPoint);
            }
        }
        else
        {
            tmpPoint.ApplyDirection(pState->path.at(i));
            pointsInPath.push_back(tmpPoint);
        }
    }

    tmpPoint.ApplyDirection(direction);

    // check for over lap
    for (int i=0; i<pointsInPath.size(); i++)
    {
        if (tmpPoint == (pointsInPath.at(i)))
            return false;
    }

    pTmpState = new botState();
    pTmpState->nStep = newStep;
    pTmpState->number= newNumber;
    pTmpState->path  = pState->path;

    pTmpState->path.push_back(direction);

    queueOfStates.push(pTmpState);

    return true;
}

bool isBetterNum(long long newNum, long long oldBest, long long target)
{
    long long newDiff = (newNum  > target) ? newNum  - target : target - newNum ;
    long long oldDiff = (oldBest > target) ? oldBest - target : target - oldBest;

    return (newDiff < oldDiff);
}

bool tryToJumpDown(long long num, botState* pState, int& nTimes)
{
    // if where the bot is, we have a clear path to go as far east as we could ever want, we can just do as many sets of eeeeeeeeee (e*10) as needed, til we are close enough to the target
    point tmpPoint;
    vector<point> pointsInPath;
    pointsInPath.push_back(tmpPoint);

    for (int i=0; i<pState->nStep; i++)
    {
        tmpPoint.ApplyDirection(pState->path.at(i));
        pointsInPath.push_back(tmpPoint);
    }

    for (int i=0; i<pointsInPath.size(); i++)
    {
        if ((pointsInPath.at(i).x > tmpPoint.x) && (pointsInPath.at(i).y == tmpPoint.y))
            return false;  // we have a point blocking our path up!
    }

    long long tmpTimes = (pState->number - num)/45;
    if ((tmpTimes>1) && (tmpTimes<upperLimit))
    {
        tmpTimes--;
        tmpTimes*=10;
        nTimes = (int)tmpTimes;
        pState->nStep+=nTimes;
        pState->number-=(tmpTimes/10)*45;
        pState->path.push_back('*');
        return true;
    }

    return false;
}

bool tryToJumpUp(long long num, botState* pState, int& nTimes)
{
    // if where the bot is, we have a clear path to go as far north as we could ever want, we can just do as many sets of nnnnnnnnnn (n*10) as needed, til we are close enough to the target
    point tmpPoint;
    vector<point> pointsInPath;
    pointsInPath.push_back(tmpPoint);

    for (int i=0; i<pState->nStep; i++)
    {
        tmpPoint.ApplyDirection(pState->path.at(i));
        pointsInPath.push_back(tmpPoint);
    }

    for (int i=0; i<pointsInPath.size(); i++)
    {
        if ((pointsInPath.at(i).x == tmpPoint.x) && (pointsInPath.at(i).y > tmpPoint.y))
            return false;  // we have a point blocking our path up!
    }

    long long tmpTimes = (num - pState->number)/45;
    if ((tmpTimes>1) && (tmpTimes<upperLimit))
    {
        tmpTimes--;
        tmpTimes*=10;
        nTimes = (int)tmpTimes;
        pState->nStep+=nTimes;
        pState->number+=(tmpTimes/10)*45;
        pState->path.push_back('*');
        return true;
    }

    return false;
}

typedef char* PChar;

bool buildPath(long long num, PChar& str, int& nLen, int& nScore, botState* startState, int nTimes)
{
    long long nBest = 0;
    int nMaxSteps = 0;
    long long nMax = 0;
    long long nMin = 0;
    int nCleanUpOnStep= 12;
    long long nFromLastCleanUp = 0;
    bool bInCleanUp = false;
    char cDirection = ' ';

    if (nTimes>0)
        cDirection = 'n';
    else if (nTimes<0)
    {
        cDirection = 'e';
        nTimes*=-1;
    }

    if (startState->nStep >= nCleanUpOnStep)
        nCleanUpOnStep= startState->nStep+10;

    str  = NULL;
    nLen = 0;
    botState* bestState = new botState();
    bestState->clone(startState);
    queue<botState*> queueOfStates;
    queueOfStates.push(bestState);  // put the starting state into the queue

    while (!queueOfStates.empty())       // while we still have states in the queue, process them
    {
        botState* pState = queueOfStates.front();
        queueOfStates.pop();             // take a state out of the queue

        if (!str)                        // no solution yet
        {
            if (pState->number == num)   // check if this is a solution
            {
                // we solved it!
                int nOffset=0;
                nLen = pState->nStep - nTimes + 17;
                str = new char[nLen+1];
                if (bDebugInfo)
                    printf("solved!\n");
                nScore = pState->nStep;
                for (int i=0; i<pState->path.size(); i++)
                {
                    if (pState->path.at(i)=='*')
                    {
                        sprintf(str+i, "(%c * %11d)", cDirection, nTimes);
                        if (bDebugInfo)
                            printf("(%c * %11d)", cDirection, nTimes);
                        nOffset=16;
                    }
                    else
                    {
                        str[i+nOffset] = pState->path.at(i);
                        if (bDebugInfo)
                            printf("%c", str[i+nOffset]);// print solution while making the string
                    }
                }
                if (bDebugInfo)
                    printf("\n");
                str[nLen]='\0';
            }
            else
            {                            // no solution yet, we need to go deeper
                if (pState->number < nMin)
                    nMin = pState->number;

                if (pState->number > nMax)
                    nMax = pState->number;

                if ((!bInCleanUp) && (queueOfStates.size()>1000000))
                {
                    nCleanUpOnStep=nMaxSteps+10;
                    bInCleanUp = true;
                }
                if (pState->nStep > nMaxSteps)
                {                        // a little tracing, so we can see progress
                    nMaxSteps = pState->nStep;
//                    printf("current states have %d steps, reached a max of %lld, and a min of %lld\n", nMaxSteps, nMax, nMin);
                    if (nMaxSteps >= nCleanUpOnStep)
                    {
                        nCleanUpOnStep+=10;
                        bInCleanUp = true;
                    }
                }

                if (isBetterNum(pState->number, nBest, num))
                {                        // a little tracing, so we can see progress
                    nBest = pState->number;
                    if (bDebugInfo)
                        printf("Got closer to the target, %lld, with %d steps (target is %lld, diff is %lld)\n", nBest, pState->nStep, num, num-nBest);
                    if (bestState != pState)
                        delete bestState;
                    bestState = pState;
                }

                if (!bInCleanUp)
                {
                    tryToAddStep(queueOfStates, pState, 'n', cDirection);
                    tryToAddStep(queueOfStates, pState, 'e', cDirection);

                    if (!nTimes)  // once we did the "long walk in one direction" don't do the west or south moves any more
                    {
                        tryToAddStep(queueOfStates, pState, 'w', cDirection);
                        tryToAddStep(queueOfStates, pState, 's', cDirection);
                    }
                }
            }
        }
        if (pState!=bestState)
            delete pState;                  // this is not java, we need to keep the memory clear.

        if ((bInCleanUp) && (queueOfStates.empty()))
        {
            queueOfStates.push(bestState);  // put the starting state into the queue
            bInCleanUp = false;
            long long diff = nFromLastCleanUp-bestState->number;
            if (!nTimes)
            {
                if ((diff>0) && (diff<100))
                    if (tryToJumpDown(num, bestState, nTimes))
                        cDirection = 'e';
                if ((diff<0) && (diff>-100))
                    if (tryToJumpUp(num, bestState, nTimes))
                        cDirection = 'n';

                if (nTimes)
                    nCleanUpOnStep = bestState->nStep;
            }
            nFromLastCleanUp = bestState->number;
        }
    }

    delete bestState;                  // this is not java, we need to keep the memory clear.
    return str!=NULL;
}

char* positiveSpine = "nnnesssssessssssss";
char* negativeSpine = "esssssssseessssss";

bool canReachNumber(long long num, PChar& str, int& nLen, int& nScore)
{
    int nTimes = 0;
    botState tmpState;
    if ((num>=0) && (num<=20))
        return buildPath(num, str, nLen, nScore, &tmpState, nTimes);

    botState bestState;
    bestState.clone(&tmpState);

    char* spine = NULL;
    if (num>0)
    {
        spine = positiveSpine;
    }
    else
    {
        spine = negativeSpine;
    }

    for (int i=0; spine[i]; i++)
    {
        tmpState.nStep++;
        tmpState.path.push_back(spine[i]);
        if (!changeNumberWithDirection(tmpState.number, spine[i], tmpState.nStep))
            return false;

        if ((num>0) && (tmpState.number<num))
        {
            bestState.clone(&tmpState);
        }
        else if ((num<0) && (tmpState.number>num))
        {
            bestState.clone(&tmpState);
        }
    }

    if (bestState.number == num)
        return buildPath(num, str, nLen, nScore, &bestState, nTimes);

    botState tryPath;
    tmpState.clone(&bestState);
    for (int i=0; i<9; i++)
    {
        tryPath.clone(&tmpState);
        bool pathOK = true;
        for (int j=0; j<i; j++)
        {
            tryPath.nStep++;
            tryPath.path.push_back('e');
            if (!changeNumberWithDirection(tryPath.number, 'e', tryPath.nStep))
            {
                pathOK = false;
                break;
            }
        }
        tryPath.nStep++;
        tryPath.path.push_back('s');
        if (!changeNumberWithDirection(tryPath.number, 's', tryPath.nStep))
        {
            pathOK = false;
            break;
        }

        if ((pathOK) && (isBetterNum(tryPath.number, bestState.number, num)))
        {
            bestState.clone(&tryPath);
        }
    }

    // in case we'll need to add, but last step was south, move one to the east.
    if ((bestState.path.at(bestState.path.size()-1) == 's') && (bestState.number<num))
    {
        bestState.nStep++;
        bestState.path.push_back('e');
        if (!changeNumberWithDirection(bestState.number, 'e', bestState.nStep))
            return false;
    }

    if (bestState.number<num)
    {
        long long diff = num - bestState.number;
        diff/=45;
        nTimes = (int)diff*10;
        bestState.nStep += nTimes;
        bestState.path.push_back('*');
        bestState.number += 45*diff;
        while (num - bestState.number > 10)
        {
            bestState.nStep++;
            bestState.path.push_back('n');
            if (!changeNumberWithDirection(bestState.number, 'n', bestState.nStep))
                return false;
        }
        return buildPath(num, str, nLen, nScore, &bestState, nTimes);
    }
    else
    {
        long long diff = bestState.number - num;
        diff/=45;
        nTimes = (int)diff*10;
        bestState.nStep += nTimes;
        bestState.path.push_back('*');
        bestState.number -= 45*diff;
        while (bestState.number - num > 10)
        {
            bestState.nStep++;
            bestState.path.push_back('e');
            if (!changeNumberWithDirection(bestState.number, 'e', bestState.nStep))
                return false;
        }
        return buildPath(num, str, nLen, nScore, &bestState, -nTimes);
    }

    return false;
}
long long aVals[] = {49445094, 71259604, 78284689, 163586986, 171769219, 211267178, 222235492, 249062828, 252588742, 263068669, 265657839, 328787447, 344081398, 363100288, 363644732, 372642304, 374776630, 377945535, 407245889, 467229432, 480714605, 491955034, 522126455, 532351066, 542740616, 560336635, 563636122, 606291383, 621761054, 648274119, 738259135, 738287367, 748624287, 753996071, 788868538, 801184363, 807723631, 824127368, 824182796, 833123975, 849666906, 854952292, 879834610, 890418072, 917604533, 932425141, 956158605, 957816726, 981534928, 987717553};

void main(void)
{
    upperLimit =     2147483647;       //  2^31 - 1
    lowerLimit =-1;       // -2^31
    lowerLimit *=2147483648;       // -2^31
    long long num=0;
    char* str=NULL;
    int nLen = 0;
    int nItems = sizeof(aVals)/sizeof(aVals[0]);
    int nScore = 0;
    long long nTotalScore = 0;
//  nItems=1;

    for(int i=0; i<nItems; i++)
    {
        if (canReachNumber(aVals[i], str, nLen, nScore))  //try to reach it
        {
            printf("%3d) to reach %10lld, it takes %9d steps, by doing: %s\n", i, aVals[i], nScore, str);

            nTotalScore+=nScore;
            delete str;
        }
        else
        {
            if (aVals[i]>0)
                printf("Failed to reach %lld, use nenenenenenen..... ('n', followed by %lld pairs of 'en')\n", aVals[i], aVals[i]-1);
            else
                printf("Failed to reach %lld, use enenenenenene..... ('e', followed by %lld pairs of 'ne')\n", aVals[i], aVals[i]-1);
            nTotalScore+=2*aVals[i]-1;
        }
    }

    printf("done, total score is %lld\n", nTotalScore);
    return;
}
```

Title: Manoeuvre the grid!

Body:
Briefing

You are a bot, in a 2D grid that extends infinitely in all four directions, north, south, east and west. When given a number, you must move the bot so that you get to the target number.

Here's how the grid works:

You can move in 4 directions: north, south, east or west. Once you move off a cell, you are not allowed to go back to that cell again (so effectively, it's been wiped off the map).

There is a "counter", which goes 1234567890 (so it goes from 1 to 2... all the way to 9, then to 0, then back to 1 again), which changes every time you move.

You also have a "value", which starts off at 0.

Once you move in any direction, a mathematical operation occurs, depending on what direction you move:

North: Your value is increased by counter (value += counter).

East: Your value is decremented by counter (value -= counter).

South: Your value is multiplied by counter (value *= counter).

West: Your value is divided by counter (value /= counter).

Division is integer division, so 5/2 -> 2.

You are not allowed to divide by 0.

Example:

If the bot moves north 3 times:

The first "north" move increments the counter to 1, and adds that to the value (which is now 1).

The second "north" move increments the counter to 2, and adds that to the value (which is now 3).

The third "north" move increments the counter to 3, and adds that to the value (which is now 6).

The final value is 6.

Move north, then south again:

The first "north" move increments the counter to 1, and adds that to the value (which is now 1).

The second "south" move errors, because the cell the bot is trying to move on is removed (from the first move).

There is no final value, because the bot errored.

Challenge

Your challenge is to write a program when, given a number, produce the suitable directions for the bot to go in so that the final value of the bot is equal to that number.

So if the number is 6, a valid solution to that would be:

```<code>nnn
</code>```

(The bot moves north 3 times in a row).

Your test values are:

```<code>49445094, 71259604, 78284689, 163586986, 171769219, 211267178, 222235492, 249062828, 252588742, 263068669, 265657839, 328787447, 344081398, 363100288, 363644732, 372642304, 374776630, 377945535, 407245889, 467229432, 480714605, 491955034, 522126455, 532351066, 542740616, 560336635, 563636122, 606291383, 621761054, 648274119, 738259135, 738287367, 748624287, 753996071, 788868538, 801184363, 807723631, 824127368, 824182796, 833123975, 849666906, 854952292, 879834610, 890418072, 917604533, 932425141, 956158605, 957816726, 981534928, 987717553
</code>```

(These are 50 random numbers from 1 to 1 billion.)

Your score is the total amount of moves made for all 50 numbers - the fewer moves, the better. In case of a tie, the person who submitted their code earlier wins.

Specs

You are guaranteed receive a positive integer for input.

Your value variable must not go above 2^31-1 or below -2^31 at any point for your generated paths.

Your final program must fit in an answer (so, < 30,000 bytes).

You may only hard-code 10 numbers.

Your program must run within 5 minutes on a reasonable laptop for any test case.

The results MUST be the same every time the program is run for each number.

Body:
C++: score = 453,324,048

OK, needed some time to rework this, but here's the way I solved it.

After studying the solution space, I decided that my strategy would be:

Uses the south steps to get as close to the target number

if the target is positive, follow this path: nnnesssssessssssss

if the target is negative, follow this path: esssssssseessssss
c. if the target is between 0 and 20, solve it "the old fashion way" (trail and error over every possible path til we reach it).

Once we have our "best place" (get as close to the target, without going "over"), we may be able to get closer by multiplying by 2 or 3; so take between 0 to 9 steps east, and then one step south.  keep the path that gets us the closest to the target.

"Run" north, or east til we are within 45 points of the target (every 10 steps north, add 45 points to the score, like wise, every 10 steps east, reduces the score by 45).

Take a few more steps in the same direction, til we are within 10 points of the target

Do "the old fashion way" from this point, it shouldn't be that hard now.

Here's my result: total score is 453324048

And the paths:

  0) to reach   49445094, it takes   1311037 steps, by doing: nnnesssssesssssseeeeese(n *     1311010)enen
  1) to reach   71259604, it takes   1320313 steps, by doing: nnnesssssesssssseeeeeese(n *     1320280)nnnnnneee
  2) to reach   78284689, it takes   1956998 steps, by doing: nnnesssssesssssseeeeeees(e *     1956970)eeee
  3) to reach  163586986, it takes   2483885 steps, by doing: nnnesssssessssssse(n *     2483860)nnnnnnn
  4) to reach  171769219, it takes   4302163 steps, by doing: nnnesssssessssssse(n *     4302130)nnnnnnnnnnennnn
  5) to reach  211267178, it takes  13079485 steps, by doing: nnnesssssessssssse(n *    13079460)nnnnnen
  6) to reach  222235492, it takes  15516886 steps, by doing: nnnesssssessssssse(n *    15516860)nnnnnnnn
  7) to reach  249062828, it takes  12390325 steps, by doing: nnnesssssessssssseeees(e *    12390290)eeeeenenneene
  8) to reach  252588742, it takes  11606785 steps, by doing: nnnesssssessssssseeees(e *    11606760)een
  9) to reach  263068669, it takes   9277915 steps, by doing: nnnesssssessssssseeees(e *     9277880)eeeeenennneee
 10) to reach  265657839, it takes   8702543 steps, by doing: nnnesssssessssssseeees(e *     8702510)eeeeenennee
 11) to reach  328787447, it takes   5326312 steps, by doing: nnnesssssessssssseeeese(n *     5326280)nnnnennnn
 12) to reach  344081398, it takes   8724966 steps, by doing: nnnesssssessssssseeeese(n *     8724940)enn
 13) to reach  363100288, it takes  12951386 steps, by doing: nnnesssssessssssseeeese(n *    12951360)enn
 14) to reach  363644732, it takes  13072373 steps, by doing: nnnesssssessssssseeeese(n *    13072340)nnnnnnnnen
 15) to reach  372642304, it takes  15071833 steps, by doing: nnnesssssessssssseeeese(n *    15071800)nnnnnnnenn
 16) to reach  374776630, it takes  15546133 steps, by doing: nnnesssssessssssseeeese(n *    15546100)nnnnnenene
 17) to reach  377945535, it takes  16250331 steps, by doing: nnnesssssessssssseeeese(n *    16250300)nnnnennn
 18) to reach  407245889, it takes  11107325 steps, by doing: nnnesssssessssssseeeees(e *    11107300)ne
 19) to reach  467229432, it takes   2222403 steps, by doing: nnnesssssessssssseeeeese(n *     2222370)nnnnnnnee
 20) to reach  480714605, it takes   5219109 steps, by doing: nnnesssssessssssseeeeese(n *     5219080)neenn
 21) to reach  491955034, it takes   7716983 steps, by doing: nnnesssssessssssseeeeese(n *     7716950)nnnnennnn
 22) to reach  522126455, it takes  14421745 steps, by doing: nnnesssssessssssseeeeese(n *    14421710)nnnnnneneee
 23) to reach  532351066, it takes  16693875 steps, by doing: nnnesssssessssssseeeeese(n *    16693850)n
 24) to reach  542740616, it takes  14866179 steps, by doing: nnnesssssessssssseeeeees(e *    14866150)eeeen
 25) to reach  560336635, it takes  10955953 steps, by doing: nnnesssssessssssseeeeees(e *    10955920)eeeeennen
 26) to reach  563636122, it takes  10222731 steps, by doing: nnnesssssessssssseeeeees(e *    10222700)eeeeene
 27) to reach  606291383, it takes    743785 steps, by doing: nnnesssssessssssseeeeees(e *      743760)e
 28) to reach  621761054, it takes   2693968 steps, by doing: nnnesssssessssssseeeeeese(n *     2693940)nnn
 29) to reach  648274119, it takes   8585761 steps, by doing: nnnesssssessssssseeeeeese(n *     8585730)nnnnnn
 30) to reach  738259135, it takes   5286413 steps, by doing: nnnesssssessssssseeeeeees(e *     5286380)eeneneee
 31) to reach  738287367, it takes   5280141 steps, by doing: nnnesssssessssssseeeeeees(e *     5280110)nneenn
 32) to reach  748624287, it takes   2983042 steps, by doing: nnnesssssessssssseeeeeees(e *     2983010)eeeenee
 33) to reach  753996071, it takes   1789313 steps, by doing: nnnesssssessssssseeeeeees(e *     1789280)eeeennee
 34) to reach  788868538, it takes   5960183 steps, by doing: nnnesssssessssssseeeeeeese(n *     5960150)nnenene
 35) to reach  801184363, it takes   8697033 steps, by doing: nnnesssssessssssseeeeeeese(n *     8697000)nnenene
 36) to reach  807723631, it takes  10150197 steps, by doing: nnnesssssessssssseeeeeeese(n *    10150170)n
 37) to reach  824127368, it takes  13795475 steps, by doing: nnnesssssessssssseeeeeeese(n *    13795440)nnnnnnnne
 38) to reach  824182796, it takes  13807795 steps, by doing: nnnesssssessssssseeeeeeese(n *    13807760)nnnnnenee
 39) to reach  833123975, it takes  15794722 steps, by doing: nnnesssssessssssseeeeeeese(n *    15794690)nennnn
 40) to reach  849666906, it takes  14397917 steps, by doing: nnnesssssessssssseeeeeeees(e *    14397880)eeeeeeeenee
 41) to reach  854952292, it takes  13223389 steps, by doing: nnnesssssessssssseeeeeeees(e *    13223350)eeeeeeeeneeen
 42) to reach  879834610, it takes   7693981 steps, by doing: nnnesssssessssssseeeeeeees(e *     7693950)eeenn
 43) to reach  890418072, it takes   5342102 steps, by doing: nnnesssssessssssseeeeeeees(e *     5342070)eeennn
 44) to reach  917604533, it takes    699395 steps, by doing: nnnesssssessssssseeeeeeeese(n *      699360)nnnneene
 45) to reach  932425141, it takes   3992863 steps, by doing: nnnesssssessssssseeeeeeeese(n *     3992830)nennnn
 46) to reach  956158605, it takes   9266963 steps, by doing: nnnesssssessssssseeeeeeeese(n *     9266930)nnnnen
 47) to reach  957816726, it takes   9635434 steps, by doing: nnnesssssessssssseeeeeeeese(n *     9635400)nnnennn
 48) to reach  981534928, it takes  14906145 steps, by doing: nnnesssssessssssseeeeeeeese(n *    14906110)nnnnnnnn
 49) to reach  987717553, it takes  16280059 steps, by doing: nnnesssssessssssseeeeeeeese(n *    16280030)nn

I'm sure there's a way to improve on this by doing some cleaver "south/west" moves (dividing by 4 and multiplying by 5; for example); but coding it, and making sure you don't over lap or get trapped, is tricky.

Another solution path, may be to try to go back down from the target, to a "reasonable" number, and then, just find a path to that smaller number; but you'll have to "aim" it right, so that the step number will match.  tricky, but might be the best way to solve this.

Anyway, here is my code code:

#include <stdio.h>
#include <vector>
#include <queue>;

using namespace std;

long long upperLimit;
long long lowerLimit;
bool bDebugInfo = false;
//bool bDebugInfo = true;

//  a point struct (x and y)
struct point
{
    int x;
    int y;

    point():x(0),y(0)
    {
    }

    bool operator ==(const point& other)
    {
        return (x==other.x) && (y==other.y);
    }

    void ApplyDirection(char direction)
    {
        switch (direction)
        {
        case 'n':
            y++;
            break;
        case 'w':
            x--;
            break;
        case 'e':
            x++;
            break;
        case 's':
            y--;
            break;
        }
    }
};

// each state is of this formate
struct botState
{
    int nStep;
    long long number;
    vector<char> path;

    botState()
        :nStep(0),
        number(0)
    {
    }

    botState* clone()
    {
        botState* tmp = new botState();
        tmp->nStep = nStep;
        tmp->number = number;
        tmp->path = path;
        return tmp;
    }

    void clone(botState* other)
    {
        nStep = other->nStep;
        number = other->number;
        path = other->path;
    }

};

bool changeNumberWithDirection(long long &number, char direction, int step)
{
    switch (direction)
    {
    case 'n':
        number += (step%10);
        break;
    case 'w':
        if (step%10)
            number /= (step%10);
        else
            return false;
        break;
    case 'e':
        number -= (step%10);
        break;
    case 's':
        number *= (step%10);
        break;

    default:
        return false;
    }

    return true;
}

bool tryToAddStep(queue<botState*>& queueOfStates, const botState* pState, char direction, char cStarDirection)
{
    botState* pTmpState;
    long long newNumber;
    int newStep = pState->nStep+1;

    newNumber = pState->number;
    if (!changeNumberWithDirection(newNumber, direction, newStep))
        return false;

    if (newNumber > upperLimit)
        return false;

    if (newNumber < lowerLimit)
        return false;

    if ((newNumber == 0) && (newStep%10 == 0))
        return false;                // no need to return back to 0 after 10 or more steps, we already have better ways to do this.

    // build the x,y points of the path up to this point
    point tmpPoint;
    vector<point> pointsInPath;
    pointsInPath.push_back(tmpPoint);

    for (int i=0; i<pState->path.size(); i++)
    {
        if (pState->path.at(i) == '*')
        {
            for (int j=0; j<100; j++)
            {
                tmpPoint.ApplyDirection(cStarDirection);
                pointsInPath.push_back(tmpPoint);
            }
        }
        else
        {
            tmpPoint.ApplyDirection(pState->path.at(i));
            pointsInPath.push_back(tmpPoint);
        }
    }

    tmpPoint.ApplyDirection(direction);

    // check for over lap
    for (int i=0; i<pointsInPath.size(); i++)
    {
        if (tmpPoint == (pointsInPath.at(i)))
            return false;
    }

    pTmpState = new botState();
    pTmpState->nStep = newStep;
    pTmpState->number= newNumber;
    pTmpState->path  = pState->path;

    pTmpState->path.push_back(direction);

    queueOfStates.push(pTmpState);

    return true;
}

bool isBetterNum(long long newNum, long long oldBest, long long target)
{
    long long newDiff = (newNum  > target) ? newNum  - target : target - newNum ;
    long long oldDiff = (oldBest > target) ? oldBest - target : target - oldBest;

    return (newDiff < oldDiff);
}

bool tryToJumpDown(long long num, botState* pState, int& nTimes)
{
    // if where the bot is, we have a clear path to go as far east as we could ever want, we can just do as many sets of eeeeeeeeee (e*10) as needed, til we are close enough to the target
    point tmpPoint;
    vector<point> pointsInPath;
    pointsInPath.push_back(tmpPoint);

    for (int i=0; i<pState->nStep; i++)
    {
        tmpPoint.ApplyDirection(pState->path.at(i));
        pointsInPath.push_back(tmpPoint);
    }

    for (int i=0; i<pointsInPath.size(); i++)
    {
        if ((pointsInPath.at(i).x > tmpPoint.x) && (pointsInPath.at(i).y == tmpPoint.y))
            return false;  // we have a point blocking our path up!
    }

    long long tmpTimes = (pState->number - num)/45;
    if ((tmpTimes>1) && (tmpTimes<upperLimit))
    {
        tmpTimes--;
        tmpTimes*=10;
        nTimes = (int)tmpTimes;
        pState->nStep+=nTimes;
        pState->number-=(tmpTimes/10)*45;
        pState->path.push_back('*');
        return true;
    }

    return false;
}

bool tryToJumpUp(long long num, botState* pState, int& nTimes)
{
    // if where the bot is, we have a clear path to go as far north as we could ever want, we can just do as many sets of nnnnnnnnnn (n*10) as needed, til we are close enough to the target
    point tmpPoint;
    vector<point> pointsInPath;
    pointsInPath.push_back(tmpPoint);

    for (int i=0; i<pState->nStep; i++)
    {
        tmpPoint.ApplyDirection(pState->path.at(i));
        pointsInPath.push_back(tmpPoint);
    }

    for (int i=0; i<pointsInPath.size(); i++)
    {
        if ((pointsInPath.at(i).x == tmpPoint.x) && (pointsInPath.at(i).y > tmpPoint.y))
            return false;  // we have a point blocking our path up!
    }

    long long tmpTimes = (num - pState->number)/45;
    if ((tmpTimes>1) && (tmpTimes<upperLimit))
    {
        tmpTimes--;
        tmpTimes*=10;
        nTimes = (int)tmpTimes;
        pState->nStep+=nTimes;
        pState->number+=(tmpTimes/10)*45;
        pState->path.push_back('*');
        return true;
    }

    return false;
}

typedef char* PChar;

bool buildPath(long long num, PChar& str, int& nLen, int& nScore, botState* startState, int nTimes)
{
    long long nBest = 0;
    int nMaxSteps = 0;
    long long nMax = 0;
    long long nMin = 0;
    int nCleanUpOnStep= 12;
    long long nFromLastCleanUp = 0;
    bool bInCleanUp = false;
    char cDirection = ' ';

    if (nTimes>0)
        cDirection = 'n';
    else if (nTimes<0)
    {
        cDirection = 'e';
        nTimes*=-1;
    }

    if (startState->nStep >= nCleanUpOnStep)
        nCleanUpOnStep= startState->nStep+10;

    str  = NULL;
    nLen = 0;
    botState* bestState = new botState();
    bestState->clone(startState);
    queue<botState*> queueOfStates;
    queueOfStates.push(bestState);  // put the starting state into the queue

    while (!queueOfStates.empty())       // while we still have states in the queue, process them
    {
        botState* pState = queueOfStates.front();
        queueOfStates.pop();             // take a state out of the queue

        if (!str)                        // no solution yet
        {
            if (pState->number == num)   // check if this is a solution
            {
                // we solved it!
                int nOffset=0;
                nLen = pState->nStep - nTimes + 17;
                str = new char[nLen+1];
                if (bDebugInfo)
                    printf("solved!\n");
                nScore = pState->nStep;
                for (int i=0; i<pState->path.size(); i++)
                {
                    if (pState->path.at(i)=='*')
                    {
                        sprintf(str+i, "(%c * %11d)", cDirection, nTimes);
                        if (bDebugInfo)
                            printf("(%c * %11d)", cDirection, nTimes);
                        nOffset=16;
                    }
                    else
                    {
                        str[i+nOffset] = pState->path.at(i);
                        if (bDebugInfo)
                            printf("%c", str[i+nOffset]);// print solution while making the string
                    }
                }
                if (bDebugInfo)
                    printf("\n");
                str[nLen]='\0';
            }
            else
            {                            // no solution yet, we need to go deeper
                if (pState->number < nMin)
                    nMin = pState->number;

                if (pState->number > nMax)
                    nMax = pState->number;

                if ((!bInCleanUp) && (queueOfStates.size()>1000000))
                {
                    nCleanUpOnStep=nMaxSteps+10;
                    bInCleanUp = true;
                }
                if (pState->nStep > nMaxSteps)
                {                        // a little tracing, so we can see progress
                    nMaxSteps = pState->nStep;
//                    printf("current states have %d steps, reached a max of %lld, and a min of %lld\n", nMaxSteps, nMax, nMin);
                    if (nMaxSteps >= nCleanUpOnStep)
                    {
                        nCleanUpOnStep+=10;
                        bInCleanUp = true;
                    }
                }

                if (isBetterNum(pState->number, nBest, num))
                {                        // a little tracing, so we can see progress
                    nBest = pState->number;
                    if (bDebugInfo)
                        printf("Got closer to the target, %lld, with %d steps (target is %lld, diff is %lld)\n", nBest, pState->nStep, num, num-nBest);
                    if (bestState != pState)
                        delete bestState;
                    bestState = pState;
                }

                if (!bInCleanUp)
                {
                    tryToAddStep(queueOfStates, pState, 'n', cDirection);
                    tryToAddStep(queueOfStates, pState, 'e', cDirection);

                    if (!nTimes)  // once we did the "long walk in one direction" don't do the west or south moves any more
                    {
                        tryToAddStep(queueOfStates, pState, 'w', cDirection);
                        tryToAddStep(queueOfStates, pState, 's', cDirection);
                    }
                }
            }
        }
        if (pState!=bestState)
            delete pState;                  // this is not java, we need to keep the memory clear.

        if ((bInCleanUp) && (queueOfStates.empty()))
        {
            queueOfStates.push(bestState);  // put the starting state into the queue
            bInCleanUp = false;
            long long diff = nFromLastCleanUp-bestState->number;
            if (!nTimes)
            {
                if ((diff>0) && (diff<100))
                    if (tryToJumpDown(num, bestState, nTimes))
                        cDirection = 'e';
                if ((diff<0) && (diff>-100))
                    if (tryToJumpUp(num, bestState, nTimes))
                        cDirection = 'n';

                if (nTimes)
                    nCleanUpOnStep = bestState->nStep;
            }
            nFromLastCleanUp = bestState->number;
        }
    }

    delete bestState;                  // this is not java, we need to keep the memory clear.
    return str!=NULL;
}

char* positiveSpine = "nnnesssssessssssss";
char* negativeSpine = "esssssssseessssss";

bool canReachNumber(long long num, PChar& str, int& nLen, int& nScore)
{
    int nTimes = 0;
    botState tmpState;
    if ((num>=0) && (num<=20))
        return buildPath(num, str, nLen, nScore, &tmpState, nTimes);

    botState bestState;
    bestState.clone(&tmpState);

    char* spine = NULL;
    if (num>0)
    {
        spine = positiveSpine;
    }
    else
    {
        spine = negativeSpine;
    }

    for (int i=0; spine[i]; i++)
    {
        tmpState.nStep++;
        tmpState.path.push_back(spine[i]);
        if (!changeNumberWithDirection(tmpState.number, spine[i], tmpState.nStep))
            return false;

        if ((num>0) && (tmpState.number<num))
        {
            bestState.clone(&tmpState);
        }
        else if ((num<0) && (tmpState.number>num))
        {
            bestState.clone(&tmpState);
        }
    }

    if (bestState.number == num)
        return buildPath(num, str, nLen, nScore, &bestState, nTimes);

    botState tryPath;
    tmpState.clone(&bestState);
    for (int i=0; i<9; i++)
    {
        tryPath.clone(&tmpState);
        bool pathOK = true;
        for (int j=0; j<i; j++)
        {
            tryPath.nStep++;
            tryPath.path.push_back('e');
            if (!changeNumberWithDirection(tryPath.number, 'e', tryPath.nStep))
            {
                pathOK = false;
                break;
            }
        }
        tryPath.nStep++;
        tryPath.path.push_back('s');
        if (!changeNumberWithDirection(tryPath.number, 's', tryPath.nStep))
        {
            pathOK = false;
            break;
        }

        if ((pathOK) && (isBetterNum(tryPath.number, bestState.number, num)))
        {
            bestState.clone(&tryPath);
        }
    }

    // in case we'll need to add, but last step was south, move one to the east.
    if ((bestState.path.at(bestState.path.size()-1) == 's') && (bestState.number<num))
    {
        bestState.nStep++;
        bestState.path.push_back('e');
        if (!changeNumberWithDirection(bestState.number, 'e', bestState.nStep))
            return false;
    }

    if (bestState.number<num)
    {
        long long diff = num - bestState.number;
        diff/=45;
        nTimes = (int)diff*10;
        bestState.nStep += nTimes;
        bestState.path.push_back('*');
        bestState.number += 45*diff;
        while (num - bestState.number > 10)
        {
            bestState.nStep++;
            bestState.path.push_back('n');
            if (!changeNumberWithDirection(bestState.number, 'n', bestState.nStep))
                return false;
        }
        return buildPath(num, str, nLen, nScore, &bestState, nTimes);
    }
    else
    {
        long long diff = bestState.number - num;
        diff/=45;
        nTimes = (int)diff*10;
        bestState.nStep += nTimes;
        bestState.path.push_back('*');
        bestState.number -= 45*diff;
        while (bestState.number - num > 10)
        {
            bestState.nStep++;
            bestState.path.push_back('e');
            if (!changeNumberWithDirection(bestState.number, 'e', bestState.nStep))
                return false;
        }
        return buildPath(num, str, nLen, nScore, &bestState, -nTimes);
    }

    return false;
}
long long aVals[] = {49445094, 71259604, 78284689, 163586986, 171769219, 211267178, 222235492, 249062828, 252588742, 263068669, 265657839, 328787447, 344081398, 363100288, 363644732, 372642304, 374776630, 377945535, 407245889, 467229432, 480714605, 491955034, 522126455, 532351066, 542740616, 560336635, 563636122, 606291383, 621761054, 648274119, 738259135, 738287367, 748624287, 753996071, 788868538, 801184363, 807723631, 824127368, 824182796, 833123975, 849666906, 854952292, 879834610, 890418072, 917604533, 932425141, 956158605, 957816726, 981534928, 987717553};

void main(void)
{
    upperLimit =     2147483647;       //  2^31 - 1
    lowerLimit =-1;       // -2^31
    lowerLimit *=2147483648;       // -2^31
    long long num=0;
    char* str=NULL;
    int nLen = 0;
    int nItems = sizeof(aVals)/sizeof(aVals[0]);
    int nScore = 0;
    long long nTotalScore = 0;
//  nItems=1;

    for(int i=0; i<nItems; i++)
    {
        if (canReachNumber(aVals[i], str, nLen, nScore))  //try to reach it
        {
            printf("%3d) to reach %10lld, it takes %9d steps, by doing: %s\n", i, aVals[i], nScore, str);

            nTotalScore+=nScore;
            delete str;
        }
        else
        {
            if (aVals[i]>0)
                printf("Failed to reach %lld, use nenenenenenen..... ('n', followed by %lld pairs of 'en')\n", aVals[i], aVals[i]-1);
            else
                printf("Failed to reach %lld, use enenenenenene..... ('e', followed by %lld pairs of 'ne')\n", aVals[i], aVals[i]-1);
            nTotalScore+=2*aVals[i]-1;
        }
    }

    printf("done, total score is %lld\n", nTotalScore);
    return;
}


答:
PHP, 113 bytes

```<code>function h($a){foreach($a as&$b)$b=count($b)+12*in_array(0,$b);if(max($a)>25)foreach($a as&$n)$n=26-$n;return$a;}
</code>```

function takes an array of arrays, returns an array of values.

Marvel the other array mapping in PHP: loops with referenced items. Waaay shorter than array_map.

Title: Score a hand of Hearts

Body:
PHP, 113 bytes

function h($a){foreach($a as&$b)$b=count($b)+12*in_array(0,$b);if(max($a)>25)foreach($a as&$n)$n=26-$n;return$a;}

function takes an array of arrays, returns an array of values.

Marvel the other array mapping in PHP: loops with referenced items. Waaay shorter than array_map.


答:
Octave, 21 bytes, 10 numbers, by Stewie Griffin

The fpr was a nice misguidance=)  But I love the (1') -> 2(1') -> 2+(1') sequence!

```<code>original:
disp(fpr___f__e_(_'_)     % original
disp(fprintf= e=(1'))     % my solution
disp(fprintf= e=2(1'))
disp(fprintf= e=2+(1'))
disp(fprintf= e=3+(1'))
disp(fprintf= e=4+(1'))
disp(fprintf= e=5+(1'))
disp(fprintf= e=6+(1'))
disp(fprintf= e=7+(1'))
disp(fprintf= e=8+(1'))
disp(fprintf= e=9+(1'))
</code>```

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:
Octave, 21 bytes, 10 numbers, by Stewie Griffin

The fpr was a nice misguidance=)  But I love the (1') -> 2(1') -> 2+(1') sequence!

original:
disp(fpr___f__e_(_'_)     % original
disp(fprintf= e=(1'))     % my solution
disp(fprintf= e=2(1'))
disp(fprintf= e=2+(1'))
disp(fprintf= e=3+(1'))
disp(fprintf= e=4+(1'))
disp(fprintf= e=5+(1'))
disp(fprintf= e=6+(1'))
disp(fprintf= e=7+(1'))
disp(fprintf= e=8+(1'))
disp(fprintf= e=9+(1'))


Title: Code ladder, Cops

Body:
Java 10+ numbers 126 tokens

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

_ is redacted