text:
Praming Puzles & Colf: Condense a String
Having spend some time on this site I have come to enjoy things being as short as possible. That may be the reason why I'm recently kind of offended by strings containing the same characters more than once. Your job is to write a function or program which condenses a given string according to the following rules:

Start with a 0-condensation, that is look for the first (leftmost) pair of the same characters with 0 other characters between them. If such a pair is found, remove one of the two characters and restart the algorithm by performing another 0-condensation. If no such pair is found, proceed with the next step. Examples:
programming -C0-> programing
aabbcc -C0-> abbcc
test -C0-> test
Then perform a 1-condensation, that is look for the first pair of same characters with 1 other character between them. If such a pair is found remove one of them and all characters between them and restart with a 0-condensation. If no such pair is found, proceed with the next step. Examples:
abacac -C1-> acac
java -C1-> ja
Continue with a 2-condensation and so on up to a n-condensation with n being the length of the original string, each time restarting after a condensation removed some letters. Examples:
programing -C2-> praming
abcdafg -C3-> afg

The resulting string is called condensed and contains each character at most once.

Input:
A lower case string of printable ascii-characters.
Output:
The condensed string according to the rules above.
Examples:
examples     -> es
programming  -> praming
puzzles      -> puzles
codegolf     -> colf
andromeda    -> a
abcbaccbabcb -> acb
if(x==1):x++ -> if(x+
fnabnfun     -> fun
abcdefae     -> abcde

Detailed examples to clarify how the algorithm works:
fnabnfun -C0-> fnabnfun -C1-> fnabnfun -C2-> fnfun -C0-> fnfun -C1-> fun -C0-> fun
 -C1-> fun -C2-> ... -C8-> fun

abcbaccbabcb -C0-> abcbacbabcb -C0-> abcbacbabcb -C1-> abacbabcb -C0-> abacbabcb
 -C1-> acbabcb -C0-> acbabcb -C1-> acbcb -C0-> acbcb -C1-> acb -C0-> acb
 -C1-> ... -C12-> acb

Your approach doesn't have to implement the algorithm from above as long as your solution and the algorithm return the same output for all allowed inputs.
This is a code-golf challenge.

Thanks to @Linus for helpful sandbox comments!

@MartinEnder Riley's test case is still necessary, because it's the only one my Retina solution doesn't work on.

@mbomb007 Ah, I see. Good point.

Will the input string ever contain non-printable characters like spaces?

@mbomb007 No, to assume printable ascii characters only is fine.

@mbomb007 However as far as I know, a space is considered a printable ascii character, e.g. here.

Related (because of their visual similarity).

Please specify "character": A) any character B) anything but whitespace C) a word character (letters and digits) D)???

The result for programming puzzles & code golf is A) puzlf B) and C) praming puzles & code golf; but never praming puzles & colf :/

@Titus Well ... yes. In order to get a fancy title I took the liberty to condense programming, puzzles, & and code golf. I'm sorry if this irregular choice of condensation-chunks disturbs you, and I apologize for it.

doesn´t disturb me, only my code :) artistic freedom is great.

JavaScript (ES6), 74 bytes

f=
(s,n=0,m=s.match(`(.).{${n}}\\1`))=>s[n]?m?f(s.replace(...m)):f(s,n+1):s
;
<input oninput=o.textContent=f(this.value)><pre id=o>

Very nice, shorter than what I would have thought of.

Perl, 38 31 30 29 bytes
This should should leave the non-golfing languages far behind...
-1 for $-[0] thanks to Riley
-1 for @{-} thanks to Dada
Includes +1 for -p
Give input on STDIN
condense.pl:
#!/usr/bin/perl -p
s/(.)\K.{@{-}}\1// while/./g

This 27 byte version should work but it doesn't because perl doesn't interpolate @- in a regex (see https://stackoverflow.com/questions/39521060/why-are-etc-not-interpolated-in-strings)
#!/usr/bin/perl -p
s/(.)\K.{@-}\1// while/./g

How does the @{\@-} part work? I thought @- held the indexes of each match, so how does it "count up" on every iteration. Also, if you print @{\@-} before and after each substitution it only ever prints 1 or 2.

@Riley The /./g progresses by 1 in the string each time, except when the string changes, then it's reset to 0. If you print @- after the /./g but before the s/// you will see it going up (use a test where the remaining string is large enough)

Printing $-[0] gives the numbers I would expect. Does @{\@-} act like $-[0] because of the regex context but not when printing for some reason? $-[0] is a byte shorter than @{\@-} if they are the same.

"@{\@-}" is not the same as @{\@-} (without ").

@Riley No, but "@{\@-}" is the same as "@-". And this should also be true for a regex substitution but it isn't. Simularly $-[0] should work but doesn't. PS: You probably somehow had scalar context applied to @- when you did your print, so you always got 1 or 2

Why doesn't $-[0] work? It gives the correct output for all of the test cases.

@Riley You're right. I mistook my test output. A workaround for this perl bug at the cost of 3 bytes should prove useful in many places

CJam, 35 bytes
rL{_,{{(_@_@#I={I)>]sj}*}h]s}fI}j

Try it online!

rL{                            }j   | run recursion on input
   _,{                      }fI     | for I from 0 to length(input)
      {                 }h]s        | one pass & clean up
       (_@                          | slice and store leading element A
          _@#I={      }*            | if next A is I steps away
                I)>                 | slice off I+1 element
                   ]sj              | clean up & recursion

You can see the individual condensations by inserting ed

Python 2, 117 104 101 bytes
Recursively do the necessary replacements. I build the regex dynamically.
import re
def f(s,i=0):t=re.sub(r"(.)%s\1"%("."*i),r"\1",s);e=s==t;return i>len(t)and t or f(t,i*e+e)

Try it online

The two return lines can be condensed into return i>len(t) and t or s!=t and f(t) or f(t,i+1) for a net of -4 bytes

Another 2 bytes can be shaved off by changing that to return t if i>len(t)else s!=t and f(t)or f(t,i+1))

Even more by e=s==t;return i>len(t)and t or f(t,i*e+e) and then you can remove the i=0 in the function definition, but you'll have to call with 0 start.

I'm going to assume that the four spaces are there not because you're using four spaces but because SE automatically expands them. If that's not the case, you can change all your spaces to either tabs or a single space for -9 bytes.

@Quelklef The meta forbids taking additional parameters.

@QPaysTaxes If you click "edit", you can see the actual code I pasted contains tabs.

You can put f all on one line and use semicolons to save two bytes.

Perl 53 52
Includes +1 for -p
for($i=0;$i<length;){$i=(s/(.).{$i}\1/\1/)?0:$i+1;}

Try it on ideone.

PHP, 90 Bytes
for($s=$argv[$c=1];$s[$i=++$i*!$c];)$s=preg_replace("#(.).{{$i}}\\1#","$1",$s,1,$c);echo$s;

or 92 Bytes
for($s=$argv[1];$s[$i];$i=++$i*!$c)$s=preg_replace("#(.).{".+$i."}\\1#","$1",$s,1,$c);echo$s;

first version: +$i instead of $i+=0 (-2).
for loop instead of while can save two bytes and allow to remove curlys (-4).
$i=++$i*!$c instead of $i=$c?0:$i+1 (-1).
\\2 is not needed, remove parentheses (-2). 5) You can allow limit 9 instead of 1 for speed (+0)

@Titus very good ideas. I had't see this Thank You

Now that I think again ... +$i doesn´t work  in every case. Try hammer. PHP doesn´t complain about the empty braces in the regex; but it doesn´t match as wanted. By the way: I count 91, not 90. But try the new 1) for($s=$argv[$c=1];$s[$i=++$i*!$c];)

@Titus Yes indeed I go back to $i+=0 and will try your proposal later. What do mean with hammer?

@Titus okay the same problem if puzzle or something else like (.)//1 but it is okay with your proposal or the $i´=0

Mathematica, 101 bytes
NestWhile[i=0;StringReplace[#,a_~~_~RepeatedNull~i++~~a_:>a,1]&,#,SameQ,2,ByteCount@#]&~FixedPoint~#&

There should be a way to make this shorter...

Haskell, 97 88 bytes
(0?)
(a:s)!(b:t)|a==b=a:t|1<3=a:s!t
s!_=s
m?s|length s<m=s|a<-s!drop m s=sum[m+1|a==s]?a

Try it online!

Old 97 byte bersion:
(a:s)!(b:t)|a==b=a:t|1<3=a:s!t
s!_=s
m?s|length s==m=s|a<-s!drop m s=(last$0:[m+1|a==s])?a
c=(0?)

Try it on ideone.
Explanation:
(a:s)!(b:t)|a==b = a:t         --perform condensation
           |1<3  = a:s!t       --recursively compare further
 s   ! _         = s           --no condensation performed

The (!) function performs one n-condensation when given a string once whole and once with the first n characters removed, e.g. abcdbe and cdbe for a 2-condensation, by recursively comparing the two leading characters.
m?s|length s==m   = s         --stop before performing length-s-condensation
   |a <- s!drop m s           --a is the m-condensation of s
    = (last$0:[m+1|a==s])?a   --disguised conditional:
                              -- if a==s       if the m-condensation did not change s
                              -- then (m+1)?a  then perform m+1-condensation
                              -- else 0?a      else restart with a 0-condensation

c=(0?)                        -- main function, initialise m with 0

Ruby, 75 64 57 bytes
(56 bytes of code + p command line option.)
Using string interpolation inside a regex to control the length of the matches that are replaced.
i=0
~/(.).{#{i}}\1/?sub($&,$1)&&i=0: i+=1while i<$_.size

Test:
$ ruby -p condense.rb <<< fnabnfun
fun


text:
Find the odd one out in a sequence
The Challenge:
Consider the function F(N) = 2^N + 1 where N is a positive integer less than 31. The sequence defined by this function is:
3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289, 1048577, 2097153, 4194305, 8388609, 16777217, 33554433, 67108865, 134217729, 268435457, 536870913, 1073741825

An input will be generated as follows:

Take 5 contiguous integers from the above sequence.
Replace one of them with a different, positive integer (which may or may not be part of the above sequence).
Optionally reorder the the 5 resulting numbers.

Given such a list of 5 integers, find the one that was swapped in and is therefore not part of the original 5 contiguous integers.
Example:

Original sublist: 5, 9, 17, 33, 65.
Replace one: 5, 7, 17, 33, 65.
Reorder: 33, 17, 5, 7, 65.

The expected output would be 7.
The 5 values in the input will always be distinct and there will always be a unique solution. (For instance, you won't have to deal with inputs like 3, 9, 17, 33, 129 where either 3 or 129 might have been swapped in.)
Test Cases:
5,9,17,33,829
o/p: 829

9,5,17,829,33
o/p: 829

33, 17, 5, 7, 65
o/p: 7

5,9,177,33,65
o/p: 177

65,129,259,513,1025
o/p: 259

129,259,513,1025,65
o/p: 259

63,129,257,513,1025
o/p: 63

65,129,257,513,4097
o/p: 4097

5, 9, 2, 17, 33
o/p: 2

536870913, 67108865, 1073741825, 1, 268435457
o/p: 1

For future reference, confusion and misunderstandings like this can often be avoided by posting challenge ideas in the sandbox first, where you can get feedback from the community before people start solving your challenge.

@Ajay Since there was still some confusion about the specification I have edited the challenge once more with what I think was your intent behind this challenge. I hope I didn't misinterpret it, but do let me know if I got anything wrong.

@MartinEnder the new test case should be 536870913,67108865,134217729,1,268435457

@JörgHülsermann Feel free to add that as well, but my intention was to add a test case that covers N = 30 as one of the input values.

Even if badly exposed, it's really a good challenge. Well done Ajay (and thanks @Martin)

Is 3,33,65,129,257 a possible input?

@Titus I'd say yes. What's wrong with it?

Nothing; but I think You should have a test case where the injected value is 2**n+1 and the min value.

If the integers in the series are contiguous, it should be just as easy to include the integer that was replaced, as well as the impostor. Anyone think it'd be easy to mod their code for this?

What if all of the integers are valid, e.g. your test case "65,129,257,513,4097"?

@MartinEnder Yep, you got the challenge right. Thanks for the edit. And, sorry everyone for posting it in a bad way. I'll try to post these challenge in sandbox from now on.

@Snowman the five value aren't contiguous.  4097 is the odd one out.

@edc65 The inputs are generated by taking 5 contiguous values and replacing one of those with an invalid one. In that test case 134217729 was replaced (just like in the third test case 9 was replaced and in the fourth one 17).

An interesting challenge because it's so easy to come up with wrong algorithms. And indeed I've never seen so many incorrect answers posted. It would have been even worse if duplicates were allowed (many set based methods (including mine) would fail)

easy...just return https://goo.gl/P9RUdN 28 bytes xD

Could you add 1 3 5 9 17 (in some order) as a testcase ? It's a sequence of  five 2^N+1 without breaks, but 1 is not in the original set so 33 has been replaced by 1 which is the odd one out

Jelly, 15 bytes
⁹R2*‘ṡ5ḟ@€µEÐfQ

TryItOnline
All test cases also at TryItOnline
Returns a list containing one list containing the odd one out.
How?
⁹R2*‘ṡ5ḟ@€µEÐfQ - Main link, a (list)
⁹               - literal 256 (saving a byte over literal 30)
 R              - range, [1,2,3,...]
  2*            - 2 ** x, [2,4,8,...]
    ‘           - increment, [3,5,9,...]
     ṡ5         - all contiguous slices of length 5
       ḟ@€      - filter with reversed arguments for each
          µ     - monadic chain separation
            Ðf  - filter on condition:
           E    - all equal (those previously filtered lists with only one value)
              Q - unique (there can be two, but both will have the same odd-one-out)

JavaScript (ES6), 62 bytes
a=>a.find(n=>--n&--n|!n)||a.sort((a,b)=>a-b)[a[0]*16>a[3]?4:0]

Completely new algorithm, since as @edc65 pointed out the previous one was broken. Explanation: We first deal with the easy case by looking for a 2 or a number that is not one greater than a power of 2. If none was found then there are two possible cases, depending on whether the extra value was below or above the original run of five, so we check whether the smallest and second largest value belong to the same run of five and if so blame the largest value otherwise the smallest value.

Almost ok but try n-1&n-2 with the value 2

@edc65 Doesn't work for [3, 17, 33, 65, 257].

@edc65 Does --n&--n|!n look good for the 2 case?

It looks good indeed

Racket 198 bytes
(λ(m)(let((l(for/list((i(range 1 31)))(+ 1(expt 2 i))))(r 1)(n(length m)))(for((i(-(length l)n)))(let
((o(for/list((j m)#:unless(member j(take(drop l i)n)))j)))(when(eq?(length o)1)(set! r o))))r))

Ungolfed version:
(define f
  (λ(m)
    (let ((l (for/list ((i (range 1 31)))
               (+ 1 (expt 2 i))))
          (res 1)
          (n (length m)))
      (for ((i (- (length l) n)))
        (let ((o (for/list ((j m)
                             #:unless (member j
                                             (take (drop l i) n)))
                    j)))
          (when (eq? (length o) 1)
            (set! res o))))
      res)))

Testing:
(f '(5 9 17 33 829))
(f '(9 5 17 829 33))
(f '(5 9 177 33 65))
(f '(65 129 259 513 1025))
(f '(129 259 513 1025 65))
(f '(63 129 257 513 1025))
(f '(65 129 257 513 4097))

Output:
'(829)
'(829)
'(177)
'(259)
'(259)
'(63)
'(4097)

Python, 84 bytes
def f(a,i=0):s=set(a)-{2**j+1for j in range(i,i+5)};return len(s)<2and s or f(a,i+1)

All test cases are at ideone
For valid input returns a set containing only the odd-one-out.
For invalid input the recursion limit will be reached and an error will be thrown.

Mathematica, 65 bytes
f[a___,x_,b___]/;NestList[2#-1&,a~Min~b/. 2->0,4]~SubsetQ~{a,b}=x

This defines a function f which should be called with 5 arguments, e.g.
f[5, 9, 17, 33, 829]

In principle the function can be called with any (non-zero) number of arguments, but you might get unexpected results...
I think this is the first time, that I managed to put the entire solution to a non-trivial challenge into the left-hand side of a =.
Explanation
This solution really puts Mathematica's pattern matching capabilities to work for us. The basic feature we're using is that Mathematica can't just define simple functions like f[x_] := (* some expression in x *) but we can use arbitrarily complex patterns on the left-hand side, e.g. f[{a_, b_}, x_?OddQ] := ... would add a definition to f which is only used when it's called with a two-element list and an odd integer. Conveniently, we can already give names to elements arbitrarily far down the left-hand side expression (e.g. in the last example, we could immediately refer to the two list elements as a and b).
The pattern we're using in this challenge is f[a___,x_,b___]. Here a___ and b___ are sequences of zero or more arguments and x is a single argument. Since the right-hand side of the definition is simply x, what we want is some magic that ensures that x is used for the input we're searching for and a___ and b___ are simply wildcards that cover the remaining elements.
This is done by attaching a condition to the pattern with /;. The right-hand side of /; (everything up to the =) needs to return True for this pattern to match. The beauty is that Mathematica's pattern matcher will try every single assignment of a, x and b to the inputs for us, so the search for the correct element is done for us. This is essentially a declarative solution to the problem.
As for the condition itself:
NestList[2#-1&,a~Min~b/. 2->0,4]~SubsetQ~{a,b}

Notice that this doesn't depend on x at all. Instead, this condition depends only on the remaining four elements. This is another convenient feature of the pattern matching solution: due to the sequence patterns, a and b together contain all other inputs.
So this condition needs to check whether the remaining four elements are contiguous elements from our sequence with at most one gap. The basic idea for checking this is that we generate the next four elements from the minimum (via xi+1 = 2xi - 1) and check whether the four elements are a subset of this. The only inputs where that can cause trouble is those that contain a 2, because this also generates valid sequence elements, so we need to handle that separately.
Last part: let's go through the actual expression, because there's some more funny syntactic sugar here.
...a~Min~b...

This infix notation is short for Min[a,b]. But remember that a and b are sequences, so this actually expands to the four elements Min[i1, i2, i3, i4] and gives us the smallest remaining element in the input.
.../. 2->0

If this results in a 2, we replace it with a 0 (which will generate values which aren't in the sequence). The space is necessary because otherwise Mathematica parses the float literal .2.
NestList[...&,...,4]

We apply the unnamed function on the left 4 times to this value and collect the results in a list.
2#-1&

This simply multiplies its input by 2 and decrements it.
...~SubsetQ~{a,b}

And finally, we check that the list containing all elements from a and b is a subset of this.

I didn't know Mathematica could do this!

05AB1E, 32 30 26 24 20 bytes
30Lo>Œ5ùv¹yvyK}Dgi`q

Explanation
30Lo>    # list containing the sequence [3 .. 1073741825]
Œ5ù      # all sequence sublists of length 5
v        # for each such list
 ¹yvyK}  # remove it's elements from input
 Dgi     # if the remaining list has length 1
    `q   # end the program and print the final list flattened

Try it online!

Haskell, 66 64 bytes
g x=[s|n<-[1..],[s]<-[filter(`notElem`[2^m+1|m<-[n..n+4]])x]]!!0

Usage example: g [65,129,257,513,4097] -> 4097.
Loops through all contiguous sublists of length 5 of F(N), keeps the elements that are not in the input list x and pattern matches those of length 1 (-> [s]).
Edit: @xnor saved two bytes by removing the upper bound of the outer loop. As a solution is guaranteed to exist, Haskell's laziness stops at the first number found.

Do you actually need the upper bound of 26?

R, 97 bytes
This turned out to be more difficult than I thought. I'm sure this can be golfed significantly though.
m=match(x<-sort(scan()),2^(1:31)+1);l=diff(m);ifelse(NA%in%m,x[is.na(m)],x[ifelse(l[4]>1,5,l>1)])

Ungolfed and explained
x<-sort(scan())                  # read input from stdin and sort, store as vector
m=match(x, 2^(1:31)+1)           # generate a vector of indices for which input matches the sequence
l=diff(m)                        # vector of the difference of indices (will only contain 4 elements)
ifelse(NA%in%m,                  # if m contains NA do:
       x[is.na(m)],              # return x where no match has been found, else:
       x[ifelse(l[4]>1,5,l>1)])  # return x by index where diff>1 unless it's the last object, then return x[5]

The match() function will return NA if the any element of the input vector is not in the sequence and consequently we can just find the index where NAexist in the input and return this: x[is.na(m)]
It gets a bit more complicated if input is part of the sequence but misplaced. Because input has been sorted, the distance between each pair of  indices should be 1. We can therefore find the misplaced element by investigating the 1st difference of the matched indices l=diff(m) and select the index for which  l>1. This would be just enough if it weren't for the fact that l contains 4 elements rather than 5. This is only a problem if the last element in the sorted input is a member of the sequence BUT not a part of the subsequence (as in the final test case). Consequently, if the 4th element >1 fetch the 5th entry in the sorted input else look for the index in the 4-length vector: x[ifelse(l[4]>1,5,l>1)]

in recent versions of R there is a function anyNA which is equivalent to any(is.na(x))

Perl, 64 59 bytes
Includes +2 for -an
Give input list on STDIN:
perl -M5.010 oddout.pl <<< "5 9 2 17 33"

oddout.pl:
#!/usr/bin/perl -an
@a=grep$_,@a{@F,map{2**$_+++1}($.++)x5}=@F while$#a;say@a

If you don't mind variable amount of space around the result this 58 byte verson works:
#!/usr/bin/perl -ap
$_=join$",@a{@F,map{2**$_+++1}($.++)x5}=@F while/\b +\b/

Both versions loop forever if the input has no solution.
This is very sick code, but I can't think of anything elegant...
The way I (ab)use %a is a new perlgolf trick as far as I know.

PHP, 87 76 75 bytes
for(;count($b=array_diff($argv,$a?:[]))-2;)$a[$n%5]=1<<++$n|1;echo end($b);

run with php -r '<code>' <value1> <value2> <value3> <value4> <value5>

'a=[]` is not neccessary

@JörgHülsermann: It is necessary for array_diff. But I can save one byte there.

It results in a warning array_diff(): Argument #2 is not an array. Nice way with fill the array with the mod 5. It will save me array_map and range in my proposal

end instead of max and your note is no more important

Python 2, 73 bytes
s=set(input());i,=d={1}
while~-len(s-d):i*=2;d=d-{i/32+1}|{i+1}
print s-d

Iterates through sets d of five consecutive sequence elements until it finds one that contains all but one of the input elements, and then prints the difference, which is the output in a singleton set.
The sets d of five consecutive elements are built up from nothing by repeatedly adding a new element i+1 and deleting any old element i/32+1 that comes before the current window of 5. Here's what its progress looks like.
{1}
{3}
{3, 5}
{3, 5, 9}
{3, 5, 9, 17}
{3, 5, 9, 17, 33}
{5, 9, 17, 33, 65}
{9, 17, 33, 65, 129}
{17, 33, 65, 129, 257}
{33, 65, 129, 257, 513}

There's a stray 1 at the start from initialization, but it's harmless because it's immediately removed. The smaller sets as it builds up to 5 elements are also harmless.

C#, 69 bytes
int M(int[]a)=>a.Except(new int[30].Select((_,i)=>(1<<i+1)+1)).Sum();

Japt -g, 17 15 bytes
Outputs a singleton array.
HÆÒ2pXÃã £kXÃl1

Try it
HÆÒ2pXÃã £kXÃl1     :Implicit input of array U
H                   :32
 Æ                  :Map each X in the range [0,32)
  Ò                 :  Negate the bitwise NOT of
   2pX              :  2 raised to the power of X
      Ã             :End map
       ã            :Sub-arrays
         £          :Map each X
          kX        :  Remove the elements in X from U
            Ã       :End map
             l1     :Filter elements of length 1
                    :Implicit output of first element

Vyxal, 11 bytes
¨²›5l¨VF~₃h

Try it Online!

Nibbles, 13 bytes (26 nibbles)
/+=~.;,30-_<5>$.@+^2$~,

Try it at nibbles.onrender.com
    .                       # each n of
      ,30                   # 1..30
     ;                      # (saving this range for later)
                            # using function:
         -_                 #   get difference between input and
           <5               #   first 5 elements
             >$             #   after dropping n elements from
                @           #   1..30
               .            #   each
                  ^2$       #   used as an exponent of 2
                 +          #   added to
                     ~      #   1
  =~                        # now group & sort results by
                       ,    #   length
 +                          # flatten this list of lists
/                           # and fold over this returning the leftmost element
                            # (which is the single element in the smallest-length list)

Java 7,85 bytes
int f(int[]a,int l){int i=1;for(;i<l;)if(a[i++-1]*2-1!=a[i])return a[i];return a[0];}

Ungolfed
int f(int[]a,int l){
    int i=1;
    for(;i<l;)
    if(a[i++-1]*2-1!=a[i])
    return a[i];
   return a[0];

}

Hmm, are you sure this works correctly? Because I'm getting an incorrect output for the test cases 1, 5, 6, and 7 (only the second, third and fourth output are correct). Also, is the parameter l 31? In the question I only see an int-array as input, but not an additional int? :S

Won't this fail if the odd value out is the second one  (at index 1) ?

Sorry guys,I misinterpret the question.. Actually now I am in hospital.. I ll change it in a short span of time.

PHP, 76 Bytes
implemented Titus idea with the mod 5
<?for(;count($x=array_diff($_GET[a],$r))-1;$r[++$i%5]=2**$i+1);echo end($x);

126 Bytes before
<?for(;$x=array_diff($_GET[a],array_map(function($z){return 2**$z+1;},range(++$i,$i+4)));)if(count($x)<2){echo end($x);break;}

anonymous function: array_map(function($z){return 2**$z+1;},range($i,$i+4)). $x[key($x)] --> end($x)

Putting 1-count($x=...) to the condition will get you rid of the break: for(;1-count($x=...););echo end($x); (-13)

Pyth, 18 bytes
hhlD-LQ.:mh^2dSCd5

Form the sequence, take sublists of length 5, Remove each sublist from Q, take the shortest result, output its only element.

Doesn't work for [5, 9, 2, 17, 33]

Kotlin, 55 bytes
fun f(a:IntArray)=a.find{it-1 !in(1..30).map{1 shl it}}

Ruby, 70 bytes
->a{(1..a.max).map{2**_1+1}.each_cons(5).map{b=a-_1
break b if !b[1]}}

Attempt This Online!

source: Stack Exchange

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

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

sort: votes


text:
Some ASCII art for N64's 20th B-Day
The official release of the Nintendo 64 in North America was on September 29, 1996.[1] I figured that this anniversary deserved an ASCII art challenge. There's one small twist though, you have to output a different ASCII art for each of three different inputs.
If the input is 1, output this ASCII art of an N64 Controller: (source)
                 | |
             _,.-'-'-.,_
      ______|           |______
   ,-'      |  NINTENDO |      `-.
 ,'   _                          `.
/   _| |_                     (^)   \
|  |_   _|                  (<) (>) |
\    |_|         (S)     (B)  (v)   /
|`.              ___       (A)    ,'|
|  `-.______   ,' _ `.   ______,-'  |
|      |    `. | (_) | ,'    |      |
|      |      \`.___,'/      |      |
|      |      |       |      |      |
|      /      |       |      \      |
\     /       |       |       \     /
 `._,'        \       /        `._,'
               \     /
                `._,'

If the input is 2, output this ASCII art of the N64 logo:(source)
                  .-"-.
               .-"     "-.
              /"-.     .-|
             /    "-.-"  |
            /      /     |
   .-"-.   /      /      |       .-"-.
.-"     "-/      /       |    .-"     "-.
|-.     .-"\    /        |   /"-.     .-|
|  '-.-"    \  /         | /'    "-.-"  |
|     \      \/   .-"-.  /'        |    |
|      \      \.-"     "-.         |    |
|       \      |-.     .-"\        |    |
|        \     |  "-.-"    '\      |    |
|         \    |    |        '\    |    |
|    |\    \   |    |          '\  |    |
|    | \    \  |    |            '\|    |
|    |  \    \ |    |    :\.            |
|    |   \    \|    |    |  \.          |
|    |    \         |    |    \.        |
'-.  |  .-"\        |    |    '.\.    .-'
   "-|-"    \       |    |      "-\.-"
             \      |    |
              \     |    |
               "-.  |  .-'
                  "-|-"

Finally, if the input is 3, outout this ASCII art of a console and TV: (source)
              o
     o       /
      \     /
       \   /
        \ /
   ______________
  |.------------.|
  ||            ||
  ||            ||
  ||            ||
  ||            ||
  ||____________||_
  |OO ....... OO | `-.
  '------_.-._---' _.'
   _____||   ||___/_
  /  _.-|| N ||-._  \      .-._
 / -'_.---------._'- \    ,'___i-i___
/_.-'_  NINTENDO _'-._\  ' /_+  o :::\
|`-i /m\/m\|\|/=,/m\i-'| | || \ O / ||
|  |_\_/\_/___\_/'./|  | | \/  \ /  \/
`-'              '-.`-'  ,      V
                    `---'

Rules:

Input may be either as a number or a string/char.
You may have any amount of leading or trailing spaces and trailing or leading newlines. (Output must be aligned correctly though)
Your submission may be either a full program or a function.
No retrieving the ASCII art from the internet.

This is code-golf, so smallest byte count wins.

@Emigna I realigned the cord and took the liberty of altering the controller to look better, as nobody has submitted any solutions yet.

I'd suggest restricting this to just the N. The others are probably too intricate to do efficiently except with plain string compression which is rather boring.

There's a ' or two in the N that I feel should be ". It's bothering me.

Javascript ES6, 1175 bytes
Using a simple Run Length Encoding to encode just the spaces.

let F=

  z=>[(f=d=>d.replace(/\d+/g,e=>' '.repeat(e)))(`17|1|
13_,.-'-'-.,_
6______|11|______
3,-'6|2NINTENDO1|6\`-.
1,'3_26\`.
/3_|1|_21(^)3\\
|2|_3_|18(<)1(>)1|
\\4|_|9(S)5(B)2(v)3/
|\`.14___7(A)4,'|
|2\`-.______3,'1_1\`.3______,-'2|
|6|4\`.1|1(_)1|1,'4|6|
|6|6\\\`.___,'/6|6|
|6|6|7|6|6|
|6/6|7|6\\6|
\\5/7|7|7\\5/
1\`._,'8\\7/8\`._,'
15\\5/
16\`._,'`),f(`18.-"-.
15.-"5"-.
14/"-.5.-|
13/4"-.-"2|
12/6/5|
3.-"-.3/6/6|7.-"-.
.-"5"-/6/7|4.-"5"-.
|-.5.-"\\4/8|3/"-.5.-|
|2'-.-"4\\2/9|1/'4"-.-"2|
|5\\6\\/3.-"-.2/'8|4|
|6\\6\\.-"5"-.9|4|
|7\\6|-.5.-"\\8|4|
|8\\5|2"-.-"4'\\6|4|
|9\\4|4|8'\\4|4|
|4|\\4\\3|4|10'\\2|4|
|4|1\\4\\2|4|12'\\|4|
|4|2\\4\\1|4|4:\\.12|
|4|3\\4\\|4|4|2\\.10|
|4|4\\9|4|4\\.8|
'-.2|2.-"\\8|4|4'.\\.4.-'
3"-|-"4\\7|4|6"-\\.-"
13\\6|4|
14\\5|4|
15"-.2|2.-'
18"-|-"`),f(`14o
5o7/
6\\5/
7\\3/
8\\1/
3______________
2|.------------.|
2||12||
2||12||
2||12||
2||12||
2||____________||_
2|OO1.......1OO1|1\`-.
2'------_.-._---'1_.'2
3_____||3||___/_
2/2_.-||1N1||-._2\\6.-._
1/1-'_.---------._'-1\\4,'___i-i___
/_.-'_2NINTENDO1_'-._\\2'1/_+2o1:::\\
|\`-i1/m\\/m\\|\\|/=,/m\\i-'|1|1||1\\1O1/1||
|2|_\\_/\\_/___\\_/'./|2|1|1\\/2\\1/2\\/
\`-'14'-.\`-'2,6V
20\`---'`)][z-1]

G=_=>h.innerHTML = F(a.value)

h.innerHTML = F(1)
<input id=a onchange="G()" type="number" value="1"></input>
<pre id=h>

JavaScript (ES6), 907 904 903 bytes
Implements a compression by successive substitutions of the most frequent sub-strings.
This can be compressed significantly more (down to about 850 bytes) by assuming Windows-125x encoding and using replacement characters in the range 0xA0 - 0xFF. But the result is just ugly. :-)

let f =

n=>[...Array(78)].map((_,i)=>s=~":<=>ABNOSV\\^_`imov|".indexOf((c=String.fromCharCode(125-i)))?s:s.split(c).join(['\\','NINTENDO',`
`][c]||"9|XsD'RE405398T08kU8K0\"-G/'0|W7/;_E/C62G5|557970..-\"6_ /|52F8@04D\"`.-','??7 25\";7|3 3|4 .-662|---. |4|43__4433  ".substr(k+=2,2)),s="c99JE_,zP;,_27fX39fe,PH3197`;2 MG_cwQ2/G_|9_cE(^)G0@F_G_Xw(<) (>)9208_X (S)E(B)3(v)n@Q57ZK(A)4M|@3`;fGM _ QGf,PF@H4Q9 (_)9 M8H@HaQZM/HH@HHbHH@jHbaH20gbbqg2 Q_M50K/5Q_MJqgJ5Q_M~c3DIJKyIJjIED|Jg4I[FJ4/j49eDInjHKDI2yp/jb4yI@;ERT/dnIED|@3';[x3/59Y'4I[F@E0a/GDI3/'dUaayI59UqH;ER0dU5T93I[4lHU5 0885l8rt3uwlFr tF854l|r3tu4:0.5rGt|8830.5F@8x5ux.d2';F3R0d84'.0.4zep|[xb87p0RJE0H8J7TuJKIF3zJwp|[~57o2EoK/2ag2qnJ0YeCCfW.LL?-;k{{{{|CCC||_WOO ]]]. OO9 `;23'L?_.h?P _.'eC_||3}Z/_23/3_D|| N}h307.h2Y P_.LLh'- TMZi-iZ2/_z_31 _'h03'Y_+3o :::0@`-iYm0/m0|0|/=,/m0iP|9} 0 OY}@F_0_/0_/Z0_/'./|F9 0/30Y30/2`P57';`P3,7VJ54`?P",k=-2)&&s.split`~`[n-1]

console.log(f(1));
console.log(f(2));
console.log(f(3));

Making-Of
The above JS was generated with the following PHP script, where "n64.txt" is basically the concatenation of the 3 original pictures separated with ~ characters.
<?php
  $str = file_get_contents("n64.txt");

  // ignore line-breaks between 2 pictures
  $str = str_replace("~\n", "~", $str);

  // replace backslashes with 0's
  $str = str_replace("\\", "0", $str);

  // replace 'NINTENDO' with 1's to have more uppercase letters
  // available as replacement characters
  $str = str_replace("NINTENDO", "1", $str);

  // replace line-breaks with 2's
  $str = str_replace("\n", "2", $str);

  // $skipped is the list of characters that can't be used as replacement
  // characters (backslash + anything existing in the original string)
  $skipped = '';

  // $dic is the replacement dictionary
  $dic = '';

  for($i = 0; $i < 75; $i++) {
    // $r = current replacement character
    $r = chr(51 + $i);

    // can we use it?
    if($r == "\\" || strpos($str, $r) !== false) {
      $skipped .= $r;
      continue;
    }

    // look for the most frequent 2-character sub-string
    $count = array();

    for($n = 0; $n < strlen($str) - 1; $n++) {
      $s = substr($str, $n, 2);
      $count[$s] = isset($count[$s]) ? $count[$s] : 0;
      $count[$s]++;
    }

    asort($count);
    $keys = array_keys($count);
    $s = array_pop($keys);

    // add it to the dictionary
    $dic = $s.$dic;

    // replace all occurences with the replacement character
    $str = str_replace($s, $r, $str);

    printf("'%s' => '%s' %d\n", $s, $r, strlen($str));
  }

  // generate JS
  file_put_contents(
    "n64.js",
    sprintf(
      "n=>[...Array(78)].map((_,i)=>".
      "s=~\"%s\".indexOf((c=String.fromCharCode(125-i)))?s:".
      "s.split(c).join(['\\\\','NINTENDO',`\n`][c]||\"%s\".substr(k+=2,2)),".
      "s=\"%s\",k=-2)".
      "&&s.split`~`[n-1]",
      str_replace("\\", "\\\\", $skipped),
      str_replace('"', '\"', $dic),
      $str
    )
  );
?>

Racket, 1059 bytes
(require file/gunzip net/base64)(display((λ(o)(gunzip-through-ports(open-input-bytes(base64-decode(list-ref'(#"H4sICMov7lcCAzEAdZExDsMgDEV3TuENkAhcoKrUqh2ypEM7osIpOvnwtTEkgaaOFIvvZ8efAAyBgKoTkvOTpse7VAupBO6bROK6m3QbBMu8vO7L7QGVzZNX4Lie4G9krwITtMgxZd6W3lEhCNFt0piTBXO25CXKfhtjnlbylbL58CEozL4fQG4afym808hfJAvitUjkozSKVKwXqvpnM5RNokXEd7uJniI3mcc6HTp1pBCOjisVDqnYqLiHRqpiQdHKyWno1K1Lqmq47bX351cy/AXpeU7EYwIAAA=="#"H4sICNkv7lcCAzIAbdIxDgQhCAXQfk5BbKzUfs/CUTj8qiACMo2J/xl/cADi11tp/Xs39/pGY24JIR8NObCO+mjYZUf70pgAuUq3g1fMbEPSSgUt3NIVnhu1yVE0cMpRXX/ugpziuJ3ZaY8jlZpikMtDY+1ECiUtNvtjLpmSnaNYKwkP9ZKtk3BolMt6eeiVP+z2wJVCyZa11kjAMECe75V1DZCyAe6SnW1v9dvvQfruEEdV2no3/z/7OUOSpRE/POm9Tzpr/AEE2h7HhgMAAA=="#"H4sICOIv7lcCAzMApVG7DsIwDNzzFd48UNt7JTYYWNoFMUVy1gyIH/DHc0l4tBIb1yjxXf1MiLZ4pHG8qA1Kecc6/RCwbvsOUEJlA40mxbZY/Clt64E1bV1JBwhmUBGFzKMFV1HHyeTKRJ+me/KezloSg6wCcYGIiPf41MITfgv7dzR1luEwMTJUqW16gwcjcrks1/NyWgle6nBjMj+0C57nOacoUsnuGSty2HGCUYUDnaN+phXVMCz6C89uWEiOndWahi9bfwBslgom2wE1uzYNekv0A6XfyBPSqZrcBwIAAA==")(-(read)1))))o)(get-output-string o))(open-output-string)))

Just gzipped data encoded as base64.
Ungolfed
(require file/gunzip net/base64)
(display ((λ (o)
            (gunzip-through-ports
             (open-input-bytes
              (base64-decode
               (list-ref
                '(#"H4sICMov7lcCAzEAdZExDsMgDEV3TuENkAhcoKrUqh2ypEM7osIpOvnwtTEkgaaOFIvvZ8efAAyBgKoTkvOTpse7VAupBO6bROK6m3QbBMu8vO7L7QGVzZNX4Lie4G9krwITtMgxZd6W3lEhCNFt0piTBXO25CXKfhtjnlbylbL58CEozL4fQG4afym808hfJAvitUjkozSKVKwXqvpnM5RNokXEd7uJniI3mcc6HTp1pBCOjisVDqnYqLiHRqpiQdHKyWno1K1Lqmq47bX351cy/AXpeU7EYwIAAA=="
                  #"H4sICNkv7lcCAzIAbdIxDgQhCAXQfk5BbKzUfs/CUTj8qiACMo2J/xl/cADi11tp/Xs39/pGY24JIR8NObCO+mjYZUf70pgAuUq3g1fMbEPSSgUt3NIVnhu1yVE0cMpRXX/ugpziuJ3ZaY8jlZpikMtDY+1ECiUtNvtjLpmSnaNYKwkP9ZKtk3BolMt6eeiVP+z2wJVCyZa11kjAMECe75V1DZCyAe6SnW1v9dvvQfruEEdV2no3/z/7OUOSpRE/POm9Tzpr/AEE2h7HhgMAAA=="
                  #"H4sICOIv7lcCAzMApVG7DsIwDNzzFd48UNt7JTYYWNoFMUVy1gyIH/DHc0l4tBIb1yjxXf1MiLZ4pHG8qA1Kecc6/RCwbvsOUEJlA40mxbZY/Clt64E1bV1JBwhmUBGFzKMFV1HHyeTKRJ+me/KezloSg6wCcYGIiPf41MITfgv7dzR1luEwMTJUqW16gwcjcrks1/NyWgle6nBjMj+0C57nOacoUsnuGSty2HGCUYUDnaN+phXVMCz6C89uWEiOndWahi9bfwBslgom2wE1uzYNekv0A6XfyBPSqZrcBwIAAA==")
                (- (read) 1))))
             o)
            (get-output-string o))
          (open-output-string)))

PHP, 2113 2112 bytes
If nobody else is going to compete I'll just grab the trophy and leave..
<?php function a($n){if($n<2){?>
                 | |
             _,.-'-'-.,_
      ______|           |______
   ,-'      |  NINTENDO |      `-.
 ,'   _                          `.
/   _| |_                     (^)   \
|  |_   _|                  (<) (>) |
\    |_|         (S)     (B)  (v)   /
|`.              ___       (A)    ,'|
|  `-.______   ,' _ `.   ______,-'  |
|      |    `. | (_) | ,'    |      |
|      |      \`.___,'/      |      |
|      |      |       |      |      |
|      /      |       |      \      |
\     /       |       |       \     /
 `._,'        \       /        `._,'
               \     /
                `._,'<?php }else if($n==2){?>
                  .-"-.
               .-"     "-.
              /"-.     .-|
             /    "-.-"  |
            /      /     |
   .-"-.   /      /      |       .-"-.
.-"     "-/      /       |    .-"     "-.
|-.     .-"\    /        |   /"-.     .-|
|  '-.-"    \  /         | /'    "-.-"  |
|     \      \/   .-"-.  /'        |    |
|      \      \.-"     "-.         |    |
|       \      |-.     .-"\        |    |
|        \     |  "-.-"    '\      |    |
|         \    |    |        '\    |    |
|    |\    \   |    |          '\  |    |
|    | \    \  |    |            '\|    |
|    |  \    \ |    |    :\.            |
|    |   \    \|    |    |  \.          |
|    |    \         |    |    \.        |
'-.  |  .-"\        |    |    '.\.    .-'
   "-|-"    \       |    |      "-\.-"
             \      |    |
              \     |    |
               "-.  |  .-'
                  "-|-"<?php }else{?>
              o
     o       /
      \     /
       \   /
        \ /
   ______________
  |.------------.|
  ||            ||
  ||            ||
  ||            ||
  ||            ||
  ||____________||_
  |OO ....... OO | `-.
  '------_.-._---' _.'
   _____||   ||___/_
  /  _.-|| N ||-._  \      .-._
 / -'_.---------._'- \    ,'___i-i___
/_.-'_  NINTENDO _'-._\  ' /_+  o :::\
|`-i /m\/m\|\|/=,/m\i-'| | || \ O / ||
|  |_\_/\_/___\_/'./|  | | \/  \ /  \/
`-'              '-.`-'  ,      V
                    `---' <?php }}?>

Thanks to @KevinCruijssen for a byte!

You can golf $n==1 to $n<2 for -1 byte. ;p

@KevinCruijssen Sweet, only a thousand and some to go!

<?php should be <? surely? And you can nudge right up to the opening php tag, so a whole 16 bytes!

This doesn't look like a serious entry to me.

@mbomb007 You think... ? The question also doesn't state standard loopholes so this is a perfectly valid answer (for now)

@BasicallyAlanTuring First of all, loopholes are disallowed by default unless explictly allowed by the OP. Secondly, answers that don't make a serious golfing attempt are to be deleted. This answer doesn't even attempt to compact the strings.

PHP, 881 Bytes
<?=json_decode(gzinflate(base64_decode("rVY9rxQxDPwr0Ta5E0lWQHcCJBAUNHcFiCoi217xeBIFDea/M3acr80eFXlPG6094x07TnK/l5fLZTH7QYbiz/hjsCUXvMVfcKn5kgzqqdmkEOdtiWiun69fP10/3ozCNx8E5RiSJg11bAKLK6Mg7Bh5+n7GM0aGksmoQVfBvTmb07tzzi/GrLjhTl/Oef6A+fRLYq4ScwtjIORYOO+F4yzpx5FYLoJYkZpws0kKUoBaGE4R8ylBVq5GKdEE5BQ3ju6sFOSf0JIWPQTuYrRvdFB9KdA91lS/LCbEOWtGV0fO/qm39lF2Q0iLW14d9aoJPi7aSrMjRz3041uwK3Lu96yZIRJmApScdC7+rGb213o1ub2+PTrDpwyoCo5LLlkrLR3mBKv1JQ5TGgGMuNo5y6y0LB721NrlpYwqcWinShmEm4eE1mlTXsf4QqBOMxKsYWaCMqg+OsIOTlrROOGVscebRtjjhTHhG6HhL6hWzxvwldDwEiU8wrc912vqCAK3XG46LrdoD8rAka99jXJT10U7Qu5hWfZ5I02LY478j9zaQtSLmRGsDSfE6+mEeK6U54LuzpijY0ds40EEUzWkYWQjBd+NoFnQ0A/0H629Aryp+XYzIQ9z41u2XLA4AGSkgIsJM66kgE3c5yMfkrhx1XC868GA5woPmG0lOY6AgPE2teRDsl5RziLY3d+1RgiL5UvdrwBAEQVYizDpBa/P5XLRG3zzd1if+OzBg/h/fevk5e4t8Q8U2X03lkBlC6ASEQnIg7/LM1p5JflFoyeZrGU+1pi2eWuGAVlic/n123HL8S3PlVz+/AU=")),1)[$argv[1]];

Making of fill the lines with the graphics use the heredoc syntax in PHP
$a[1]=<<<A

A;
$a[2]=<<<B

B;
$a[3]=<<<C

C;
echo base64_encode(gzdeflate(json_encode($a)));

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


text:
Interpret loose ranges
Interpret loose ranges
ListSharp is an interpreted programming language that has many features, one of those features is a 1 index based range creator that works like this:
You define a range as (INT) TO (INT) or just (INT) where both or the single int can go from min to max int32 value
Then you can use those ranges to extract elements of an array without fearing to overstep it's boundaries

therefore:
1 TO 5 generates: {1,2,3,4,5}
3 generates: {3}
Ranges can be added up using the AND operator
1 TO 5 AND 3 TO 6 generates: {1,2,3,4,5,3,4,5,6}
remember this works with negative numbers as well
3 TO -3 generates: {3,2,1,0,-1,-2,-3}

The challenge is the following:
Input
A character array and the previously defined range clause as a string
Output
The elements at the 1 index based locations of the range (non existing/negative indexes translate to an empty character)

How to win
As a code-golf challenge you are supposed to create the program with the shortest byte count to win

It has been pointed out empty characters do not exist, therefore you should be ignoring them (I only showed them here to make it easier to understand yet it confused people)
Test cases:
input array is:
{'H','e','l','l','o',' ','W','o','r','l','d'}

range clause:
"1 TO 3" => "Hel"
"5" => "o"
"-10 TO 10" => "Hello Worl"
"0 AND 2 AND 4" => "el"
"8 TO 3" => "oW oll"
"-300 AND 300" => ""
"1 TO 3 AND 3 TO 1" => "HelleH"
"-20 TO 0 AND 1 AND 4" => "Hl"

Are we allowed to use 0-index instead of 1-index as input string? So the range clause becomes "0 TO 2" => {'H', 'e', 'l'}?

The ASCII table does not have an empty character (excluding non-printable ones). What's wrong with using space?

a char array is basically a string, therefor empty chars just wont be printed or returned

Are you saying that e.g. el, eWoll, and (nothing) are valid outputs for the last three test cases?

Also, will e.g. 3 TO 3 ever be an input and what is the expected output?

Actually, the fifth test case looks wrong. Shouldn't the '' be ' '?

you are correct, nice catch
yes 3 TO 3 is like 3 and is perfectly valid
el
oWoll
(nothing)
is valid

You need some test cases for ANDing multiples ranges. Also, You didn't answer if we can use zero-based indexing, which is standard in most languages.

were keeping 1 based indexing to stay original to the inspiration of the challenge, and ill add more test cases when im home

Python 2 - 239 211 210 bytes
Thanks to @mbomb007 and @Cyoce for further golfing this solution!
def r(s):
 t=[]
 for x in s.split("AND"):
  if"T"in x:a=map(int,x.split("TO"));b=2*(a[0]<a[1])-1;t+=range(a[0],a[1]+b,b)
  else:t+=int(x),
 return t
lambda p,v:[(['']+p+['']*max(map(abs,r(v))))[x]for x in r(v)]

Straight-forward approach. Tried generators and a recursive version, but they couldn't beat the simple for each loop. I'm a golfing noob, so this can most likely be improved quite a bit. Also, the major flaw of this snippet is that the range as a list object is computed again each time an element is retrieved from the character array (see last line, list comprehension). This means r(s) is executed len(r(s)) + 1 times.
Ungolfed code:
def find_range(string):
    result = []

    # Split at each AND and look at each element separately
    for element in string.split("AND"):
        # Element is just a number, so add that number to the result list
        if "TO" not in string:
            result += [int(string)]

        # Generate a list with all the values in between the boundaries
        # (and the boundaries themselves, of course) and append it to the result list
        else:
            boundaries = map(int, string.split("TO"))
            ascending = boundaries[0] < boundaries[1]

            # range(start, stop, step) returns [start, ..., stop - 1], so extend the stop value accordingly
            # range(8, 3, 1) returns just [], so choose respective step (negative for a descending sequence)
            result += range(boundaries[0], boundaries[1] + (1 if ascending else -1), 1 if ascending else -1)

# Make the char array 1-indexed by appending an empty char in 0th position
# Add enough empty chars at the end so too large and negative values won't wrap around
interpret = lambda chars, range_expr: [(['']+chars+['']*max(map(abs, find_range(range_expr))))[x] for x in find_range(range_expr)]

Test cases:
c = list("Hello World")
print interpret(c, "1 TO 3")
print interpret(c, "5")
print interpret(c, "-10 TO 10")
print interpret(c, "0 AND 2 AND 4")
print interpret(c, "8 TO 3")
print interpret(c, "-300 AND 300")

Output:
['H', 'e', 'l']
['o']
['', '', '', '', '', '', '', '', '', '', '', 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l']
['', 'e', 'l']
['o', 'W', ' ', 'o', 'l', 'l']
['', '']

Great first answer! Welcome to PPCG!

You may benefit from viewing Tips for Golfing in Python. You can replace 2 spaces for double-indentation with a single tab. You can put the code following the if on the same line and separate them with semicolons. And remove the space in [x] for. Also, 1if b else-1 can be replaced with either b and 1or-1 or 2*bool(b)-1 to save a byte.

Thanks! I already looked at and (tried to) use.d some of them. Will have another look through all the answers again later. :)

And I think you can use an unnamed lambda, since it's not recursive.

t+=[int(x)] canbecome t+=int(x),

Scala, 165 bytes
(s:String,r:String)=>r split "AND"map(_ split "TO"map(_.trim.toInt))flatMap{case Array(a,b)=>if(ax}map(i=>s lift(i-1)getOrElse "")

Explanation:
(s:String,r:String)=> //define a function
r split "AND"         //split the range expression at every occurance of "AND"
map(                  //map each part...
  _ split "TO"          //split at to
  map(                  //for each of these splitted parts, map them to...
    _.trim.toInt          //trim all whitespace and parse as an int
  )
)                     //now we have an Array[Array[Int]]
flatMap{              //map each inner Array...
  case Array(a,b)=>if(ax             //otherwise just return it
}                     //and flatten, so we get an Array[Int]
map(i=>               //for each int
  s lift(i-1)         //try to get the char with index i-1, since Scala is zero-based
  getOrElse ""        //otherwise return ""
)

Groovy (99 97 Bytes)
{n,v->Eval.me("[${n.replaceAll(" TO ","..").replaceAll(" AND ",",")}]").flatten().collect{v[it]}}

Try it here: https://groovyconsole.appspot.com/edit/5155820207603712
Explanation:

.replaceAll(" TO ","..") - Replace the to with a traditional range.
.replaceAll(" AND ", ",") - Replace all ands with a comma.
"[${...}]" - Surround it with the "list" notation in Groovy.
Eval.me(...) - Evaluate string as Groovy code.
.flatten() - Flatten the mixture of 2D array and 1D array into a 1D array.
.collect{v[it]} - Collect the indices from the array into a single structure.

Here's a 115 113 byte solution removing nulls from the output:
https://groovyconsole.appspot.com/edit/5185924841340928
Here's a 117 byte solution if you say it MUST be indexed at 1 instead of 0:
https://groovyconsole.appspot.com/edit/5205468955803648
If you want me to swap out the original for the 113/117 byte one, let me know.

If you don't like me using "nulls" for the characters that aren't there, +5 bytes at the end for "-null", which removes all nulls from the set.

I love this clever coincidence

I learned something from this though, never knew Groovy had Eval.me(...) until now; given using it in practice would be ridiculously insecure, still a cool thing to know.

C#, 342 bytes
a=>r=>{var s=r.Replace(" AND","").Replace(" TO ","|").Split();int b=a.Length,i=0,n,m,j,o;var c=new List<char>();for(;i<s.Length;){var d=s[i++].Split('|');if(d.Length<2)c.Add(b<(n=int.Parse(d[0]))||n<1?' ':a[n-1]);else{o=(m=int.Parse(d[0]))<(n=int.Parse(d[1]))?1:-1;for(j=m;o>0?j<=n:j>=n;j+=o)c.Add(b<j||j<1?' ':a[j-1]);}}return c.ToArray();};

Ungolfed method:
static char[] f(char[] a, string r)
{
    var s=r.Replace(" AND","").Replace(" TO ","|").Split();
    int b=a.Length,i=0,n,m,j,o;
    var c=new List<char>();
    for(;i<s.Length;)
    {
        var d=s[i++].Split('|');
        if(d.Length<2)
            c.Add(b<(n=int.Parse(d[0]))||n<1?' ':a[n-1]);
        else
        {
            o=(m=int.Parse(d[0]))<(n=int.Parse(d[1]))?1:-1;
            for(j=m;o>0?j<=n:j>=n;j+=o)
                c.Add(b<j||j<1?' ':a[j-1]);
        }
    }

    return c.ToArray();
}

Full program with test cases:
using System;
using System.Collections.Generic;

namespace InterpretLooseRanges
{
    class Program
    {
        static void PrintCharArray(char[] a)
        {
            for (int i=0; i<a.Length; i++)
                Console.Write(a[i]);
            Console.WriteLine();
        }

        static void Main(string[] args)
        {
            Func<char[],Func<string,char[]>>f= a=>r=>{var s=r.Replace(" AND","").Replace(" TO ","|").Split();int b=a.Length,i=0,n,m,j,o;var c=new List<char>();for(;i<s.Length;){var d=s[i++].Split('|');if(d.Length<2)c.Add(b<(n=int.Parse(d[0]))||n<1?' ':a[n-1]);else{o=(m=int.Parse(d[0]))<(n=int.Parse(d[1]))?1:-1;for(j=m;o>0?j<=n:j>=n;j+=o)c.Add(b<j||j<1?' ':a[j-1]);}}return c.ToArray();};

            char[] ar = {'H','e','l','l','o',' ','W','o','r','l','d'};

            PrintCharArray(f(ar)("1 TO 3"));
            PrintCharArray(f(ar)("5"));
            PrintCharArray(f(ar)("-10 TO 10"));
            PrintCharArray(f(ar)("0 AND 2 AND 4"));
            PrintCharArray(f(ar)("8 TO 3"));
            PrintCharArray(f(ar)("-300 AND 300"));
        }
    }
}

A naive solution, using a char list, which uses ' ' as an empty character and gets the job done. Hoping to improve soon.

JavaScript (ES6), 141
Unnamed function with 2 parameters, the first being the character array (can be a string either), the second the string containing the range definition.
The return value is an array where each element can either be a single character or the js value undefined. When stringified, this result in a sequence of comma separated chars having undefined shown as the "empty" char - as the test cases in the first version of the question.
Using .join you can get a string result similar to the test case output in the current version of the question.
(l,r,u,z=[])=>(r+' E').replace(/\S+/g,x=>x>'T'?u=t:x>'A'?[...Array((t-(w=(u=u||t)-(d=+u<t?1:-1)-1)-1)*d)].map(_=>z.push(l[w+=d]),u=0):t=x)&&z

Less golfed
(
 l, r, // input paramaters, array/string and string
 u,    // local variable start at 'undefined'
 z=[]  // local variable, will contain the ouput
) =>
  (r+' E') // add an end marker
  .replace( /\S+/g, x=> // execute for each nonspace substring
    x > 'T' // check if 'TO'
    ? u = t // if 'TO' save first value in u (it's a string so even 0 is a truthy value)
    : x > 'A' // check if 'AND' or 'E'
      ? (
          u = u||t, // if u is falsy, it's a single value range t -> t
          d = +u < t ? 1 :-1, // direction of range up or down,comparison has to be numeric, so the leading +
          w = u - d - 1, // starting value (decrement by 1 as js array are 0 based)
          u = 0, // set u to falsy again for next round
          [...Array((t - w - 1) * d)] // build the array of required number of elements
          .map(_ => z.push(l[w+=d])) // iterate adding elements of l to z
        )
      : t = x // if not a keyword, save value in t
  ) && z // return output in z

Test

f=
(l,r,u,z=[])=>(r+' E').replace(/\S+/g,x=>x>'T'?u=t:x>'A'?[...Array((t-(w=(u=u||t)-(d=+u<t?1:-1)-1)-1)*d)].map(_=>z.push(l[w+=d]),u=0):t=x)&&z

function run(x)
{
  R.value=x;
  O.textContent=f(L.value,x)
}

run("10 TO 5 AND 5 TO 10")

Base string	<input id=L value="Hello World">

Custom range	<input id=R ><button onclick='run(R.value)'>-></button>

Output

Test case ranges
<select id=T onchange='run(this.value)'>
<option/>
<option value="1 TO 3">1 TO 3 => {'H','e','l'}</option>
<option value="5">5 => {'o'}</option>
<option value="-10 TO 10">-10 TO 10 => {'','','','','','','','','','','','H','e','l','l','o',' ','W','o','r','l'}</option>
<option value="0 AND 2 AND 4">0 AND 2 AND 4 => {'','e','l'}
"8 TO 3" => {'o','W',' ','o','l','l'}</option>
<option value="-300 AND 300">-300 AND 300 => {'',''}</option>
<option value="1 TO 3 AND 3 TO 1">1 TO 3 AND 3 TO 1 => "HelleH"</option>
<option value="-20 TO 0 AND 1 AND 4">-20 TO 0 AND 1 AND 4 => "Hl"</option>
</select>

R, 142 bytes
Assuming I understood the challenge correctly, here I am assuming that r is the pre-defined range clause in string format, and that the input array ("Hello world", in the examples) is read from stdin.
r=eval(parse(t=paste("c(",gsub("AND",",",gsub("TO",":",r)),")")))
o=strsplit(readline(),e<-"")[[1]][r[r>0]]
o[is.na(o)]=e
c(rep(e,sum(r<1)),o)

Some test cases:
r="1 TO 3"
[1] "H" "e" "l"

r="5"
[1] "o"

r="-10 TO 10"
[1] ""  ""  ""  ""  ""  ""  ""  ""  ""  ""  ""  "H" "e" "l" "l" "o" " " "w" "o" "r" "l"

r="0 AND 2 AND 4"
[1] ""  "e" "l"

r="8 TO 3"
[1] "o" "w" " " "o" "l" "l"

r="-300 AND 300"
[1] "" ""

Ungolfed/explained
Line 1
r=eval(parse(t=paste("c(",gsub("AND",",",gsub("TO",":",r)),")")))

R has a nice infix operator : which generates sequences. 1:5 gives [1, 2, 3, 4, 5], and 0:-2 gives [0, -1, -2]. So, we replace the TO in the loose range clause with :.
                                         gsub("TO",":",r)

Interpreting AND is just concatenation. We can use the function c for that, which handily is able to take an arbitrary number of arguments, comma-separated. So we replace AND with ,
                          gsub("AND",",",      ...       )

and then wrap the whole thing in c(, ).
               paste("c(",              ...               ,")")

This yields a character string that could look like c( 1 : 5 , 7 ). We call parse to convert to type "expression" and then eval to evaluate the expression. The resulting sequence of numbers is then re-assigned to the variable r.
r=eval(parse(t=                     ...                        ))

Line 2
o=strsplit(readline(),e<-"")[[1]][r[r>0]]

Now for the ugly part - dealing with strings in R, which gets messy quickly. First we define e to be an empty string (we will need this later).
                      e<-""

We read from stdin and convert the character string to an array of individual characters by splitting at the empty string. (E.g. we go from "Hi" to ["H", "i"].) This returns a list of length 1, so we have to ask for the first element [[1]] to get an array that we can work with. Ugh, I warned you this was messy.
  strsplit(readline(), ... )[[1]]

R indexes beginning at 1, and has a nice feature with negative numbers. Suppose x is ['a', 'b', 'c']. Calling x[1] unsurprisingly returns 'a'. Calling x[-1] returns all of x except index 1, i.e. ['b', 'c']. This is a cool feature, but means that we have to be careful with our negative indices for this problem. So for now, we just return the elements of the input array with index >0, and assign the result to o.
o=               ...             [r[r>0]]

Line 3
However, there's a problem! For indices that are greater than the length of the array, R just returns NA values. We need it to return empty strings. So we redefine the elements of o for which is.na(o) is TRUE to be the empty string.
o[is.na(o)]=e

Line 4
c(rep(e,sum(r<1)),o)

Finally, how do we deal with the negative (and zero) indices? They all need to return the empty string, so we repeat the empty string N times, where N is the number of indices that are <1.
  rep(e,sum(r<1))

Finally, we concatenate the previously-defined o to this (potentially empty) list.
c(      ...      ,o)

Python 2, 156 155 bytes
My answer has some similar ideas as 1Darco1's answer, but by using a different approach from the start (string slicing rather than lists), it ended up quite a bit shorter. It would be four bytes shorter if 0-indexing was allowed.
s,r=input()
o=""
for x in r.split("AND"):
    i=map(int,x.split("TO"));d=2*(i[0]<i[-1])-1
    for _ in-1,0:i[_]-=11**9*(i[_]<0)
    o+=s[i[0]-1:i[-1]+d-1:d]
print o

Try it online
Fortunately, I can parse strings containing spaces into integers. Negative indexing in Python indexes from the end of the string, so I use i[-1] to either be the same as i[0] or the second value, if there is one. Then I have to adjust any negative range values to more negative, so they won't mess with the slicing. Multiplying negative values by 11**9 (2357947691) will account for ranges using integer min value. Then, simply slice the string, using reverse slice if the range is reversed.
With zero-indexing (151 bytes):
s,r=input()
o=""
for x in r.split("AND"):
    i=map(int,x.split("TO"));d=2*(i[0]<i[-1])-1
    for _ in-1,0:i[_]-=11**9*(i[_]<0)
    o+=s[i[0]:i[-1]+d:d]
print o

Good job! Slicing definitely is the way to go here. My range approach is basically just a super verbose form of exactly that. And you even got rid of the whole if"T"in x: else: part. +1

Jelly, 28 27 25 19 bytes
-3 Thanks to caird coinheringaahing
ḟØẎṣ”Aṣ€”OVr/€FfJ}ị

A dyadic Link accepting the range clause on the left and the array on the right (both as lists of characters) that yields the resulting list of characters.
TryItOnline
How?
ḟØẎṣ”Aṣ€”OVr/€FfJ}ị - Link: range-clause, C; array, W
 ØẎ                 - upper-case consonants ['B','C','D','F',...,'Z']
ḟ                   - filter remove (from C) (i.e. TO->O, AND->A)
   ṣ”A              - split at 'A's
      ṣ€”O          - split each at 'O's      e.g. [["-1","2"],["7"]]
          V         - evaluate as Jelly code       [[-1,2],[7]]
            /€      - rescue each by:
           r        -   inclusive range            [[-1,0,1,2],[7]]
              F     - flatten                      [-1,0,1,2,7]
                J}  - range of length (of W)
               f    - filter keep (those of F that are in bounds of W)
                  ị - index into (W)

Your TIO link still has the 27 byte version. -3 bytes

Thanks @cairdcoinheringaahing, golfed another three off :)

Good to see that you’re rescueing the inputs ;)

Perl - 110 bytes
Calling the script in the command line with the string as the first argument, and the range as the second.
for(split AND,pop@ARGV){$_>0?print+(split//,"@ARGV")[$_-1]:0for(/(.+)TO(.+)/?($1>$2?reverse$2..$1:$1..$2):$_)}

De-obfuscated :
for $subrange (split 'AND', $ARGV[1]) {
    for $index ($subrange =~ /(.+)TO(.+)/
        ? ($1 > $2 ? reverse $2..$1 : $1..$2) # All indices of that range
        : $subrange) # Otherwise, an index only
    {
        if ($index > 0) {
            # Here, 'split' returns an array of all characters
            print((split //, $ARGV[0])[$index - 1]);
        }
    }
}

Python 2, 146 bytes
lambda s,a:[a[i]for x in[map(int,c.split('TO'))for c in s.split('AND')]for i in range(x[0]-1,x[-1]-2*(x[-1]<x[0]),1-2*(x[-1]<x[0]))if 0<=i<len(a)]

All tests are at ideone
Splits the clause, s, on "AND", splits each of the resulting sub-clauses on "TO", converts the resulting strings to int using map. The results will each have either 1 or 2 items (1 if no "TO" was present in the sub-clause).
Constructs 0-based ranges for each of these using the step parameter of range as 1 or -1 by inspection of the values at indexes 0 and -1 (a list with one entry has that entry at both indexes).
Runs through these ranges and constructs a list of the output, if the indexes provided are in-range (if 0<=i<len(a)).

Clojure 232 230 229 bytes
Oh what a monster I have created... But actually this was 260 when I was about to submit it.
Edit: removed a space from #(get r %_""), (if_(< f t) and (take-nth 2_%) (indicated as _).
(let[S clojure.string/split](fn[r s](apply str(map #(get r %"")(mapcat #(apply(fn([f][(dec f)])([f t](if(< f t)(range(dec f)t)(reverse(range(dec t)f)))))%)(map #(mapv read-string(take-nth 2%))(map #(S % #" ")(S s #" AND "))))))))

Less golfed:
(def f (let[S clojure.string/split]
         (fn[r s] (->> (map #(S % #" ") (S s #" AND "))
                       (map #(mapv read-string (take-nth 2 %)))
                       (mapcat #(apply(fn
                                        ([f][(dec f)])
                                        ([f t](if (< f t)
                                                (range (dec f) t)
                                                (reverse (range (dec t) f)))))  %))
                       (map #(get r % ""))
                       (apply str)))))

Uses clojure.string/split to split by " AND " and " ", take-nth drops "TO" between integers, function argument matching handles the case of 1 or 2 arguments and that is about it.
Calling convention: (f "Hello World" "1 TO 3 AND 2 AND 8 TO 2")

You can remove a heck of a lot of bytes by removing spaces in general, especially between the # chars.

Are you sure I could remove a space between any #? I tried it without success, it gets "merged" with the previous token. Oh, one more space to remove before % there.

Scala, 151 bytes
_.split(" AND ").flatMap{case s"$a TO $b"=>a.toInt-1 to(b.toInt-1,(b.toInt-a.toInt).sign);case x=>Seq(x.toInt-1)}flatMap _.map("".+).orElse{case _=>""}

Try it in Scastie!


text:
Make Ascii buildings with arguments
Make 2d ASCII buildings depending on what the input is. The submissions can either be a program that takes input, or a function that accepts input via its parameters.
e.g. An input of 5,3,6 would output
          ┌──┐
          │┌┐│
┌──┐      │└┘│
│┌┐│      │┌┐│
│└┘│      │└┘│
│┌┐│      │┌┐│
│└┘│ ┌──┐ │└┘│
│┌┐│ │┌┐│ │┌┐│
│└┘│ │└┘│ │└┘│
│┌┐│ │┌┐│ │┌┐│
│└┘│ │└┘│ │└┘│
│┌┐│ │┌┐│ │┌┐│
│└┘│ │└┘│ │└┘│

and 4,2 would output
┌──┐
│┌┐│
│└┘│
│┌┐│
│└┘│ ┌──┐
│┌┐│ │┌┐│
│└┘│ │└┘│
│┌┐│ │┌┐│
│└┘│ │└┘│

The input can either be a string that contains the integers separated by a comma, or it can be a sequence of integers, or as an array of integers, or any other similar way. The integers will have a maximum value of 255 and they will not be negative or equal to 0. Standard loopholes apply.
Trailing spaces and newlines allowed.
Copy and paste items

Building Top: ┌──┐
Window Top: │┌┐│
Window Bottom: │└┘│

(my first golf, hope it's not too bad)
EDIT: Turns out box drawing isn't ascii, but they seem to print in textmode, so that's okay. This is different because of the varying height and caps
EDIT 2: standard input is okay, too if commandline arguments are bad (something like python's input())
EDIT 3: The program can either be a program or a function. In the case of a program, it should take input via STDIN or similar if it is not possible in your language. In the case of a function, the input will be passed as parameters.
This is code-golf so the program with the shortest byte count wins!

It's not ASCII art if it requires non-ASCII characters (like the box drawing characters). Also, it's close enough to this challenge to be a duplicate in my eyes.

Welcome to PPCG! This is a nice first challenges, but here is some advice: requiring input via command-line arguments is very limiting and frowned upon in this community. It's usually best to stick to the default I/O methods. Secondly, let me recommend the sandbox for future challenges where you can get feedback for your ideas before the challenge goes live. Keep it up!

@Mego with the touching buildings and half-integer input the other one seems a lot trickier than this. (That said, there might be a closer duplicate somewhere, but I wouldn't consider that one a dupe.)

@MartinEnder I disagree. This is essentially the subset of that challenge with only integer inputs (the different characters and the spacing between the buildings doesn't change the core challenge much).

Except you can't chose to answer the subset of a challenge, such answer would be disqualified. So while I think the other challenge is more interesting, this one 1) could be more accessible to beginners 2) could allow other interesting golfing tricks by its simplicity

@Mego (I think) This is different, because the figures are different heights and are not fixed. The caps might also make a difference

The windows make a remarkable difference. This is trickier than switching between two different roofs. Sharing walls and empty ground were easy.


text:
Priority to the right
Your task is to regulate traffic on a crossroads. There are 4 roads coming from north, east, south and west.
The input is a string representing the upcoming traffic on each road. For example, NNNWS indicates there is a total of 5 cars: three at the north, one at the west and one at the south. The order of characters has no importance here, NNNWS is equivalent to WNNSN.
You must output the order in which the cars should go, using the priority to the right rule: cars coming from the south must let cars coming from east go first, east gives way to north, north gives way to west and west gives way to south.
For example, with the input NNNWS, the south car should go first, then the west car, then the 3 north cars. The output should thus be SWNNN.
There are some indecidable cases, for example NS or NNWSE : you should then output the string stuck.
Test cases
N => N
NW => WN
NWS => SWN
SNW => SWN
SSSSS => SSSSS
ENNNNES => NNNNEES
NS => stuck
NNWSE => stuck

Both of those seem a lot harder because they take the outgoing directions into account as well.

I would recommend using undefined behavior instead of printing stuck.

@Erik when dealing with road safety, an undefined behavior cannot be accepted :-)

@Fatalize.  The "Solve a traffic intersection" challenge is far more demanding and intricate than the present challenge.

Related. Related.

@SuperChafouin So, code golfing is accepted, huh?

Is the empty string possible as input ? If so, what should the result be? And why is NS stuck ? Because both NS and SN would be a solution ?

can we stop the program/print nothing instead of printing stuck?

Perl, 65 bytes
Includes +2 for -lp
Give input on STDIN. Assumes the empty string is not a valid input
#!/usr/bin/perl -lp
s%.%'+(y/NESW/ESWN/*s/N(.*)W/W$1N/,/N/^/S/)'x4%gere+0or$_=stuck

If you don't mind the absence of a newline after stuck you can drop the l option

PHP, 267 Bytes
use the new spaceship operator and usort
-5 Bytes by @IsmaelMiguel
<?foreach($f=[E,S,W,N]as$l)$s.=+!($r=strstr)($i=$argv[1],$l);if(in_array($s,[0101,1010,0000]))die(stuck);$x=($p=strpos)($s,"1");$t=$r($j=join($f),$f[$x]).$r($j,$f[$x],1);$a=str_split($i);usort($a,function($x,$y)use($t,$p){return$p($t,$x)<=>$p($t,$y);});echo join($a);

Breakdown
# Extended Version without notices
$s="";
foreach($f=["E","S","W","N"] as $l){$s.=+!strstr($i=$argv[1],$l);} #bool concat swap the false true values in string
if(in_array($s,["0101","1010","0000"])){die("stuck");} # NS WE NESW -> stuck = end program
$x=strpos($s,"1"); # find the first false value for an begin for the sort algorithm
$t=strstr($j=join($f),$f[$x]).strstr($j,$f[$x],1); # create the sort pattern
#sort algorithm example sort string = NESW-> N is not in the string
function c($x,$y){
    global $t;
    return strpos($t,$x)<=>strpos($t,$y); # e.g. comparison E<=>W =-1 , W<=>S=1, W<=>W =0
}
$a=str_split($i); # Input in an array
usort($a,"c"); #sort array
echo join($a);# output array as string

Instead of function c($x,$y){global$t,$p;return$p($t,$x)<=>$p($t,$y);}$a=str_split($i);usort($a,c);, you can use $a=str_split($i);usort($a,function($x,$y)use($t,$p){return$p($t,$x)<=>$p($t,$y);}); and save 5 bytes. The spaceship operator really helped with this sort of sorting. For you to understand what I did, I moved the function into usort(), making it an anonymous function. Then, instead of global (NEVER use it), I've used function(...)use($t,$p){...}. The use(...) syntax allows you to pass variables into the anonymous function body (it accepts recerences too).

@IsmaelMiguel Thank You for this wonderful explaining.

You're welcome. I really love the use() bit on anonymous functions. You should use and abuse it.

JavaScript (ES6), 108 107 106 104 bytes
s=>(r=t=`NESWNE`,s.replace(/./g,c=>r|=2<<t.search(c)),t.substr(449778192>>r&3,1053417876>>r&3)||`stuck`)

Accumulates a bitmask of which directions have approaching cars and extracts the appropriate portion of the priority string.

Uncaught SyntaxError: Invalid regular expression: missing /

@Cyoce Whoops. What happened was that the browser wrapped the code at that point and I thought a newline had crept in. Sorry about that.

no problem, just letting you know.

Batch, 216 bytes
@echo off
set/pt=
set/an=2,e=4,s=8,w=16,r=0
:l
set/ar^|=%t:~0,1%
set t=%t:~1%
if not "%t%"=="" goto l
set/a"o=449778192>>r&3,l=1053417876>>r&3"
if %l%==0 (echo stuck)else set t=NESWNE&call echo %%t:~%o%,%l%%%

Simple port of my JavaScript answer. Takes input on STDIN in upper or lower case.


text:
Dennis numbers 2.0
PPCG user and elected mod, @Dennis just became the second ever user to earn over 100k rep!

This is a totally original idea, that I did not get from anybody else, but let's make a challenge based off of his user ID, 12012 as a tribute!
Looking at it, you'll notice that there are two distinct "sections" to his ID.

12

and

012

Both of these sections add up to a 3. That's a pretty interesting property.
Let's define a "Dennis 2.0 number" as any positive integer where every maximal subsequence of strictly increasing digits sums to the same number. For example,
123

is a Dennis 2.0 number because there is only one maximal sublist of strictly increasing digits, and it sums to 6. Additionally, 2,846,145 is also a Dennis 2.0 number because the three maximal sublists of increasing digits, namely
28
46
145

All sum to 10. Additionally, numbers that just repeat the same digit must be Dennis 2.0 numbers because, for example, 777 can be broken down into
7
7
7

which clearly all sum to seven.
A number such as 42 is not a Dennis 2.0 number, since it is broken down into
4
2

which clearly do not sum to the same number.
The challenge
You must write a program or function to determine if a given number is a Dennis 2.0 number or not. You can take input and output in any reasonable input format, e.g. as a string, as a number, from a file, funtion arguments/return, from STDIN/STDOUT, etc. and then return a truthy value if this number is a Dennis 2.0 number, and a falsy value if it is not. For reference, here is every Dennis 2.0 number up to 1,000:
1
2
3
4
5
6
7
8
9
11
12
13
14
15
16
17
18
19
22
23
24
25
26
27
28
29
33
34
35
36
37
38
39
44
45
46
47
48
49
55
56
57
58
59
66
67
68
69
77
78
79
88
89
99
101
111
123
124
125
126
127
128
129
134
135
136
137
138
139
145
146
147
148
149
156
157
158
159
167
168
169
178
179
189
202
222
234
235
236
237
238
239
245
246
247
248
249
256
257
258
259
267
268
269
278
279
289
303
312
333
345
346
347
348
349
356
357
358
359
367
368
369
378
379
389
404
413
444
456
457
458
459
467
468
469
478
479
489
505
514
523
555
567
568
569
578
579
589
606
615
624
666
678
679
689
707
716
725
734
777
789
808
817
826
835
888
909
918
927
936
945
999

Standard loopholes apply, and the shortest answer measured in bytes wins!

Just for reference, Martin Ender was the first one to ever get 100k rep.

Is 12366 a valid 2.0 number? (123|6|6 vs. 1236|6)

@sp3000 That is not a Dennis number. It would be 1236|6

Can I take each digit as it's unary representation with a , between them? This is probably stretching it a lot.

@Riley Yeah, that's definitely stretching it. Unless it's the only possible way to take numeric input in your language, I'm gonna say no, that doesn't count.

I have a solution in sed. I'll just have to do the conversion myself.

@Riley Hmm. Somehow that seems more reasonable for a purely regex based language like sed. I guess I don't really have any problem with it (Since it will be a cool solution that probably wouldn't be the shortest anyway)

Im scared Dennis will destroy all of us in this challenge nontheless

I'll post both, and no, they are not even close to winning.

@downrep_nation Who knows? Now, Jonathan Allan has been constantly outgolfing Dennis in Jelly.

Some say that TheLegend12012 was the first PPCG user ever... born from Jelly... (that sounds weird, also resurrecting old memes >_>)

Are you sure you mean "subsequence", not "substring"? (135 is a subsequence of 12345.)

Jelly, 13 12 bytes
1 byte thanks to @Dennis.
DIṠ’0;œṗDS€E

Try it online!
Explanation
DIṠ’0;œṗDS€E    Main link. Argument: N
D               Convert N to its digits.
 I              Find the differences between the elements.
  Ṡ             Find the sign of each difference. This yields 1 for locations where the
                list is strictly increasing and 0 or -1 elsewhere.
   ’            Decrement. This yields 0 for locations where the list is strictly
                increasing and -1 or -2 elsewhere.
    0;          Prepend a 0.
        D       Get another list of digits.
      œṗ        Split the list of digits at truthy positions, i.e. the -1s and -2s.
         S€     Sum each sublist.
           E    Check if all values are equal.

JavaScript (ES6), 72 70 bytes
Takes a string as input. Returns either false or a truthy value (which can be a number).
It's using a regular expression to transform an input string such as "2846145" into:
"(a=2+8)&&(a==4+6)&&(a==1+4+5)"

Then calls eval() on this expression.

let f =

n=>eval(n.replace(/./g,(v,i)=>(v>n[i-1]?'+':i?')&&(a==':'(a=')+v)+')')

console.log(f("101"));
console.log(f("102"));
console.log(f("777"));
console.log(f("2846145"));

Nice, that's a really smart idea. :-)

Like that idea as well!
But this is not working:
console.log(f("2011")); // false
console.log(f("189"));  // 18

@user470370 - I think that's actually correct. The definition states "subsequences of strictly increasing numbers", so 2011 splits as  2 / 01 / 1 and is not a D2.0 number. As for 189, it is a D2.0 number and 18 is a truthy value.

Ups
Of course, you are right. Didn't get that before. I think, I have to rework my own solution :D

Python, 50 bytes
r='0'
for d in input():r=d+'=+'[r<d]*2+r
1/eval(r)

Expects input() to evaluate to a string, so the input  needs surrounding quotes in Python 2. Output is via exit code, where 0 indicates success (truthy) and 1 indicates failure (falsy).
Test it on Ideone.
How it works
We initialize r to the string 0 and iterate over all digits d in the input.

If d is larger than the first digit of r (initially 0, then equal to the previous value of d), r<d evaluates to True and '=+'[r<d]*2 yields ++.
If d is smaller than the first digit of r, '=+'[r<d]*2 yields ==.
If d is equal to the first digit of r, r will be longer than the singleton string d, so '=+'[r<d]*2 yields once again ==.

In all cases, the digit d and the two generated characters get prepended to r.
Once all input digits have been processed, eval(r) evaluates the generated expression.

If the input consists of a single strictly increasing sequence of (positive) digits, the expression evaluates to their sum.
For example, the integer 12345 results in the expression 5++4++3++2++1++0, which yields 15 when evaluated. Note that each second + is a unary plus, so it doesn't affect the result. Dividing 1 by 15 is valid (the result is not important); the program exits normally.
If the input consists of two strictly increasing sequences of digits, the expression consists of a simple comparison.
For example, the integer 12012 results in the expression 2++1++0==2++1++0, which yields True when evaluated since both terms have sum 3. Dividing 1 by True (1) is valid (the result is not important); the program exits normally.
On the other hand, the integer 12366 results in the expression 6==6++3++2++1++0, which yields False when evaluated since the terms have sums 6 and 12. Dividing 1 by False (0) raises a ZeroDivisionError; the program exits with an error.
If the input consists of three or more strictly increasing sequences of digits, the expression consists of a chained comparison, which returns True if and only if all involved comparisons return True.
For example, the integer 94536 results in the expression 6++3==5++4==9++0, which yields True when evaluated since all terms have sum 9. As before, the program exits normally.
On the other hand, the integer 17263 results in the expression 3==6++2==7++1++0, which yields False when evaluated since the terms have sums 3, 8, and 8. As before, the program exits with an error.

About time I posted a submission to this challenge...

Brachylog, 13 bytes
~c@e:{<+}a!#=

Try it online!
Explanation
~c               Find a list of integers which when concatenated result in the Input
  @e             Split the integers into lists of digits
    :{<+}a       Each list of digit is stricly increasing, and compute its sum
          !      Discard all other choice points (prevents backtracking for smaller sublists)
           #=    All sums must be equal

~c will unify with the biggest sublists first.

PowerShell v2+, 100 64 61 bytes
-join([char[]]$args[0]|%{("+$_","-eq$_")[$_-le$i];$i=$_})|iex

A literal one-liner, as this is all one pipeline. Takes input as a string $args[0]. Loops through it as a char-array, each iteration placing either the current element with a + or -eq in front of it onto the pipeline based on whether the current value is -less-than-or-equal to the previous value $i. Those strings are -joined together and piped to iex (short for Invoke-Expression and similar to eval. For example, for input 2846145 this will be evaluated as +2+8-eq4+6-eq1+4+5, which is True.
That Boolean is left on the pipeline, and True/False is implicitly written at program completion.
NB - for single-digit input, the resulting digit is left on the pipeline, which is a truthy value in PowerShell.
Examples
PS C:\Tools\Scripts\golfing> 2846145,681,777,12366,2|%{"$_ -> "+(.\dennis-number-20.ps1 "$_")}
2846145 -> True
681 -> False
777 -> True
12366 -> False
2 -> 2

Pyke, 18 bytes
mb$1m>0R+fMbms}lt!

Try it here!
mb                 -         map(int, input)
  $                -        delta(^)
   1m>             -       map(^, 1>i)
      0R+          -      [0]+^
         f         -     input.split_at(^)
          Mb       -    deep_map(int, ^)
            ms     -   map(sum, ^)
              }    -  uniquify(^)
               lt! - len(^) == 1

GNU sed 217 or 115
Both include +1 for -r
217:
s/./&,/g;s/^/,/g;:;s,0,,;s,2,11,;s,3,21,;s,4,31,;s,5,41,;s,6,51,
s,7,61,;s,8,71,;s,9,81,;t;s/(,1*)(1*)\1,/\1\2X\1,/;t;s/,//g
s,1X1(1*),X\1a,;t;/^1.*X/c0
/Xa*$/s,a*$,,;y,a,1,;/1X1/b;/1X|X1/c0
c1

Takes input in normal decimal
Try it online!

115:
s/^|$/,/g;:;s/(,1*)(1*)\1,/\1\2X\1,/;t;s/,//g
s,1X1(1*),X\1a,;t;/^1.*X/c0
/Xa*$/s,a*$,,;y,a,1,;/1X1/b;/1X|X1/c0
c1

Takes input as a comma separated list of the numbers digits in unary. e.g. 123 would be 1,11,111
Try it online!

JavaScript (ES6), 66 65 63 bytes
Saved 2 bytes thanks to @edc65
x=>[...x,p=t=z=0].every(c=>p>=(t+=+p,p=c)?(z?z==t:z=t)+(t=0):1)

Takes input as a string. Old version (only works in Firefox 30+):
x=>[for(c of(p=t=0,x))if(p>=(t+=+p,p=c))t+(t=0)].every(q=>q==+p+t)

Hint: [...x,0] -> [...x,p=t=z=0]

@edc65 Thanks, I hadn't thought of that!

Perl, 38 + 3 (-p) = 41 bytes
-9 bytes thanks to @Ton Hospel !
s%.%2x$&.(~$&le~$')%eg;$_=/^(2+1)\1*$/

Since there is a $', the code needs to be in a file to run. So -p counts for 3 bytes. Outputs 1 if the number is a Dennis 2.0 number, or an empty string otherwise :
$ cat dennis_numbers.pl
s%.%2x$&.(~$&le~$')%eg;$_=/^(2+1)\1*$/
$ perl -p dennis_numbers.pl <<< "1
10
12315
12314"

I think this is probably the best approach in perl, but you can golf it down to 42: s%.%2x$&.($&.O ge$')%eg;$_=/^(2+1)\1*$/ with the -p option (+3 because the code has $')

Indeed, using the result of the comparison instead of that random A is much better! Thanks! I don't understand the .O though... Without it, it fails on some cases, but I can't see why.

$' is the next digit and all the ones after it. So in e.g. 778 it compares 7 to 78 which to lt looks like a rising sequence. The O breaks that and compares 7O to 78  (anything above 9 in ASCII works)

Oh right, that's nice! I looked for a way to use $' or $ ` instead of my capture groups, but couldn't find it, because of that "and all the ones after it". Thanks for the tip!

Mmm, ~$&le~$' should be 1 shorter

Mathematica, 38 bytes
Equal@@Tr/@IntegerDigits@#~Split~Less&

Anonymous function. Takes a number as input, and returns True or False as output.

Brachylog 2, 10 bytes, language postdates challenge
ẹ~c<₁ᵐ!+ᵐ=

Try it online!
This is basically the same algorithm as @Fatalize's answer (which I didn't see until after I'd written this), but rearranged somewhat to make it golfier under Brachylog 2's syntax.
It's a full program, returning false. if it isn't a Dennis 2.0 number, or true if it is.
Explanation
ẹ~c<₁ᵐ!+ᵐ=
ẹ           Interpret the input number as a list of digits
      !     Find the first (in default order)
 ~c           partition of the digits
   <₁ᵐ        such that each is in strictly increasing order
         =  Assert that the following are all equal:
       +ᵐ     the sums of each partition

As usual for a Brachylog full program, if all the assertions can be met simultaneously, we get a truthy return, otherwise falsey. The default order for ~c is to sort partitions with fewer, longer elements first, and in Prolog (thus Brachylog), the default order's defined by the first predicate in the program (using the second as a tiebreak, and so on; here, ~c dominates, because ẹ is deterministic and thus has nothing to order).

MATL, 24 23 20 18 16 bytes
Tjdl<vYsG!UlXQ&=

Returns a truthy of falsey matrix
Try it Online!
Also, congrats @Dennis!
Explanation
T       % Push a literal TRUE to the stack
        %   STACK: {1}
j       % Explicitly grab the input as a string
        %   STACK: {1, '2846145'}
d       % Compute the difference between successive ASCII codes
        %   STACK: {1, [6 -4 2 -5 3 1]}
l<      % Find where that difference is less than 1
        %   STACK: {1, [0 1 0 1 0 0]}
v       % Prepend the TRUE value we pushed previously
        %   STACK: {[1 0 1 0 1 0 0]}
Ys      % Compute the cumulative sum. This assigns a unique integer label to
        % each set of increasing numbers
        %   STACK: {[1 1 2 2 3 3 3]}
G!U     % Grab the input as numeric digits
        %   STACK: {[1 1 2 2 3 3 3], [2 8 4 6 1 4 5]}
lXQ     % Compute the sum of each group of increasing digits
        %   STACK: {[10 10 10]}
&=      % Computes element-wise equality (automatically broadcasts). A
        % truthy value in MATL is a matrix of all ones which is only the case
        % when all elements are equal:
        %   STACK: {[1 1 1
        %            1 1 1
        %            1 1 1]}
        % Implicitly display the result

Nice use of &=!

PHP, 108 105 92 bytes
$p=-1;foreach(str_split("$argv[1].")as$d)$p>=$d?$r&&$s-$r?die(1):($r=$s)&$s=$p=$d:$s+=$p=$d;

takes input from argument, exits with 0 for Dennis-2.0 number, with 1 else.
breakdown
$p=-1;                              // init $p(revious digit) to -1
foreach(str_split("$argv[1].")as$d) // loop $d(igit) through input characters
                                    // (plus a dot, to catch the final sum)
    $p>=$d                              // if not ascending:
        ?$r                             // do we have a sum remembered
        &&$s-$r                         // and does it differ from the current sum?
                ?die(1)                     // then exit with failure
                :($r=$s)&$s=$p=$d           // remember sum, set sum to digit, remember digit
        :$s+=$p=$d                      // ascending: increase sum, remember digit
    ;
//

05AB1E, 18 bytes
SD¥X‹X¸«DgL*ê¥£OÙg

Explanation
N = 12012 used as example.
                    # implicit input N = 12012
S                   # split input number to list of digits
                    # STACK: [1,2,0,1,2]
 D                  # duplicate
                    # STACK: [1,2,0,1,2], [1,2,0,1,2]
  ¥                 # reduce by subtraction
                    # STACK: [1,2,0,1,2], [1,-2,1,1]
   X‹               # is less than 1
                    # STACK: [1,2,0,1,2], [0,1,0,0]
     X¸«            # append 1
                    # STACK: [1,2,0,1,2], [0,1,0,0,1]
        DgL*        # multiply by index (1-indexed)
                    # STACK: [1,2,0,1,2], [0,2,0,0,5]
            ê       # sorted unique
                    # STACK: [1,2,0,1,2], [0,2,5]
             ¥      # reduce by subtraction
                    # STACK: [1,2,0,1,2], [2,3]
              £     # split into chunks
                    # STACK: [[1,2],[0,1,2]]
               O    # sum each
                    # STACK: [3,3]
                Ù   # unique
                    # STACK: [3]
                 g  # length, 1 is true in 05AB1E
                    # STACK: 1

Try it online!

DgL* can be ƶ for -3.

Ruby 2.3, 56 bytes
p !gets.chars.chunk_while(&:<).map{|a|eval a*?+}.uniq[1]

Almost certainly not the golfiest way to do this, but it shows off some nice language features.
(Not newline-tolerant, so run like ruby dennis2.rb <<< '12012')

JavaScript (ES6), 58
s=>![...s,z=x=p=0].some(c=>[c>p?0:z-=(x=x||z),z-=p=c][0])

Applying my rarely useful tip https://codegolf.stackexchange.com/a/49967/21348
It scans the string char by char identifying run of ascending chars, at the end of each rum it checks if the sum is always the same

c : current char
p : previous char
z : running sum, at the end of a run will be compared to ...
x : sum to compare against, at first run is simply made equal to z

Test

f=
s=>![...s,z=x=p=0].some(c=>[c>p?0:z-=(x=x||z),z-=p=c][0])

function run()
{
  var i=I.value
  O.textContent = i + ' -> ' + f(i)
}

run()

test=`1 2 3 4 5 6 7 8 9 11 12 13 14 15 16 17 18 19 22 23 24 25 26 27 28 29 33 34 35 36 37 38 39 44 45 46 47 48 49 55 56 57 58 59 66 67 68 69 77 78 79 88 89 99 101 111 123 124 125 126 127 128 129 134 135 136 137 138 139 145 146 147 148 149 156 157 158 159 167 168 169 178 179 189 202 222 234 235 236 237 238 239 245 246 247 248 249 256 257 258 259 267 268 269 278 279 289 303 312 333 345 346 347 348 349 356 357 358 359 367 368 369 378 379 389 404 413 444 456 457 458 459 467 468 469 478 479 489 505 514 523 555 567 568 569 578 579 589 606 615 624 666 678 679 689 707 716 725 734 777 789 808 817 826 835 888 909 918 927 936 945 999`.split` `

numerr=0
for(i=1; i<1000; i++)
{
  v = i + '';
  r = f(v);
  ok = r == (test.indexOf(v) >= 0)
  if (!ok) console.log('Error',++numerr, v)
}
if(!numerr) console.log('All test 1..999 ok')
<input id=I value=612324 type=number oninput='run()'>
<pre id=O>

Python 2, 69 bytes
Takes input as a string.
lambda I:len(set(eval(reduce(lambda x,y:x+',+'[y>x[-1]]+y,I+' '))))<2

Explanation:
ex 1201212012
Converts to list of sums:
1+2,0+1+2,1+2,0+1+2,
Evals and converts to set.
set([3])
If the length of the set is 1, all sums are the same.

PHP, 144 bytes
<?php preg_match_all("/0?1?2?3?4?5?6?7?8?9?/",$argv[1],$n);foreach($n[0]as$i)if(strlen($i)&&($a=array_sum(str_split($i)))!=$s=$s??$a)die;echo 1;

I'm sure there's a much cleverer (and shorter) way to do this but it will do for now.

Pyth, 20 bytes
Two versions
!t{sMcJjQThMx1<R0.+J
LS{b!t{sMhyI#I#./jQT

Try the first one online!
Try the second one online!

Ruby, 117 105 85 bytes
# original (117):
j,k=0,?0;"#{i}".chars.group_by{|n|n>k||j=j+1;k=n;j}.values.map{|a|a.map(&:to_i).reduce(&:+)}.reduce{|m,n|n==m ?m:nil}

# inspired by PHP regexp approach (105):
"#{i}".scan(/0?1?2?3?4?5?6?7?8?9?/).map{|a|a.chars.map(&:to_i).reduce(&:+)}.reduce{|m,n|!n||n==m ?m:nil}

# some number comparison simplification (85):
!"#{i}".scan(/0?1?2?3?4?5?6?7?8?9?/).map{|a|a.chars.map(&:to_i).reduce(&:+)}.uniq[1]

This would return the integer of this dennis number or nil if not a dennis number. All integers will be considered true in ruby as well nil is considered false. i is the integer that is being check.
Third version actually returns true and false.
P.S. tested to return 172 integers from 1 to 1000 as in the answer.

APL, 23 bytes
{1=≢∪+/↑N⊂⍨1,2>/N←⍎¨⍕⍵}

Explanation:

N←⍎¨⍕⍵: get the individual digits in the input, store in N
N⊂⍨1,2>/N: find the sublists of strictly increasing numbers in N
+/↑: sum each sublist
1=≢∪: see if the resulting list has only one unique element

Add++, 109 bytes
D,g,@@#,BF1_B
D,k,@@#,bR$d@$!Q@BFB
D,f,@,BDdVÑ_€?1€_0b]$+€?dbLRBcB*BZB]GbL1+b]+qG€gd€bLÑ_0b]$+BcB]£k€¦+Ñ=1$ª=

Try it online!
How it works
We define our 3 functions, \$f\$, \$g\$ and \$k\$. \$f\$ is the main function, which transforms the input to the correct output.
\$f(x)\$
First, we convert the input \$x\$ into a list of digits, then take the forward increments. Next, we take the sign of each increment. For increasing subsequences, this yields a subsequence of \$1\$, for equal subsequences, such as \$[4, 4, 4]\$, this yields \$0\$s and for decreasing sections, \$-1\$ is returned. We then take the complement of each of these signs, to turn \$1\$ into a falsey value, and everything else into a truthy value. Next, \$0\$ is prepended to this array, and we take the sign of each element again. This yields an array, \$A\$, of \$0\$ and \$1\$, with the first element always being \$0\$.
We then yield the range \$[1, 2, ... length(A)]\$ and remove the elements that correspond to \$0\$ in \$A\$. This leaves us with a second array, \$A'\$. We then push the number of digits in the input, add one and append this number to \$A'\$. We then deduplicate \$A'\$, to yield a new array, \$A''\$.
Next, we use the \$g\$ helper function. As \$g\$ is dyadic (takes 2 arguments), it behaves slightly differently when paired with the each operator, €. Dyadic functions pop a value from the stack and bind that value as their right argument to create a partial monadic function. This partial function is then mapped over each element in the argument. Here, the bound right argument is the digits of the input and the partial function is mapped over \$A''\$.
\$g(x, y)\$
Let's take a look at just one iteration of \$g(x, y)\$ where \$x := [1, 2, 0, 1, 2]\$ and \$y = 3\$. Note that \$3\$ is the first index in \$A''\$ where the signs from \$A\$ corresponded with \$1\$, rather than \$0\$. In fact, for \$x = 12012\$, we can see that \$A'' = [3, 6]\$. \$3\$ is the only non-zero index in \$A\$, and \$6\$ is the length of \$x\$ plus one.
So, for \$g([1, 2, 0, 1, 2], 3)\$ the following happens: First, we swap the two arguments so that the stack has the digits below the index. We then flatten the array and decrement the index. So far, the stack looks like [1 2 0 1 2 2]. We then perform the head command. We pop the index from the top f the stack and take that many characters from the stack, starting at the bottom. This yields \$[1, 2]\$, which is then returned by \$g\$.
So, \$g(x, y)\$ is mapped over each element \$y \in A''\$, which returns a series of prefixes of the input of various increasing lengths. This part could get slightly confusing, so we'll work through it with the example input of \$x := 12012\$. After the mapping of \$g\$, the stack currently looks like
[[[1 2] [1 2 0 1 2]]]

We then push an array containing the length of each array in the top element, or in this instance, the array \$[2, 5]\$. This is the same as \$A'' - 1\$, if the \$-\$ operator maps, but it takes more bytes to use this relationship. Next, the forward differences of the lengths is taken, and \$0\$ is prepended, yielding, in this example, \$[0, 3]\$. This new array is then zipped with the results from \$g\$ to create \$B\$ and the starmap operator is run over each pair.
\$k(x, n)\$
The starmap operator uses the function \$k\$ as its argument, and works by taking a dyadic function and a nested array. The array must consist of pairs, such as \$[[1, 2], [3, 4], [5, 6]]\$, and the dyadic function is mapped over each pair, with each element of the pairs being the left and right arguments respectively.
Here, our example nested array is \$[[[1, 2], 0], [[1, 2, 0, 1, 2], 3]]\$ and our function is \$k\$. We'll focus simply on \$k([1, 2, 0, 1, 2], 3)\$ for now.
\$k(x, n)\$ starts, similar to \$g\$, by swapping the two arguments, so that the array is the top of the stack. We then reverse the array and swap the arguments back. Now, \$n = 0\$, we want to leave the array unchanged, so we duplicate the integer and rotate the top three arguments, so that the stack has the format of \$[n, x, n]\$. Next, we return the array if \$n = 0\$. Otherwise, the top element is discarded, and we arrange the stack back to how it was i.e. with the reversed array at the bottom and the integer at the top, or in our example: \$[[2, 1, 0, 1, 2], 3]\$. We then flatten the stack, and take the first \$n\$ elements of \$x\$. These elements are then returned and replace \$x\$ in \$B\$.
For our input, this returns \$[0, 1, 2]\$. (Strictly speaking, it returns\$[2, 1, 0]\$, but order doesn't matter for the rest of the program).
After \$k(x, n)\$ is mapped over each pair \$(x, n) \in B\$, we take the sum of each pair, then check that each element is equal, by asserting that each neighbouring pair are equal, and then asserting that each of those equality tests result in \$1\$ (a truthy value). Finally, this result is returned.