text:
Robot on a ladder
Background
I have a ladder leaning on a wall, and a remote-controlled robot that can climb it.
I can send three different commands to the robot:

UP: the robot takes one step upwards. If it was on the highest step, it trips over, falls down and explodes.
DOWN: the robot takes one step downwards. If it was on the lowest step, nothing happens.
RESET: the robot returns to the lowest step.

I can also send a series of commands, and the robot will execute them one by one.
Your task is to predict its movements.
Input
Your inputs are a positive integer N, representing the number of steps in the ladder, and a non-empty string C over UDR, representing the commands I have sent to the robot.
You can assume that N < 1000.
The robot is initialized on the lowest step of the ladder.
Output
It is guaranteed that at some point, the robot will climb over the highest step and explode.
Your output is the number of commands it executes before this happens.
Example
Consider the inputs N = 4 and C = "UDDUURUUUUUUUDDDD"
The robot, denoted by @, moves along the 4-step ladder as follows:
|-|   |-|   |-|   |-|   |-|   |-|   |-|   |-|   |-|   |@|   |-||
|-|   |-|   |-|   |-|   |-|   |@|   |-|   |-|   |@|   |-|   |-||
|-|   |@|   |-|   |-|   |@|   |-|   |-|   |@|   |-|   |-|   |-|v
|@| U |-| D |@| D |@| U |-| U |-| R |@| U |-| U |-| U |-| U |-|# Boom!

The remaining commands are not executed, since the robot has exploded.
The explosion took place after 10 commands, so the correct output is 10.
Rules and scoring
You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.
Test cases
  1 U -> 1
  1 DDRUDUU -> 4
  4 UDDUUUUURUUUUDDDD -> 7
  4 UDDUURUUUUUUUDDDD -> 10
  6 UUUUUDRUDDDDRDUUUUUUDRUUUUUUUDR -> 20
 10 UUUUUURUUUUUUURUUUUUUUURUUUUUUUUUUUUUU -> 34
  6 UUUDUUUUDDDDDDDDDDDDDDRRRRRRRRRRRUUUUUU -> 8
  6 UUUDUUUDURUDDDUUUUUDDRUUUUDDUUUUURRUUDDUUUUUUUU -> 32
 20 UUDDUDUUUDDUUDUDUUUDUDDUUUUUDUDUUDUUUUUUDUUDUDUDUUUUUDUUUDUDUUUUUUDUDUDUDUDUUUUUUUUUDUDUUDUDUUUUU -> 56
354 UUDDUUDUDUUDDUDUUUUDDDUDUUDUDUDUDDUUUUDUDUUDUDUUUDUDUDUUDUUUDUUUUUDUUDUDUUDUDUUUUUDUDUUDUDUDUDDUUUUUUUDUDUDUDUUUUUDUDUDUDUDUDUDUDUUDUUUUUURUUUDUUUUDDUUDUDUDURURURUDUDUUUUDUUUUUUDUDUDUDUDUUUUUUDUDUUUUUUUDUUUDUUDUDUDUUDUDUDUUUUUUUUUUDUUUDUDUUDUUDUUUDUUUUUUUUUUUUUDUUDUUDUDUDUUUDUDUUUUUUUDUUUDUUUDUUDUUDDUUUUUUUUDUDUDUDUDUUUUDUDUUUUUUUUDDUUDDUUDUUDUUDUDUDUDUUUUUUUUUDUUDUUDUUUDUUDUUUUUUUUUUUDUDUDUDUUUUUUUUUUUUDUUUDUUDUDDUUDUDUDUUUUUUUUUUUUDUDUDUUDUUUDUUUUUUUDUUUUUUUUUDUDUDUDUDUUUUUUDUDUDUUDUDUDUDUUUUUUUUUUUUUUUDUDUDUDDDUUUDDDDDUUUUUUUUUUUUUUDDUDUUDUUDUDUUUUUUDUDUDUDUDUUUUDUUUUDUDUDUUUDUUDDUUUUUUUUUUUUUUUUUUDUUDUUDUUUDUDUUUUUUUUUUUDUUUDUUUUDUDUDUUUUUUUUUDUUUDUUUDUUDUUUUUUUUUUUUDDUDUDUDUUUUUUUUUUUUUUUDUUUDUUUUDUUDUUDUUUUUUUUUUUDUDUUDUUUDUUUUUUDUDUDUUDUUUUUUUUUUUUDUUUDUUDUDUDUUUUDUDUDUDUDUUUUUUUUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUUU -> 872

Related

I'm disappointed the task isn't to generate that ASCII art.

@immibis You know what to do...

Instead of a string, can we take a list of character codes?

@Cyoce Only if your language has no other means to represent a string.

@Zgarb what about a list of commands (characters)?

@Cyoce Same answer, only if that's how your language represents strings.

CJam, 26 25 22 bytes
0l{i"()~ "=~0e>_}%ri#)

Input format is the instructions on the first line and the ladder height on the second.
Test it here.
Explanation
0         e# Push a 0 - the initial position of the robot.
l         e# Read the instructions.
{         e# Map this block over the instruction...
  i       e#   Convert to character code. D -> 68, U -> 85, R -> 82.
  "()~ "= e#   We use these as cyclic indices into this array. Note that the values
          e#   modulo 4 are 0, 1 and 2, respectively. So U -> ) (increment),
          e#   D -> ( (decrement), R -> ~ (bitwise NOT, i.e negated and decrement).
  ~       e#   Evaluate the character as code.
  0e>     e#   Clamp to non-negative numbers. So D can't go below 0, and since R is
          e#   guaranteed to yield something negative, this resets it to zero.
  _       e#   Duplicate, so we keep one copy of the current position on the stack.
}%        e# Since this was a map, the result will be wrapped in an array.
ri        e# Read the ladder height and convert it to an integer.
#         e# Find its first occurrence in the list of positions.
)         e# The result is off by one, so we increment it.

Good idea to process all commands even after the explosion. I'll borrow that to save a few bytes

C, 83 71 + 4 = 75 bytes
Thanks @Josh for showing me the K&S style, which allowed 8 bytes off !!
f(i,s,z,a)char*s;{z-=*s<82?z>0:*s>82?-1:z;return z-i?f(i,s+1,z,a+1):a;}

Explaining:
f(i,s,z,a)char*s;{ // function needs one integer and one "string"
  z-=              // z is the bot's height
    *s<82?         // if 'Down'
      z>0          // then subtract 1 when z>0 or nothing otherwise
    :*s>82?        // else if 'Up'
      -1           // increase height z-=-1
    :z;            // else reset z=z-z
  return z-i?      // if z is not the max height
    f(i,s+1,z,a+1) // try next step
  :a;              // else print how many calls/steps were made
}                  // end of function

Example call:
f(1,"U",0,1);    // I've added 4 bytes in the score because of ",0,1"

Live test on ideone

Nice answer, but it might be worth noting that the function can effectively only be used once since globals z and a are not reset.

@Josh. I've updated. :)

Awesome!  You can also save a couple characters by playing around with the type declarations in your function: http://codegolf.stackexchange.com/a/40266/13877

@Josh. Wow this is awesome! thanks

JavaScript (ES6), 54 53 bytes
n=>c=>(f=p=>n-p?f({D:p&&p-1,U:p+1}[c[i++]]|0):i)(i=0)

Explanation
Uses a recursive function internally.

var solution =

n=>c=>(
  f=p=>             // f = recursive function, p = position of robot on ladder
    n-p?            // if p != n
      f({           // execute the next command
          D:p&&p-1, // D -> p = max of p - 1 and 0
          U:p+1     // U -> p = p + 1
        }[c[i++]]   // get current command then increment i (current command index)
        |0          // R -> p = 0
      )
    :i              // else return the current command index
)(i=0)              // initialise p and i to 0 for the first recurse
N = <input type="number" id="N" value="354" />

C = <input type="text" id="C" value="UUDDUUDUDUUDDUDUUUUDDDUDUUDUDUDUDDUUUUDUDUUDUDUUUDUDUDUUDUUUDUUUUUDUUDUDUUDUDUUUUUDUDUUDUDUDUDDUUUUUUUDUDUDUDUUUUUDUDUDUDUDUDUDUDUUDUUUUUURUUUDUUUUDDUUDUDUDURURURUDUDUUUUDUUUUUUDUDUDUDUDUUUUUUDUDUUUUUUUDUUUDUUDUDUDUUDUDUDUUUUUUUUUUDUUUDUDUUDUUDUUUDUUUUUUUUUUUUUDUUDUUDUDUDUUUDUDUUUUUUUDUUUDUUUDUUDUUDDUUUUUUUUDUDUDUDUDUUUUDUDUUUUUUUUDDUUDDUUDUUDUUDUDUDUDUUUUUUUUUDUUDUUDUUUDUUDUUUUUUUUUUUDUDUDUDUUUUUUUUUUUUDUUUDUUDUDDUUDUDUDUUUUUUUUUUUUDUDUDUUDUUUDUUUUUUUDUUUUUUUUUDUDUDUDUDUUUUUUDUDUDUUDUDUDUDUUUUUUUUUUUUUUUDUDUDUDDDUUUDDDDDUUUUUUUUUUUUUUDDUDUUDUUDUDUUUUUUDUDUDUDUDUUUUDUUUUDUDUDUUUDUUDDUUUUUUUUUUUUUUUUUUDUUDUUDUUUDUDUUUUUUUUUUUDUUUDUUUUDUDUDUUUUUUUUUDUUUDUUUDUUDUUUUUUUUUUUUDDUDUDUDUUUUUUUUUUUUUUUDUUUDUUUUDUUDUUDUUUUUUUUUUUDUDUUDUUUDUUUUUUDUDUDUUDUUUUUUUUUUUUDUUUDUUDUDUDUUUUDUDUDUDUDUUUUUUUUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUUU" />

<button onclick="result.textContent=solution(+N.value)(C.value)">Go</button>

Haskell, 65 bytes
x%'U'=x+1
x%'D'=max(x-1)0
x%_=0
f n=length.fst.span(<n).scanl(%)0

Usage example: f 4 "UDDUURUUUUUUUDDDD" -> 10.
% adjusts the current position on the ladder, scanl makes a list of all positions, fst.span(<n) takes the part before the explosion and length counts the steps.

Nice job with the combination of named arguments and composition/currying

JavaScript (SpiderMonkey 30+), 65 64 bytes
(n,s,i=0)=>[for(c of s)if(i<n)c<'E'?i&&i--:c>'T'?i++:i=0].length

How it works
We first set the variable i to 0. This will keep track of how many steps the robot has climbed up. Then for each char c in the input string, we run the following logic:

If i is larger than or equal to n, don't do anything.
If c is "D":

If i is 0, leave it as is.
Otherwise, decrement it by 1.

If c is "U", increment i by 1.
Otherwise, set i to 0.

By cutting off if i>=n, we avoid adding any more items to the array after the robot has reached the top. Thus, we can simply return the length of the resulting array.

Perl, 47 + 2 = 49 bytes
$z-=-/U/||$z&&/D/;$z*=!/R/;$^I<=$z&&last}{$_=$.

Requires the -p flag, -i$N for latter height and a newline separated list of moves:
$ perl -pi10 ladderbot.pl <<<< $'U\nU\nU\nU\nU\nU\nR\nU\nU\nU\nU\nU\nU\nU\nR\nU\nU\nU\nU\nU\nU\nU\nU\nR\nU\nU\nU\nU\nU\nU\nU\nU\nU\nU\nU\nU\nU\nU'
34

How it works:
                                                # '-p' wraps the code in (simplified):
                                                # while($_=<>) {...print $_}
$z-=-/U/||$z&&/D/;                              # Subtract -1 if UP. subtract 1 if DOWN
                  $z*=!/R/;                     # If R then times by zero
                           $^I<=$z&&last        # Break while loop if N is reached
                                        }{      # Eskimo operator:
                                                # while($_=<>){...}{print$_}
                                          $_=$. # `$.` contains number of lines read from input.

Deparsed:
LINE: while (defined($_ = <ARGV>)) {
    $z -= -/U/ || $z && /D/;
    $z *= !/R/;
    last if $^I <= $z;
}
{
    $_ = $.;
}
continue {
    die "-p destination: $!\n" unless print $_;
}
-e syntax OK

JavaScript (ES6), 65 bytes
(n,s)=>[...s].map(_=>i=_<'E'?i&&i-1:_>'T'?i+1:0,i=0).indexOf(n)+1

Let us continue this discussion in chat.

I think 0,i=0 can be changed to i=0

@Cyoce hmm, fails for me in a new tab (works on this page b/c i is already defined)

@CharlieWynn sorry, got my precedence mixed up

PowerShell, 86 79 bytes
param($a,[char[]]$b)$b|%{$d++;if(($c-=((1,0)[!$c],-1,$c)[$_%4])-ge$a){$d;exit}}

A slight retooling of my When does Santa enter the basement? answer.
Takes input $a and $b, explicitly casting $b as char-array. We then loop with |%{...} over all of $b. Each iteration we increment our counter $d.
Then, an if statement to check whether we've hit the top with -ge$a. If so, we output $d and exit. The if statement is constructed from a pseudo-ternary created by assigning $c minus-equal to the result of several indexes into an array.
We have a trick that the ASCII values of D, R, and U correspond to 0, 2, and 1 when taken modulo-4, so $_%4 serves as our first index. If it's R, that sets $c equal to $c-$c, doing the reset. If U, that means we need to go up, so the $c-(-1) result. Otherwise it's a D, so we need to check if we're already at the bottom (that's the !$c - in PowerShell, "not-zero" is "true" or 1) and set $c equal to $c-0 or $c-1 respectively.
Edit - Saved 7 bytes by using minus-equal assignment rather than direct assignment

Perl 5, 61 bytes
Includes two bytes for -F -i. (-M5.01 is free.)
Input of the integer (e.g. 10) is as perl -M5.01 -F -i10 robot.pl; input of the ladder commands is as STDIN.
for(@F){($i+=/U/)-=/R/?$i:$i&&/D/;$j++;last if$^I<=$i}say$j

using perl 5.12.5, i also had to explicitly enable autosplit mode with -anF before it would print anything for me. but it seems to get implicitly enabled with only -F in 5.20.3. can you verify this?

@ardnew, just -F sufficed for me (5.20 or 5.22 or so). Iirc the current perldoc perlrun says it implies -a and -a implies -n.

How much does we count -i for? I can see you count it as 1 but I would guess it should actually be counted as 3? :-)

@dev-null, why three? I think the convention on PPCG.SE is to count the letters in a flag but not the hyphen-minus characters, but please correct me if I'm wrong. (It looks like you're using the same counting convention for yoru own answer to this question, too. (Incidentally, nice answer.))

@msh210 I was just counting the difference when using -i and without perl -i10 -pe';' vs perl -pe';' 3  characters more and then the input number - which I guess we shouldn't count. But I might be wrong just though about it this morning :-)

@dev-null, but why not count p?

@msh210 p would only be counted as 1 because it can be stacked together with e.

MATL, 37 34 bytes
Oj"t@4\1=?Q}6M?x0}qt0>*]]]N$h=f1)q

Try it online!
Explanation
Position is 0-based. Each new position is pushed onto the stack keeping the older positions. So the stack size represents the number of movements up to now, plus 1.
A loop is used to process each command. The loop is exited when position reaches ladder height processes all commands, even after the explosion (idea taken from Martin's answer). The final result is given by the index of the first position that equals the ladder height.
O             % push a 0: initial position (0-based)
j             % take first input (commands) as a string
"             % for each command
  t           %   duplicate current position
  @           %   push command
  4\          %   modulo 4. This gives 1, 2, 0 for 'U','R', 'D'
  1=?         %   if result equals 1 (command 'U')
    Q         %     increase position by 1
  }           %   else
    6M?       %     if result was nonzero (command 'R')
      x0      %       delete current position and push 0
    }         %     else (command 'D')
      q       %       decrement by 1
      t0>*    %       turn negative values into 0
    ]         %     end if
  ]           %   end if
]             % end for each
N$h           % pack all numbers in the stack into an array
=             % implicitly read second input: ladder height
f1)q          % find first position equal to that, and subtract 1.
              % Implicitly display

Python 2, 63 62 bytes
f=lambda n,s,h=0:h^n and-~f(n,s[1:],-[2%~h,~h,0][ord(s[0])%4])

For example, f(4, 'UDDUURUUUUUUUDDDD') is 10.
xnor found an even shorter expression: 2%~h is really cool :)

Nice find with the %4. If I'm not mistaken, you can save a character by doing -[2%~h,~h,0][ord(s[0])%4].

Vitsy, 44 bytes
There probably could be some reductions - I'll figure out some more things if I can.
0vVWl:X[4M1+mDvV-);]lvXv?v-N
vD([1-]
v1+
vX0
Explanation (in progress):
0vVWl:X[4M1+mDvV-);]lvXv?v-N
0v             Save 0 as our temp var to edit.
  V            Save the input as a global var.
   W           Grab a line of STDIN.
    l          Push the length of the stack.
     :         Clone the stack. This is for later use.
      X        Remove the top item of the stack (we don't need the length right now.
[            ] Do the stuff in the brackets infinitely.
 4M            Modulo 4.
   1+          Add one.
     m         Go to the line index as specified by the top item of the stack.
      Dv       Duplicate the top item, save it in the temp var.
        V-);   If the top value is equal to the input number, exit the loop.
l              Push the length of the stack.
 vXv           Dump the temp var, then save the top item.
    ?          Rotate back to the original stack.
     v-        Subtract the top item (the original length) by the temp var (new length)
       N       Output the top item of the stack of the number.

vD([1-]
v              Push the temp variable to the stack.
 D([  ]        If this value is not zero...
    1-         Subtract one from it.

v1+            Push the temp variable to the stack, then add one to it.

vX0            Dump the temp var and replace it with zero.
Try It Online! (big test case)

Python 3, 90
Saved 6 bytes thanks to DSM.
Pretty simple right now.
def f(c,n):
 f=t=0
 for x in c:
  f+=1|-(x<'E');f*=(x!='R')&(f>=0);t+=1
  if f>=n:return t

Test cases:
assert f('U', 1) == 1
assert f('DDRUDUU', 1) == 4
assert f('UDDUUUUURUUUUDDDD', 4) == 7
assert f('UDDUURUUUUUUUDDDD', 4) == 10
assert f('UUDDUUDUDUUDDUDUUUUDDDUDUUDUDUDUDDUUUUDUDUUDUDUUUDUDUDUUDUUUDUUUUUDUUDUDUUDUDUUUUUDUDUUDUDUDUDDUUUUUUUDUDUDUDUUUUUDUDUDUDUDUDUDUDUUDUUUUUURUUUDUUUUDDUUDUDUDURURURUDUDUUUUDUUUUUUDUDUDUDUDUUUUUUDUDUUUUUUUDUUUDUUDUDUDUUDUDUDUUUUUUUUUUDUUUDUDUUDUUDUUUDUUUUUUUUUUUUUDUUDUUDUDUDUUUDUDUUUUUUUDUUUDUUUDUUDUUDDUUUUUUUUDUDUDUDUDUUUUDUDUUUUUUUUDDUUDDUUDUUDUUDUDUDUDUUUUUUUUUDUUDUUDUUUDUUDUUUUUUUUUUUDUDUDUDUUUUUUUUUUUUDUUUDUUDUDDUUDUDUDUUUUUUUUUUUUDUDUDUUDUUUDUUUUUUUDUUUUUUUUUDUDUDUDUDUUUUUUDUDUDUUDUDUDUDUUUUUUUUUUUUUUUDUDUDUDDDUUUDDDDDUUUUUUUUUUUUUUDDUDUUDUUDUDUUUUUUDUDUDUDUDUUUUDUUUUDUDUDUUUDUUDDUUUUUUUUUUUUUUUUUUDUUDUUDUUUDUDUUUUUUUUUUUDUUUDUUUUDUDUDUUUUUUUUUDUUUDUUUDUUDUUUUUUUUUUUUDDUDUDUDUUUUUUUUUUUUUUUDUUUDUUUUDUUDUUDUUUUUUUUUUUDUDUUDUUUDUUUUUUDUDUDUUDUUUUUUUUUUUUDUUUDUUDUDUDUUUUDUDUDUDUDUUUUUUUUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUUU', 354) == 872

JavaScript, 131 106 Bytes-
I know this won't win a Code Golf competition, but this was a fun and stupid solution to implement:
l=>s=>Function('i=c=0;'+s.replace(/./g,x=>`c++;i${{R:"=0",U:`++;if(i>=${l})return c`,D:"--"}[x]};`))()

I kinda went the opposite of a "functional" route by making a dynamically-generated imperative solution, any instance of an instruction is replaced with an increment or decrement, and a counter increment.
Thanks to Cycoce for saving me 29 bytes!

Here, I golfed off 29 bytes: l=>s=>Function('i=c=0;'+s.replace(/./g,x=>\c++;i${{R:"=0",U:`++;if(i>=${l})return c`,D:"--"}[x]};`))()`

Python, 121 bytes
def f(a,n):
 i=c=0
 while i<n:i={'U':lambda x:x+1,'D':lambda x:0 if x==0 else x-1,'R':lambda x:0}[a[c]](i);c+=1
 return c

Welcome to PPCG! Here we require by default that answers are either full programs that take input from STDIN and print to STDOUT, or functions that take inputs as arguments and return the output value. Your solution hard-codes the inputs, which is not allowed.

Corrected by forming into function, I was using interpreter when I wrote it.

Thank you! You should also add a header of the form ## Python, <N> bytes to show others your score.

I don't think there can be an unnamed function.

You can save bytes by replacing 0 if x==0 else x-1 with x and x-1

PHP, 88 bytes
This generates some (3+2n where n is the number of commands run) notices but that doesn't matter for golfing, right?
<?php for(;$x++<$argv[1];)switch($argv[2][$i++]){case R;$x=2;case D;--$x?--$x:0;}echo$i;

ungolfed:
<?php                    # actually 1 byte shorter not as a function
for(;$x++<$argv[1];)     # not initialising the $x causes a notice but still works
                         # post increment $x by 1 regardless of the command (saves us writing a U case)
  switch($argv[2][$i++]) # get next command, increment number of commands
    {case R;             # R gets treated as a constant with value 'R'. and a notice
      $x=2;              # falling through to D which will double decrement so set to 2
    case D;              # same trick as R
      --$x?--$x:0;}      # decrement once then again if >0
echo$i;                  # output

Notices are fine, as long as the code can still be run.

PHP, 129 bytes
function r($h,$s){$i=0;$c=1;while($x=$s[$i++]){if($x=='U'){$c++;}elseif($x=='D'){--$c<1?$c=1:0;}else{$c=1;}if($c>$h){return$i;}}}

Not winning, but fun to create. PHP seems to dislike empty parts in the ternary operator (it throws a Syntax Error), so I had to put a 0 there.
Ungolfed version:
function r($h,$s) {          // $h - height of ladder; $s - instructions
  $i = 0;                    // Instruction index
  $c = 1;                    // Position on ladder
  while ($x = $s[$i++]){     // Set $x to current instruction and increment index
    if ($x == 'U'){          // If instruction is U...
      $c++;                  // Increment ladder position
    } elseif ($x == 'D') {   // If instruction is D...
      --$c < 1 ? $c = 1 : 0; // Decrement ladder position, if under 1 set to 1
    } else {                 // If instruction is anything else (in this case R)
      $c = 1;                // Reset ladder position
    }
    if ($c > $h) {           // If ladder position is larger than height...
      return $i;             // Return current instruction index
    }
  }
}

PHP, 113 bytes
Smaller version of https://codegolf.stackexchange.com/a/74575/13216
function r($h,$s){$i=0;$c=1;while($x=$s[$i++]){$c+=($x=='U'?1:($x=='D'?($c>1?-1:0):1-$c));if($c>$h){return $i;}}}

Ungolfed:
// $h - height of ladder; $s - instructions
function r($h,$s) {
    $i = 0;
    $c = 1;
    while ($x = $s[$i++]) {
        $c += (
            $x=='U'?
                1
            :
                (
                    $x=='D'? (
                        $c>1?
                            -1
                        :
                            0
                    ):
                        1-$c
                )
        );
        if ($c > $h) {
            return $i;
        }
    }
}

Great first post! I edited your post for better readability. Happy golfing!

Java, 250 bytes
int cmds(int n, String s) {
int steps=1;
int count=0;
for (int i=0;i< s.length();i++) {
count++;
char c=s.charAt(i);
switch(c){
case 'D':
steps=(steps==1)?1:--steps;
break;
case 'R':
steps=1;
break;
case 'U':
++steps;
break;
}
if(steps>n)
return count;
}
return 0;
}

When answering a [tag:code-golf]-challenge, you should start your answer with # <language_name>, XX bytes. Also you can reduce your variable names to one character each and remove extra whitespaces, this way your byte count will reduce (which is the objective here)... Ah, and welcome to PPCG!

Some tips: To indent your code as code add 4 spaces at the line's start. You removed some spaces, but you can still remove more (ex: instead of int steps=1; int count=0; you can use int s=1,c=0; - look I changed the variable name - and so on). You can still show your ungolfed version below the golfed version with an explanation (this way is easy for someone help you golfing more bytes).

Mathematica, 114 120 bytes
(d=#~Max~1-1&;u=#+1&;r=1&;s=StringToStream@ToLowerCase@#;l=1;t=1;While[(l=ToExpression[s~Read~Character]@l)<=#2,t++];t)&

Anonymous function, which takes the two arguments (C,N).
Careful using this, as it doesn't close the stream it opens. Also it assigns all its variables globally.
Edited to replace d=#-1& with d=#~Max~1-1&, so that robie doesn't go digging.

Wait: I don't think this is valid. It allows the robot to go down negative rungs. Whoops. That'll teach me to test non-comprehensively...
I'll put a corrected one up when I get the chance.

Pyth, 19 bytes
x.u@[tWNNhN00)CYz0Q

Try it online: Demonstration or Test Suite
Explanation:
x.u@[tWNNhN00)CYz0Q   implicit: z = input string, Q = input number
 .u             z0    reduce z: for each char Y in z manipulate N = 0 with:
    [        )           create a list with
     tWNN                  * N-1 if N>0 else N
         hN                * N+1
           0               * 0
            0              * 0
   @          CY         replace N by the ord(Y)-th element (mod 4)
 .u                   .u give us a list with all intermediate values of N
x                 Q   print the index of Q in this list

C, 91 bytes
No warnings with gcc -Wall. Recursion and comma-separated expressions.
r.c contains bare function:
int r(int N,int n,int s,char*C){return*C&&s<=N?s+=*C&2?-s:*C&1?1:-1,r(N,n+1,s?s:1,C+1):n;}

Commented,
int r(int N,   // number of steps on ladder
      int n,   // result, seed with 0
      int s,   // current step, seed with 1
      char *C  // command string
      )
{
    return *C&&s<=N ?  // still reading commands and still on ladder?
       s+=                // increment step value by...
        *C&2?             // bit test if 'R' but not 'U' or 'D'.
         -s               // negate to 0, will set to 1 in call if needed
         :*C&1?           // Not 'R', is it 'U'?
            1             // 'U', add 1
            :-1,          // Must be 'D', subtract 1
       r(N,n+1,s?s:1,C+1) // Recursive call, and fix case where s==0.
      :n;                 // end of string or fell off ladder
}

For reference,
'U'.charCodeAt(0).toString(2)
"1010101"
'D'.charCodeAt(0).toString(2)
"1000100"
'R'.charCodeAt(0).toString(2)
"1010010"

roboladder.c wrapper,
#include <stdio.h>
#include <stdlib.h>
#include "r.c"
int main(int argc, char * argv[])
{
  int N = atoi(argv[1]);
  int n = r(N,0,1,argv[2]);
  int check = atoi(argv[3]);
  printf("%d : %d\n", n, check);
  return 0;
}

Makefile for testing,
run:
    @gcc -Wall robotladder.c -o robotladder
    @./robotladder 1 U 1
    @./robotladder 1 DDRUDUU 4
    @./robotladder 4 UDDUUUUURUUUUDDDD 7
    @./robotladder 4 UDDUURUUUUUUUDDDD 10
    @./robotladder 6 UUUUUDRUDDDDRDUUUUUUDRUUUUUUUDR 20
    @./robotladder 10 UUUUUURUUUUUUURUUUUUUUURUUUUUUUUUUUUUU 34
    @./robotladder 6 UUUDUUUUDDDDDDDDDDDDDDRRRRRRRRRRRUUUUUU 8
    @./robotladder 6 UUUDUUUDURUDDDUUUUUDDRUUUUDDUUUUURRUUDDUUUUUUUU 32
    @./robotladder 20 UUDDUDUUUDDUUDUDUUUDUDDUUUUUDUDUUDUUUUUUDUUDUDUDUUUUUDUUUDUDUUUUUUDUDUDUDUDUUUUUUUUUDUDUUDUDUUUUU 56
    @./robotladder 354 UUDDUUDUDUUDDUDUUUUDDDUDUUDUDUDUDDUUUUDUDUUDUDUUUDUDUDUUDUUUDUUUUUDUUDUDUUDUDUUUUUDUDUUDUDUDUDDUUUUUUUDUDUDUDUUUUUDUDUDUDUDUDUDUDUUDUUUUUURUUUDUUUUDDUUDUDUDURURURUDUDUUUUDUUUUUUDUDUDUDUDUUUUUUDUDUUUUUUUDUUUDUUDUDUDUUDUDUDUUUUUUUUUUDUUUDUDUUDUUDUUUDUUUUUUUUUUUUUDUUDUUDUDUDUUUDUDUUUUUUUDUUUDUUUDUUDUUDDUUUUUUUUDUDUDUDUDUUUUDUDUUUUUUUUDDUUDDUUDUUDUUDUDUDUDUUUUUUUUUDUUDUUDUUUDUUDUUUUUUUUUUUDUDUDUDUUUUUUUUUUUUDUUUDUUDUDDUUDUDUDUUUUUUUUUUUUDUDUDUUDUUUDUUUUUUUDUUUUUUUUUDUDUDUDUDUUUUUUDUDUDUUDUDUDUDUUUUUUUUUUUUUUUDUDUDUDDDUUUDDDDDUUUUUUUUUUUUUUDDUDUUDUUDUDUUUUUUDUDUDUDUDUUUUDUUUUDUDUDUUUDUUDDUUUUUUUUUUUUUUUUUUDUUDUUDUUUDUDUUUUUUUUUUUDUUUDUUUUDUDUDUUUUUUUUUDUUUDUUUDUUDUUUUUUUUUUUUDDUDUDUDUUUUUUUUUUUUUUUDUUUDUUUUDUUDUUDUUUUUUUUUUUDUDUUDUUUDUUUUUUDUDUDUUDUUUUUUUUUUUUDUUUDUUDUDUDUUUUDUDUDUDUDUUUUUUUUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUDUUUUDUDUUUUUU 872
    @wc -c r.c

Mathematica, 112 Bytes
i=0;First@Position[ToExpression["{"<>#~StringReplace~{"U"->"i++,","D"->"i=i~Max~1-1,","R"->"i=0,"}<>"0}"],#2-1]&

Mathematica, 67 bytes
(p=i=0;While[p<#,p=Switch[#2[[++i]],"U",p+1,"D",1~Max~p-1,_,0]];i)&

Unnamed functions of two arguments, a positive integer and a list of characters, that returns a positive integer. A more straightforward While implementation than the other Mathematica entries, that manages to result in a more competetive length.

Clojure, 92 84 bytes
Counts n to zero instead zero to n, can utilize take-while pos?.
#(count(take-while pos?(reductions(fn[p o](if o(min(o p 1)%)%))%(map{\U -\D +}%2))))

Original:
#(count(take-while(partial > %)(reductions(fn[p o](if o(max(o p 1)0)0))0(map{\U +\D -}%2))))

Maps 2nd argument U to +, D to - and others to nil. Reducing function runs (operand position 1) with non-null operand and 0 otherwise. Takes values until we are higher than the 1st input argument and counts how many we've got.


text:
CSV for fun and profit (mostly neither)
Similar to the Catalogue of hello world. I want to produce a catalogue of short ways to produce CSV.
CSV Definition
In this case CSV meaning the more literal interpretation of;
A string representation of a list or array separated by commas.
The input types should not be mixed i.e [1, "hello"] is NOT valid input
The output should not start with a comma or end with a comma.
The output should not contain newline (in any way shape or form).
see example;
"John,Henry,Carol,Carl"
Input
An array of variable length, containing only simple types.
The array representation is how your chosen language defines arrays or lists.
Output
A string representation of the array separated with commas.
Example
Input: ["John", "Henry", "Carol", "Mike"]
Output: "John,Henry,Carol,Mike"
How do I win?
This is code-golf, so shortest answer (in bytes) in wins.
The Catalogue
The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
## Language Name, N bytes

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

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

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

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

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

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

    var lang = a.language;
    lang = jQuery(''+lang+'').text();

    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
    return 0;
  });

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

}
body { text-align: left !important}

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

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

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

coming right up

Many languages can't take an array as input (or in fact, have an array of any kind). How should these languages compete? In addition, several languages can take a CSV string as an array with no additional work. This seems underspecified, I'd recommend moving it to the sandbox.

This needs a full specification of what you consider to be CSV, because there are competing variants.

Full spec coming up

@nimi an uncaught mistake, and additional spacing has been defined

Changing the output format invalidates my answer. It's an easy fix, but this is why you need to post in the sandbox first.

I will fix the definition.

So many downvotes - First Golf challenge for my part.
And i'm already almost at the point where I would rather buy winrar, than try another golf lol

@VisualBean That's what the sandbox is for. There's a decent idea underneath the incomplete spec. The sandbox would've let you iron those problems out before posting it.

This also needs a clarification for "containing only simple types". Would this mean a python answer would have to support: [1, "hello"]?

@MorganThrapp what is "The Sandbox"

@VisualBean It's linked in the sidebar under "Featured on Meta" The Sandbox

I guess I didn't specify this enough in my last comment, but you also need to say whether or not something like [1, 2] would be acceptable. Several answers used the language's native string join, which in some cases won't work on "simple types", which is also pretty unclear for something like python, where all types are basically the same.

Probably also need to address one-element input arrays, arrays where the strings contian newlines, arrays where the strings contain the comma character, arrays where the strings contian only whitespace, arrays where the strings contain unprintable, arrays where the string contains unicode, arrays where the strings contian rtl chars/combining chars/direction chars... And probably more... You can probably save a bunch of these by restricting input to printable ASCII? Still got some problems though...

Even if the spec was clarified. I'm down voting as too trivial. An empty program in TeaScript does this

@Downgoat: all catalogue challenges so far are trivial.  Many of them have 0 bytes solutions.

Congrats on making your first challenge! These things don't always go as planned; often what's clear in your head isn't perfectly clear to others. That's part of what makes creating a good challenge much harder than making a good answer. As has been mentioned, for this purpose we have the Sandbox, where challenge ideas can be posted for community feedback before going to the main site. I hope this experience hasn't discouraged you from challenge writing though. I guarantee it's better than purchasing WinRAR.

Is there any reason for “The output should not contain newline (in any way shape or form).” other than unfairly prioritizing functions over full programs?

I'm voting to close as unclear because "simple types" is not descriptive.

TeaScript, 0 bytes

An empty TeaScript program does this.
TeaScript implicitly adds the input to the operator stack.
The result of the operator stack is outputted. In this case it's the input, due to JavaScript's nature, when it's casted to a string, commas are added.
Try it online

What does this compile to?

@CatsAreFluffy this simply compiles to x. Which is the variable containing the input

Well this was interesting while it lasted, I wonder how many other languages have the same behavior, also is the cs output due to the nature of the language or the compiler.

JavaScript (ES6), 7 bytes
a=>a+""

an array cast to a string has ,s implicitly inserted.

Python 3, 8 bytes
Saved 12 bytes thanks to DSM.
This isn't even close to a complete implementation of the CSV, but it satisfies the letter of what the challenge is looking for.
','.join

Haskell, 16 bytes
tail.((',':)=<<)

Usage example: tail.((',':)=<<) $  ["john", "henry", "carol", "Mike"] -> "john,henry,carol,Mike".

Pyth, 4 bytes
j\,Q

Evaluates input and joins by comma. Nothing much to say.
Try it online.

, 1 char / 2 bytes
ï

Try it here (Firefox only).
This one just outputs the input; however, with arrays, the brackets and quotes are discarded, leaving only the items and commas.

DUP, 29 bytes
[`$~][$'"=^'[=2ø']=||[][,]?]#

Try it here.
Takes input from STDIN as something like ["asdf","adsf","fdsa"] because DUP doesn't really have arrays that can hold strings.
Explanation
[   ][                     ]# {while loop}
 `$~                          {read an input char until end of input (-1)}
      $'"=^'[=2ø']=||         {check if input char is [,], or "}
                     [][ ]?   {conditional}
                        ,     {if not, output char}

Hooray for DUP!

Python 2, 10 bytes (or may be 8, without assignment)
x=','.join

Test
>>> x(["John", "Henry", "Carol", "Mike"])
'John,Henry,Carol,Mike'

Generally it's acceptable to provide functions that are not assigned to variables.

@CatsAreFluffy, I see, but somebody already posted same in python3, so, I will leave it like this.

Perl 6,  12 bytes
{.join: ','}

PowerShell, 16 bytes
$args[0]-join','

Takes input, -joins 'em together. PowerShell supports mixed array types without anything special.
Example
PS C:\Tools\Scripts\golfing> .\csv-for-fun.ps1 ('Doorknob',33,'Martin','Peter')
Doorknob,33,Martin,Peter

Additionally
If you want an actual CSV output, PowerShell also has the excellent Export-CSV command. For example, ('Doorknob',33,'Martin','Peter')|epcsv -Path .\c.csv (with epcsv as an alias).

Jelly, 3 bytes
j”,

Try it online!

Explanation:
j       join list
”,    with separator ","

That sums it up nicely.

Even works for [1,2]

POSIX sh, 15 bytes
IFS=,
echo "$*"

Example
# bash, dash, zsh, ksh, mksh... any basically POSIX-compatible shell.
dash -c 'IFS=,;echo "$*"' -- 'Foo B' ar baz
# -> Foo B,ar,baz

Explanation
$* is basically argv[1:].join(IFS[0]). Double-quoted to avoid further splitting and globbing, which in our case will give us back a b c. If you passed something like a b '*' in instead, you will find all your files listed due to the globbing.
The positional parameters, i.e. argv[1:], is the basic way to represent arrays in pure POSIX shell scripts. Functions are sometimes used to create new space for holding such parameter lists. You can only have one array working at a time using this technique.

Milky Way 1.6.5, 10 bytes
'C"'[]"-G!

Explanation
'C          ` push input to the stack as a list of characters
  "'[]"     ` push a string containing a single quote & square brackets
       -    ` remove the characters in the TOS from the STOS
        G!  ` output the remaining characters

Usage
$ ./mw <path-to-code> -i "['John','Phil','Dave','Matt H.','Matt D.']"
John,Phil,Dave,Matt H.,Matt D.

Input should be provided as the string of an array, containing no double quotes.

Ah, never mind. I missed the requirement for mandatory file extension. Works fine now. (Of course, excepting the weird “The output should not contain newline (in any way shape or form).” rule, which personally I find plain stupid.)

Dyalog APL, 11 bytes
1↓∊',',¨⍕¨⎕

Works even on numbers and mixed datatypes (remove ⍕¨ if unnecessary`). Takes list of strings as prompted input
⎕ prompt for and evaluate input
',',¨ prepend comma to each
∊ flatten
1↓ remove initial comma

PHP, 37 34 bytes
function i($a){echo join(",",$a);}

The vast majority of the size comes from setting the function.  As a simple call it's just join(",",$a).
If we allow the array to come from the URL:
PHP, 24 21 bytes
echo join(",",$_GET);

Mathematica, 19 30 28 bytes
""<>Riffle[ToString/@#,","]&

#~StringRiffle~","& works if only strings will be input (which nobody actually knows)

Retina, 3 bytes
¶
,

Try it online!
Takes newline-separated list. If this isn't valid, here's another 6-byte solution that takes a more... conventional... format.
["{}]
<empty>

Try it online!

Lua, 42 Bytes
Simple use of the table.concat() function, limiting the type-mixing possibility to only numbers and strings.
function f(t)print(table.concat(t,","))end

Gogh, 1 byte
s

Usage:
$ ./gogh noa "s" 'John Mike Henry'

See the wiki to understand Gogh's array input.

Explanation
     “ Implicit input    ”
s    “ String conversion ”
     “ Implicit output   ”

source: Stack Exchange

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

sort: votes


text:
Leaping Lizards!
Suppose we define a simple program that takes an array L of natural numbers with some length N and does the following:
i=0                 #start at the first element in the source array
P=[]                #make an empty array
while L[i]!=0:      #and while the value at the current position is not 0
    P.append(L[i])  #add the value at the current position to the end of the output array
    i=(i+L[i])%N    #move that many spaces forward in the source array, wrapping if needed
return P            #return the output array

Every such program will either run forever or will eventually terminate, producing a list of positive integers. Your job is to, given a list P of positive integers, produce a shortest list, L, of natural numbers that terminates and produces P when plugged into the previous program.
Such a list always exists, since one can just add P[i]-1 zeros after each P[i] in the list, then one final 0, and it will produce the original list. For example, given [5,5], one solution is [5,0,0,0,0,5,0,0,0,0,0]. However, [5,0,5] is much shorter, so the automatic solution is not a valid one for your program.
[5,6]->[5,6,0,0]
[5,7]->[5,0,0,0,0,7,0,0]
[5,6,7]->[5,6,0,7]
[5,6,8]->[5,0,8,0,0,6,0,0,0]
[1,2,3,4]->[1,2,0,3,0,0,4,0]
[1,2,1,2]->[1,2,0,1,2,0,0]
[1,3,5,7]->[1,3,0,0,5,0,0,0,0,7]
[1,3,5,4]->[1,3,4,0,5,0,0]

Input is a list of positive integers(in some format you can specify) and output should be in the same format. List and integer size can be up to 2^16. This is code golf, so shortest program in bytes wins!

Are you sure that handling arbitrary lists of up to 65536 elements in 10 minutes is feasible? Do you have a reference implementation which achieves it?

Just an FYI, the sandbox is more effective when used for longer than 3 hours :P I understand it can be  tempting to post right away, but I think Peter's comment shows how this question could have benefited from a longer run there.

Python 3, 109 102 100 95 93 bytes
def f(L,k=1,i=0):
 P=[0]*k
 for x in L:x=P[i]=P[i]or x;i=(i+x)%k
 return P[i]and f(L,k+1)or P

A recursive solution.
Call it like f([1,2,3,4]).
Watch it pass all test cases.
We start with k=1 (length of output) and i=0 (position in output), and make a list P with k zeros.
Then we iterate along the elements x of L, updating P[i] to P[i]or x (so P[i] keeps its value if it's nonzero) and i to (i+P[i])%k.
After that, we check that the final value of P[i] is zero, incrementing k if it's not, and return P.
If at any point of the algorithm P[i] is already nonzero, it enters a loop going around some of the nonzero values of P, and ends up at a nonzero value; then we recurse.

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


text:
Find the different letter
You may have seen puzzles like this:

Find the 0:
OOOOOOOOOOOOOOOOOOOO0OOOOOOOOOOOOOOOOOO

The challenge is to write a program that finds the index of the different letter given an image.
Input
Input will be an Image. The image will consist of one line of black text in the Helvetica 24 pt. font on a white background. The text will consist from a selection of two characters: one character that is repeated, and one character that appears only once. For instance:

Output
Output will be an Integer, the index of the different character. In the example above, the output will be 4. (Note that indices of a string start at 0)
Program Specifications
As per usual for code golf, the shortest program wins.

Test Cases
 => 10
 => 11
 => 5
 => 16
 => 10
 => 21
 => 20
 => 13
 => 11
 => 4
 => 7

Pedantic note: your real-world example isn't a puzzle per se. It's more of an amusing eye-game.

How is this scored?

It's a code golf, so the shortest program that successfully outputs the answer to each of the examples.

Will the difference ever be at the beginning?

Yes, it can be there, although none are included in the examples.

Note that the shortest answer for some languages may actually be hard-coding the results and choosing one based on something like the size of the input image (which I assume is not allowed).

@AMACB "although none are included in the examples", then it might be a good idea to change that ;). Also what's the minimum number of characters we have to handle? (At least 3 I  guess, or can we assume it's more than that?) There should also be a test case for that minimum.

(Pity that the input is an image and not a string...)

will there always be at least one completely white column of pixels between characters?

Dyalog APL, 31 32 bytes
{1⍳⍨+⌿∘.≡⍨{⍵/⍨~∧⌿⍵}¨⍵⊂⍨2>/∧⌿1,⍵}

⎕IO←0 to get indices starting with 0 (per OP), and which is anyway default in many APL systems.
1,⍵ prepend a column of white pixels (to ensure margin)
∧⌿ boolean for each column if all-white (vertical AND-reduction)
2>/ boolean at each character's left edge (pair-wise greater-than)
⍵⊂⍨ split into blocks beginning at each TRUE.
{…}¨ for each block
∧⌿⍵ boolean for each column if all-white (vertical AND-reduction)
⍵/⍨~ columns that are not [all-white]
∘.≡⍨ match each element to all elements
+⌿ number of blocks identical to each block (vertical plus-reduction)
1⍳⍨ index of first one (i.e. unique element)
Assumes the image is black (0) and white (1) pixels in the matrix I, and that there is at least one all-white pixel column between characters.
      f←{1⍳⍨+⌿∘.≡⍨{⍵/⍨~∧⌿⍵}¨⍵⊂⍨2>/∧⌿1,⍵}

"!I!!":
      ⊢I←6 12⍴(13/1),(22⍴0 1 1),(5/1),0,(8/1),(10⍴0 1 1),13/1
1 1 1 1 1 1 1 1 1 1 1 1
1 0 1 1 0 1 1 0 1 1 0 1
1 0 1 1 0 1 1 0 1 1 0 1
1 1 1 1 0 1 1 1 1 1 1 1
1 0 1 1 0 1 1 0 1 1 0 1
1 1 1 1 1 1 1 1 1 1 1 1
      f I
1

"mmnmm":
      ⊢I←7 31⍴(94/1),0 0,(∊0 1⌽¨2/⊂12⍴6↑1 0 1 1),0 1,(62⍴1 1 1,(⊢,⌽)(14⍴0 1)),33/1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 1 0 1 1 0 0 1 0 1 1 0 0 0 1 1 0 0 1 0 1 1 0 0 1 0 1 1 1
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
      f I
2

Can't you completely remove the {⍵/⍨~∧⌿⍵}¨ and remain with only {1⍳⍨+⌿∘.≡⍨⍵⊂⍨2>/∧⌿1,⍵}?

@lstefano Then it would stop working if there was varying amounts of white-space.

I see what you mean.

Mathematica, 125 bytes
StringCases[#,x:Except[StringCases[#~StringTake~3,x_~~___~~x_:>x][[1]]]:>Position[Characters@#,x]][[1,1,1]]-1&@*TextRecognize

Ahh, Mathemeatica builtins. So amazing. (And so long...)
Blows up on |/! :/; ,/. `/' and blows up differently on m/n.

How many inputs does this work for? My copy won't recognise any text in the first example (pipes and exclamation mark) for example.
Unless I'm missing something I have identical performance with
Length[Split[Characters@TextRecognize@#][[1]]] &

Oops, forgot about Split....And it relies on Mathematica's built in text recognizer...And you can never trust it.

I'll post mine as a separate solution then.

Mathematica, 46 bytes
Length@First@Split@Characters@TextRecognize@#&

Same failures as the other mathematica solution as it relies on the same TextRecognize function.

Bytesave: Length@First@Split@Characters@TextRecognize@#&

@CatsAreFluffy Cheers

Too bad it's just long enough that @* doesn't save.


text:
Who said that? 2016 Presidential election
In this challenge, your task is to make write a program with less than 300 characters that takes a short paragraph or a few sentences that a candidate has said and output who said it.
Input: Can be taken as a parameter to a function, input to a program etc. It will be a short paragraph, properly punctuated.
Output: The candidate that you think it is. This could be one of
Ben Carson (1)
Ted Cruz (2)
John Kasich (3)
Marco Rubio (4)
Donald Trump (5)
Hillary Clinton (6)
Bernie Sanders (7)

I've left off the names of people who have dropped out as of March 1st. You may output the name itself, or, more conveniently, the number that corresponds to the name.
Scoring:
Your score is the percentage of test cases you get right. Highest score wins. Ties (or perfect scores) are broken by code length as in a code golf.
The test cases can be pulled from:
http://www.presidency.ucsb.edu/debates.php
Click on each debate, both Democrat and Republican that has happened so far (before March 1st). Every paragraph is a test case, unless the "paragraph" is less than 20 characters long.
Here is code that pulls out the test cases from a particular page:
var t = $(".tools").parentNode.querySelectorAll("p");
var categ = {}, cur = 0;
for (var i = 0; i < t.length; ++i) {
  var p = t[i], str = p.innerText;
  if (p.querySelector("b")) {
    cur = p.querySelector("b").innerText.replace(':', '');
    str = str.replace(/^.*?:\s/, '');
  }
  str = str.replace(/\[applause\]/g, '')
  if (str.length < 20) continue;
  if (categ[cur] == null) categ[cur] = [];
  categ[cur].push(str);
}

You can then do categ.SANDERS to get a list of all the paragraphs that Senator Sanders has said.
You can discard anything that isn't said by the candidates listed above (e.g. categ.BUSH or categ.CHRISTIE).
Here is the file with all the test cases: https://drive.google.com/file/d/0BxMn8--P71I-bDZBS2VZMDdmQ28/view?usp=sharing
The file is organized by candidate
CANDIDATE CANDIDATE_LAST_NAME
(empty line)
Series of statements. Each paragraph is separated by (NEW PARAGRAPH)-
(empty line)
CANDIDATE NEXT_CANDIDATE_LAST_NAME
(empty line)
etc.

An example partial submission would be:
if (/ win | wall | great | beautiful/.test(p)) return 5;
if (/ percent | top one | rigged /.test(p)) return 7;
// etc. for all candidates

or
var words = p.split(' ');
// majority of words have less than 5 characters
if (words.length - words.filter(a => a.length < 5).length < 4) evidence[5]++;
// at the end
return /* index with the most evidence */

Here is a place where you can test javascript solutions: https://jsfiddle.net/prankol57/abfuhxrh/
The code uses the parameter p to represent the phrase to classify. Example code that scores around 20% (guessing would get around 11%):
if (/ rigged | top | percent | Wall Street /.test(p)) return 'Sanders';
return 'Trump';

Exactly what I'm asking: Write a program/function in less than 300 characters that takes as input a phrase that a candidate has said and returns as output which candidate said it. Your score is the percentage of test cases you get right. Highest score wins.
Yes, I know that a lot of lines have [laughter] or [cheering] in them. These will not be removed. At worst, they are extra information you can ignore; at best, they are extra information you can use (e.g. I made this up, but maybe people laughter is evidence that Marco Rubio is speaking). The test cases are as they appear in the text file.

I have a suggestion. How about you make it code-golf, but you have to get all the quotes right? Also, you might want to make the quotes a lot shorter, as this is a little ridiculous to solve as-is.

@Cyoce The point of the challenge is you look for key words and phrases that are associated with the candidates. You aren't supposed to get all of them right.

@Cyoce getting all the quotes right would be ridiculous (I think) considering the sheer number of quotes.

which is why I suggested reducing the quotes. Paired together, it would make this challenge a lot more manageable

@Cyoce The reasons I made this a code challenge is because a) if it is code golf, I have to limit the number of quotes, and I feel like the answer won't be interesting. In other words, the best answer will be some sort of hash that happens to work but isn't very general. b) The candidates have pretty distinct personalities and word choice so it can't be too hard. The point of the challenge is to figure out what kinds of things candidates say and apply them.

ok. I see what you're going for. I'll have to run a word-frequency count on the quotes to determine my approach

Clever challenge idea, may need some refining though. Have you considered posting in Sandbox for some feedback?

What is the winning criterion? (And why do you think that no-one will get a perfect score?)

@PeterTaylor The submission that classifies the most of the candidates' speech correctly wins.

@PeterTaylor isn't [tag:test-battery] an objective winning criterion in itself?

@soktinpk it would be nicer if you cleaned up the test cases (like one file for each candidate containing all test-cases clearly separated). Are elements between brackets such as [laughter] etc. part of the test-cases?

@plannapus, I don't think so. It's like code-challenge: it tells you something about the winning criterion, but doesn't fully specify it.

@PeterTaylor fair enough, I see your point.

@PeterTaylor I edited it, is it clearer now? Sorry for the delay.

Interesting challenge. Inspired by this perhaps? http://googleresearch.blogspot.co.uk/2016/02/on-personalities-of-dead-authors.html

The source data you provided is a little messy (difficult to parse automatically), which I think takes away some of the spirit of the challenge. I've made a cleaned-up version which uses one line per quote, with a blank line separating the next candiate name. This is much easier to parse in most languages. I've uploaded it here: https://drive.google.com/file/d/0B3uyVnkMpqbVSnVrZkVwTUhDODg (other than changing newlines, I've left the data untouched. That includes what looks like an encoding issue for –)

Polyglot, ~18.6%
This works in: Cjam, Pyth, TeaScript, Japt, Seriously, 05AB1E, GolfScript, Jelly, and probably many more.
6

This outputs Hillary for all inputs. This is because Hillary said the most. While it's not the most
ingenious way to do this. It works ¯\_(ツ)_/¯

I like how this gets flagged as low quality post. :P

@DenkerAffe probably for being short

Any reason for using JavaScript? You could've golfed it down to one character in some other language :P

@ghosts_in_the_code fixed

Pyth, 34.16% (297 bytes)
FNc"7creta
6enato
3ohio
2donal
7 major
6o try t
5tot
5se me
7nai
4m pres
2he ob
3 bala
5jeb
6e aff
5mendous
2mnest
5. we'r
7ave got to
2c ter
4ntur
7 campaign
2flat
5obo
4is pre
4-here'
2note
2m el
4 issue
5, very
6o af
1fact o
6en's
5pany
6he republicans
7 --
4meon
5bea
4ory o
7"bI}tNrzZhNB

(note that some lines end in spaces)
I've gone with the simplest option I could think of: check a list of patterns, and as soon as you find a match, output the corresponding candidate. If all else fails, output the most likely candidate from the remainder. After that, it's all about cramming as much data into 300 bytes as possible.
FNc"<data>"bI}tNrzZhNB

Breakdown:
FN                      for N in ...
   "<data>"              the hard-coded data (newline separated)
  c                      split using...
           b             '\n' constant,
            I           if
              tN         tail (all but first char) of current item
             }           is contained within
                rzZ      the input (lowercased),
                        then:
                   hN    print the head (first char) of the current item
                     B   and break out of the loop.

So where does that data come from? Well the structure is simply:
<candidate_number><phrase>
<candidate_number><phrase>
<etc.>

(with an entry at the end with no phrase to act as the final fall-back)
But why those particular items? I wrote a C++ program to analyse the provided dataset (with some manual cleaning of newlines first to make the structure consistent). It looks at all substrings ("tokens") in each quote (1-16 characters), then repeatedly checks for the token which gives the most benefit to go next in the list. Once a pattern is in the list, remove any quotes which match it and repeat (it gets a bit more complicated to keep it fast but that's the basics). The code is probably too long to include here, but I might put it on github later (when I've cleaned it up a little).
I tried a couple of scoring systems. In the end I went with this one:
score = (
    + matching_quote_count_for_most_likely_author * 10
    - matching_quote_count_for_other_authors * 7
    - token_length
)

A stricter approach of only allowing new items which don't introduce incorrect answers seemed to get stuck at about 20-25%, needing a lot of patterns to get higher. This fuzzier approach does much better, and can still reach ~80% accuracy (with 550 items). The submitted score has 38 items, which was the most I could fit in the 300 character limit.
The 34% result actually comes from a test C++ program which performs the same steps. It should match, but I haven't got a Pyth test harness to check it with.
This is the first time I've used Pyth, so I imagine some more bytes could be squeazed out, allowing a bit more data.

Also I now know that Sanders loves talking about secretary Clinton, Clinton's obsessed with senator Sanders, Kasich loves Ohio, Cruz is always mentioning Donald Trump, Rubio is obsessed with Centuries, Carson has all the "fact[s] of the matter", and Trump totally loves saying "totally". This feels like the beginnings of a politics-bingo generator. I'll have to try it on some UK personalities…

I think you could save some bytes here by packing the string with .".

Javascript, 32.87%
299 Characters:
function Q(a,b){return p.toLowerCase().split(' ').join('').includes(a)<<b}z=Q('ink',0)+Q('int',1)+Q('ona',2)+Q('rica',3)+Q('twe',4)+Q("we'",5)+Q('youkn',6);return '55472726464727446676664676767676563641233643334456364233336141745116222136477126111113361611262316263122216111673336225611363276'[z]*1

Strategy:
I did a bruce force search on which word segments to include in a "hash". Then a string lookup happens with that hash in such a way that chooses the most likely candidate for that hash.
The code itself:
// The Q function checks if a string is present.
// Then left-shifts the true/false result up to e.g. 64,32,16,8,4,2,1
// This way we can combine results into any number 0 to 127.
function Q(a,b){return p.toLowerCase().split(' ').join('').includes(a)<<b}

// Now we check for key string occurrences:
z=Q('ink',0)+Q('int',1)+Q('ona',2)+Q('rica',3)+Q('twe',4)+Q("we'",5)+Q('youkn',6)

// Finally, use this as an index into the lookup string. (Multiply by 1 to convert char to int.)
return '55472726464727446676664676767676563641233643334456364233336141745116222136477126111113361611262316263122216111673336225611363276'[z]*1

This is my first ever code golf submission, so suggestions are welcome :)

Mathematica, 23.7775 %
(l=ToLowerCase@#;Ordering[-StringCount[l,#]&/@{"fact","donald"|"obama","done"|"ohio","issue"|"united"|"why"|"world","great"|"many","senator","american"|"believe"|"campaign"|"secretary"|"street"|"wall"},1])[[1]]&

It counts the occurences of common keywords unique to each candidate and outputs the number of the candidate with the highest score.
Basically, I found the commonest words of all candidates
t = Import["~/Documents/candidate quotes.txt"];
ts = DeleteCases[StringSplit[t, "\n\n"], ""];
tss = Split[ts, StringLength[#2] > 20 &][[{3, 4, 5, 6, 7, 1, 2}]];
names = StringSplit[#][[2]] & /@ tss[[All, 1]];
quotes = StringSplit[#, "(NEXT PARAGRAPH)"] & /@ StringJoin /@ tss[[All, 2 ;;]];
(* remove the 100 commonest english words *)
wd = WikipediaData["Most common words in English", "ArticleWikicode"];
Flatten[StringSplit[StringCases[wd,
  Shortest["{| class=\"wikitable\"" ~~ w__ ~~ "}"] -> w], "\n"]];
common100 =
Alternatives @@ ToLowerCase@DeleteDuplicates@Flatten[StringSplit /@
     StringCases[#,
      "|| " ~~ ("[[" | "") ~~ w : ((WordCharacter | " ") ..) ->
       w] & /@ %];
commonest =
  Commonest[
Flatten[StringSplit[
    StringDelete[ToLowerCase[#],
     PunctuationCharacter | (WordBoundary ~~ (common100) ~~
        WordBoundary)]] & /@ #], 20] & /@ quotes;

and chose the common keywords that are unique for each candidate.
keywords =
 Alternatives @@@
  Table[Complement[commonest[[n]],
    Union[Flatten[Delete[commonest, n]]]], {n, Length[names]}];

After manually deleting some of the keywords, this is the final table:

Carson    fact
Cruz      donald|obama
Kasich    done|ohio
Rubio     issue|united|why|world
Trump     great|many
Clinton   senator
Sanders   american|believe|campaign|secretary|street|wall

With these keywords the total function length is 211 characters. I tested the function over all quotes:
pairs = Flatten[MapThread[Table[q -> #1, {q, #2}] &, {names, quotes}]];
test[q_ -> n_] := Boole[n === names[[p@q]]] (* here p is my function that outputs the predicted candidate's number *)
Total[ParallelMap[test, pairs]]/Length[pairs] // N

which gives an accuracy of 23.7775 %.

Python,  25.677868%
Arbitrarily picked four different characters that would be used to identify the candidates. Each candidate is given a score factor per character based on a hill climbing search that I ran for a few minutes to end up at 25.68%.
I suppose that this at least proves that the concept is better than picking a candidate blindfolded or just picking Clinton, but I would be interested in seeing someone apply a better search algorithm, both for the factors and for the characters used.
w=dict(zip("hr?.",((.847,.491,.821,.54,.744,.765,.234),(.494,.777,.202,.587,.7,.852,.484),(.915,.187,.161,.559,.748,.244,.43),(.11,.013,.628,.974,1.037,.484,.302))))
def f(t,r=(0,0,0,0,0,0,0)):
 s=r
 for c in t:s=map(lambda a,b:a+b,s,w.get(c,r))
 return s.index(max(s))+1

Javascript, TBD
a=[...p].reduce((a,b)=>(a<<5)-a+b.charCodeAt(0)|0,0)%1000,alert(a>0?0:1000,a<79?1:a<226?2:a<333?3:a<497?4:a<697?5:a<849?6:7)

Converts each string to a hash code, then uses probabilistic methods to determine the speaker. Would be nice if someone with a good setup could test this for me.

I count about 16.1%, but I'm not really sure what it does. What does the a+=a?0:1000 do? (I had to replace the alert with a return so I wasn't sure exactly what to do)

@soktinpk Sorry, the a+= must have been a typo.


text:
Human Friendly Filename Detection
Introduction
File names can be wildly varying things, ranging from a simple blah.txt to 303549020150514101638190-MSP0.txt. The former is usually human generated, while the latter is often machine generated. Wouldn't it be nice to have a simple function to make educated guesses on whether or not a file might be considered "human-friendly"?
Inspired by a post by Eduard Florinescu that has since been deleted. His idea was good, but just needed a little fleshing out.
Challenge
Write a program or function in the language of your choice that can take an string, and determine if it is considered "human-friendly", as defined by this challenge.
Some further details and rules are as follows:

Input will be a string consisting of the 95 printable ascii characters.
"human-friendly" shall be defined thusly:

Exclude the extension in the consideration. An extension is defined as the final period followed by a series of alpha-numeric characters (as few as 1, as many as 6).
No more than half of the string by length (excluding extension) may consist of the following defined groupings of characters (combined):

Decimal characters longer than 8 in a row.
Hexadecimal characters (upper xor lower case) of at least 16 in a row (must consist of letters and numbers, and of which at least a third of the characters are numbers).
Base64 characters (using %+= as the special characters) of at least 12 in a row (must consist of letters and numbers, be mixed case, and of which at least a third of the characters are uppercase letters).

If any of the above groupings overlap in definition (such as one that qualifies as base64, but has 8 digits in a row), choose the longest of them to be excluded.

Output should be a truthy or falsy value, depending on if the string is considered "human-friendly" or not.
Assume that only valid input will be used. Don't worry about error handling.

The winner will be determined by the shortest program/function. They will be selected in at least 7 days, or if/when there have been enough submissions. In the event of a tie, the answer that came earlier wins.
Examples
Here's a few examples of input and output that your code should be able to handle:
"results_for__michael_greer.txt.zip" => true

"Georg Feuerstein - Connecting the Dots.pdf" => true

"M People - Search for the Hero-ntuqTuc6HxM.mp4" => true

"index.html?v=QTR4WGVTUzFsV3d8NHxvcmlnaW5hbHx8MTExMTAxBHxodHRwOi8vLCwsLHRyLDcsMA%3D%3D.html" => false

"ol2DCE0SIyQC(173).pdf" => false

"d41d8cd98f00b204e9800998ecf8427e.md5" => false

"12792331_807918856008495_7076645197310150318_o.jpg" => false

Javascript, 466 bytes
s=>(s=s.split(/\.[a-z\d]{1,6}$/i)[j=d=0],h=s[l='length']/2|0,m=[],g=r=>(++j,m=m.concat((s[n='match'](r)||[]).map(x=>[x,j]))),p='replace',g(/\d{9,}/g),g(/[\da-f]{16,}/ig),g(/[\da-z%+=]{12,}/ig),m.sort((x,y)=>y[0][l]-x[0][l]).every(x=>x[1]-1?x[1]-2?s=s[p](x[0],y=>y[n](/[a-z]/)&&y[n](/\d/)&&(y+'A')[n](/[A-Z]/g)[l]>y[l]/3|0?(d+=y[l],''):y):s=s[p](x[0],y=>!!y[n](/[A-F]/)^!!y[n](/[a-f]/)&&(y+'0')[n](/\d/g)[l]>y[l]/3|0?(d+=y[l],''):y):(s=s[p](z=x[0],''),d+=z[l])),d<=h)

Explaining:

f=s=>(                                 // f: take string s (filename) as input
    s=s.split(/\.[a-z\d]{1,6}$/i)[j=d=0],  // s: input without extension
                                           // d: combined rules' sum
                                           // j: combined rule-number step
    h=s[l='length']/2|0,                   // h: half string
                                           // l: length
    m=[],                                  // m: matches
    g=r=>(++j,                             // j: next combined rule number
        m=m.concat(                            // m: join
            (s[n='match'](r)||[]).map(             // new (r)egex-matches
            x=>[x,j])                              // mapped with its rule number
    )),p='replace',                        // p: replace
    g(/\d{9,}/g),                          // combined rules §1
    g(/[\da-f]{16,}/ig),                   // combined rules §2
    g(/[\da-z%+=]{12,}/ig),                // combined rules $3
    m.sort((x,y)=>y[0][l]-x[0][l])         // matches ordered by length
        .every(x=>x[1]-1?                      // for combined rule §1
            x[1]-2?                                // for combined rule §2
                s=s[p](x[0],y=>                        // for combined rule §3
                    y[n](/[a-z]/)&&y[n](/\d/)&&            // if lower and digit and
                    (y+'A')[n](/[A-Z]/g)[l]>y[l]/3|0?      // upper at least `total/3`
                (d+=y[l],''):y)                        // replace by empty and sum up `d`
            :s=s[p](x[0],y=>                       // replace if
                !!y[n](/[A-F]/)^!!y[n](/[a-f]/)&&      // (upper xor lower case) and
                (y+'0')[n](/\d/g)[l]>y[l]/3|0?         // digits: at least `total/3`
            (d+=y[l],''):y)                        // by empty and sum up `d`
        :(s=s[p](z=x[0],''),d+=z[l]))          // no treatment
    ,d<=h                                  // output if "no more than half of string"
);

["results_for__michael_greer.txt.zip",
"Georg Feuerstein - Connecting the Dots.pdf",
"M People - Search for the Hero-ntuqTuc6HxM.mp4",
"index.html?v=QTR4WGVTUzFsV3d8NHxvcmlnaW5hbHx8MTExMTAxBHxodHRwOi8vLCwsLHRyLDcsMA%3D%3D.html",
"ol2DCE0SIyQC(173).pdf",
"d41d8cd98f00b204e9800998ecf8427e.md5",
"12792331_807918856008495_7076645197310150318_o.jpg"]
.forEach(x=>document.body.innerHTML+='<pre>"'+x+'" => '+f(x)+'</pre>')


text:
Reproportioning a population by adding fixed sized groups
Introduction
Say you have a population of people.  This population is made up of 100 Alices and 25 Bobs. So, 80% of the population are Alices and 20% are Bobs.  We want to change the proportional makeup of the population to be 62% Alices and 38% Bobs.
Rules

You can only add to the population.  You cannot take any away from the starting population.
You can only add in multiples of the original subpopulation size.  So following the above example, you can only add batches of 100 Alices to the group; likewise, you can only add batches of 25 Bobs to the group.
You have a pool of unlimited Alices and Bobs that are not in the population yet.
The algorithm must be able to handle N different name groups (e.g. N=4: Alice, Bob, Carol, David).

Pseudocode framework
# 100 Alices, 25 Bobs, 35 Carols, 60 Davids
starting_population = (100, 25, 35, 60)

# Goal percentages, must sum to 100
reproportion_goal = (10, 20, 30, 40)

# Reproportion the population to meet the goal percentages, following the rules
new_population = reproportion_population(starting_population, reproportion_goal)

Winner
Create an algorithm to re-proportion the population following the rules with an arbitrary starting_population and reproportion_goal.
The winning algorithm will solve the above-quoted problem in the fastest time on a single-core single-CPU i686 system with fixed clock speed.  The algorithm must also solve other reasonable cases through the same code-path.  That is, do not special-case for the example data.
I will use many thousands of iterations to test the timing of the approach.  VM/runtime startup times will not be counted.  The algorithm will be warmed up before timing starts. You can specify the specific version of framework you would like me to run your code under, and if I can reasonably set it up, I will.
Introduction
Say you have a population of people.  This population is made up of 100 Alices and 25 Bobs. So, 80% of the population are Alices and 20% are Bobs.  We want to change the proportional makeup of the population to be 62% Alices and 38% Bobs.
Rules

You can only add to the population.  You cannot take any away from the starting population.
You can only add in multiples of the original subpopulation size.  So following the above example, you can only add batches of 100 Alices to the group; likewise, you can only add batches of 25 Bobs to the group.
You have a pool of unlimited Alices and Bobs that are not in the population yet.
The algorithm must be able to handle N different name groups (e.g. N=4: Alice, Bob, Carol, David).

Pseudocode framework
# 100 Alices, 25 Bobs, 35 Carols, 60 Davids
starting_population = (100, 25, 35, 60)

# Goal percentages, must sum to 100
reproportion_goal = (10, 20, 30, 40)

# Reproportion the population to meet the goal percentages, following the rules
new_population = reproportion_population(starting_population, reproportion_goal)

Winner
Create an algorithm to re-proportion the population following the rules with an arbitrary starting_population and reproportion_goal.
The winning algorithm will solve the above-quoted problem in the fastest time on a single-core single-CPU i686 system with fixed clock speed.  The algorithm must also solve other reasonable cases through the same code-path.  That is, do not special-case for the example data.
I will use many thousands of iterations to test the timing of the approach.  VM/runtime startup times will not be counted.  The algorithm will be warmed up before timing starts. You can specify the specific version of framework you would like me to run your code under, and if I can reasonably set it up, I will.
Dates (deadline and winner)
Deadline for submissions is before March 14, 2016.  I will post benchmarks by March 20.  Feel free to answer after these dates, but I can't commit to re-benchmarking submissions after March 14.

I have no idea why you are getting close votes.  This challenge (even in its revision history) is quite clear in my opinion, and its nice to see a [tag:fastest-code] around here :)   That said, I'd definitely add some more test cases that you will use to test the speed.

I'm guessing he didn't put test cases because the same input can have multiple valid outputs

Will the percentages always be integers?

The amount of computation needed to solve this is too low for a fastest-code question. The time to solve won't be measurable.

Also, will he download compiliers for each language submitted?  Install nodejs to ensure  there's less overhead than a browser?  He could run 1000 cases per language to get a measurable timeframe

Sorry for the unclear instructions guys.  I'll use the sandbox next time.  Yes, I will use multiple iterations to test the timing of the approach.  You can specify the framework you would like me to run your code under.  I added more clarification to the question details.

@MikeClark Does the solution need to be the minimal solution, or any solution that works?

@MrPublic I wanted the minimal solution, but I forgot to specify that.  Being a newbie, I didn't know about the sandbox!   I left the question as is: any solution is valid, since it is bad manners to change the rules after the question has been posted.

Is there another version of this question with the minimal-solution requirement?

C
void reproportion(
        const unsigned int n,
        const unsigned int *const starting_population,
        const unsigned int *const reproportion_goal,
        unsigned int *const new_population)
{
    unsigned int unit = 1U;

    for(unsigned int i = 0U; i != n; ++i) {
        unit *= starting_population[i];
    }

    for(unsigned int i = 0U; i != n; ++i) {
        new_population[i] = reproportion_goal[i] * unit;
    }
}

This assumes that the original subpopulation sizes are greater than zero. starting_population = { 0, 1, 2 } and reproportion_goal = { 0, 50, 50 } would give the incorrect result of new_population = { 0, 0, 0 }. If the original subpopulation size can be zero, unit *= starting_population[i]; should be preceded by if(starting_population[i] != 0U).
Call this function from within your program like so:
#include <stdio.h>

int main(void)
{
    unsigned int starting_population[] = { 1, 2, 31, 4 };
    unsigned int reproportion_goal[] = { 25, 25, 40, 10 };
    unsigned int new_population[4];

    reproportion(4, starting_population, reproportion_goal, new_population);

    for(int i = 0; i < 4; ++i) {
        printf("%d ", new_population[i]);
    }
}

Welcome to Programming Puzzles & Code Golf! This is a nice first answer. :)

With large N, this should vectorize well with SIMD.  (e.g. x86 SSE / AVX).  In that case, you'd actually get faster results from float than from 32-bit integers, since vector-integer 32-bit multiply requires SSE4.1, but vector-float multiply only requires SSE1.  vector-int _mm_mullo_epi32 also has worse performance than _mm_mul_ps.  (See http://agner.org/optimize/)

Javascript ES6
I'm not really sure how you time these things but here's what I have
(p,g)=>g.map(_=>_*m,m=p.reduce((l,o)=>o*l))

the instinct to use
(p,g)=>g.map(_=>_*p.reduce((l,o)=>o*l))

to save a few bytes is overwhelming, but I suspect js isn't smart enough to reuse the p.reduce for each iteration
[I know this gives back larger than necessary solutions, but I don't think that a minimal solution was a requirement :)
]
Usage
f=(p,g)=>g.map(_=>_*m,m=p.reduce((l,o)=>o*l))

f([100, 25],[62, 38])
//outputs [155000, 95000]
//sum of those is 250000

//155000/250000 = 0.62

f([100, 25, 35, 60] ,[10, 20, 30, 40])
//outputs [52500000, 105000000, 157500000, 210000000]
//sum of those is 525000000

Indeed, I didn't ask for the minimal solution and perhaps I should have.  But I'm going to leave it as I wrote it.  I didn't make it clear, but the algorithm needs to generalize to N subpopulations.  For 3 subpopulations, would you do (p,g,t)=>g.map(_=>_*p.reduce((l,o,m)=>o*l*m))?

I'm expecting p to be an array of current population, and g to be an array of desired percentages, so it should work for any pop size :)  I'll add usage to my answer

I am unfamiliar with some of these ES6 lambda and mapping constructs, so usage would be appreciated.  Thanks!

For a fastest-code competition I like non-efficient answers.  Like how for smallest-code terribly inefficient algorithms often win :)

@MikeClark for the future, you can get feedback (and potentially find these kinds of issues) if you post your challenge in the sandbox: meta.codegolf.stackexchange.com/questions/2140/sandbox-for-proposed-challenges

@NathanMerrill Thanks!  I will use that!

In real life, this can be expanded (probably already has been) to draw the boundaries of election districts.  Make one district 100% alice and the others 49% alice and 51% bob; bob wins all of the districts but one, with fewer voters in all.

Matlab
This function is very fast, but doesn't return the minimal solution
function s=reproportion_population(a,T)
s=prod(lcm(a,T)).*T;

This version returns the minimal solution.
function s=reproportion_population(a,T)
L=lcm(a,T);
g=prod(L)./a;
r=g(1);
rt=T(1);
for i=1:numel(g)-1
    r=gcd(r,g(i+1));
    rt=gcd(rt,T(i+1));
end
s=g./r.*a.*T/rt;

Usage is, for both versions, new_population = reproportion_population(starting_population, reproportion_goal), for example,
reproportion_population([100 25],[62 38])

which returns [182590000 111910000] (first version) or [3100 1900] (second version), or
reproportion_population([100 25 35 60],[10 20 30 40])

which returns [2520000000 5040000000 7560000000 10080000000] (first version) [2100 4200 6300 8400] (second version).
If you don't have Matlab, it should work as-is in Octave, although you need to need to add endfunction at the end of the file (I think---I don't have Octave).

Rust
To change the cases, simply change the numbers in the vectors (if you want commandline arguments instead, I can do that). On my computer I ran
time for i in {1..1000}; do target/release/population > /dev/null; done;

and got the output
real    0m4.202s
user    0m0.748s
sys 0m3.613s

I'm not sure how much actual optimization there is to be done, and how much will even show because its so fast.
fn reproportion_population(
    starting_population: &Vec<usize>,
    reproportion_goal: &Vec<usize>,
) -> Vec<usize> {
    let mut prod: usize = 1;
    let mut size: usize = 0;

    for i in starting_population {
        size += 1;
        prod *= *i;
    }

    let mut answers: Vec<usize> = vec![0; size];

    for i in 0..size {
        answers[i] = reproportion_goal[i] * prod;
    }

    answers
}

fn main() {
    let starting_population: Vec<usize> = vec![100, 25, 35, 60, 100];

    let reproportion_goal: Vec<usize> = vec![10, 20, 30, 30, 10];

    let answers: Vec<usize> = reproportion_population(&starting_population, &reproportion_goal);

    /*
    // the following prints out POPULATION: PERCENT with a newline for each pop.
    // the percent is given as a decimal.

    let mut total: usize = 0;
    for i in 0..reproportion_goal.len() {
        total += answers[i];
    }
    for i in 0..reproportion_goal.len() {
        println!("{}: {}", answers[i], (answers[i] as f64)/(total as f64));
    }
    */
}

To compile (after rust+cargo are installed) run cargo build --release. To run ./target/release/<binary_name>.

Python
Assuming that any valid solution is acceptable, and not the minimal solution...
def reproportion_pop(start_pop, pop_goal):
 import operator
 reduced = reduce(operator.mul, start_pop)
 new_pop = []
 for x in range(len(start_pop)):
  new_pop.append(reduced*pop_goal[x])
 return new_pop

This can be put in a .py file, pasted into an interpreter, or run Here, whichever you prefer.
Function call is in the form of reproportion_pop(list_of_start_pop, list_of_pop_goal)
Examples:
> reproportion_pop([100,25],[62,38])
[155000, 95000]

> reproportion_pop([100,25,35,60],[10,20,30,40])
[52500000, 105000000, 157500000, 210000000]

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