text:
Binary Countdown Length
inspired by Count down from infinity
Given a non-negative integer N, output the number of repetitions of the following steps it takes to reach 0:

Convert N to binary (4812390 -> 10010010110111001100110)
Flip each bit (10010010110111001100110 -> 01101101001000110011001)
Trim leading zeroes (01101101001000110011001 -> 1101101001000110011001)
Convert back to decimal (1101101001000110011001 -> 3576217)

Rules

Input and output may be in any unambiguous, consistent format
The input will be within the native representable integer range for your language (if your language supports arbitrarily-large integers, there is no bound)

Test Cases
0 -> 0
1 -> 1
42 -> 6
97 -> 3
170 -> 8
255 -> 1
682 -> 10
8675309 -> 11
4812390 -> 14
178956970 -> 28
2863311530 -> 32

This sequence is A005811 in the OEIS.

Step 3 is of no use at all

@edc65 Seems like you could do either step 3 or step 4, depending on how your algorithm is laid out

@edc65 Maybe for you it is of no use. A simple inverse operator doesn't trim leading zeros for you. ~(~a) == a

@Poke Bitwise NOT inverts all bits of the binary representation, including leading zeroes (and an infinite amount of them in languages with arbitrary precision integers). This is not equivalent to step 2.

@Poke A simple inverse operation is different from applying the steps 1..4. If you want to apply these steps, the step 3 is of no use, because the flip in step 2 (as it is shown) does not change the leading 0s. If the step 2 does change the leading 0s to leading 1s, then obviuosly you have to remove the leading 1s in step 3, not the leading 0s

Got it. I still wouldn't say that step 3 is of no use. It's more that the steps seem inconsistent with the examples for each step.

Jelly, 6 4 bytes
^HBS

Try it online! or verify all test cases.
Background
Let n be a non-negative integer.
Steps 2 and 3 of the process described in the spec can alternatively be stated as removing all leading 1's and toggling the remaining bits.
This means that we'll remove exactly one group of adjacent and equal binary digits in each iteration, so the Binary Countdown Length of n is just the number of these groups in the binary representation of n. For the purposes of this challenge, think of 0 as having no digits.
For n = 8675309, the process looks as follows in binary.
100001000101111111101101
 11110111010000000010010
     1000101111111101101
      111010000000010010
         101111111101101
          10000000010010
           1111111101101
                   10010
                    1101
                      10
                       1
                       0

Instead of counting these groups (which would fail for edge case 0), we do the following.
n and n:2 have the following binary representations.
n   = 8675309 = 100001000101111111101101_2
n:2 = 4337654 =  10000100010111111110110_2

Note that n:2's binary representation is simply n's, shifted one bit to the left.
If we XOR n and n:2, we'll obtain a 1 (MSB), and an additional 1 for each pair of different adjacent digits. The number of groups is thus equal to the number of set bits in n ⊻ n:2.
How it works
^HBS  Main link. Argument: n

 H    Halve; yield n:2.
^     XOR n with n:2.
  B   Convert the result to binary.
   S  Compute the sum of the resulting binary digits.

Amazing! A totally different reasoning

Python 2, 30 bytes
lambda n:bin(n^n/2).count('1')

Test it on Ideone.
Background
Let n be a non-negative integer.
Steps 2 and 3 of the process described in the spec can alternatively be stated as removing all leading 1's and toggling the remaining bits.
This means that we'll remove exactly one group of adjacent and equal binary digits in each iteration, so the Binary Countdown Length of n is just the number of these groups in the binary representation of n. For the purposes of this challenge, think of 0 as having no digits.
For n = 8675309, the process looks as follows in binary.
100001000101111111101101
 11110111010000000010010
     1000101111111101101
      111010000000010010
         101111111101101
          10000000010010
           1111111101101
                   10010
                    1101
                      10
                       1
                       0

Instead of counting these groups (which would fail for edge case 0), we do the following.
n and n:2 have the following binary representations.
n   = 8675309 = 100001000101111111101101_2
n:2 = 4337654 =  10000100010111111110110_2

Note that n:2's binary representation is simply n's, shifted one bit to the left.
If we XOR n and n:2, we'll obtain a 1 (MSB), and an additional 1 for each pair of different adjacent digits. The number of groups is thus equal to the number of set bits in n ⊻ n:2.

Python 2, 29 bytes
f=lambda n:n and-n%4/2+f(n/2)

Counts the number of alternations between 0 and 1 in the binary expansion, counting the leading 1 as an alternation. Does so by checking whether the last two binary digits are different, then recursing onto the number with the last digit removed. The last two digits are different exactly if n%4 is 1 or 2, which can be checked as -n%4/2.

Haskell, 34 bytes
b 0=0
b n|x<-b$div n 2=x+mod(x+n)2

I like how it says "0=0" :)

JavaScript (ES6), 26 bytes
f=n=>n&&(n^(n>>=1))%2+f(n)

Works by counting the transitions between 0 and 1. Only works up to 31 bits. 29 bytes to support 53 bits:
f=n=>1<=n&&(n%2^n/2%2)+f(n/2)

05AB1E, 7 5 bytes
Saved 2 bytes thanks to Dennis.
b0ÛÔg

Without the edge case of 0 this could be 3 bytes bÔg.
Try it online! or as a Test suite
Explanation
b      # convert to binary
 0Û    # trim off leading zeroes
   Ô   # remove adjacent duplicates
    g  # length

Alternatively: ;^bSO

CJam, 14 bytes
ri0{2b:!2bj)}j

Try it online!
ri      e# read integer
0       e# value for terminal case
{       e# recursive function
  2b    e#   create binary representation with no leading zeros
  :!    e#   flip bits
  2b    e#   convert binary back to integer
  j     e#   recursive call
  )     e#   increment from 0 on the way up
}j      e# end

Basically a knock off of my answer to the other question.

Java 7,112 108 100 90 73 bytes
int c(int i){int l=1,j=i;for(;(j=j/2)>0;l*=2);return i<1?0:1+c(2*l-1-i);}

Basic idea
 Lets take an no 10110(21)
 then you do set all bits in no 21 and you will get 11111
 and after that you would subtract the original number from 11111.
 You will get 01001 and loop it until you will get 0

j=j/2 can be shortened to j/=2. Apart from that a great answer!

Hmm.. a port from @Neil's JavaScript answer is shorter though: int c(int i){return i>0?((i^(i>>=1))%2+c(i):0;} (47 bytes). I would still leave your current answer as well though, since it's more original, and ports from other users are the complete opposite of original. :)

J, 14 bytes
**1+/@,2~:/\#:

Counts the number of runs in the binary digits of n with the special case returning 0 for n = 0.
Usage
   f =: **1+/@,2~:/\#:
   (,.f"0) 0 1 42 97 170 255 682 8675309 4812390 178956970 2863311530
         0  0
         1  1
        42  6
        97  3
       170  8
       255  1
       682 10
   8675309 11
   4812390 14
 178956970 28
2863311530 32

Explanation
**1+/@,2~:/\#:  Input: integer n
            #:  Get the binary digits of n
       2   \    For each overlapping sublist of size 2
        ~:/       Reduce by not-equals
  1   ,         Prepend a 1
   +/@          Reduce by addition
*               Sign(n), returns 0 for n = 0 else 1
 *              Multiply with the previous sum and return

CJam, 11 10 bytes
Thanks to @Dennis for saving one byte!
ri_2be`,e&

Try it online!
Explanation
ri            #e Read as integer
              #e STACK: 97
  _           #e Duplicate
              #e STACK: 97, 97
   2b         #e Convert to binary
              #e STACK: 97, [1 1 0 0 0 0 1]
     e`       #e Run-length encoding
              #e STACK: 97, [[2 1] [4 0] [1 1]]
       ,      #e Length
              #e STACK: 97, 3
        e&    #e Return first value if 0, or else the second value
              #e STACK: 3

e& (logical AND) saves a byte over \g*.

@Dennis Thanks! It's handy how CJam's logical AND works, I had no idea

Racket 349 bytes
(define(h s)(apply string(map(λ(x)(if(eq? x #\0)#\1 #\0))(string->list s))))(define(g s)(let*
((l(string-length s))(k(for/list((i s)(n l)#:final(not(equal? i #\0)))n)))(substring s(last k))))
(define(f n)(if(= 0 n)0(begin(let loop((n n)(c 1))(define m(string->number(string-append "#b"
(g(h(number->string n 2))))))(if(> m 0)(loop m(add1 c))c))))

Ungolfed:
(define (invertBinary s)
  (apply string
         (map
          (λ(x)(if(eq? x #\0)#\1 #\0))
          (string->list s))))

(define (trimLeading0s s)
  (let* ((l (string-length s))
         (k (for/list ((i s)
                       (n l)
                       #:final (not(equal? i #\0)))
              n)))
    (substring s (last k))))

(define (f n)
  (if (= 0 n) 0
      (begin
        (let loop ((n n)
                   (c 1))
          (define m
            (string->number
             (string-append
              "#b"
              (trimLeading0s
               (invertBinary
                (number->string n 2))))))

          (if (> m 0)
              (loop m (add1 c))
              c)))))

Testing:
(f 0)
(f 1)
(f 42)
(f 97)
(f 170)
(f 255)
(f 682)
(f 8675309)
(f 4812390)
(f 178956970)
(f 2863311530)

Output:
0
1
6
3
8
1
10
11
14
28
32

You can save 2 bytes by changing tl and ib to 1-byte names.

Done. Thanks for the suggestion.

MATL, 7 bytes
BY'nwa*

Try it online!
Explanation
          % Implicit input, for example 97
          % STACK: 97
B         % Convert to binary
          % STACK: [1 1 0 0 0 0 1]
 Y'       % Run-length encoding
          % STACK: [1 0 1], [2 4 1]
   n      % Number of elements
          % STACK: [1 0 1], 3
    w     % Swap
          % STACK: 3, [1 0 1]
     a    % Any: gives 1 if any element is nonzero
          % STACK: 3, 1
      *   % Multiply
          % STACK: 3
          % Implicit display

Vim, 62 59 bytes
-3 bytes thanks to DJMcMayhem
C0
<C-r>=pri<Tab>'%b',<C-r>")
<Esc>0qqC<C-r>=tr(@",'01','10')
<Esc>:s/^0\+
k<C-a>j@qq@q

Here is the xxd output with the unprintable characters intact:
0000000: 4330 0d12 3d70 7269 0927 2562 272c 1222  C0..=pri.'%b',."
0000010: 290d 1b30 7171 4312 3d74 7228 4022 2c27  )..0qqC.=tr(@",'
0000020: 3031 272c 2731 3027 290d 1b3a 732f 5e30  01','10')..:s/^0
0000030: 5c2b 0d6b 016a 4071 7140 71              \+.k.j@qq@q

Try it online!
Explanation
C                                   " Delete the number (it goes in @")
0<CR>                               " Print 0 (our counter) and a carriage return
<C-r>=pri<Tab>'%b',<C-r>")<CR><Esc> " Use `printf()` to insert the number as base 2
0qq                                 " Return to column 0, start recording a macro
  C<C-r>=tr(@",'01','10')<CR><Esc>  "   Replace 0s with 1s and vice versa
  :s/^0\+<CR>                       "   Delete leading 0s
  k<C-a>                            "   Increment the number on the line above
  j                                 "   Return to the previous line
  @q                                "   Invoke macro recursively
q@q                                 " Stop recording and invoke macro

Nice! Some tips: :s/^0* is one byte shorter than :s/^0\+, and while you are in the "eval" register, you can just do pr<S-tab>'%b',<C-r>") for autocomplete. (Saves 4 bytes)

Oh, thanks for the autocomplete tip! I can't use :s/^0* because it matches an empty line, and I need it to fail for empty an empty line to escape the recursive macro.

Burlesque, 8 bytes
rib2gnL[

Try it online!
ri   # Read as integer
b2   # Convert to binary
gn   # Collapse like bits
L[   # Find length

29 bytes
ri0j{j+.j2dg)n!2ug}{^^nz}w!vv

Try it online!
Actually doing the calculation
ri       #Read val as int
0j       #Push a 0 (counter) to the bottom of the stack
{
 j+.j    # Increment counter and put back
 2dg     # Get the digits of binary val
 )n!     # Not each digit
 2ug     # Convert back to decimal
}
{^^nz}w! # While not zero
vv       # Drop final zero leaving counter

Ruby, 26 bytes
f=->n{n<1?0:-n%4/2+f[n/2]}

Inspired by xnor's Python answer.

Vyxal 3 s, 3 bytes
½⊻b

Try it Online!
port of the jelly answer

Go, 172 bytes
import(."fmt";."strings")
func f(n uint)(i int){for;n>0;i++{Sscanf(Map(func(r rune)rune{if r<'1'{return'1'}else{return'0'}},TrimLeft(Sprintf("%b",n),"0")),"%b",&n)}
return}

Attempt This Online!
Implements the algorithm more or less verbatim from the OP.

C (gcc), 76 Bytes, 72 Bytes (thanks to celingcat)
unsigned n,m,i;f(x){for(i=0;n=x;x^=m-1,i++)for(m=2;n/=2;m+=m);return i;}

Try it online!

Java 7, 64 bytes
long g(Long n){return n.toString(n,2).split("0+").length*2-n%2;}

I know this could be beaten by a port of one of the better answers, but I came up with it in chat, and I can't not post it after Poke said something about it :)

PHP, 64 bytes
based on my countdown solution
for($n=$argv[1];$n;print 1)$n=bindec(strtr(decbin($n),"01",10));

prints 1 character k times, where k is the number of iterations.

+4 bytes for integer output: (empty output for 0)
for($n=$argv[1];$n;$i++)$n=bindec(strtr(decbin($n),"01",10));echo$i;

JavaScript (ES6), 44
Recursive function
Limited to javascript positive integer, 31 bits:
f=(a,s=0)=>a?f((-1>>>Math.clz32(a))-a,s+1):s

Managing double precision number up to 53 significant bits - 59 bytes:
F=(a,s=0)=>a?F('0b'+a.toString(2).replace(/./g,1)-a,s+1):s

In another way: using the amazing algorithm by @Dennis, non recursive function managing up 53 bits, 43 bytes:
a=>a&&a.toString(2).match(/(.)\1*/g).length

PHP, 51 bytes
<?=preg_match_all('/(1+|0+)/',decbin($argv[1])?:o);

Uses a regex to count the number of runs of 1 or 0. Unfortunately this needs a special case for input of 0 that requires 3 additional bytes (and gives a notice).

a) Use a digit >1 instead of o to avoid the notice. b) You can save 3 bytes with the -F flag and $argn instead of $argv[1]. c) /1+|0+/ should suffice for the regex.

Java 7, 71 bytes
int b(Long a){return a==0?0:1+b(~a&-1L>>>64-a.toString(a,2).length());}
I know this is beaten by Geobits' split solution (which will eventually be posted) but this was still fun to write

Octave, 47 bytes
@(x)(sum(dec2bin(bitxor(x,idivide(x,2)))=='1'))

According to the OEIS entry, the value we are looking for as the solution to this challenge is also equal to the number of 1s in the Gray code for the given integer.
Wikipedia tells me the Gray code can be calculated as x ^ (x >> 1), so in the above function I calculate the Gray code as such, convert it to a binary string, and count how many digits of that string are 1.

Tcl, 119 bytes
proc D n i\ 0 {
while \$n {set n [regsub ^0+(?=.) [string map {0 1 1 0} [format %b $n]] ""]
incr i
scan $n %b n}
set i}

Try it online!
Still very ungolfed for my taste

Bash, 57 bytes
Packages: Core Utililities, grep, sed, vim (for xxd)
Assume the number is given in binary format. Any length is acceptable :)
xxd -b -c1|cut -d" " -f2|sed s/^0*//|grep -o .|uniq|wc -l

Perl 5, 31 + 1 (p) = 32 bytes
$_=(sprintf'%b',$_^$_/2)=~y/1//

Try it online!
Using @Dennis's method.

APL, 13 characters/bytes
+/2≠/0,2⊥⍣¯1⊢

base 10 to base 2 conversion with all necessary digits
2⊥⍣¯1⊢

2⊥⍣¯1⊢4812390
---> 1 0 0 1 0 0 1 0 1 1 0 1 1 1 0 0 1 1 0 0 1 1 0

add a leading 0
0,

0,1 0 0 1 0 0 1 0 1 1 0 1 1 1 0 0 1 1 0 0 1 1 0
---> 0 1 0 0 1 0 0 1 0 1 1 0 1 1 1 0 0 1 1 0 0 1 1 0

pair-wise reduction that gives 1 if consecutive elements are not equal
2≠/

2≠/0 1 0 0 1 0 0 1 0 1 1 0 1 1 1 0 0 1 1 0 0 1 1 0
---> 1 1 0 1 1 0 1 1 1 0 1 1 0 0 1 0 1 0 1 0 1 0 1

sum
+/

+/1 1 0 1 1 0 1 1 1 0 1 1 0 0 1 0 1 0 1 0 1 0 1
---> 14

PHP, 55 52 bytes
for($i=$argn;$i;$c++,$i^=(1<<log($i,2)+1)-1);echo$c;

Try it online!
All done arithmetically/bitwise (no strings).  Am stuck getting it smaller than the 51 byte answer though...

PHP, 50 bytes
<?=array_sum(str_split(decbin($argn&-2^$argn*2)));

Try it online!
Unfortunately, really don't think I can get it any more golfed than this!
The idea is to count transitions 1->0 or 0->1.

Husk, 6 bytes
ΣẊ≠:0ḋ

Try it online!
Algorithm from Popov's APL answer.
Husk, 9 bytes
←LU¡ȯḋm¬ḋ

Try it online!
The approach shown in the question.
Explanation
←LU¡ȯḋm¬ḋ
   ¡      apply function pinfinitely, collecting results
    ȯ     composition of three function
        ḋ convert to binary digits
      m¬  negate each bit
     ḋ    convert back to base-10
  U       split infinite list at first non-unique value
 L        get the length of the list
←         decrement


text:
Primes with a twist
Note: this is heavily inspired by this question.
Task:
Your task is to generate the nth prime, when each character of your program is repeated n times in place.
Let's say your program is:
Derp

Every character in there is repeated once, so it should output 2.
When every character is duplicated in place, like so:
DDeerrpp

This should generate the 2nd prime, which is 3.
Specs:

Your program must accept no input, and output the respective prime.
Your program must work for all primes, given enough time and memory.
Leading and trailing newlines are fine.
The output must be in the default base of the language - if there is no default, any base is fine.

This is code-golf, so shortest code in bytes wins.

Does Your program must work for all primes, given enough time and memory. mean I cannot use, e.g, int in C?

Jelly, 13 bytes
“Ŀo‘’FQỌµḟ;¹V

Try it online! or run the first ten programs.
Background
Jelly has several different types of string literals; all of them start with a “. If the literal contains more than one “, a string array is returned, and “ separates the strings from each other.
For example, “abc“def” yields ['abc', 'def'].
Depending on the last character of the literal (any of ”«»‘’, where « is currently unimplemented), one can choose between the different types of literals. For ‘, we get the code points in Jelly's code page instead of the corresponding Unicode characters.
For example, “abc“def‘ yields [[97, 98, 99], [100, 101, 102]].
The literals in the first three programs correspond to the following code point arrays.
“Ŀo‘           -> [199, 111]
““ĿĿoo‘        -> [[], [199, 199, 111, 111]]
“““ĿĿĿooo‘     -> [[], [], [199, 199, 199, 111, 111, 111]]

How it works (n = 3)
“““ĿĿĿooo‘‘‘’’’FFFQQQỌỌỌµµµḟḟḟ;;;¹¹¹VVV  Main link. Implicit argument: 0

“““ĿĿĿooo‘                               Yield the 2D array
                                         [[], [], [199, 199, 199, 111, 111, 111]].
          ‘‘                             Increment twice, yielding
                                         [[], [], [201, 201, 201, 113, 113, 113]].
            ’’’                          Decrement thrice, yielding
                                         [[], [], [198, 198, 198, 110, 110, 110]].
               F                         Flatten, yielding
                                         [198, 198, 198, 110, 110, 110].
                FF                       Twice more. Does nothing.
                  Q                      Unique; yield [198, 110].
                   QQ                    Twice more. Does nothing.
                     Ọ                   Unordinal; convert the Unicode code points
                                         198 and 110 to 'Æ' and 'n'.
                      ỌỌ                 Twice more. Does nothing.
                        µµµ              Begin three monadic chains, all with
                                         argument s := "Æn".
                           ḟ             Filter-false; remove the characters of s
                                         from s, yielding "".
                            ḟḟ           Twice more. Does nothing.
                              ;;;¹       Concatenate with s three times, yielding
                                         "ÆnÆnÆn".
                                  ¹¹     Identity function. Does nothing.
                                    V    Eval the resulting Jelly code, i.e.,
                                         call the next-prime atom thrice, with
                                         initial implicit argument 0.
                                     VV  Eval two more times. This is a no-op
                                         on integers.

This definitely is in need of an explanation... and depending on how it's laid out, it might be the only language that can do this?

What... how? That is simply way too quick.

@ValueInk I've edited my answer.

GS2 (commit 67fea47), 6 3 bytes
dnR

How it works
Like most commands, GS2‘s d is overloaded. Initially, there's an empty list (the input or the lack thereof) on the stack, so d computes its sum. After the first iteration, there's a 0 on the stack, and d computes its parity (also 0). Thus, no matter how many times we repeat d, the result will always be a single 0.
The next part is straightforward. The command n pops the top of the stack and pushes the next prime number. Thus, repeating n k times computes the k prime.
Finally, the command simply applies str to the top of the stack, which converts a number to its string representation and does no affect strings. Thus, no matter how many times we repeat R, the result will be the string representation of the k prime.

what on earth!?

Do Not Resuscitate

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Square-unspiral the string!
Given a string, first square it as follows:
First, write the string.
abcde

Next, write the string rotated one left.
abcde
bcdea

Keep doing this until you have written len(string) lines.
abcde
bcdea
cdeab
deabc
eabcd

Now, read from the string like this:
----+
+--+|
|+>||
|+-+|
+---+

Which gives:
abcdeabcdcbaedcbcdeabaede

Print this string.
Test cases
abcdef -> abcdefabcdedcbafedcbcdefabcbafedefaf
cena! -> cena!cenanec!anena!cec!a!
ppcg -> ppcgppcppgcpcgpg
abc -> abcabacbc
ab -> abab
a -> a
 ->

Please comment if a test case is incorrect.
Remember, this is code-golf, so the code with the smallest number of bytes wins.

cena! is wrong. It should match your example with abcde since both are 5 letters: cena!cenanec!anena!cec!a!

@Linus Thank you, I have fixed it.

JavaScript (ES7), 83 80 78 77 bytes
s=>s.repeat(l=s.length).replace(/./g,_=>s[(c-=--i**.5-l&1||-1)%l],c=-1,i=l*l)

Bonus ES3-compliant program:
for(s=prompt(r=""),c=-1,l=s.length,i=l*l;i;)r+=s[(c-=l-Math.sqrt(i--)&1||-1)%l];alert(r)

Explanation
This takes advantage of the fact that the output for e.g. a length 5 string can be represented as:
abcdeabcd cbaedcb cdeab aed e
012345678 7654321 23456 543 4

where each digit represents an index in the string (starting at 0), modulo the length of the string. In other words, if n is the length of the string, we increment the index 2n - 1 times, then decrement it 2(n - 1) - 1 times, then increment it 2(n - 2) - 1 times, etc. This can be simplified to the following algorithm:

Start the index i at -1.
For each integer x in the range [n2..1]:

If floor(sqrt(x)) is of the same parity (even/odd) as n, increment i.
Otherwise, decrement i.
Add the character at index i mod n to the output.

This works because floor(sqrt(x)) switches parities after 2n - 1 iterations, then 2(n - 1) - 1 iterations, etc.

Rediculous. Good Job!

Pyth, 15 bytes
.Wp.(H0_CZ.<LQU

A program that takes input of a "quoted string" and prints the result.
Try it online! or verify all test cases (modified for multiple input).
How it works
.Wp.(H0_CZ.<LQU  Program. Input: Q
            L U  Map over [0, 1, 2, 3, ..., Q-1] (implicit input):
          .< Q     Q left-shifted by that many characters
                 Call this X
.W               While
   .(H0          popping the first element of X (mutates X in-place)
  p              and printing it with no trailing newline is truthy:
         Z           X =
        C            X transposed
       _             reversed

Jelly, 11 10 bytes
ẋ2µṖȮṖUµÐL

TryItOnline!, or all tests
How?
The unspiralled square is a series of "top-edge plus right-edge" and "bottom-edge plus left-edge" runs, each of which is the  reverse of the previous run without the first and last letter, and the first of which is the input plus the input without the last letter (e.g. input "abcde" has an output of "abcdeabcd" + "cbaedcb" + "cdeab" + "aed" + "e").
ẋ2µṖȮṖUµÐL - Main link: s                            e.g. abcde
ẋ2         - repeat s twice                          e.g. abcdeabcde
  µ    µ   - monadic chain separation
        ÐL - repeat until results are no longer unique:
   Ṗ       -     remove the last character                abcdeabcd / cbaedcb / cdeab / aed / e   / ""
    Ȯ      -     print z (with no linefeed) and return z
     Ṗ     -     remove the last character                abcdeabc  / cbaedc  / cdea  / ae  / ""  / ""
      U    -     reverse                                  cbaedcba  / cdeabc  / aedc  / ea  / ""  / "" <- no longer unique.

05AB1E, 12 bytes
2×[DõQ#¨D?¨R

Try it online!
Explanation:
 2×[DõQ#¨D?¨R
               # Implicit input
 2×            # Repeat twice
   [           # Begin infinite loop
┏>  DõQ#       # If empty string, break
┃       ¨      # Remove last character
┃        D     # Duplicate
┃         ?    # Print with no newline and pop
┃          ¨   # Remove last character
┃           R  # Reverse
┗━━━━━━━━━━━━┛ # Implicit end infinite loop

Python 2.7 (in CMD.EXE), 91 bytes
This requires a terminal with a working backspace(\b), and will not work on repl.it or ideone.com. A print statement ending in a comma separates further output with space instead of a newline or return. The backspace allows us to overwrite the separating space.

s=input();r=s[::-1];n=len(s)-1;i=0
while i<=n:print'\b'+s[i:]+s[:n-i]+r[i+2:]+r[:n-i],;i+=2

Python 2.7, 96 bytes
Try it on ideone.com or repl.it (thanks to Oliver). Input must be a python string, e.g.'cena!'.

s=input();r=s[::-1];n=len(s)-1;i=0;S=''
while i<=n:S+=s[i:]+s[:n-i]+r[i+2:]+r[:n-i];i+=2
print S

The four slices appended by the loop (s[i:],s[:n-i],r[i+2:],r[:n-i]) are taken from four edges of the spiral. For instance with 01234 the square is:
01234
12340
23401
34012
40123

So we take 01234,0123,210,4321. The variable i is the index of the top-left value in each step of the process. In the final spiral several of the slices may be empty.

It's probably not the only save, but by changing to Python 3, getting rid of the S='', print S, and S+=, and wrapping everything before the i+=2 in a print() statement with sep='', you can save 2 bytes.

@Shebang I'm not following right off. Feel free to add a python 3 answer yourself.

You can change i<=n to n>i

It saves a byte.

@Oliver, Thanks... but it does not work for "a string of odd length."

@Oliver No, it would be n>=i, since the equality case must be kept.

Perl, 99 bytes
$_=<>;
chop;
@a=split//;
print(@a[$%,(@f=1-($b=@a-$%)..$b-3),$b-1?$b-2:(),reverse@f]),$%+=2 until$%>@a

Whitespace is not part of the program and is provided for readability.
Not extremely efficient code.  I should be able to shorten the first three lines somehow, but everything I tried to do failed.  That ternary operator also needs to be fixed somehow, but having it this way made it possible to shorten my code by like, 10 bytes because I could cut out so much.
The code works by compiling a list of palindromes, separated by even numbers, which represent the place values of the string to be pulled.

You can use -F  which will replace line 1 and 3. Give the input with echo -n to remove the chop. (that should get you around 81 bytes)

Actually, 21 13 bytes
This algorithm is largely based on Jonathan Allan's Jelly answer. There are two ways to go about printing the result as one string. The approach used here duplicates an intermediate step and then adds it to a running total in register 1 (an empty string by default); ;╕ in the function, then ╛ at the end. The other approach is to duplicate an intermediate step, leave those duplicate steps on the stack, and sum them into one string at the end; ; in the function, then kΣ at the end.
Golfing suggestions welcome. Try it online!
2*`dX;╕dXR`Y╛

Ungolfing
         Implicit input s.
2*       Push a string that repeats s two times.
`...`Y   Call the following function until there is no change from the last call
  dX       Discard the last element. Call this new string m.
  ;╕       Duplicate m and add it to the running total in register 1.
  dXR      Discard the last element again and reverse the string.
╛        Push the unspiralled string from register 1 to the stack.
         Implicit return.

C, 95 94 Bytes
i,j,k,l;f(char*s){for(k=-1,l=i=strlen(s);i--;)for(j=i*2;~j--;putchar(s[(k+=(l-i)%2*2-1)%l]));}

Inspired by @ETHproductions answer.

Suggest l-i&1?1:-1 instead of (l-i)%2*2-1

MATL, 27 bytes
"GX@q_YS]vGn1YL_GnoQ&Ple&S)

The empty input exits with an error (producing the correct output).
Try it online! Or verify all test cases.

Python 3, 59 bytes
x=input()*2
while x:x=x[:-1];print(x,end='');x=x[:-1][::-1]

repl.it
A direct port of my Jelly answer; only a full program taking input (rather than a function).
The print(x,end='') is a print statement which will not print the default newline.

Python 3, 93 bytes
s=input();r,n,i=s[::-1],len(s)-1,0
while n-i:print(s[i:]+s[:n-i]+r[i+2:]+r[:n-i],end='');i+=2

Try it online!

Rather than print(...,end=''), do print(end=s[i:]+s[:n-i]+r[i+2:]+r[:n-i]

Anyway, this solution doesn't work for abcde, it's missing an e at the end.

Try i<=n instead of n-i for your condition.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
What degree is this palindrome?
Your task is to determine the palindromic degree of a given non-empty string.
To do this, loop until one of the following conditions are met:

The string is not a palindrome.
You encounter a string that has already been encountered.

And do the following:

If it is a palindrome, add one to the degree.
Depalindromize.

For example, if I had the string babababab, the calculation would go:
babababab     1
babab         2
bab           3
ba

For the string zzzzz, it would go:
zzzzz         1
zzz           2
zz            3
z             4
z

Test cases
abc 0
cenea 0
pappap 2
aa 2
aba 1
aaa 3
cccc 3
zzzzz 4

Explanation:
abc : 0
cenea : 0
pappap -> pap -> pa : 2
aa -> a -> a : 2
aba -> ab : 1
aaa -> aa -> a -> a: 3
cccc -> cc -> c -> c: 3
zzzzz -> zzz -> zz -> z -> z : 4

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

To be clear, the unpalindromize a string, you take half of it, including the center if the original had odd length?

@xnor Yes.-----

This gives a loop once you get down to length 1, since those un-palindromize to themselves. You should make explicit if you define them to have degree 1.

Also, I don't understand the test cases. How do you get cenea -> 1? zzzzz -> 4? You really should iron these things out in the sandbox.

zzzzz → zzz → zz → z so 4 is correct but cenea obviously wrong

I have clarified the question.

Can the input be the empty string? Looks clear otherwise. I'd suggest the test cases be just the input and outputs for easy copy-pasting, with the derivations shown separately.

Can you include a longer 1-palindrome (e.g. abcdedcba)?

no restriction on how input is provided?

@ardnew Nope.--

Perl, 53 bytes
52 bytes of code + 1 byte for -p.
$\++while s/^((.+).?)(??{reverse$2})$/$1/||s/^.$//}{

To run it :
perl -pE '$\++while s/^((.+).?)(??{reverse$2})$/$1/||s/^.$//}{' <<< "zzzzz"

Jelly, 11 9 bytes
ŒHḢ$ƬUƑƤS

Try it online!
-2 bytes thanks to Unrelated String!
How it works
ŒHḢ$ƬUƑƤS - Main link. Takes a string S on the left
   $Ƭ     - Until reaching a previously encountered string:
ŒH        -   Split into halves
  Ḣ       -   Take the first one
       Ƥ  - Over each prefix:
     U    -   Reverse each string in the prefix
      Ƒ   -   Does that equal the prefix?
        S - Sum

As sweet as that \a is, -3

@UnrelatedString Very nice use of Ƒ and U's vectorisation!

JavaScript (ES6), 85 bytes
f=s=>s[1]?(t=s.slice(0,l=-~s.length/2))==[...s.slice(-l)].reverse().join``?1+f(t):0:1

Haskell, 58 bytes
p[a]=1
p a|reverse a==a=1+p(take(div(1+length a)2)a)
p _=0

05AB1E, 14 bytes
[ÐÂÊ#¼g#2ä¬])\

Uses the CP-1252 encoding. Try it online!

Scala, 56 bytes
s=>if(s.reverse==s&&s.size>1)1+h(s.take(s.size/2))else 2

requires an assignmentt to a variable with type declaration:
val f:(String=>Int)=...

Pyth - 21  bytes
The case of palindromes never running out really cost me, will look for a better way.
.xxK.uhc2NQ)hf!_ITKlK

Test Suite.

@ETHproductions i'm not sure if that works, but thanks, I'll look into that

Python 2, 94 87 77 bytes
The recursive approach... this currently assumes that empty & single letter strings get a score of 1.
def P(x,c=0):a=len(x);return c+(a<2)if(x[::-1]!=x)+(a<2)else P(x[:-~a/2],-~c)

Try it online!

Java 7,147 bytes
int c(String s,int t){int l=s.length();return l<2?t+1:s.equals(new StringBuilder(s).reverse().toString())?c(s.substring(0,l%2>0?l/2+1:l/2),++t):t;}

new StringBuilder(s).reverse().toString() can be new StringBuffer(s).reverse()+"" and l%2>0?l/2+1:l/2 can be l/2+l%2. EDIT: l/2+l%2 can be -~l/2 instead. So it becomes 128 bytes.

Pyth, 17 bytes
a!_IQl.u?_IJhc2NJ

Test suite
The previous Pyth answer uses an older version of the language and a significantly different approach.
Explanation:
a!_IQl.u?_IJhc2NJ   | Full program
a!_IQl.u?_IJhc2NJNQ | with implicit variables filled
--------------------+-------------------------------------------------------------------------------------------------------------------------
      .u          Q | Repeat the following until a repeated value is found, collecting the intermediate results, with N starting as Q (input):
           Jhc2N    |  J = the first half of N (longer half is necessary)
        ?_I     JN  |  if J is invariant over reversal (i.e. is a palindrome), N = J, else N = N
     l              | take the length of the resulting list
a                   | subtract
 !_IQ               |  0 if Q is a palindrome, 1 otherwise

Python 3, 53 bytes
f=lambda x:2>>len(x)or-~f(x[len(x)//2:])*(x==x[::-1])

Try it online!
How it works:

2>>len(x) will give us 1 if len(x)==1 and 0 if len(x)>1 (we don't have to treat the case where x is the empty string)

if the previous gives 0 then we recurse with x[len(x)//2:] which is the second part of our palindrome (including the center), -~ we add 1 and multiply by (x==x[::-1]) to return 0 if it is not a palidrome

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Let's abbreviate those numbers! Now reverse?
Introduction:
Like Twitter and Instagram and others, I wanted to display numbers like 1.2K and 3.8 M instead of 1,222 or 3,823,456.
But that's not all! As we all know, there might be some human beings which undoubtely won't like these abbreviations and will try to reverse them. So, 1.2k will become 1,200 and 3.8 M will become 3,800,000.
The task:

your task is to write a program or a function that converts a list of numbers (which are given as strings) into their abbreviate pairs and vice-versa.

For example, if the input list (or any STDIN) was ['1.4k', '1,234,567', '7.99M'], then you should output:
['1,400', '1.2M', '7,990,000']

You can follow the next schema for abbreviations:

103 -> one kilo -> K
106 -> one million -> M
109 -> one billion -> B

Your code may assume all lowercase, all uppercase, mixed case or undefined case for input and use any of these for output, but should be consistent.
Rules and restrictions:

you may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.
input may be in any convenient list or string format. You may assume that the ai are less than 231 each and that the list contains at least one element.
each abbreviated number will contain only one . while a normal number will contain as many , as necessary (you may assume that this numbers won't be altered).
you MAY NOT enter a number as '123456' but rather 123,456
standard code-golf rules apply.

Test cases:
Input: ['1.5M', '77.6k', '123,456,789']         Output: ['1,500,000', '77,600', '123.4M']
Input: ['3,000,000,000', '581k', '2b']          Output: ['3B', '581,000', '2,000,000,000']
Input: ['0.1k']                                 Output: ['100']
Input: ['888', '33']                            Output: ['0.888k', '0.033k']

Clarifications:

for numbers < 1000 after the decimal point in abbreviation output you should have as many digits as required to get the correct result. (e.g: 2 -> will become 0.002k) - that means 3 decimals at most; for numbers > 1000 you can have a maximum of 1 decimal.
the abbreviation may be in both lower or upper case
I removed the built-ins restriction as suggested in the comments

The shortest code in bytes wins!

Requests for clarification: how many digits after the decimal point in abbreviation output? how to abbreviate numbers < 1000? uppercase or lowercase or both in input and output?

@edc65 I updated the test cases and added some clarifications

Shouldn't '123,456,789' -> '123.4M'? Also, this doesn't clarify how many decimals to use. Surely anything under 1000 shouldn't need to be abbreviated anyways.

@Shebang, yea' that k was a typo. Actually, I wanted to make it a bit interesting by adding the constraint of not keeping numbers < 1000 as they are. So, for those numbers, you may use 3 decimals at most, and for the rest, at most 1.

How far up do we have to support?  Up to the decillions, or what?

@anonymous2 read the third rule.

Can our output for numbers expanded from abbreviation have decimals? i.e. 1.5m -> 1,500,000.0

@Shebang that would be a little confusing and it might be harder to read. Let's not allow it and keep our output clear ^_^

Forgive my ignorance, but what is ai?

@anonymous2 ai is an element of the list / string or whatever STDIN you'd like to use.

According to as many digits as required to get the correct result , 888 should result in 0.888k, not 0.8k.

@Titus oopsie, missed that. Fixed :)

"you're not allowed to use any built-in module / function" Any built-in function?

@mbomb007 actually 2^31 stops at billions so that should be the limit. I removed the so on which was confusing.

The question disagrees with itself on whether the abbreviation for thousands is k or K, and whether the abbreviation for billions is b or B. It also fails to specify the acceptable rounding modes.

@PeterTaylor no, it doesn't. It might as well be k as much as K. As for the rounding modes, I didn't think it's required but I'll add it shortly ^_^

Your usage of "kilo" suggests SI prefixes and those would be ["k", "M", "G"]. What does "while a normal number will contain as many , as necessary" mean, in my country it would be a mistake to use any.

@Angs People don't care if it's k or K when you're looking at Twitter. Most people aren't likely to think it's Kelvin.

Can the output be separated by newlines? For example: "1,500,000\n 77,600\n123.4M"

@KritixiLithos yes, that would be allowed

Also, shouldn't ['3,000,000,000', '581k', '2b'] be ['3,000,000,000', '581k', '2B']

@KritixiLithos It's just an example. The OP said case is not important. "It might as well be k as much as K." See the comments above.

I think that not allowing any builtin (for number-formatting, I guess) takes something from the challenge. As it is, you force everybody to one algorithm, and the language that can do that with the least overhead gets the cup. Removing that restriction will surely add more color to the answers and more to learn for the spectators.

@Titus ok, I removed that restriction! I hope everything is ok now as it is !

I made one more edit to prevent pennypicking questions; I think it doesn´t really matter (for the code) if the abbreviations are upper or lower case.

PHP, 234 224 213 201 205 bytes
for(;$x=$argv[++$n];){$y=str_replace(",","",$x)/1e3;for($i=0;$y>999;$i++)$y=($y|0)/1e3;echo(A<$c=substr($x,strlen($x)-1))?number_format($x*[k=>1e3,m=>1e6,b=>1e9][$c]):($i?($y*10|0)/10:$y).kmb[$i]," ";}

6 bytes saved by insertusernamehere, 4 bytes inspired by that.

takes input from command line arguments, prints results space-separated with a trailing separator
expects lower case abbreviation
run with -r

-2 bytes if underscore as separator is ok: Replace " " with _.
-1 byte if correct rounding is ok: Replace ($y*10|0)/10 with round($y,1).
-17 bytes for PHP 7.1: Replace substr($x,strlen($x)-1) with $x[-1].

80 (63) bytes for expanding one argument only:
<?=number_format(($x=$argv[1])*[K=>1e3,M=>1e6,B=>1e9][substr($x,strlen($x)-1)]);

save to file, then execute (or replace <?= with echo +space and run with -r.

Your second example doesn't compile.

You have unbalanced parens.

@AlexHowansky oops that was the untested version. Fixed, thanks! Byte count was correct, however.

-4 bytes: for($j=1;$x=$argv[$j++];) – instead of foreach($argv as$i=>$x)if($i)

-2 bytes: kmb[$i] – instead of "kmb"[$i].

-10 bytes: $x[-1]>A – instead of ord(strrev($x))>57 (PHP 7 only)

@insertusernamehere Negative string indexes are coming in PHP 7.1; and that´s a RC (yet). Thanks for the other bytes!

You're right, sorry about that. And I actually thought this was a 7.0 feature. But I see, you could still use the approach anyhow. :)

Can't answer, but 05AB1E, 48 bytes l'.¡`D'kåsD'måsD'bås¨Dl4-('0s×1@1@1@‚‚˜1k3*'0s×J

@Oliver It´s reopened; you can now turn your comment into an answer.

05AB1E, 67 bytes
…KMBU3L3*°Vε',Ku¤©ai¨®XY‡*ïR3ô',ýRëY/ʒ1@N_~}ε4°z+N_·Ì.ò¨0Ü'.ÜXNè«}θ

What a mess.. :/
Try it online.
Explanation:
…KMB                     # Push string "KMB"
    U                    # Pop and store it in variable `X`
3L                       # Push list [1,2,3]
  3*                     # Multiply each by 3: [3,6,9]
    °                    # Take 10 to the power each: [1000,1000000,1000000000]
     V                   # Pop and store it in variable `Y`
ε                        # Map over the (implicit) input-list:
 ',K                    '#  Remove all ","
    u                    #  Convert it to uppercase
 ¤                       #  Get the last character (without popping)
  ©                      #  Store this in variable `®` (without popping)
   ai                    #  If it's a letter:
     ¨                   #   Remove it from the string
      ®                  #   Push the letter from variable `®`
       XY‡               #   Transliterate it to the correct value in `Y` based on `X`
          *              #   Multiply the two numbers together
           ï             #   Cast it to an integer
     R                   #   Reverse it
      3ô                 #   Split it into parts of size 3
        ',ý             '#   Join it with "," delimiter
           R             #   Reverse it back
    ë                    #  Else:
     Y/                  #   Divide it by each value in list `Y`
       ʒ                 #   Filter this triplet by:
        1@               #    Check if it's >= 1
            ~            #    OR
          N_             #    The 0-based filter-index is 0
                         #    (so we'll still have a result left if <1000)
       }ε                #   After the filter: map over the remaining values:
         4°z+            #    Add 0.0001 to the number:
         4°              #     Push 10 to the power 4
           z             #     Divide 1 by this
            +            #     Add this 1/10000 to the number
         N               #    Push the 0-based map-index
          _              #    Check if it's 0 (1 if 0; 0 otherwise)
           ·             #    Double it (2 if 0; 0 otherwise)
            Ì            #    Increase by 2 (4 if 0; 2 otherwise)
             .ò          #    Round to that many decimals
               ¨         #    Remove the last digit
                0Ü       #    First trim potential trailing "0"
                '.Ü     '#    And then also trim a potential trailing "."
                   XNè«  #    Append the `N`'th letter of string `X`
        }θ               #   After the inner map: pop and leave the last item
                         # (after which the mapped list is output implicitly as result)

JavaScript, 545 524 522 518 514 508 504 498 494 214 bytes
Thanks to @ETHproductions for saving 180 bytes!
d=F=>F.map(f=>1/f.slice(-1)?f=(f=f.replace(/,/g,""))[9]?(f/1e8|0)/10+"B":f[6]?(f/1e5|0)/10+"M":f/1e3+"k":R(R(f.slice(0,-1)+"e"+' kMB'.indexOf(f.substr(-1))*3-0+"").match(/.{1,3}/g)+""),R=x=>[...x].reverse().join``)

To call the function:
d(["1.5M","1,500,000"]) //["1,500,500","1.5M"]

Outputs as alert, where each alert contains a different element of the input
Readable version:
d = F => F.map(f => 1 / f.slice(-1) ? f = (f = f.replace(/,/g, ""))[9] ? (f / 1e8 | 0) / 10 + "B" : f[6] ? (f / 1e5 | 0) / 10 + "M" : f / 1e3 + "k" : R(R(f.slice(0, -1) + "e" + ' kMB'.indexOf(f.substr(-1)) * 3 - 0 + "").match(/.{1,3}/g) + ""), R = x => [...x].reverse().join ``)

Summary of edits: converted function to an arrow function

removed semi-colons ';'
removed var
converted to an arrow function
used map to iterate through the individual elements of the array
used |0 instead of floor
used regex for testing
used ternary operators instead of if-else statements
included a separate function for .reverse().join''

Here are some of the ways to golf this down. Feel free to ask any questions you might have :-)

Python, 322 321 318 bytes
import math
def f(l,r=[]):
 for s in l:
  if(c:=s[-1])in(p:=' kMB'):r+=[f'{int(float(s[:-1])*10**(p.index(c)*3)):,}']
  elif(i:=int(s.replace(',','')))>999:
   if(l:=math.log10(i))<4.5:r+=[f'{round(i/1e3,1)}k']
   elif l<7.5:r+=[f'{round(i/1e6,1)}M']
   else:r+=[f'{round(i/1e9,1)}B']
  else:r+=[f'{i/1e3}k']
 return r

-3 thanks to jezza_99
Attempt This Online!

-3 bytes by removing unnecessary whitespace

Python, 207 203 bytes
lambda L:[s[-1]in'kMB'and f'{int(float(s[:-1])*10**(" kMB".index(s[-1])*3)):,}'or((i:=int(s.replace(',','')))>999>(j:=(i>1e6)+(i>1e9))and f'{(i/10**(j*3+2)+.5)//1/10}{"kMB"[j]}'or f'{i/1e3}k')for s in L]

Attempt This Online!
Similar to @TheThonnu's answer , but in a single line lambda and with sufficient differences that I feel it deserves a seperate answer
-4 bytes thanks to @97.100.97.109

203 bytes


text:
How many integers contain a number in a specific range
The program should take input the number, the start of the range and the end of the range, and output how many integers the number appears between the start and end of the range, inclusive. Both programs and functions are allowed.
Example Inputs
For example:
//Input example 1
3,1,100
//Input example 2
3
1
100
//Input example 3
3 1 100
//Input example 4
a(3, 1, 100);

All the above four input examples are valid and all of them mean that 3 is the number in question, 1 is the beginning of the range and 100 the the end of the range.
And then the program should output how many times 3 appears in the range from 1 to 100 inclusive. 3 appears in the integers 3, 13, 23, 30, 31, 32, 33, ..., 93 at a total of 19 times. So the program should output 19 as the output because that is how many times 3 appears in the range from 1 to 100.
Rules

Both programs and functions are allowed.
All numbers will be integers, meaning that there will not be any floats or doubles.
Note: the sought number will always be in the range 0≤x≤127. There will be no cases where it will be outside this 0≤x≤127 range.
As in the first example, with the case as 33, the number 3 will be counted as appearing only once, not twice.
The values of the start and end of the range will be between -65536 and 65535 inclusive.
The value of range's start will never exceed or equal to range's end. start < end
Also the range is inclusive. For example if the input was 8 8 10, the range would be 8≤x≤10 and hence the output will be 1.
Input can be taken in any of the ways shown in the examples. Input can be taken as a string or as a number, any way you wish.

Test Cases
3 1 100
19

3 3 93
19

12,-200,200
24          //This is because 12 appears in -129, -128, ..., -112, -12, 12, 112, 120, 121, 122, ...

123,1,3
0           //This is because all of 123's digits have to appear in the same order

3 33 34
2           //Because 3 appears in 2 numbers: 33 and 34

a(0,-1,1);
1

$ java NotVerbose 127 -12 27
0

Snack Snippet
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
# Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:
# Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the leaderboard snippet:
# [><>](http://esolangs.org/wiki/Fish), 121 bytes

/* Configuration */

var QUESTION_ID = 98470; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 41805; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (/ b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}

<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

05AB1E, 6 bytes
Input in the form: upper bound, lower bound, number.
Ÿvy³åO

Explanation:
Ÿ       # Inclusive range, [a, ..., b]
 vy     # For each element...
   ³å   # Check if the third input is a substring of the number
     O  # Sum up the results

Uses the CP-1252 encoding. Try it online!

Chooses Groovy {a,b,c->} Aww... dangit, I lost before I started again.

Congrats for winning this challenge!

@KritixiLithos Thank you! :)

6-bytes alternative: Ÿʒ³å}g

Bash, 20 bytes
the obvious answer
seq $2 $3|grep -c $1

example
$ bash golf 3 1 100
19

Perl, 20 bytes
Saved 2 bytes by using grep as in @ardnew's answer.
Bytecount includes 18 bytes of code and -ap flags.
$_=grep/@F/,<>..<>

Give the 3 numbers on three separate lines :
perl -ape '$_=grep/@F/,<>..<>' <<< "3
1
100"

Jelly,  7  6 bytes
-1 thanks to caird coinheringaahing! (Use w and filtering to avoiding @.)
rAwƇ⁵L

TryItOnline!
Input: Start, End, ToFind
How?
rAwƇ⁵L - Main link: Start, End, ToFind
r      - range: [Start, ..., End]
 A     - absolute values
    ⁵  - third input: ToFind
   Ƈ   - filter keep those (absolute values, a) for which:
  w    -   first index of sublist (implicit digits of ToFind) in (implicit digits of a)
     L - length

The default casting of an integer to an iterable for the sublist existence check casts to a decimal list (not a character list), so negative numbers have a leading negative value (e.g. -122->[-1,2,2] which won't find a sublist of [1,2]) so taking the absolute value first seems like the golfiest solution.

6 bytes

Thanks @cairdcoinheringaahing that's great, I went with something closer to the original.

Python 2, 47 43 Bytes
Relatively straightforward, making use of Python 2's repr short-form.
f=lambda n,a,b:a<b and(`n`in`a`)+f(n,-~a,b)

Ouput:
f(  3,    1, 100) -> 19
f(  3,    3,  93) -> 19
f( 12, -200, 200) -> 24
f(123,    1,   3) -> 0
f(  3,   33,  34) -> 2
f(  0,   -1,   1) -> 1
f(127,   12,  27) -> 0

Why did you have to be all fancy and use -~a instead of a+1?

@Artyer for fun!

JavaScript (ES6), 46 45 bytes
f=(n,s,e)=>s<=e&&!!`${s++}`.match(n)+f(n,s,e)

(My best nonrecursive version was 61 bytes.) Edit: Saved 1 byte thanks to @edc65.

!!match instead of includes.

PowerShell v2+, 64 62 56 bytes
param($c,$a,$b)$(for(;$a-le$b){1|?{$a++-match$c}}).count

-6 bytes thanks to mazzy
Input via command-line arguments of the form number lower_bound upper_bound. A little goofy on the notation, because of the semicolons inside the for causing parse errors if it's not surrounded in $(...) to create a script block. We basically loop upward through $a until we hit $b, using Where-Object (the |?{...}) to pull out those numbers that regex -match against $c. That's encapsulated in parens, we take the .count thereof, and that's left on the pipeline and output is implicit.

If, however, we guarantee that the range will be no more than 50,000 elements, we can skip the loop and just use the range operator .. directly, for 45 43 bytes. Since that's not in the challenge specifications, though, this isn't valid. Bummer.
param($c,$a,$b)($a..$b|?{$_-match$c}).count

Great! Thanks for 50K elements info. A couple of suggestions param($c,$a,$b)$(for(;$a-le$b){1|?{$a++-match$c}}).count

The param($c,$a,$b)($a..$b|?{$_-match$c}).count works with range -65536..65535 on Powershell 5.1

Vim, 46, 41 bytes
C<C-r>=r<tab><C-r>")<cr><esc>jC0<esc>:g/<C-r>"/norm G<C-v><C-a>
kd{

Input is in this format:
1, 100
3

R, 32 bytes
Quite straightforward:
function(a,b,c)sum(grepl(a,b:c))

Welcome to PPCG! Nice answer but assuming that input is already specified is generally not accepted. To make your answer qualify you would either have to read input from stdin such as: a=scan();sum(grepl(a,a[2]:a[3])) or as arguments to a function: function(a,b,c)sum(grepl(a,b:c)), both equivalent in this case.

@Billywob thanks, will keep this in mind! edited the answer accordingly.

Java 7 85 bytes
int x(int a,int b,int c){int t=0;for(;b<=c;)if((b+++"").contains(a+""))t++;return t;}

Swift 3, 96 93 bytes
import Cocoa
func c(n:Int,s:Int,e:Int){print((s...e).filter{"\($0)".contains("\(n)")}.count)}

Edit 1:
Saved 3 bytes by using shorthand parameters

Scala, 50 bytes
(c:String)=>(_:Int)to(_:Int)count(""+_ contains c)

takes the first input curried; call it like this: f("12")(-200,200)
Explantion:
(c:String)=>  //define an anonymous function taking a string parameter
  (_:Int)     //create a range from an anonymous int parameter
  to          //to
  (_:Int)     //another anonymous int parameter
  count(      //and count how many...
   ""+_       //elements converted to a string
   contains c //contain c
  )

Haskell, 65 bytes
import Data.List
(s#e)i=sum[1|x<-[s..e],isInfixOf(show i)$show x]

The import ruins the score. Usage example: ((-200)#200)12 -> 24.

The usage example should output 24 because 12 appears 24 times between -200 and 200

@KritixiLithos: Oh sorry! It does of course, it's just a copy & pase error.

PHP, 68 63 bytes
for($a=$argv;$a[2]<=$a[3];)$o+=strstr($a[2]++,$a[1])>'';echo$o;

use like:
 php -r "for($a=$argv;$a[2]<=$a[3];)$o+=strstr($a[2]++,$a[1])>'';echo$o;" 3 1 100

edit: 5 bytes saved thanks to Titus

strstr($a[2]++,$a[1])>"" instead of strpos($a[2]++,$a[1])!==false saves 5 bytes.

C#, 71 bytes
Beat my Java answer thanks to lambdas
(t,l,u)=>{int d=0;for(;l<=u;)if((l+++"").Contains(t+""))d++;return d;};

Java also has lambdas

Yeah I just started reading about it, but don't they require some boilerplate stuff that would make the bytecount larger, or can I not count it

Shamelessly stole @Grax s javascript answer (n,s,e)=>s>e?0:((""+s).Contains(n+"")?1:0)+f(n,++s,e); is way shorter

Ruby 44 bytes
m=->(n,s,f){(s..f).count{|x|x.to_s[/#{n}/]}}

Test Cases:
m.(3,1,100)     #=> 19
m.(3,3,93)      #=> 19
m.(12,-200,200) #=> 24
m.(123,1,3)     #=>  0
m.(3,33,34)     #=>  2
m.(0,-1,1)      #=>  1
m.(127,-12,27)  #=>  0

C, 143 135 bytes
Thanks to @Kritixi Lithos for helping save 8 bytes
Surely this can be done better, but its the best I've got for now.  C doesn't handle strings very gracefully, so naturally it takes quite a few operations.
int C(int N,int l,int h){char b[99],n[99];int t=0,i=1;sprintf(n,"%d",N);for(;i<=h;i++){sprintf(b,"%d",i);if(strstr(b,n))++t;}return t;}

Ungolfed + program
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

int C(int N,int l,int h)
{
    char b[99], n[99];
    int t=0,i=1;
    sprintf(n,"%d",N);
    for(;i<=h;i++)
    {
        sprintf(b,"%d",i);
        if(strstr(b,n))
            ++t;
    }
    return t;
}

int main()
{
  printf("%d\n", C(3, 1, 100));
}

I think you can remove the int i=l from the for-loop and instead initialise it with int t=0 like such int t=0,i=l to save a few bytes.

This not compile?  C( N, l, h){char b[99], n[99];int t=0,i=l;sprintf(n,"%d",N);for(;i<=h;i++){sprintf(b,"%d",i);if(strstr(b,n))++t;}return t;} I think compile even with no include...

93 bytes b[9],n[9],t;C(N,l,h){for(t=!sprintf(n,"%d",N);l<=h;strstr(b,n)&&++t)sprintf(b,"%d",l++);N=t;}

PHP, 62 bytes
Pretty straight forward approach:
<?=count(preg_grep('/'.($a=$argv)[1].'/',range($a[2],$a[3])));

Try it online

Save 4 bytes with underscore or any letter as regex delimiter. (needs no quotes)

You can save 3 Byte <?=count(preg_grep("/$argv[1]/",range($argv[2],$argv[3])));

JavaScript, 46 45 bytes
f=(i,s,e)=>s>e?0:RegExp(i).test(s)+f(i,++s,e)

Recursively count until start > end
Edit: Switch to RegExp test to save a byte

Japt, 14 8 bytes
Takes the integer to be found as the last input value.
õV èÈsøW

Try it online

Explanation
             :Implicit input of integers U=start, V=end & W=number
õV           :Range [U,V]
    È        :Map
     s       :  Convert to string
      øW     :  Contains W?
   è         :Count truthy values

Since the previous versions lack an explanation I'm not sure about those, but your current 6-byte solution is incorrect I'm afraid. See this rule: "As in the first example, with the case as 33, the number 3 will be counted as appearing only once, not twice." Your occurrence-count for W would count the 3 twice.

Thanks, @KevinCruijssen, came back to it ~a month later and was wondering why I was doing it the way I was when there was a shorter way - should have reread the challenge before updating! I've rolled it back now.

I had the same thing happen a few times. I see my answer, think: this can be much easier, am changing it. And right before I hit save changes I see I now misinterpret the challenge. Btw, I'm still curious about the explanation for the 8-byte solution. :)

@KevinCruijssen: explanation added.

Powershell, 48 bytes
According to the rule, the range can contain more than 50,000 elements. So we can't use the range operator .. directly. Thanks AdmBorkBork.
Straightforward:
param($c,$a,$b)for(;$a-le$b){$i+=$a++-match$c}$i

Test script:
$f = {

param($c,$a,$b)for(;$a-le$b){$i+=$a++-match$c}$i

}

@(
    ,(19, 3,1,100)
    ,(19, 3,3,93)
    ,(24, 12,-200,200)
    ,(0, 123,1,3)
    ,(2, 3,33,34)
    ,(1, 0,-1,1)
    ,(0, 127,-12,27)
    ,(44175, 0,-65536,65535)
) | % {
    $e,$a = $_
    $r = &$f @a
    "$($e-eq$r): $r"
}

Output:
True: 19
True: 19
True: 24
True: 0
True: 2
True: 1
True: 0
True: 44175

Vyxal s, 7 bytes
÷ṡƛS?hc

Try it Online!

Racket 91 bytes
(for/sum((i(range s(+ 1 e))))(if(string-contains?(number->string i)(number->string d))1 0))

Ungolfed:
(define(f d s e)
  (for/sum ((i (range s (+ 1 e))))
    (if(string-contains?
        (number->string i)
        (number->string d))
       1 0 )))

Testing:
(f 3 1 100)
(f 3 3 93)
(f 12 -200 200)
(f 123 1 3)
(f 3 33 34)
(f 0 -1 1)

Output:
19
19
24
0
2
1

Java, 92 89 71 bytes
Now with lambdas!
(t,l,u)->{int z=0;for(;l<=u;)if((l+++"").contains(t+""))z++;return z;};

Old 89 byte function solution:
int d(int t,int l,int u){int a=0,i=l;for(;i<=u;)if((i+++"").contains(t+""))a++;return a;}

Hooray for the super increment function!

You can remove int i=l from the for-loop and instead declare it with a like int a=0,i=l; to save few bytes

Ah I knew I missed something, thanks!

Basically the same as this answer.

GolfSharp, 41 bytes
(w,q,e)=>r(q,1+e-q).w(n=>n.T().I(w)).L();

A 45 byte version:

(w,q,e)=>r(q,1+e-q).w(n=>n.T().I(w.T())).L();

Groovy, 48 bytes
{a,b,c->(a..b).collect{"$it".count("$c")}.sum()}

Axiom bytes 90
f(y,a,b)==(c:=0;for x in a..b repeat(if position(y::String,x::String,1)~=0 then c:=c+1);c)

results
(3) -> f(3,1,100)=19,f(3,3,93)=19,f(12,-200,200)=24,f(123,1,3)=0,f(3,33,34)=2
   (3)  [19= 19,19= 19,24= 24,0= 0,2= 2]
                                  Type: Tuple Equation NonNegativeInteger
(4) -> f(0,-1,1)=1, f(127,12,27)=0
   (4)  [1= 1,0= 0]
                                  Type: Tuple Equation NonNegativeInteger

Mathematica, 70 bytes
(w=ToString;t=0;Table[If[StringContainsQ[w@i,w@#1],t++],{i,#2,#3}];t)&

input

[12,-200,200]

output

24

Clojure, 65 bytes
#(count(for[i(range %2(inc %3)):when(some(set(str %))(str i))]i))

PHP, 56 Bytes
run as pipe
Try it online
Input
$argv = [number_to_find, range_start, range_end];

Code
<?=substr_count(join(range(($a=$argv)[1],$a[2])),$a[0]);

Explanation
#substrcount, counts the aparitions of a subtring in a string
substr_count(
           join( range(($a=$argv)[1],$a[2])), # String with the range
           $a[0]);                            # The number you are looking for

Perl 6, 32 bytes
{+grep *.contains($^a),$^b..$^c}

Try it online!

Vyxal rs, 5 bytes
_ṡ?vc  # main program

_      # discard the initial number
 ṡ     # inclusive range over implicit inputs
  ?    # number to be checked
   vc  # vectorized contains, sum the list

I had to use -r because v vectorizes the first part of the stack otherwise (?)
Try it Online!

Thunno 2, 3 bytes
IƝc

Try it online!
Explanation
IƝc  # Implicit input
I    # Inclusive range between the first two inputs
 Ɲ   # Join it on newlines
  c  # Count occurrences of the third input
     # Implicit output


text:
Draw some mountain peaks
Write a program or function that draws a mountain range, where each subsequent larger mountain peak is "behind" the ones in front, and alternates which side is visible.
This is a mountain range of size 1
/\

This is a mountain range of size 2
 /\
/\ \

This is a mountain range of size 3
  /\
 / /\
/ /\ \

This is a mountain range of size 4
   /\
  /\ \
 / /\ \
/ /\ \ \

This is a mountain range of size 5
    /\
   / /\
  / /\ \
 / / /\ \
/ / /\ \ \

And so on.
Input
A single positive integer in any convenient format, n > 0.
Output
An ASCII-art representation of the mountain range, following the above rules. Leading/trailing newlines or other whitespace are optional, provided that the peaks line up appropriately.
Rules

Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Charcoal, 16 bytes
ＮλＦλ«Ｐ↘⁻λι←↙¹‖Ｔ→

Try it online!
How?
Ｎλ inputs the size of the largest mountain into λ. Ｆλ« runs a loop over values of ι from 0 through λ-1. (The closing » is implied at the end of the program.)
Inside the loop, Ｐ↘⁻λι calculates λ-ι and draws, without moving the cursor afterward, a line of that length going southeast. Based on its direction, this line will consist of \ characters. ← moves one step to the west, and ↙¹ draws a line of length 1 going southwest (made of /). Finally, ‖Ｔ→ horizontally reflects the drawing, transforming characters as appropriate: \ becomes / and / becomes \.
Adding the dump instruction Ｄ at the beginning of the loop (try it) allows us to see the progression:
    /\
   /
  /
 /
/
    /\
   /\ \
  /    \
 /      \
/        \
    /\
   / /\
  / /\ \
 / /    \
/ /      \
    /\
   /\ \
  / /\ \
 / /\ \ \
/ /    \ \
    /\
   / /\
  / /\ \
 / / /\ \
/ / /\ \ \

I guess this is the ideal language for the challenge :-)

@ETHproductions This language is created specifically for ASCII art. It also has its own codepage.

@EriktheGolfer I have my own (unimplemented) ASCII art language, called Crayon. The docs are kind of lost at the moment because I'm in the middle of moving them, but you can see most of them here. I wonder how short a Crayon program for this would be in comparison to Charcoal...

@ETHproductions When are you going to implement it? Is there a chatroom for it or can I make one (called "Crayon Implementation")?

@EriktheGolfer Unfortunately, I don't know when I'll have time to implement it. But you can create a chatroom if you'd like ;-)

@ETHproductions You're welcome! I saved you from that hassle, and maybe provided some help on that/

@DLosc. How do you count bytes? Your code is 16 characters long, but it is actually 42 bytes.

@sbisit Charcoal has a custom code page, the characters of which can each be counted as one byte. Using the code page, this program is (in hex): ceec c6ec a8d0 1ead ece9 111f b1bb d413.

JavaScript (ES6), 75 bytes
for(n=prompt(s="/\\");n--;s=n%2?s+' \\':'/ '+s)console.log(" ".repeat(n)+s)

The full program is currently slightly shorter than the recursive function:
f=n=>n?" ".repeat(--n)+`/\\
`+f(n).replace(/\S.+/g,x=>n%2?x+" \\":"/ "+x):""

Python 2, 67 bytes
n=input()
s='/\\'
while n:n-=1;print' '*n+s;s=['/ '+s,s+' \\'][n%2]

Prints line by line, accumulating the string s by alternately adding a slash to the left or right based on the current parity of n. Prefixes with n spaces.
An alternative way to update was the same length:
s=n%2*'/ '+s+~n%2*' \\'
s=['/ '+s,s+' \\'][n%2]

A recursive method was longer (70 bytes).
f=lambda n,s='/\\':n*'_'and' '*~-n+s+'\n'+f(n-1,[s+' \\','/ '+s][n%2])

Haskell, 77 bytes
0%_=""
n%s=(' '<$[2..n])++s++'\n':(n-1)%(cycle[s++" \\","/ "++s]!!n)
(%"/\\")

Usage:
putStrLn $ f 5
    /\
   / /\
  / /\ \
 / / /\ \
/ / /\ \ \

Prints line by line, accumulating the string s by alternately adding a slash to the left or right based on the current parity of n. Prefixes with n-1 spaces.

Haskell, 117 107 105 97 90 bytes
b!1=["/\\"]
b!n|m<-(1-b)!(n-1)=map(' ':)m++[[("/ "++),(++" \\")]!!b$last m]
(unlines.(1!))

Try it on Ideone.
Edit: Saved 8 bytes with an idea from Neil.
Ungolfed version:
p b 1 = ["/\\"]
p b n = let m = p (1-b) (n-1)
            k = last m
            r = map (' ':) m
        in if b == 1
           then r ++ [k ++ " \\"]
           else r ++ ["/ " ++ k]
f n = unlines(p 1 n)

Recursive approach. The shape for n is generated by adding a space in front of each line of the n-1 shape and taking the last line of n-1 and add "/ " before if n is odd or " \" after if n is even ... or so I thought before noticing that this last step is reversed for all recursive steps when the final n is odd. Therefore a flag b is passed which alternates each recursive call and determines if the next mountain part is added left or right.

Rather than comparing b to odd n each time, can you not just pass a flag in at the beginning and flip it on every recursive call? Something like f n = unlines(p 0 n) and let m = p (1-b) (n-1).

Flipping to -b is another char off.

@xnor Thanks for the hint, but I found another way to golf it further which needs b to be 0 or 1.

Batch, 202 bytes
@echo off
set/af=%1^&1
set m=/\
set s=
for /l %%i in (2,1,%1)do call set s= %%s%%
for /l %%i in (2,1,%1)do call:l
:l
echo %s%%m%
set s=%s:~1%
set/af^^=1
if %f%==1 (set m=%m% \)else set m=/ %m%

Takes input as a command-line parameter. Falls through to execute the last loop.

@TimmyD Sorry, I typoed while golfing. Fixed now.

Ruby, 61 bytes
A pretty straightforward port of ETHproductions' JavaScript answer.
->n{s="/\\"
(puts" "*n+s
s=n%2>0?s+" \\":"/ "+s)until 0>n-=1}

See it on repl.it: https://repl.it/EPU5/1
Ungolfed
->n{
  s = "/\\"
  ( puts " "*n+s
    s = n%2 > 0 ? s+" \\" : "/ "+s
  ) until 0 > n -= 1
}

Java 7,130 bytes
String f(int n,String s){String l="";for(int i=1;i++<n;l+=" ");return n>1?n%2<1?l+s+"\n"+f(--n,s+" \\"):l+s+"\n"+f(--n,"/ "+s):s;}

Ungolfed
class Mountain {
 public static void main(String[] args) {
    System.out.println(f( 5 , "/\\" ) );
  }
 static String f(int n,String s){
    String l = "";
    for (int i = 1; i++ < n; l += " ") ;
      return n > 1? n % 2 < 1?l + s + "\n" + f(--n , s + " \\")
                           :l + s + "\n" + f(--n , "/ " + s)
                            :s;
    }

}

Nice answer, +1. You can golf it by 2 bytes though: n%2 to n--%2, and both --n to n. EDIT: And 1 more by adding ,x=s+"\n" and changing both s+"\n" to x. (So in total: String f(int n,String s){String l="",x=s+"\n";for(int i=1;i++<n;l+=" ");return n>1?n--%2<1?l+x+f(n,s+" \\"):l+x+f(n,"/ "+s):s;} 127 bytes)

Canvas, 7 bytes
Ｈ＼║ｎ↔｝↕

Try it here!
I guess Canvas is now the ideal language for this challenge.

C++ 138(function)
Function :-
#define c(X) cout<<X;
#define L(X,Y) for(X=0;X<Y;X++)

void M(int h){int l=1,r=1,j,H=h,i;L(i,h){for(j=H;j>0;j--)c(" ")L(j,l)c(" /")L(j, r)c("\\ ")c("\ n")(h%2)?(i%2)?r++:l++:(i%2)?l++:r++;H--;}

Full program :-
#include<conio.h>
#include<iostream>

using namespace std;

#define c(X) cout<<X;
#define L(X,Y) for(X=0;X<Y;X++)

void M(int h)
{
    int l=1,r=1,j,H=h,i;

    L(i, h)
    {
        for (j = H;j > 0;j--)
            c(" ")
        L(j, l)
            c(" /")
        L(j, r)
            c("\\ ")
        c("\n")

        (h % 2) ? (i % 2) ? r++ : l++ :(i % 2) ? l++ : r++;
        H--;
    }
}

int main()
{
    int h;
    cin >> h;
    M(h);
    _getch();
    return 0;
}

NOTE :  the function _getch() may have different prototype names across different compilers.


text:
Minimum insertions to make palindrome
Today you will be doing another palindrome challenge!
So, your task today is to take a string, and determine the minimum amount of letters required to insert to turn it into a palindrome.
For example, let's take the string fishes.
In this, case the best way would be to add h if, so the result would be 3.
fishe s
     h if
---------
fishehsif

Now let's try with codegolf. Since there is a repeated o, we can just do:
  codeg  o lf
fl     ed c
-------------
flcodegedoclf

to get a result of 5.
Test cases
ppcg -> 2
codegolf -> 5
palindrome -> 9
stackexchange -> 8
programmingpuzzlesandcodegolf -> 20

Related, with insertions only happening on the right.

Wow, again, I had this exact challenge idea two days ago... but the scoring system would have been the length of your code + the output when its code is run through itself. (i.e. code is ppcg, score is 4 + 2 = 6)

This is a nice challenge, but I'd prefer if challenges the same topic were more spaced out. There's been a lot of palindrome the last couple of days.

It could be difficult to prove that a given program really finds the minimum amount of letters

Python, 112 bytes
d=lambda x,l,h:0if h<l else d(x,l+1,h-1)if x[l]==x[h]else-~min(d(x,l+1,h),d(x,l,h-1));e=lambda x:d(x,0,len(x)-1)

Very inefficient.
Try it online! You have to wait a minute for the last case to finish.
Call with e(<string>, 0, <length of string - 1>), like e("fishes", 0, 5)`.
Ungolfed (sort of) with explanation:
def minInsert(x, l, h):                # Declare func, arugments for x, l, h       # d=lambda x,l,h:
  if l >= h:                           # If l is the same or past h                #                 if h<l
    return 0                           #     then return 0                         #                0
  elif x[l] == x[h]:                   # If first and last character are the same  #                        else             if x[l]==x[h]
    return minInsert(x, l + 1, h - 1)  #     then return the min w/o first & last  #                             d(x,l+1,h-1)
  else:                                # If not, we shave off a character          #                                                      else
    a = minInsert(x, l, h - 1)         #     (last one)                            #                                                                d(x,l+1,h)
    b = minInsert(x, l + 1, h)         #     (first one)                           #                                                                           d(x,l,h-1)
    return min(a, b) + 1               #     and add one for the char we took off  #                                                          -~min(          ,          )

Getting an extra input with data (the list length) isn't legal by default. Neither is the input of 0, but you could fix that with a default argument l=0.

@xnor Fixed.---

@edc65 I etited.

Pyth, 10 bytes
test suite.
l.-Qe@y_Qy

         y   All subsequences of the input (implicit), sorted by length
      y_Q    All subsequences of the reversed input, sorted by length
     @       Their setwise intersection: the common subsequences
    e        Last element: the longest common subsequence
 .-Q         Remove it bagwise from the input: the letters not in this LCS
l            The length of that

There's a few equivalent characterizations of the value we're after:

The fewest insertions needed to make a palindrome
The fewest deletions needed to make a palindrome
Half the number of delete or insert operations needed to transform the string to its reverse
The length of the input with its longest palindromic subsequence removed
The length of the input, removing the longest common subsequence between it and its reverse. (The code uses this one.)

The common idea is the "skeleton" of letters in the input that are matched with  letters of the input in the final product.
  codeg  o lf
   *  *  *
fl o  gedoc

flcodegedoclf

This skeleton is always a palindrome, with letters matching to their reversed counterparts. Each non-skeleton letters is unmatched and must have its counterpart inserted.
A same-length alternative instead uses the fourth condition, the length of the input minus the length of its longest palindromic subsequence
l.-Qef_ITy

Link to test suite.
The part that's different is
f_ITy

    y   All subsequences of the input (implicit), sorted by length.
f       Filtered on:
 _IT     being invariant under reversal, i.e. a palindrome

For both, instead of removing the palindromic subsequence from the input and taking the length, we could instead subtract its length from the length of the input. Either one costs 4 bytes: -lQl vs l.-Q.

05AB1E, 11 bytes
Uses CP-1252 encoding.
ÂæsæÃ¤g¹g-Ä

Try it online! or as a Test suite
Explanation
              # implicit input
Â             # push a reversed copy
 æ            # compute powerset of the reversed string
  sæ          # compute powerset of the string
    Ã¤g       # get length of the longest common subset
      ¹g-     # subtract the length of the original string
         Ä    # take absolute value

Brachylog, 9 bytes
⊆P↔P;?lᵐ-

Try it online!
This challenge really needed a Brachylog v2 answer, as insertion palindromization is so intuitive in that language.
Explanation
⊆P↔P really is what does palindromization by insertion (see this example)
⊆P           P is an ordered superset of the input
 P↔P         P reversed is P (i.e. P is a palindrome)
   P;?lᵐ     Compute the length of both P and the input
        -    Subtraction

C, 89 121 bytes
#define g(a) f(a,a+strlen(a)-1)
f(char*a,char*b){return a>=b?0:*a-*b?f(a+1,b)<f(a,b-1)?f(++a,b)+1:f(a,--b)+1:f(++a,--b);}

Shameless port of Oliver's answer, could not think of any shorter solution.
g calls f with the pointer to the first and the last char of a string (the last char is part of the string, not the '\0'). Gets even more inefficient because f is called two times for the min case.
Ungolfed:
f(char*a,char*b){
 return a>=b ? 0 :
   *a-*b ?    //if the pointed chars are not the same
     f(a+1,b)<f(a,b-1) ? f(a+1,b)+1 : f(a,b-1)+1    //min(f..,f..)+1
   : f(a+1,b-1);  //if they were the same, make it more narrow
 }

Usage:
int main(){
 char s[]="palindrome";
 printf("%d\n",g(s));
}

Getting an extra input with data isn't legal by default

Brachylog v1, 13 bytes
,IrIs?:I:lar-

Try it online!
You can check the palindromes it finds with this code.
Explanation
I'm almost surprised this even works, seeing how ridiculously simple it is.
,IrI             I reversed is I (i.e. I is a palindrome)
   Is?           The Input is an ordered subset of I
     ?:I:la      The list [length(Input), length(I)]
           r-    Output = length(I) - length(Input)

This is guaranteed to find the smallest palindrome because IrI will generate strings of increasing length when backtracking, starting from the empty string.
This is not efficient enough to compute the last test case on TIO, because of the use of s - Ordered subset.

Batch, 234 232 bytes
@echo off
set n=99
call:l 0 %1
echo %n%
exit/b
:g
set/am=%1
if %m% lss %n% set/an=m
exit/b
:l
if "%2"=="" goto g
set s=%2
if %s:~,1%==%s:~-1% call:l %1 %s:~1,-1%&exit/b
call:l %1+1 %s:~1%
set s=%2
call:l %1+1 %s:~,-1%

Works by recursively trying to insert nonmatching characters at both ends, so very slow (I didn't try the last test case). Recursion limits mean that this only works for a limited string length anyway, so the 99 is somewhat arbitrary. I have to use call parameters as local variables as I couldn't get setlocal to work for me, which means that %1 parameter to the :l subroutine is an expression that evaluates to the number of insertions done so far.


text:
The nth numerator
You can create a list of all rationals 0 < r ≤ 1 by listing them ordered first by denominator and then by numerator:
1  1  1  2  1  3  1  2  3  4  1  5  1  2  3  4  5
-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
1  2  3  3  4  4  5  5  5  5  6  6  7  7  7  7  7

Note that we skip any rational number that already occurred before. E.g. 2/4 is skipped because we already listed 1/2.
In this challenge we're interested in the numerators only. Looking at the list above, write a function or program taking a positive integer n that returns the nth numerator from the list.

Testcases:
1 -> 1
2 -> 1
3 -> 1
4 -> 2
5 -> 1
6 -> 3
7 -> 1
8 -> 2
9 -> 3
50 -> 4
80 -> 15

partially relevant OEIS, may be helpful

Actually just a list of the rationales in (0,1]

@RobertFraser Good point.

Can this be zero indexed?

Jelly, 11 9 bytes
gRỊTµ€Fị@

Try it online! or verify all test cases.
How it works
gRỊTµ€Fị@  Main link. Argument: n

    µ€     Map the monadic chain to the left over [1, ..., n]; for each k:
 R           Range; yield [1, ..., k].
g            Compute the GCD of k and each j in [1, ..., k].
  Ị          Insignificant; yield 1 for 1; 0 for 2, ..., k.
   T         Truth; yield all indices of 1's, i.e., all coprimes with k.
      F      Flatten the resulting 2D array.
       ị@    At-index swapped; return the n-th element.

MATL, 17 13 bytes
:tt!/XR6#uG))

Try it online! Or verify all test cases.
Input size may be limited by floating point accuracy. All test cases give the correct result.
Explanation
This generates all fractions k/m with k, m in [1 2 ...n], as an n×n matrix. The row indicates the numerator and the column indicates the denominator. Actually the matrix entry contains the inverse fraction m/k, instead of k/m, but this is irrelevant and can be ignored in the rest of the explanation.
Matrix entries are implicitly considered to be sorted in column-major order. In this case this corresponds to the required order: denominator, then numerator.
Three types of entries need to be disregarded from this matrix:

Entries k/m, k>m, that have the same value as a previous entry (for example, 2/4 is disregarded because it is the same as 1/2)
Entries k/k, k>1.
Entries that have a numerator exceeding the denominator
Entries k/m, k<m (these are not part of the problem).

Disregarding entries is done with a unique function, which stably removes duplicate values and outputs the indices of the surviving entries. With this, entries of type 1 above are automatically removed. To deal with types 2 and 3, the matrix entries at the diagonal and below are set to 0. This way, all zero entries will be removed except the first (corresponding to the valid fraction 1/1).
Consider input 4 as an example.
:     % Input n implicitly. Push range [1 2 ...n]
      % STACK: [1 2 3 4]
t     % Duplicate
      % STACK: [1 2 3 4], [1 2 3 4]
t!    % Duplicate and transpose
      % STACK: [1 2 3 4], [1 2 3 4], [1; 2; 3; 4]
/     % Divide element-wise with broadcast: gives matrix with all pairs
      % STACK: [1 2 3 4], [1       2       3       4;
                           0.5000  1       1.5000  2;
                           0.3333  0.6667  1       1.3333;
                           0.2500  0.5000  0.7500  1     ]
XR    % Upper triangular part above the diagonal. This sets to 0 all entries
      % corresponding to fractions that equal or exceed 1. (Since the matrix
      % actually contains the inverse fractions, nonzero entries will contain
      % values greater than 1)
      % STACK: [1 2 3 4], [0       2       3       4;
                           0       0       1.5000  2;
                           0       0       0       1.3333;
                           0       0       0       0     ]
6#u   % Indices of first appearance of unique elements
      % STACK: [1 2 3 4], [1; 5; 9; 10; 13; 15]
G     % Push input n again
      % STACK: [1 2 3 4], [1; 5; 9; 10; 13; 15], 4
)     % Index: get the n-th entry from the array of indices of unique elements
      % STACK: [1 2 3 4], 10
)     % Index (modular): get the corresponding real part. Display implicitly
      % STACK: 2

Wolfram Language (Mathematica), 53 49 bytes
(Join@@Array[Pick[r=Range@#,r~GCD~#,1]&,#])[[#]]&

Try it online!

Haskell, 40 bytes
((0:[n|d<-[1..],n<-[1..d],gcd n d<2])!!)

An anonymous function. Pretty straightforward: uses a list comprehension to generate an infinite list, looping over all numerators n and relatively prime denominators d. To convert zero-index to one-indexed, we prepend a 0, which takes 4 bytes.

n<-[0..d] adds the zero in a shorter way and saves the 4 bytes

Pyth, 13 bytes
@smfq1idTUhdh

Try it online. Test suite.

Pyth, 11 bytes
@sm.mibdhdS

Try it online: Demonstration
Explanation:
@sm.mibdhdSQQ   implicit Qs at the end (Q = input number)
  m       SQ    map each denominator d from [1, 2, ..., Q] to:
   .m   hd        select the numerators b from [0, 1, ..., d]
     ibd             for which gcd(b, d) == 1 (which is the smallest possible gcd)
                  this gives [0, 1] for d=1, [1] for d=2, [1,2] for d=3, ...
 s              combine all lists to a big one
@           Q   print the Qth element

Actually, 15 bytes
This answer is based on Dennis' Jelly answer. I use HN at the end to avoid issues with 0-indexing and needing to decrement n and swap at the beginning or end. H gets the first n members of the list of numerators that results and N gets the last member of that selection, i.e. the nth numerator, all without fiddling about with stack operations. Golfing suggestions welcome. Try it online!
;R`;r;)♀┤░`MΣHN

Ungolfing
          Implicit input n.
;         Duplicate n. Leave one n on the stack for getting the nth numerator at the end.
R`...`M   Map the following function over the range [1..n]. Variable m.
  ;         Duplicate m. Leave one m on the stack for checking coprimality later.
  r         Push the range [0...m].
  ;)        Move a duplicate of range [0...m] to BOS.
  ♀┤        Push a list of 0's and 1's where a 1 denotes a number coprime to m (a numerator),
             and 0 denotes a fraction we have counted before.
  ░         Filter the second list (range [0...m])
             by the truthy values in the first list (our coprime check).
Σ         Sum all of the lists in the result into one list.
H         Push result[:n] using the duplicate of n from the beginning of the program.
N         Push result[:n][:-1], which is the same as result[n-1], our nth numerator.
          Implicit return.

Python, 111 110 bytes
from fractions import*
def g(n):
 x,y=1,1
 while n>1:
  x+=1
  if x>y:x,y=1,y+1
  if gcd(x,y)<2:n-=1
 return x

The fraction is represented with x/y. The argument n is decremented when a new fitting fraction is found (the gcd from fractions checks can the fraction be reduced). In each iteration of the loop, x is incremented, then, if x>=y, a new series of fractions with y+1 is started, > because of the "special case" (x,y)=(2,1), golfed to x>y.
I am sure this can be golfed more, but I am missing where I could improve it. Found it.
Link to code and test cases

JavaScript (ES6), 95 bytes
n=>[...Array(n*n).keys()].filter(i=>i%n<=i/n&g(i%n+1,i/n+1|0)<2,g=(a,b)=>b?g(b,a%b):a)[n-1]%n+1

Works by generating all n² fractions with numerators and denominators from 1 to n and filtering out those greater than 1 or previously seen, then taking the nth.

Perl, 82 + 2 (-pl flag) = 84 bytes
perl -ple '{{$d>$n?($n++,(grep!($n%$_||$d%$_),2..$d)&&redo):($n=1,$d++)}++$i!=$_&&redo;$_=$n}'

Ungolfed:
while (<>) {  # -p flag
    chomp();  # -l flag

    my $i = 0;
    my $n = 0;
    my $d = 0;

    for (;;) {
        for (;;) {
            if ($d <= $n) {
                $n = 1;
                $d++;
                last;
            }
            else {
                $n++;
                last unless grep { !($n % $_) && !($d % $_) } 2 .. $d;
            }
        }
        if (++$i == $_) {
            $_ = $n;
            last;
        }
    }
}
continue {
    print($_, "\n");
}

JavaScript (ES6), 76
x=>eval("for(g=(a,b)=>b?g(b,a%b):a,d=n=0;x;g(n,d)-1||--x)n=++n>d?(++d,1):n")

Less golfed
x=>{
  g=(a,b) => b ? g(b,a%b) : a; // gcd
  for (d=n=0; x; )
  {
     ++n;
     if (n > d)
     {
        ++d;
        n=1;
     }
     if (g(n,d) == 1) // if the fraction is irreducible
        --x;
  }
  return n
}

Test

f=
x=>eval("for(g=(a,b)=>b?g(b,a%b):a,d=n=0;x;g(n,d)-1||--x)n=++n>d?(d++,1):n")

;`1 -> 1
2 -> 1
3 -> 1
4 -> 2
5 -> 1
6 -> 3
7 -> 1
8 -> 2
9 -> 3
50 -> 4
80 -> 15`.split`\n`.forEach(
  r=>{
    var [a,k]=r.match(/\d+/g),r=f(a)
    console.log(r==k?'OK':'KO',a,r)
  }
)

Clojure, 85 bytes
#(if(= 1 %)1(numerator(nth(distinct(for[i(range)j(range 1(inc i))](/ j i)))(dec %))))

Uses list comprehension to generate list of all rationals, then filters it to get only distinct ones. Takes nth item of the list and returns its numerator. Also separate condition is needed for the first element because Clojure isn't able to take numerator of an integer. (for whatever reason considering an integer to be not Rational – https://goo.gl/XETLo2)
See it online – https://ideone.com/8gNZEB


text:
Binary Convolution
A binary convolution is described by a number M, and is applied to a number N. For each bit in the binary representation of M, if the bit is set (1), the corresponding bit in the output is given by XORing the two bits adjacent to the corresponding bit in N (wrapping around when necessary). If the bit is not set (0), then the corresponding bit in the output is given by the corresponding bit in N.
A worked example (with 8-bit values):

Let N = 150, M = 59. Their binary respresentations are (respectively) 10010110 and 00111011.
Based on M's binary representation, bits 0, 1, 3, 4, and 5 are convolved.

The result for bit 0 is given by XORing bits 1 and 7 (since we wrap around), yielding 1.
The result for bit 1 is given by XORing bits 0 and 2, yielding 0.
The result for bit 2 is given by the original bit 2, yielding 1.
The result for bit 3 is given by XORing bits 2 and 4, yielding 0.
The result for bit 4 is given by XORing bits 3 and 5, yielding 0.
The result for bit 5 is given by XORing bits 4 and 6, yielding 1.
The results for bits 6 and 7 are given by the original bits 6 and 7, yielding 0 and 1.

The output is thus 10100110 (166).

The Challenge
Given N and M, output the result of performing the binary convolution described by M upon N. Input and output may be in any convenient, consistent, and unambiguous format. N and M will always be in the (inclusive) range [0, 255] (8-bit unsigned integers), and their binary representations should be padded to 8 bits for performing the binary convolution.
Test Cases
150 59 -> 166
242 209 -> 178
1 17 -> 0
189 139 -> 181
215 104 -> 215
79 214 -> 25
190 207 -> 50
61 139 -> 180
140 110 -> 206
252 115 -> 143
83 76 -> 31
244 25 -> 245
24 124 -> 60
180 41 -> 181
105 239 -> 102
215 125 -> 198
49 183 -> 178
183 158 -> 181
158 55 -> 186
215 117 -> 198
255 12 -> 243

I think the title is wrong. it should be "Binary Revolution" :)

JavaScript (ES6), 31 bytes
(n,m)=>n^m&(n^(n*=257)>>1^n>>7)

Python 2, 35 bytes
lambda m,n:n^m&(n^n*257/2^n*2^n>>7)

Doesn't seem to work for n=255?

@Neil Good catch. I don't see a nice way around that with mod, shifting instead for an extra byte.

J, 34 bytes
2#.[:({"_1],._1&|.~:1&|.)/(8#2)#:]

Straight-forward approach that applies the process defined in the challenge. Takes input as an array [n, m].
Forms seven smileys, [:, :(, :1, (8, 8#, #:, and :].
Usage
   f =: 2#.[:({"_1],._1&|.~:1&|.)/(8#2)#:]
   f 150 59
171
   f 59 150
166
   f 209 242
178
   f 17 1
0
   f 139 189
181

Something must be wrong if J scores the same as Python :D

x64 machine code, 17 bytes
88CD88C8D0C9D0C530E930C120D130C8C3

Disassembled:
0:  88 cd                   mov    ch,cl
2:  88 c8                   mov    al,cl
4:  d0 c9                   ror    cl,1
6:  d0 c5                   rol    ch,1
8:  30 e9                   xor    cl,ch
a:  30 c1                   xor    cl,al
c:  20 d1                   and    cl,dl
e:  30 c8                   xor    al,cl
10: c3                      ret

Suitable for the Win64 calling convention (arguments in rcx, rdx).

Haskell, 66 bytes
import Data.Bits
n%m=n.&.(255-m)+(rotate n 1`xor`rotate n(-1)).&.m

Works as intended when called with Word8 data. Replace (255-m) with complement m (+5 bytes) to make the function work with any unsigned integral datatype.