text:
Tips for golfing in Jolf
Jolf is a procedural golfing language made by @CᴏɴᴏʀO'Bʀɪᴇɴ.
What tips do you have for golfing in Jolf?
Please post one tip per answer.
These tips should be at least somewhat specific to Jolf, e.g. remove comments is an answer, but not a very good one.

Welcome to the site, please read the [ask] page and the [tour] page for more information.

JavaScript fall back
If for some strange reason Jolf isn't golfy enough, or simply cannot cope, it may be of use to use JavaScript eval. This can happen in one of two ways.
1. Designed eval
Anything inside of $...$ is literally carried over to the JS transpilation. For example, +3$~$5 transpiles to add(3, ~5). Equivalently, +3:~5.
2. Array eval
You can use JS arrays in Jolf! Mostly. It's kind of a bug, but I'm not going to fix it. For example:
u[3*5,5/6,(3+4)/5]

Transpiles to:
sum([2 * 3, 5 / 3, (3 + 4) / 5]);

If for some strange reason Jolf is golfy enough (...?)

@EriktheOutgolfer isn't **

Know your auto-assigning variables!
Jolf has many ways to "auto assign" variables. The standard one is γ, which takes the value of the next expression. Β is the same thing, but converts the next expression to a number.
Also, ζ (zeta) is a variable initialized to -1/12 (guess why), and can be re-assigned with Ζ (Zeta).
For example, let's say you want to compare I (the input string) to an operation over itself. For now, let's see if I + I = reverse(I + I). This is written as, conventionally:
=+II_+II

But this can be golfed down to:
=γ+II_γ

Does your -1/12 zeta have to do with string theory? I know of a way to add up every natural number and obtain -1/12

@GheyPhistor Which string theory? But yeah, it's that the zeta function over the natural numbers is -1/12.

Use @
@ is a command that takes the next character in the source code and returns that character's code point. (For example, @X returns 88.) This is often very useful since you can express any number between 0 and 255 in two bytes.

"between 100 and 255"

@KennyLau In Jolf, 10 is actually the number 1 and the number 0 not the number 10, so it's more like 10-255.

Read the source
As of right now, there are a lot of undocumented things -- the mysterious m module among them, which has a lot of builtins. However, they do exist in the source, and it's really not hard to read once you get the hang of it, so read the source.

The mysterious math module.

module. (6 more to go...)

Increase Function Arity
Every function has an arity. For example, + has an arity of 2. If you want to (say) add 5 elements, you could use 5 +s... or do +θ12345. Specifically:

θ incrases the arity of the function by 3.
~θ increases the arity of the parent function by 3. (So *+~θ345678 increases the arity of the * by 3)
M increases the arity of the function by 2.
~M increases the arity of the parent function by 2.
; increases the arity of the function by 1.
~; increases the arity of the parent function by 1.
η decreases the arity of the function by 1.
~η decreases the arity of the parent function by 1.
\xad sets the arity of the parent function to the next character's charcode.

What's the advantage of *+~θ over *θ+?

@immibis There isn't in that case, it was merely illustrative. There are some functions in Jolf that pass two functions when parsed. Then, the only way to access the top function's arity is using ~<char>.

Take advantage of implicit input
If a function does not have enough arguments, it will look to the input for the remainder of the arguments. For example:
+uz

Would transpile to:
add(sum(unaryRange(x)), x)

It's equivalent to
+uzxx

Use o to store values
Similar to how other languages can assign variables for easy/short referencing, Jolf has o.
For example, oThx prints the input plus 1.
This is a useless example, but when the expression is more complicated than hx, it can save some serious byteage.
Also, v"var name"<val> allows for a multi-char variable name, and V"var name" gets a variable from the scope.
Thanks to Conor for explaining this to me, and giving the previous sentence.

Also note that v"var name"<val> allows for a multi-char variable name, and V"var name" gets a variable from the scope.

@CᴏɴᴏʀO'Bʀɪᴇɴ oh, so that's what they do. Adding to the post.

o Thx for this tip :P

@EᴀsᴛᴇʀʟʏIʀᴋ It was a pun on o being the assignment variable

@CᴏɴᴏʀO'Bʀɪᴇɴ o, yeah....

source: Stack Exchange

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

sort: votes


text:
Compute the histogram entropy estimation of a string
Write a program or function that estimates the Shannon entropy of a given string.
If a string has n characters, d distinct characters, xi is the i th distinct character, and P(xi) is the probability of that character occuring in the string, then our Shannon entropy estimate for that string is given by:

For the estimation in this challenge we assume that the probability of a character occurring in a string is simply the number of times it occurs divided by the total number of characters.
Your answer must be accurate to at least 3 digits after the period.

Test cases:
"This is a test.", 45.094
"00001111", 8.000
"cwmfjordbankglyphsvextquiz", 122.211
"             ", 0.0

Opposed to my usual challenges, this one looks complicated, but is actually quite simple :)

Related: http://codegolf.stackexchange.com/q/24316

Is it safe to assume printable ASCII for the input string?

@TimmyD No. Any string that your language's string type supports.

Unfortunately, Mathematica's Entropy counts bits per character, not total for the string; oh well...

Jelly, 11 8 bytes
ċÐ€÷Ll.S

Try it online!

Can I ask, how you enter those characters? With copy and paste?

At least on Linux, they can all be typed on the US international keyboard.

Python 3.3+, 64 bytes
import math
lambda s:sum(math.log2(len(s)/s.count(c))for c in s)

Got math.log2 from mbomb007's solution.

So @orlp didn't give us a fully simplified formula, eh...?

@mbomb007 Depends for what purpose you're simplifying. Writing it in terms of probabilities and distinct characters is natural as a definition, but for golfing it's shorter to work with counts and iterate over all characters.

Pyth answer with your formula: http://pyth.herokuapp.com/?code=smlclQ%2FQ&test_suite=1&test_suite_input=%22This+is+a+test.%22%0A%2200001111%22%0A%22cwmfjordbankglyphsvextquiz%22%0A%22+++++++++++++%22&debug=0 8 bytes

APL, 18 14 bytes
+/2⍟≢÷(+/∘.=⍨)

This is an unnamed, monadic function train that accepts a string on the right and returns a real.
Like all good things in life, this uses xnor's formula. We get a matrix of booleans corresponding to the occurrences of each character in the string using ∘.=⍨, sum this along the first axis (+/) to get the number of occurrences of each character, divide the length of the string by each, then take log base 2 (2⍟) and sum.
Try it here
Saved 4 bytes thanks to Dennis!

Perl 5, 58 bytes
A subroutine:
{for$a(@a=split'',pop){$t+=(log@a/grep/\Q$a/,@a)/log 2}$t}

A tip of my hat to xnor for the formula.

-F doesn't work (in Strawberry, anyway) because it includes the $/.

MATL, 17 bytes
S4#Y'ts/tZl*sGn_*

Try it online!

You may be able to save some bytes with Ym

J - 18 16 14 bytes
1#.2^.#%1#.=/~

Shortened using the idea in Dennis' method.
Usage
   f =: 1#.2^.#%1#.=/~
   f 'This is a test.'
45.0936
   f '00001111'
8
   f 'cwmfjordbankglyphsvextquiz'
122.211
   f '             '
0

Explanation
1#.2^.#%1#.=/~  Input: string S
           =/~  Create a table testing for equality
        1#.     Convert each row from a list of base 1 digits to decimal
                This is equivalent to taking the sum and forms a list of tallies
      #         Get the length of S
       %        Divide the length by each tally
   2^.          Log base 2 of each
1#.             "Sum" those values and return

I don't think this counts as a function. If you assign the code to a variable, it does something entirely different.

@Dennis From what I gather, it appears J interprets it as a chain of compositions, using 3 : '... y' with the same syntax would be a valid way to define it as a function. J states that it evaluates from right-to-left, so I've refactored my code as a train. I don't like caps [: but I can't find any other way to make a train.

JavaScript (ES6), 67 bytes
s=>[...s].map(c=>t+=Math.log2(s.length/~-s.split(c).length),t=0)&&t

I need to use ~-s.split because that accepts strings rather than regexps. As usual, map beats reduce by a byte.
s=>[...s].reduce((t,c)=>t+Math.log2(s.length/~-s.split(c).length),0)

MATL, 14 bytes
!Gu=stGn/Zl*s|

Try it online!
!      % transpose implicit input into column vector
Gu     % row vector with unique elements of input
=      % test for equality, element-wise with broadcast
s      % sum of each column
tGn/   % duplicate. Divide by number of input characters
Zl     % binary logarithm
*      % element-wise multiplication
s      % sum of array
|      % absolute value. Display implicitly

Julia, 37 bytes
x->sum(log2(endof(x)./sum(x.==x',1)))

Takes a character array as input. Try it online!

Pyth - 17 bytes
*_lQsm*FlBc/QdlQ{

Try it online here.

Jolf, 26 bytes
_*liuΜGμiEd*γ/l miLeHlimzγ

Try it here! (Note that the test suite function is borked.)
Explanation
_*liuΜGμiEd*γ/l miLeHlimzγ
       μi                   unique members of i
      G  E                  split on ""
     Μ    d                 map over function
               _miLeH       match i with regex escaped member
             /l      li     divide length of (^) by length of i
            γ               γ = (^)
           *           mzγ  (^) * log_2(γ)
 *li                        (^) * length of i
_                           negate

Python 3.3+, 95 91 89 85 bytes
Simple solution. Version 3.3 is required to use math.log2.
import math
def f(s):C=s.count;return-sum(C(x)*math.log2(C(x)/len(s))for x in set(s))

Try it online

Do you think there's anything unnecessary here? n*sum(s.count(c)/n

@orlp Thanks. I originally had a separate function for finding the probability, but had pasted it inside twice and deleted it to save chars.

You don't have to store n in a variable now that you only use it once.

Factor, 98 bytes
[ [ length ] [ dup [ [ = ] curry dupd count ] { } map-as nip ] bi [ / log 2 log / ] with map sum ]

This is a direct translation of this Python answer. I'll add an explanation over dinner.

k (32 bytes)
{-+/c*(log c%n:+/c:#:'=x)%log 2}

Or in q, the translation is not all that short but clearer:
{neg sum c*2 xlog c%n:sum c:count each group x}

Mathematica, 45 bytes
Tr[Log[2,Tr@#/#]#]&@Values@CharacterCounts@#&

Usage
This returns exact results so we approximate them with N.
  f = Tr[Log[2,Tr@#/#]#]&@Values@CharacterCounts@#&
  f["This is a test."]//N
45.0936
  f["00001111"]//N
8.
  f["cwmfjordbankglyphsvextquiz"]//N
122.211
  f["             "]//N
0.

Java 7, 207 bytes
double C(String x,Map<Character,Integer>f){double H=0,g;for(char c:x.toCharArray())f.put(c,f.containsKey(c)?f.get(c)+1:1);for(char c:f.keySet()){g=f.get(c);H+=g*Math.log(g/x.length())/Math.log(2);}return-H;}

Detailed try online
double log2(double d) { return Math.log(d) / Math.log(2); }

double C(String x, Map<Character,Integer>f)
{
    double H=0,g;

    // frequency
    for(char c : x.toCharArray())
    {
        f.put(c, f.containsKey(c) ? f.get(c)+1 : 1);
    }

    // calculate entropy
    for(char c : f.keySet())
    {
        g = f.get(c);
        H += g * log2(g / x.length());
    }

    return -H;
}

Racket, 130 bytes
:c
#lang racket
(require math)(λ(S)(let([s(string->list S)])(sum(map(λ(c)(/(log(/(length s)(count(λ(x)(char=? c x))s)))(log 2)))s))))

Translation of my Factor answer, so it's an indirect translation of Kenny Lau's Python answer.

R, 67 bytes
l=length(i<-strsplit(readline(),"")[[1]]);-sum(log2(l/table(i)[i]))

Explanation
Take input from stdin and split it into a list of characters. (This clunky syntax is why string golf challenges are so tough in R...)
         i<-strsplit(readline(),"")[[1]])

This assignment is hidden inside of a length command, so we get two assignments for the price of one. We have i, the list of characters, and l, its length.
l=length(i<-strsplit(readline(),"")[[1]]);

Now we calculate the entropy. R has a nice function table which returns the counts of all unique values. For input This is a test, table(i) returns
> table(i)
i
  . a e h i s t T
3 1 1 1 1 2 3 2 1

This is indexed by characters, which is nice, as we can then use i as an index to get the count of each character, like so:
> table(i)[i]
i
T h i s   i s   a   t e s t .
1 1 2 3 3 2 3 3 1 3 2 1 3 2 1

The rest of the code is then a simple implementation of the entropy formula, flipped around a little.
                                           -sum(log2(l/table(i)[i]))

Save two bytes (also your submission does not work on TIO)

61 chars using utf8ToInt

C#, 159 bytes
Golfed:
string f(string s){var l=s.Length;double sum=0;foreach(var item in s.GroupBy(o=>o)){double p=(double)item.Count()/l;sum+=p*Math.Log(p,2);}return(sum*=-l)+"";}}

Ungolfed:
string f(string s)
{
  var l = s.Length;
  double sum = 0;
  foreach (var item in s.GroupBy(o => o))
  {
    double p = (double)item.Count() / l;
    sum += p * Math.Log(p, 2);
  }
  return (sum *= -l) + "";
}

Test:
var codeGolf = new StringHistogramEntropyEstimation();
    Console.WriteLine(codeGolf.f("This is a test.")); //45.0935839298008
    Console.WriteLine(codeGolf.f("00001111")); //8
    Console.WriteLine(codeGolf.f("cwmfjordbankglyphsvextquiz")); //122.211432671668
    Console.WriteLine(codeGolf.f("             ")); //0

Groovy, 100 Bytes
{a->n=a.size();a.toList().unique().collect{p=a.count(it)/n;p*(Math.log(p)/Math.log(2.0f))}.sum()*-n}

Tests:
This is a test. = 45.09358393449714
00001111 = 8.0
cwmfjordbankglyphsvextquiz = 122.21143275636976
aaaaaaaa = -0.0

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


text:
Reverse positive runs
Input
Your input is a list of single-digit numbers in any reasonable format, including a string of digits.
The input will not be empty.
Output
Your output shall be the input list, but with each maximal run of nonzero digits being reversed.
Example
Consider the input
95883007414830
<--->  <---->

where the nonzero runs have been marked with arrows.
Reversing each of these runs, we obtain the output
38859003841470

Rules and scoring
You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.
This challenge is related, but much more complex, since it includes additional string processing.
Test cases
4 -> 4
00 -> 00
123 -> 321
0010 -> 0010
12000345 -> 21000543
18161604 -> 61618104
95883007414830 -> 38859003841470
010230456078912 -> 010320654021987
357509902003550 -> 575309902005530
2492882377675046 -> 5767732882942064
03026302053000357099 -> 03036202035000753099

Leaderboard
Here's a Stack Snippet to generate a leaderboard and list of winners by language.
To make sure your answer shows up, start it with a header of the form
## Language, N bytes

You can keep old scores in the header by using the strikethrough tags: <s>57</s> will appear as 57.

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  });

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

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

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

    var lang = a.language;
    if (! /<a/.test(lang)) lang = '' + lang + '';
    lang = jQuery(lang).text().toLowerCase();

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

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

  langs.sort(function (a, b) {
    if (a.uniq > b.uniq) return 1;
    if (a.uniq < b.uniq) 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/Sites/codegolf/all.css?v=617d0685f6f3">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

Pyth, 8
j0_Mcz\0

Split on zeros, reverse and join back on zeros.
Test Suite

IPOS, 5 bytes
'0!r%

% splits the input string on zeroes, applies the command r (reverse) to every substring and joins the result back on zeroes.

Retina, 15 bytes
S`0
O%^$`.

¶
0

Try it online! (Slightly modified to run all test cases at once.)
Explanation
S`0

Split the input around 0s that is, put each (possibly empty) run of non-zero digits on its own line.
O%^$`.

This reverses each line, by:

Applying the stage to each line individually with %.
Matching each character individually with ..
Sorting it by the result of the substitution ($) with the empty string (the empty second line). I.e. it doesn't sort at all, since all sort values are identical.
Then reverses the order of the sorted characters.

Finally:
¶
0

Turn the linefeeds back into 0s.

05AB1E, 6 bytes
Code:
0¡€R0ý

Explanation:
0¡      # Split on zeros
  €R    # For each item in the array, reverse it
    0ý  # Join by zeros

Uses CP-1252 encoding. Try it online!.

Julia, 30 bytes
s->replace(s,r"[^0]+",reverse)

This is an anonymous function that accepts a string and returns a string. To call it, assign it to a variable.
The replace function provides the ability to replace matches of a regular expression with the result of a function applied to each match. In this case we can get nonzeros using [^0]+ and replace those runs with the result of the reverse function applied to the matched text.
Verify all test cases online!

Jolf, 8 bytes
RΜGi0λ_0

Try it here!
Explanation
RΜGi0λ_0
  Gi0     split input on zeroes
 Μ   λ_   map over reversal as a lambda
R      0  join by zeroes

The code explanation looks sort of like a lambda if you squint.
An equivalent 8-byte answer:
RΜGi0΅O0

Same thing, but it uses ΅O (string mirror lambda) instead.

I'd say it looks more like some text in a funny shape when I squint at it. Maybe I should put this telescope away.

@cat No, no, keep it, but look at the lambda when you do.

Retina, 25 24
O^$#`[^0](?=(.*?0)*)
$#1

Try it online
Saved 1 byte thanks to Martin!
Sort the nonzero digits by the number of zeros that follow the digit, in reverse order.
See Martin's solution for a clever use of per-line mode to get a shorter program!

Mathematica, 30 bytes
Join@@Reverse/@#~SplitBy~Sign&

e.g. Join@@Reverse/@#~SplitBy~Sign&[{1,2,3,0,0,5,9,0}] = {3, 2, 1, 0, 0, 9, 5, 0}

Ruby, 29 bytes
->x{x.gsub /[^0]*/,&:reverse}

Jelly, 5 bytes
ṣ0Uj0

Try it online!

Python, 58 50 bytes
lambda x:"0".join([n[::-1] for n in x.split("0")])

Takes in a string x and splits on the zeros and reverses each element in the split and adds a zero and returns the this minus last zero.

Welcome to PPCG :) You should be able to do "0".join and then drop the addition and the slice.

@FryAmTheEggman thanks for the tip

No problem :) You can also remove the space between ] and for. You can check out our tips page for more pointers, if you'd like.

lambda x:"0".join(n[::-1]for n in x.split("0"))

PowerShell v2+, 45 bytes
($args-split0|%{-join$_[$_.length..0]})-join0

Abusing the implicit casting like there's no tomorrow. Likely can't get much shorter, as there's no builtin for reverse that's shorter than this indexing trick.
Explanation
An example of how this works -- suppose 123045 was the input $args. After the -split on 0, the pipeline would contain an array (123,45). The first loop with |%{...} has the current element $_ equal to 123, which is then implicitly cast as a string, then reversed with the [] indexing. That makes it ('3','2','1') as a char-array. The loop's -join puts that back into a string "321" and leaves it on the pipeline. The next (last) loop iteration reverses the input to "54". So now our pipeline is "321", "54". That's encapsulated in parens () so it's reformed into an array, and re-joined back together with zeros to produce the resultant output string "321054". That's left on the pipeline and output to the console is implicit.
If there are subsequent zeros in the original input, the array would be populated with null elements, so there are the correct number of zeros on the output. For example, 1230045-split0 turns into (123,,45) and things continue as above.

Haskell, 45 bytes
r%(0:t)=r++0:[]%t
r%(h:t)=(h:r)%t
r%_=r
([]%)

Recursively accumulates the reversed chunk so far in r, prepending it when a 0 is reached. When the remaining string is empty, it also discharges r.
The first two repeat some code, but I didn't find a shorter way to combine them (45 and 47 bytes):
r%(h:t)|h<1=r++h:[]%t|1>0=(h:r)%t
r%_=r
([]%)

r%l|0:t<-l=r++0:[]%t|h:t<-l=(h:r)%t
r%_=r
([]%)

I think you need one more pair of parenthesis in line #2: r%(h:t)=(h:r)%t

Factor, 35 bytes
Beating Pyfon and Clojure, booyah!
[ "0"split [ reverse ] map "0"join ]

This anonymous function is a literal translation of this Python answer.
It's quite simple, just split the string on zeroes, reverse every element of the resulting array, and join all the elements (including zero-length strings) with "0".
Here's an example of it running on all test cases:
IN: scratchpad auto-use {
        "4"
        "00"
        "123"
        "0010"
        "12000345"
        "18161604"
        "95883007414830"
        "010230456078912"
        "357509902003550"
        "2492882377675046"
        "03026302053000357099"
        }
        [
          "0" split [ reverse ] map "0" join
        ]
        map .

{
    "4"
    "00"
    "321"
    "0010"
    "21000543"
    "61618104"
    "38859003841470"
    "010320654021987"
    "575309902005530"
    "5767732882942064"
    "03036202035000753099"
}

"00120" -> { "" "" "12" "" } -> { "" "" "21" "" } -> "00210"

J, 20 18 bytes
0}:@;@(<@|.;.1)@,]

Thanks to Zgarb for helping with this! Takes a space-separated list as a right argument.
-2 bytes thanks to Zgarb!

Pyke, 8 bytes
\0cm_\0J

Explanation:
\0c      -   input().split("0")
   m_    -  map(reversed, ^)
     \0J - "0".join(^)

Try it here!

JavaScript (ES6), 50 49 bytes
String version:
s=>s.replace(/[^0]+/g,r=>[...r].reverse().join``)

Saved a byte thanks to @Kevin Lau!
Array version (60 bytes):
a=>a.map((n,i)=>n?a[z-i+[...a,0].indexOf(0,i)]:(z=i,0),z=-1)

Clojure/ClojureScript, 44 chars
#(flatten(map reverse(partition-by pos? %)))

Same solution as others, just more verbose thanks to long function names.  Wasn't going to post it because of that, but it beats some other answers so why not?
Works on any sequence type.  In ClojureScript, this also works on strings since strings are processable as lists of characters, which are really just 1-length strings, which coerce to numbers for things like pos?.

Haskell, 46 bytes
import Data.Lists
(reverse=<<).split(oneOf"0")

Usage example: (reverse=<<).split(oneOf"0") $ "0123004500678090"-> "0321005400876090".
Sadly the split function requires the expensive import. Split the input list at every 0, e.g. split(oneOf"0") "0120030" -> ["","0","12","0","","0","3","0",""], reverse each chunk and concatenate into a single string.

Perl, 22 bytes
Including +1 for -p option:
s/[^0]+/reverse$&/eg

This is a pretty trivial substitution - sorry to be so boring.  Note that if your input is newline-terminated (e.g. using perl -pe 's/[^0]+/reverse$&/eg' <<<21000543 in Bash), it will catch the newline with the digits - use echo -n or printf to avoid that.  Alternatively, for a cost of one additional byte, change the character class to [1-9], and you can provide many inputs, one per line.

F#, 103 bytes
let f x=x="";x.Split '0'|>Array.map(fun s->System.String(s|>Seq.toArray|>Array.rev))|>String.concat "0"

Java, 179 bytes(with import)
import java.util.*;static void r(String s){StringJoiner x= new StringJoiner("0");for(String a:s.split("0",s.length())){x.add(new StringBuilder(a).reverse());}System.out.print(x);}

Takes in a string input and splits the characters by zero then adds them back by calling the add method on the StringJoiner class.

Oracle SQL 11.2, 131 123 bytes
Abusing XML functions.
SELECT LISTAGG(REVERSE(COLUMN_VALUE||''))WITHIN GROUP(ORDER BY rownum)FROM XMLTABLE(('"'||REPLACE(:1,'0','","0","')||'"'));

C, 105 bytes
#define x(o)for(p=s;*s&&'0'o*s;++s);for(r=s;r-->p;putchar(*r));
f(s,p,r)char*s,*p,*r;{x(^)x(==)*s&&f(s);}

Call f with the list of digits as a nul-terminated string, and it will print the correct output.
Ungolfed and explained:
f(s,p,r)
char*s,*p,*r; // K&R style to avoid repeating `char`
{

    // x(^)x(==) expands to...

    // Find the next zero digit
    for(p = s; *s && '0' ^ *s; ++s)
        ;

    // Print that run backwards
    for(r = s; r-- > p; putchar(*r))
        ;

    // Find the next non-zero digit
    for(p = s; *s && '0' == *s; ++s)
        ;

    // Print that run backwards (no difference, it's all zeros)
    for(r = s; r-- > p; putchar(*r))
        ;

    // If there's more string, recurse
    *s && f(s);
}

See it live on Coliru

Husk, 4 bytes
ṁ↔ġ¬

Try it online! or verify all test cases
Input is a list of digits.
ġroups all adjacent runs of nonzero (¬=NOT) digits, then ṁaps the 'reverse a list' (↔=REV) function across all groups, concatenating the result.

K (ngn/k), 10 bytes
"0"/|'"0"\

Try it online!
Similar to many of the other approaches; takes (implicit) input as a string of digits:

"0"\ split input on 0s
|' reverse each chunk
"0"/ join with 0s

Vyxal, 4 bytes
0ẆRṅ

Takes input as a string instead. If that's not allowed then the Ṡ flag can be added.
Try it online!
Explanation:
0     # Push the literal digit 0
 Ẇ    # Split and keep delimiter
  R   # Reverse each one
   ṅ  # Join by nothing

Perl 5, 52 bytes
A subroutine:
{$_=pop;y/0/ /;map$i.=reverse,split/\b/;$i=~y/ /0/r}

-a doesn't work (in Strawberry at least) when the input string ends in 0, since split/\b/ includes the $/ with the 0.

C#, 133 bytes

Golfed
String m(String s){for(int i=0,p=i;i<s.Length;i++){if(s[i]=='0'){p=i+1;}else{s=s.Insert(p,s[i].ToString()).Remove(i+1,1);}}return s;}

Ungolfed
String m( String s ) {
    // i = Index on the String
    // p = Pointer of the last '0' found
    for (int i = 0, p = i; i < s.Length; i++) {
        if (s[ i ] == '0') {
            // Move the 'p' pointer to the index after this '0'
            p = i + 1;
        } else {
            // Insert the Char at the Index location to the Pointer location
            //    and remove the one at the Index Location + 1,
            //    since the String was incremented by one char due to the 'Insert()'.
            s = s.Insert( p, s[ i ].ToString() )
                 .Remove( i + 1, 1 );
        }
    }

    return s;
}

Full code
using System;
using System.Collections.Generic;

namespace Namespace {
    class Program {
        static void Main( String[] args ) {
            List<String> ls = new List<String>() {
                "4",
                "00",
                "123",
                "0010",
                "12000345",
                "18161604",
                "95883007414830",
                "010230456078912",
                "357509902003550",
                "2492882377675046",
                "03026302053000357099"
            };

            foreach (String s in ls) {
                String f = m( s );

                Console.WriteLine( String.Format( "{0,30}", s.Replace( "0", "0 " ) ) );
                Console.WriteLine( String.Format( "{0,30}", f.Replace( "0", "0 " ) ) );
                Console.WriteLine( "" );
            }

            Console.ReadLine();
        }

        static String m( String s ) {
            for (Int32 i = 0, p = i; i < s.Length; i++) {
                if (s[ i ] == '0') {
                    p = i + 1;
                } else {
                    s = s.Insert( p, s[ i ].ToString() ).Remove( i + 1, 1 );
                }
            }

            return s;
        }
    }
}

Just noticed now that @downrep_nation had already posted here a solution for C#, that beats my code by 2 bytes... ( It can be more.... )

Actually, 22 bytes
k"a%sa"%'0@s♂R'0j#pXdX

This actually made me notice that there's a bug in the split command - it doesn't preserve empty splits. As a workaround, I surround the input string with as before doing the split, reverse, and join, then remove the as at the end. Input is taken as a string, output is a list of single-character strings.
Try it online
Explanation:
k"a%sa"%'0@s♂R'0j#pXdX
k"a%sa"%                surround input with "a" characters
        '0@s            split on 0
            ♂R          reverse each piece
              '0j       join on 0
                 #pXdX  listify, remove first and last element (the "a"s)

C#, 131 bytes ##
solution flawed!
string j(string i){foreach(var s in i.Split('0'))if(s!="")i=i.Replace(s,new string(s.ToCharArray().Reverse().ToArray()));return i;}

ungolfed:
string j(string input)
    {

        string[] a = input.Split('0');

        foreach (string s in a)
        {
            if (s!="")
            input=input.Replace(s, new string(s.ToCharArray().Reverse().ToArray()));
        }

        return input;
    }

I believe this method has a bug when one string to be reversed is a subset of another.  If given the input 01201230, this would return 02102130.  This is because the String.Replace method replaces all occurrences of the first string with the second.  This bug would also be caused if one pattern shows up when reversed (0120210 would return 0120120).

I didn't even think of that..

Java, 126
a->{String r="",t[]=a.split("0");for(String s:t){r+=new StringBuilder(s).reverse()+"0";}return r.substring(0, r.length()-1);}

If you declare the s variable at the front with r and t[], can you omit the type declaration of s in the for loop?

Nope, I checked it, enhanced for loops need a newly declared variable.

huh. That's weird. Oh well

Clojure, 37 bytes
#(mapcat reverse(partition-by #{0}%))

Uses #{0} instead of pos? (save 1 byte by concatenating with %) and using mapcat instead of (flatten(map. Still longer than Factor.

Wonder, 23 bytes
rstr[`[^0]*`g;'><"".rev

Usage:
(rstr[`[^0]*`g;'><"".rev)1230123

Reverses all parts of the input that match the global regex [^0]*.

05AB1E, 5 bytes
0¡í0ý

Try it online!
0¡í0ý  # full program
    ý  # join...
       # implicit input...
 ¡     # split by...
0      # literal...
 ¡     # s...
  í    # with each element reversed...
    ý  # by...
   0   # literal...
    ý  # s
       # implicit output

APL (Dyalog Unicode), 20 bytes
('[1-9]+'⎕R{⌽⍵.Match})

It's just a simple regular expression with an anonymous function.
'[1-9]+' ⍝ a regex pattern
  ⎕R ⍝ the replace operator
    {⌽⍵.Match} ⍝ an anonymous function that recieves a regex namespace (object). ⌽ reverses the string.

Try it online!

Don't need the parens so 20 bytes

@rak1507 Oh, right. Thanks.

C (gcc), 90 bytes
char*t;f(char*s){*s>48&&putchar(*s,f(s+1),++t);}g(char*s){for(t=s;f(t),*t;putchar(*t++));}

Try it online!

Raku, 22 bytes
{S:g[<-[0]>+]=$/.flip}

Try it online!
Basic regex solution.  <-[0]> matches any nonzero character (it's Raku's version of the classic [^0]), and $/.flip reverses each sequence.

Arturo, 39 bytes
$=>[chunk&=>[0=&]|map=>reverse|flatten]

Try it

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


text:
Can Gravity Guy Make It?
Gravity Guy is a game where the only user input is a single key that flips the direction of gravity. Given an ASCII art level, determine if it is possible for Gravity Guy to reach the end.

Rules

The initial direction of gravity is down.
The first column of the input will always contain only one #, which Gravity Guy starts on top of.
Each iteration, he moves to the character directly on his right.
If his path is blocked and he moves into a #, the player loses.
After moving, the player can optionally switch gravity from down to up, or up to down.
Gravity Guy then falls on to the next # (in the current direction of gravity).
If there is no # to fall on to and he falls off the grid, the player loses.
If Gravity Guy moves off the right side of the input grid, the player wins.

Example
If this was the input grid:
  ###

#  # #
 ###

Gravity Guy would start at the x and the be at these positions after each iteration. ^ = switch gravity to up and v = switch gravity to down.
v                        ^                               v
-------------------------------------------------------------
  ###   |    ###   |    ###   |    ###   |    ###   |    ###
x       |          |    x     |     x    |      x   |
#  #    |  #x #    |  #  #    |  #  #    |  #  #    |  #  # x
 ### #  |   ### #  |   ### #  |   ### #  |   ### #  |   ### #

As you can see, by switching gravity at these times Gravity Guy reaches the end, so this input would return a truthy value.
Specifications

Input grid can be in any appropriate "grid" format (multiline string padded with spaces, array of line strings, array of array of characters, etc).
If it is possible for the player to win the level, output a truthy value. If not, output a falsey value.
The width and height of the grid will be 50 characters at most.
This is code-golf, may the shortest code in bytes win!

Test Cases
(each case separated by ----------, any blank lines should also be padded with spaces)
True
 #########   ########      ######     ######
          #  #       #    #      #   #      #
###    #   # #    #   #  #       #  #        #
  #    ##  # #    ##  # #     # #  #      ##
  #    #   # #    #   # #    #     #     #######
  #       #  #       #  #     ###  #          #
  #    ##    #    ##     #       #  #         #
  #    #          #              #        #   #
  #    ####################################   #
  #                                           #
  #############################################

----------

###

----------

   #####

####

----------

 #####
 # # #

# # #
 #####

----------

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

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

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

----------

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

----------

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

----------

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

----------

  ###

#  # #
 ###

----------

  ###  ###

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

----------

  #
     #   #
       #
#   #     #
        #
   #
      #
 #

----------

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

----------

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

False
 ###
   #
####

----------

### ###

----------

    #
 ### ###

#### ###
    #

----------

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

----------

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

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

----------

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

Are we allowed the grid in columnar format?

@Neil You mean a transposed/rotated array? I'm going to say no, since it's altering the input. But if your language has a special column type, that would be OK to use I guess.

Is it possible for the # in the first column to be in the first row?

@feersum No, you can assume the grid will include space for the Gravity Guy to "stand" in.

Shame; the transposition increases my byte count by 20%.

Snails, 15 bytes
Try it online?
^
\ n\ ,=\#r}+~

     0. ^ is an option that requires the pattern to start at the top left.

\ : match space

n: Turn 90 degrees in either direction

\ ,: match space zero or more times

=\# check that there is a # in front of us

r: set the direction to right

}+: do all of the preceding one or more times

~ match a cell which is out of the grid bounds

This gives 0 for most of the True test cases

@Bas Have you padded the empty lines with spaces?

@MartinBüttner I directly copied some of the inputs, doing so indeed removed some of the spaces. It works indeed after adding spaces

Since nobody's said it yet: This is Awesome!

Perl, 93 89 81 77 76 75 74 bytes
Includes +2 for -0p
Run with the input pattern (with all lines space padded to the same length) on STDIN:
gravity.pl < gravity.txt

gravity.pl:
#!/usr/bin/perl -0p
/
/;$n=".{@-}";s/#$n\K( $n)*\b |(^|w)([w ]$n)*\K $n#/w|$&/es&&redo;$_=m;w

This file based version needs the final newline, so that is really 75 bytes. But the commandline based version doesn't need that extra newline so this counts as 74 bytes:
perl -0pe '/
/;$n=".{@-}";s/#$n\K( $n)*\b |(^|w)([w ]$n)*\K $n#/w|$&/es&&redo;$_=m;w' < gravity.txt

Explanation:
This will construct a string with a w in each positions gravity guy can reach.
So for the second to last truthy example it will construct:
     #########
    ##### ####
   #wwwww#wwww#
  #w  # #w ##ww#
wwwww wwwwwww#ww#
#####  ####  w#ww
     wwwwwwwwww#
     #########

So gravity guy can make it if and only if there is a w in the last column.
The string will be constructed by replacing one reachable space by w in each round.
Each replacement will be of the form
s/prefix \K space postfix/ w | $& /e

which will demand that the space is preceded by prefix and followed by postfix but replace only the space by w without needing lots of advanced grouping.
Assume $n contains a regex that will progress just enough that the left and right sides are exactly below each other. Then the relevant regexes are:
/^( $n)*\K $n#/       From the first position drop down as long as you
                      encounter spaces until you encounter a #.
                      This puts gravity guy on his starting platform

/#$n\K( $n)*\b /      A space immediately below a # and if you (optionally)
                      go down further from there (as as the descent is
                      over spaces) you get to a space that follows a word
                      boundary. The only way to get a word boundary is if
                      there is a w in front of that space. This selects the
                      position gravity guy ends up on if starting from that
                      w and gravity is up
/w([w ]$n)*\K $n#/    A w followed by a space (or w) and if you go down from
                      there as long as it is over spaces (or w) you finally
                      end up on a space directly above a #. This handles the
                      gravity down case. The test uses "space or w" instead
                      of just space to handle this case:

                       #
                      ww
                      #x
                       #

                      Position x is currently a space and must be replaced by a
                      w but the gravity up regex has already put a w directly
                      after the w gravity guy takes off from. So for gravity
                      down we must handle w as if it is still a space. This
                      is not needed for gravity up because regex always matches
                      starting at the earliest possible character, so
                      gravity up matches before gravity down

With that out of the way the program is easy:
#!/usr/bin/perl -0p   Slurp all of STDIN into $_, at the end print $_

/\n/                  Match the first newline (needed to measure the row
                      length)
$n=".{@-}"            $n effectively becomes rowlength-1 times ".". This
                      will be the regex that goes one step down a column

s/#$n\K( $n)*\b |(^|w)([w ]$n)*\K $n#/w|$&/es

                     This is the 3 regexes shown above combined. The s
                     modifier is needed so the . in $n also matches newline

    &&redo           Keep looping as long as w's keep getting added

$_=m;w\n;            Check if the last column contains a w: He made it!
                     The \n; at the end is not written. These 2 bytes sneakily
                     come from the -p option for the ; and the -e option
                     for the \n

JavaScript (ES6), 174 bytes
a=>[...a[0]].map((_,i)=>[...t].map(x=>s[x]<'#'&&g(s.indexOf('#',x),-1)&&g(s.lastIndexOf('#',x),1),s=a.map(s=>s[i]),t=new Set),t=new Set([0]),g=(i,d)=>i<0||t.add(i+d))&&t.size

Takes a horizontal array of strings and returns the number of exit points. Transposing the array costs me 29 bytes. Ungolfed:
function gravity(array) {
    var set = new Set;
    set.add(0); // starting point
    for (var i = 0; i < array[0].length; i++) {
        var s = array.map(s => s[i]); // transpose array
        var old = set;
        set = new Set;
        for (var x of old) {
            if (s[x] == '#') continue; // hit wall
            var j = s.indexOf('#', x); // try downward gravity
            if (j >= 0) set.add(j - 1);
            j = s.lastIndexOf('#', x); // try upward gravity
            if (j >= 0) set.add(j + 1);
        }
    }
    return set.size;
}

Pip, 85 68 62 59 + 1 = 60 bytes
Uses the -r flag to read all lines of stdin.
FcZg{YlFxiIc@xQsyPB(Jc@<x@?`# *$`)+1PB(c@>x@?'#)+x-1i:UQy}i

Try it online!
Brief explanation
The strategy is essentially a breadth-first search. We transpose the input and loop over the lines (columns), keeping a list of the y-positions the player could reach in that column. The output after the last column is a non-empty list if the player can win, or an empty list (which prints as just a trailing newline) if the player loses.
Full explanation
Built-in variables used in this program: i == 0, l == [], s == " ".
The -r flag puts a list of the lines of input into g. FcZg{...} zips g and loops over each column c. (Unary Z, when applied to a list of iterables, acts like Python zip(*g), neatly transposing a 2D array.) Note that c will be a list, not a string.
Inside the column loop, we reset y to the empty list by Yanking l. Fxi loops over i. In later iterations, i will be a list of the y-coordinates the player was able to reach in the previous column. The first time through, we want to start with just 0 (upper left corner). The variable is preinitialized to a Scalar 0, not a List [0], but Pip iterates over it just fine either way.
For each of the valid positions in the last column, Ic@xQs checks whether there is a space in that position in the current column. If not, the player just ran into a wall and we go on to try the next possibility. If so, then we want to find the positions the player will fall to in this column for each direction of gravity, and add them to the list y using the PushBack operator.
Gravity going up (left, in the transposed version):
(Jc@<x@?`# *$`)+1
  c@<x             Slice everything left of x in the column
 J                 Join into a string so we can do a regex search on it
      @?`# *$`     Find index of the last # in this string
(             )+1  The player's index is the space below/to the right of this #

Gravity going down (right, in the transposed version):
(c@>x@?'#)+x-1
 c@>x              Slice everything right of x in the column
     @?'#          Find index of the first # in this list (no need to join into string)
(        )+x       Translate to index number in entire column
            -1     The player's index is the space above/to the left of this #

If the player falls off the grid in a particular direction, the respective @? operation will not find a # and will give nil. This is not a valid index and will generate some warnings in the next iteration--which, however, are not visible without the -w flag. For our purposes, these cases are essentially eliminated from consideration.
After the inner loop, i:UQy takes the list y of positions we've built, eliminates duplicates, and assigns it to i. (Eliminating duplicates is necessary because otherwise the list balloons exponentially.) We then go to the next column. When we have looped through all columns, if there was a valid path through, i will be a nonempty list of positions (truthy); if not, it will be an empty list (falsey).


text:
CamelCase2snake_case()
Write a function to convert CamelCased text to snake_case: FunctionForHTMLManipulation becomes function_for_html_manipulation
The input text will be a single suitable identifier in many languages. It must start with an English letter, then be followed by any number of English letters or digits. No other characters (spaces, symbols, etc.) are allowed.
Each "word" within the CamelCased text will start with a capital letter unless at the beginning of the text or immediately after a digit, and be followed by zero or more letters, all of the same case. Groups of digits will be considered as separate words but pass through unchanged.
In other words, a lowercase letter followed by an uppercase letter indicates a word break. Any letter and digit next to each other indicates a word break. An uppercase letter followed by another uppercase letter and a lowercase letter indicates a word break.
...lU... => ...l_u...
...l9... => ...l_9...
...U9... => ...u_9...
...9l... => ...9_l...
...9U... => ...9_u...
...UUl... => ...u_ul...
Both Buy24Beers and buy24beers become buy_24_beers.
MacDonaldAndObrian becomes mac_donald_and_obrian.
MACDonaldAndOBrian becomes mac_donald_and_o_brian.

"MACDonaldAndOBrian becomes mac_donald_and_o_brian" - why?

@Qwertiy Because I thought those names would be fun. Unless you're asking about the rule, which is covered by ...UUl... => ...u_ul....

Very closely related

@DigitalTrauma Amazingly close to my original question but without the complaints about being two questions in one and no downvotes! The biggest difference is in the treatment of ALLCAPS strings. I searched to see if the question had been asked before but I didn't find it.

thought I had a sub 70 JS solution then I read the curveballs....  won't bother

@ggorlen the ... indicates it's in the middle of a string.

@Renzo The idea is to recognise HTML as a word.

Retina, 61 37 bytes
r1>`[A-Z]?[a-z]+|[A-Z]+|\d+
_$&
T`L`l

Try it online! (Slightly modified to run a full test suite.)
Explanation
Instead of finding word boundaries to insert underscores, we simply match each word and prepend a _. Matching words from the left is a bit annoying because of the UUl rule, but using .NET's right-to-left matching we can easily match words greedily. To avoid a leading _, we make use of Retina's limits.
r1>`[A-Z]?[a-z]+|[A-Z]+|\d+
_$&

The r activates right-to-left mode, the 1> tells Retina to process everything except the first match (counting from left to right). Then there's four types of "words": Ulll, lll, UUU, ddd. These are easily matched with the given pattern. The substitution just writes a _ followed by the word itself.
T`L`l

This simply turns upper case into lower case to complete the transformation.

JavaScript (ES6), 79 bytes
s=>s.match(/[A-Z]+(?=[A-Z][a-z]|\d|$)|[A-Z]?[a-z]+|\d+/g).join`_`.toLowerCase()

JavaScript (ES6), 89 bytes
s=>s.replace(/\d(?=\D)|\D(?=\d)|[a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z])/g,"$&_").toLowerCase()

Lua, 135 bytes
function snake(s)return s:gsub('%f[^%l]%u','_%1'):gsub('%f[^%a]%d','_%1'):gsub('%f[^%d]%a','_%1'):gsub('(%u)(%u%l)','%1_%2'):lower()end

Try it online!
This solution benefits from Lua's shorthand notation for C's character classes (lowercase %l, uppercase %u, alphabetic %a, digit %d), frontier notation (%f[]), and from the whole match being added as the implicit first capture in the absence of any other captures.

Powershell, 77 bytes
Based on Neil's answer.
$args-creplace'\d(?=\D)|\D(?=\d)|[a-z](?=[A-Z])|.(?=[A-Z][a-z])','$&_'|% *wer

Less golfed test script:
$f = {

$args-creplace'\d(?=\D)|\D(?=\d)|[a-z](?=[A-Z])|.(?=[A-Z][a-z])','$&_'|% toLower

}

@(
    ,("Buy24Beers", "buy_24_beers")
    ,("buy24beers", "buy_24_beers")
    ,("MacDonaldAndObrian", "mac_donald_and_obrian")
    ,("MACDonaldAndOBrian", "mac_donald_and_o_brian")
    ,("BigD", "big_d")
) | % {
    $s,$expected = $_
    $result = &$f $s
    "$($result-ceq$expected): $result"
}

Output:
True: buy_24_beers
True: buy_24_beers
True: mac_donald_and_obrian
True: mac_donald_and_o_brian
True: big_d

Retina, 62 bytes
Shamelessly translated from the JavaScript solution.
\d(?=\D)|\D(?=\d)|[a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z])
$&_
T`L`l

Try it online!

Python 2, 82 bytes
lambda x:re.sub('(\d+|.([A-Z]*|[a-z]*)(?![a-z]))(?!$)','\\1_',x).lower()
import re

Try it online!

PowerShell, 68 92 bytes
Briefly deleted, +24 bytes for using the wrong RegEx.
($args-creplace'\d(?=\D)|\D(?=\d)|[a-z](?=[A-Z])|.(?=[A-Z][a-z])','$&_').Trim('_').ToLower()

Try it online!
Basically the same as the JavaScript solutions.

It does not work with buy24beers and MACDonaldAndOBrian. Sorry.

@mazzy fixed, thanks.

Raku, 61 bytes
{S:g:P5/\d+|[A-Z]+(?=[A-Z]|\d)|[A-Z][a-z]*/{$/.lc~"_"}/.chop}

Try it online!

Factor, 140 bytes
[ R/ [a-z][A-Z][a-z]/ [ dup from>> swap dup to>> swap seq>> subseq R/ [A-Z][a-z]/ [ "_" prepend ] re-replace-with ] re-replace-with >lower ]

Ungolfed:
: slice>subseq ( slice -- subseq )
dup from>> swap dup to>> swap seq>> subseq ;

: camel-case>snake-case ( string -- string' )
    R/ [a-z][A-Z][a-z]/ [
        slice>subseq R/ [A-Z][a-z]/
        [ "_" prepend ] re-replace-with
    ] re-replace-with >lower ;


text:
How many minimum days will he take to complete N units of work?
A person has to complete N units of work; the nature of work is the same.
In order to get the hang of the work, he completes only one unit of work in the first day.
He wishes to celebrate the completion of work, so he decides to complete one unit of work in the last day.
He is only allowed to complete x, x+1 or x-1 units of work in a day, where x is the units of work completed on the previous day.
Your task is to create a program or function that will compute the minimum number of days will he take to complete N units of work.
Sample Input and Ouput:
input -> output (corresponding work_per_day table)
-1    -> 0      []
0     -> 0      []
2     -> 2      [1,1]
3     -> 3      [1,1,1]
5     -> 4      [1,1,2,1] or [1,2,1,1]
9     -> 5      [1,2,3,2,1]
13    -> 7      [1,2,2,2,3,2,1]

Input may be taken through STDIN or as function argument, or in any appropriate way.
Output may be printed or as the result of a function, or in any appropriate way.
This is code-golf. Shortest solution wins.

Hint: this integer list could be helpful.

So, is input restricted to positive integers, since Kenny showed that it's possible to achieve a negative work count? Or is the work per day restricted to a minimum of zero?

Why did you accept the Pyth answer? My Jelly answer is 3 bytes shorter...

Hey,@Dennis I need to understand the approach and @Kenny Lau help me to understand it.

I am new to CodeGolf so It will take some time to understand all stuffs here fully.

Jelly, 5 bytes
×4’½Ḟ

This uses a closed form of @LeakyNun's approach.
Try it online!
Due to a lucky coincidence, Ḟ is overloaded as floor/real for real/complex numbers. This is one of the only three overloaded atoms in Jelly.
How it works
×4’½Ḟ  Main link. Argument: n (integer)

×4     Compute 4n.
  ’    Decrement; yield 4n - 1.
   ½   Square root; yield sqrt(4n - 1).
       If n < 2, this produces an imaginary number.
    Ḟ  If sqrt(4n - 1) is real, round it down to the nearest integer.
       If sqrt(4n - 1) is complex, compute its real part (0).

One does not simply...

"Lucky coincidence"

Pyth, 8 bytes
tfg/*TT4

How it works:
tfg/*TT4   Q is implicitly assigned to the input.
 f         test for T=1,2,3,... returning the first successful case
   /*TT4   whether T * T / 4
  g     Q  is greater than or equal to the input (second argument implied)
t          and subtract 1 from the first successful case

Try it online!
In pseudo-code:
for(int T=1;;T++)
    if(T*T/4 >= Q)
        return T-1;

bonus, 22 bytes
"should return 7 for -1"
+tfg/*TT4?>Q0Q-2Q1*4g1

Try it online!

JavaScript (ES2016), 24 bytes
Shortened version of the ES6 variant below thanks to @Florent and the Exponentiation Operator (currently only in Firefox nightly builds or transpilers).
n=>(n-1)**.5+(n+1)**.5|0

JavaScript (ES6), 30 bytes
n=>(s=Math.sqrt)(n-1)+s(n+1)|0

Based upon this sequence.

f=n=>(s=Math.sqrt)(n-1)+s(n+1)|0

units.oninput = () => output.value = f(+units.value||0);
Units: <input id="units" type="number" value="0" />
Days: <input id="output" type="number" value="0" disabled />

Even shorter in ES2016 (26 chars): f=n=>(n-1)**.5+(n+1)**.5|0

@Florent Wow thanks, wasn't aware of the upcoming exponentiation operator.

JavaScript, 32 31 bytes
f=(q,t=1)=>q>t*t/4?f(q,t+1):t-1

Ungolfed code:
function f(q, t = 1) {
  return q > t * t / 4
    ? f(q, t + 1)
    : t - 1
}

It uses the same algorithm as Kenny Lau's anwser but it is implemented as recursive closure to save some bytes.
Usage:
f(-1)  // 0
f(0)   // 0
f(2)   // 2
f(3)   // 3
f(5)   // 4
f(9)   // 5
f(13)  // 7

REPL solution, 23 bytes
for(t=1;t*t++/4<q;);t-2

Prepend q= to run the snippet:
q=-1;for(t=1;t*t++/4<q;);t-2 // 0
q=9;for(t=1;t*t++/4<q;);t-2  // 5
q=13;for(t=1;t*t++/4<q;);t-2 // 7

It even uses the same variable names as mine :)

Can save one byte by turning >= to < :D

@KennyLau Thanks! It's been a long time since i've not golf. I'm a little bit rusted x)

for(t=1;;)if(t*t++/4>=q)return t-1; is only 36 bytes :)

@KennyLau but it does not accept any input

t=0;while(t*t++/4<q);return t-1; is 32 bytes!

I thought hard-coded variables are acceptable?

q=13;t=0;while(t*t++/4<q);t-1; // 8 (KO)

@KennyLau I've added 23 bytes solution :)

What does REPL mean?

I don't know if it's shorter but you can eval the REPL code to use it as a function I.e. q=>eval('... Code ...')

UGL, 30 25 bytes
i$+$+dc^l_u^^$*%/%_c=:_do

Try it online!
Does not work for negative inputs.
How it works:
i$+$+dc^l_u^^$*%/%_c=:_do
i$+$+d                     #n = 4*input-1
      c                    #i=0
       ^l_     %/%_c=:_    #while      > n:
           ^^$*            #      i**2
          u                #                i = i+1
                       do  #print(i)

Previous 30-byte solution:
iuc^l_u^^$*cuuuu/%_u%/%_c=:_do

Online interpreter here.
Does not work for negative inputs.
How it works:
iuc^l_u^^$*cuuuu/%_u%/%_c=:_do
iuc                             #push input; inc; i=0;
   ^l_u             %/%_c=:_    #while        > input:
       ^^$*cuuuu/%_             #      i**2/4
                   u            #                      i = i+1
                            do  #print(i)

Python, 28 bytes
lambda n:max(4*n-1,0)**.5//1

Outputs a float. The max is there to give 0 for n<=0 while avoiding an error for square root of negative.

MATL, 11 bytes
E:t*4/G<f0)

Similar algorithm to @KennyLau except that rather than looping indefinitely, I loop from 1...2n to save some bytes.
Try it Online!
Explanation
    % Implicitly grab the input
E   % Double the input
:   % Create an array from 1...2n
t*  % Square each element
4/  % Divide each element by 4
G<  % Test if each element is less than G
f   % Get the indices of the TRUE elements in the array from the previous operation
0)  % Get the last index (the first index where T*T/4 >= n)
    % Implicitly display the result.

Pyke, 8 bytes
#X4f)ltt

Try it here!
Uses same algorithm as @KennyLau

Python, 43 bytes
f=lambda n,i=1:i-1if i*i>=n*4 else f(n,i+1)

can save a byte by using < instead of >=

Java 8, 30 24 bytes
n->(int)Math.sqrt(n*4-1)

Try it online.
No need to check if n is larger than 0, because Java's Math.sqrt returns NaN for negative inputs, which becomes 0 with the cast to int we already use for the positive inputs.

Ruby, 30 bytes
->n{n<1?0:((4*n-1)**0.5).to_i}

Try it online!
Saving a byte here with .to_i instead of .floor.
Support for non-positive amounts of work comes at a cost of 6 bytes (n<1?0:).


text:
Reverse Greek Conversion Golf
Introduction
You must create a function to convert Greek numerals into Arabic numerals. The input will be a Greek numeral less than 1000 and more than 0. This is the reverse of my previous challenge.
Algorithm

Split input into letters (e.g. ΡΚΓ -> Ρ, Κ, Γ)
Take each letter, and change to character found in table below, for letter symbol, (e.g. ΡΚΓ -> Ρ, Κ, Γ -> 100, 20, 3).
Add (e.g. ΡΚΓ -> Ρ, Κ, Γ -> 100, 20, 3 -> 123)

Specifications

No built-in number-system conversion
Input will be capitalized as in example.
Output must be in base 10.
ΡΡΡΡ will never happen. It will be Υ.

Test Cases
ΡΚΓ -> 123
Η -> 8
ΨΟΖ -> 777
Ρ -> 100
ΧϜ -> 606
ΡϘ -> 190
ΜΒ -> 42
Ν -> 50

Table
Α = 1 = Alpha = 913 UTF-8
Β = 2 = Beta = 914 UTF-8
Γ = 3 = Gamma = 915 UTF-8
Δ = 4 = Delta = 916 UTF-8
Ε = 5 = Epsilon = 917 UTF-8
Ϝ = 6 = DiGamma = 988 UTF-8
Ζ = 7 = Zeta = 918 UTF-8
Η = 8 = Eta = 919 UTF-8
Θ = 9 = Theta = 920 UTF-8

Ι = 10 = Iota = 921 UTF-8
Κ = 20 = Kappa = 922 UTF-8
Λ = 30 = Lambda = 923 UTF-8
Μ = 40 = Mu = 924 UTF-8
Ν = 50 = Nu = 925 UTF-8
Ξ = 60 = Xi = 926 UTF-8
Ο = 70 = Omicron = 927 UTF-8
Π = 80 = Pi = 928 UTF-8
Ϙ = 90 = Koppa = 984 UTF-8

Ρ = 100 = Rho = 929 UTF-8
Σ = 200 = Sigma = 931 UTF-8
Τ = 300 = Tau = 932 UTF-8
Υ = 400 = Upsilon = 933 UTF-8
Φ = 500 = Phi = 934 UTF-8
Χ = 600 = Chi = 935 UTF-8
Ψ = 700 = Psi = 936 UTF-8
Ω = 800 = Omega = 937 UTF-8
Ϡ = 900 = SamPi = 992 UTF-8

Will we ever have input like ΡΡΡΡ? If so, what would the result be?

@CᴏɴᴏʀO'Bʀɪᴇɴ No. That would be Upsilon.

Oh, I misunderstood the question, haha.

@CᴏɴᴏʀO'Bʀɪᴇɴ I edited that spec in just now. You didn't miss it.

I think your test cases should cover all possible patterns of zeroes, so at least add something like 180, 42 and 50.

Jelly, 47 45 bytes
⁵*×‘}
“#'nn(2jj33556;r”Or2/F+878Ọ
¢iÐ€’d9ñ/€S

Try it online! or verify all test cases.

What encoding are you using?  Try It Online says it is 47 bytes. You seem to be missing a <newline>Ç€ at the end.

Jelly has its own encoding (bytes link in the header). The verify all test cases link includes an extra Ç€ that applies the function to all test cases. The first link shows to actual program, which is 44 bytes long.

This seems to be the shortest so far...

Python 3, 112
Saved 4 bytes thanks to vaultah.
Booyah, beating JS!
lambda x,z="ΑΒΓΔΕϜΖΗΘΙΚΛΜΝΞΟΠϘΡΣΤΥΦΧΨΩϠ".find:sum((z(c)%9+1)*10**(z(c)//9)for c in x)

With test cases:
assert(f("ΡΚΓ")==123)
assert(f("Η")==8)
assert(f("ΨΟΖ")==777)
assert(f("Ρ")==100)
assert(f("ΧϜ")==606)

Loops through the string and uses its index in the list of potentials chars to calculate how much it's worth.

JavaScript (ES7), 115 bytes
s=>[...s].map(c=>n+=((i="ΑΒΓΔΕϜΖΗΘΙΚΛΜΝΞΟΠϘΡΣΤΥΦΧΨΩϠ".search(c))%9+1)*10**(i/9|0),n=0)|n

Haskell, 116 113 bytes
f x=sum[v|d<-x,(l,v)<-zip"ΑΒΓΔΕϜΖΗΘΙΚΛΜΝΞΟΠϘΡΣΤΥΦΧΨΩϠ"$(*)<$>[1,10,100]<*>[1..9],d==l]

Usage example: map f ["ΡΚΓ","Η","ΨΟΖ","Ρ","ΧϜ","ΡϘ","ΜΒ","Ν"] -> [123,8,777,100,606,190,42,50].
Lookup the value of the greek letter from a list of pairs (letter, value) and sum. The list of values is build by (*)<$>[1,10,100]<*>[1..9], where (*)<$>[1,10,100] builds a list of functions [(*1),(*10),(*100)] (multiply by 1, 10 and 100) which are applied separately to the elements of [1..9] and concatenated into a single list.
Edit: 3 bytes with thanks to @xnor.

It's shorter to take the product as (*)<$>[1,10,100]<*>[1..9].

@xnor: <*> in list context, again. I never think of it myself. Thanks!

I wouldn't think of it either, I got it from here.

Julia, 82 70 bytes
x->10.^((t=findin([1:5;76;6:16;72;17;19:25;80]+912,x)-1)÷9)⋅(t%9+1)

Try it online!

JavaScript (ES6), 116 bytes
s=>[...s].map(c=>n+=+((i="ΑΒΓΔΕϜΖΗΘΙΚΛΜΝΞΟΠϘΡΣΤΥΦΧΨΩϠ".search(c))%9+1+"e"+(i/9|0)),n=0)|n

Only 1 byte longer than ES7!

I'm not familiar with JavaScript, what does the +"e" do?

@MorganThrapp String concatenation. For example, with Ϡ you would get 9+"e"+2 and then the +("9e2") becomes 900.

Ah, that's really weird. Javascript always manages to ---terrify--- surprise me.

Python 3, 188 Bytes
def f(x,l=list,z=0):
 r=l(range(1,10));R=[a*10for a in r]
 for a,b in l(zip(l("ΑΒΓΔΕϜΖΗΘΙΚΛΜΝΞΟΠϘΡΣΤΥΦΧΨΩϠ"),r+R+[a*10for a in R])):
  z+=(0,b)[a in x]
 return z

Try it out! (Test cases included)

You can save 25 bytes by condensing it down to def f(x):r=list(range(1,10));R=[a*10for a in r];return sum(b*(a in x)for a,b in zip("ΑΒΓΔΕϜΖΗΘΙΚΛΜΝΞΟΠϘΡΣΤΥΦΧΨΩϠ",r+R+[a*10for a in R])).

Retina, 72 bytes
T`_Ι-ΠϘ0ΡΣ-ΩϠ`dl
[a-j]
$0aa
\d
$&0
T`_Α-ΕϜΖ-Θl`dd
\d+
$*
1

Try it online.
Explanation
Basically - replace every Greek symbol with the number that it represents, then return the sum of all the resulting numbers:
Transliterate 10s digits to Arabic and 100s digits to the Latin alphabet (0-9 => a-j):
T`_Ι-ΠϘ0ΡΣ-ΩϠ`dl

Append "aa " to any 100s digits:
[a-j]
$0aa

Append "0 " to any 10s digits:
\d
$&0

Transliterate 1's digits and Latin alphabet to Arabic:
T`_Α-ΕϜΖ-Θl`dd

Convert all space-separated decimal numbers to unary:
\d+
$*

Count the total number of unary 1s:
1


text:
What's the missing column/row? (GCJ 2016-1A rankfile)
There is an N x N square of numbers.

All columns increase strictly monotonically from top to down
All rows increase strictly monotonically from left to right
There is exactly one valid answer for each input.

You are given 2N-1 rows of N numbers representing rows or columns in this square. The task is to find the row that isn't in the input.
Your Task
Write a program or function that outputs the row or column that isn't in the input.
Input
First, you get the number N.
Then follow 2N-1 lines of N space-separated numbers, representing rows or columns of this N x N square. The lines are given in left-to-right or top-down order. There may be multiple equal lines. It is ok to omit the initial N from the input, or modify the input format as you like.
3
1 2 3
2 3 5
3 5 6
2 3 4
1 2 3

Output
Your program or function should output a single line of N numbers; the row or column from the square that was not present in the input. You may change the output format as you please.
3 4 6

This would correspond to one of two squares:
1 2 3     1 2 3
2 3 4     2 3 5
3 5 6     3 4 6

Either way, the output is the same.
Bonus
Your solution should be able to calculate 2 ≤ N ≤ 10 within a minute on a normal computer. If your solution handles the big input, 2 ≤ N ≤ 50, within a minute, you get -10% byte count.
Test cases
2
22 222
2 22
22 222
-> 2 22

3
1 2 3
2 3 5
3 5 6
2 3 4
1 2 3
-> 3 4 6

4
11 14 16 22
3 6 9 11
6 7 11 14
9 11 15 19
10 11 19 22
6 7 10 11
3 6 8 10
-> 8 10 15 16

Note that you can simply change what line in these inputs that is omitted, and reorder them in any way you want, to generate new test cases.
This is a simplified version of Google Code Jam 2016 round 1A problem B: Rank and File. The original Google Code Jam problem, where you can get more test cases (but without answers), is available here: https://code.google.com/codejam/contest/4304486/dashboard#s=p1

You should make the N input optional - many languages would just read and discard/ignore it because it can be inferred from the rows.

Changed it to allow omitting N from input.

More generally, I think you should adapt your I/O format to be more flexible by letting languages do input and output in their native list types. See Things to avoid when writing challenges.

I/O rules further loosened :)

Removed bad testcase. It should follow the original as close as possible, but with a simpler problem statement and only a single testcase per run.

If there's a bonus for test cases of a certain size, you should include such a test case in the question body.

This strikes me as a chameleon challenge. Once you solve the puzzle, you find that it's really about cancelling duplicates.

We also discourage bonuses in code golf

After reading the answers, I realize this was indeed an accidental chameleon challenge. I did not know about the simple solution, and that's not how I solved it myself. I tried to simplify the description as far as I could.

CJam, 5 - 10% = 4.5
This is an unnamed function (block) that takes an array of arrays and returns an array:
{:^$}

(With some inspiration from Dennis)
Try it online
And here is the code I actually submitted at GCJ (24 bytes):
li2*({l~}*]$e`{(2%*~}%S*

Try it online
Explanation:
This basically lists the values that appear an odd number of times.
:^    reduce by symmetric difference; pairs of duplicate values "cancel" each other
$     sort the resulting array

Jelly, 3.6 bytes
œ^/Ṣ

The source code is 4 bytes long and qualifies for the -10% bonus. Try it online!
How it works
Since there are 2N rows/columns in total, each number must appear 2N times. Therefore, it suffices to take the numbers that appear in an odd number of the 2N - 1 rows/columns from input.
œ^/Ṣ  Main link. Argument: A (2D list of integers)

  /   Reduce the rows by...
œ^    symmetric multiset difference.
   Ṣ  Sort the result.

Damn, this is impressive. Also, obligatory "but this is eight bytes in Unicode" comment-- wait, you linked the codepage this time! Never mind.

Obligatory Unicode is not an encoding response.

For Pyth, it is still 12 bytes using your algorithm... One does not simply outgolf Dennis.

Oh, it's 11 bytes now.

JavaScript (ES6), 179 bytes
f=(n,a,p=[],o)=>(p[n-1]?p.every((_,j)=>~(a.map(v=>v+"").indexOf((m=p.map((_,k)=>p.map(r=>r[k]))[j])+""))?1:o=!o&&m):a.map((c,i)=>o=o||f(n,x=a.slice(),p.concat(x.splice(i,1)))))&&o

Explanation
Whew! That took quite a bit of effort to do without any combinatorics built-ins...
Possibly qualifies for the bonus. I haven't tested with n = 50.
The entire function is a recursive permutation function. It takes the size n and input array a, then moves each item individually from a to the current permutation array p. p becomes every permutation of rows.
Once the length of p becomes n, it transposes p to get an array of the columns. It searches these columns for each item in a.
Because a should contain all these columns except one if this is the correct result, output the column in the transposed p which is missing from a if there is only one column missing.

f=(n,a,p=[],o)=>(
  p[n-1]?                                        // once p is a square
    p.every((_,j)=>                              // find each column in the transposed square a,
                                                 //     a is missing a column so one should fail
      ~(a.map(v=>v+"")                           // convert column arrays to strings so we can use indexOf
        .indexOf(                                // search for current column
          (m=p.map((_,k)=>p.map(r=>r[k]))[j])+"" // transpose p to match a
        )
      )?1:o=!o&&m                                // if there is only one column missing from a, o = missing column
    )
  :a.map((c,i)=>                                 // add each row to the permutation
    o=o||                                        // set o to first found result
    f(n,x=a.slice(),p.concat(x.splice(i,1)))     // get next permutation
  )
)&&o                                             // return o

// Test
var testCases = [[
    2, [
      [22,222],
      [2,22],
      [22,222]
    ]
  ], [
    3, [
      [1,2,3],
      [2,3,5],
      [3,5,6],
      [2,3,4],
      [1,2,3]
    ]
  ], [
    4, [
      [11,14,16,22],
      [3,6,9,11],
      [6,7,11,14],
      [9,11,15,19],
      [10,11,19,22],
      [6,7,10,11],
      [3,6,8,10]
    ]
]];
document.write("<pre>"+testCases.map(c=>f(c[0],c[1])).join`\n`);

Pyth, 13 12 11 9 x 0.9 = 8.1 bytes
S{f%/QT2Q

Flattened list as input.
Try it online!
previous 11-byte solution
M-+GH@GHSgF

Uses Dennis' algorithm.
previous 12-byte solution:
S{f%/.nQT2.n

Try it online!
alternative 13 byte solution:
eCf%hT2rS.nQ8

Try it online!

If you take a flat list as input (I guess that's allowed), you can shorten your 12-byte solution to 9 bytes.

@Dennis Thanks, but I still cannot outgolf you :D

Julia, 19.8 bytes
x->sort(symdiff(x...))

The source code is 22 bytes long and qualifies for the -10% bonus. Try it online!

JavaScript (Firefox 30-57), 62 bytes
(a,s=[])=>[for(b of a)for(c of b)s[c]^=c]&&[for(c of s)if(c)c]

Only works for positive integers. 64 bytes to work with zero too:
(a,s=[])=>[for(b of a)for(c of b)s[c]^=~c]&&[for(c of s)if(c)~c]

101 bytes to work with arbitrary floating-point numbers:
(a,m=new Map)=>[for(b of a)for(c of b)m.set(c,!m.get(c))]&&[for(b of m)if(b[1])b[0]].sort((a,b)=>a-b)

109 bytes to work with strings instead:
(a,m=new Map)=>[for(b of a)for(c of b)m.set(c,!m.get(c))]&&[for(b of m)if(b[1])b[0]].sort((a,b)=>(a>b)-(a<b))

GolfScript, 5  - 10% = 4.5 bytes
Port of the CJam answer - reduce by symdiff, sort.
{^}*$

Try it online!


text:
How many 14ers did I climb?
In mountaineering terminology, a "14er" is any mountain with an elevation of 14 000 feet or more. However, there is another distinction. For a peak to count as a 14er, it must also have a "geographic prominence" of 300 or more feet. This means that to move from one 14er to another, you must first descend at least 300 feet before rising again. Take this example. Line 1 counts as 14 000 feet, and each line counts as 100 feet.
  /\__/\
 /      \
/        \

Now, both of these peaks have enough elevation to count, but there isn't enough drop in elevation between them to count as two separate peaks. Therefore, one of these counts as a 14er, and the other one is just a "partial peak". Here is an example where the two peaks count as two separate 14er:
   /\    /\
  /  \  /  \
 /    \/    \
/            \

There can also be a partial peak on the decline between two 14ers. Here's a slightly modified version of the last mountain range:
   /\      /\
  /  \/\  /  \
 /      \/    \
/              \

This mountain range also counts as two 14ers.
You must write a program or function that takes an ascii-art representation of a mountain range, and return how many 14ers are in the range. You can take input in whatever format is most convenient for you, be it 2D array of characters, a string with newline, or a string with some other delimiter. You can assume that all inputs will only contain the characters /\_, and that the length of each line will be the same (including trailing spaces). You can also assume that the mountain range starts on the bottom left corner with either a / or a _.
If the last section of a mountain is not on the bottom line, you can assume that the mountain only decreases after that, e.g.
  /
 /
/

Counts as a single 14er.
You do not have to handle invalid mountain ranges.
Here is some sample I/O:
         /\___/\_
        /        \    /\
       /          \  /  \
   _/\/            \/    \
  /                       \
 /                         \
/                           \_

2

                  /\    /\
         /\      /  \  /
  /\    /  \    /    \/
 /  \  /    \  /
/    \/      \/

4

       /\
 _/\__/  \
/         \

1

      /\
     /  \   /\
    /    \_/  \
   /           \
  /             \
 /               \
/                 \

1

              /\
    /\_/\    /  \_
   /     \  /     \     /\
  /       \/       \   /
 /                  \_/
/

3

So the starting line counts as 14,000 feet?

@R.Kap Yes, I believe that's correct, assuming you mean the bottom line when you say starting line.

And you always begin with a 14er?

Is a trailing newline admissible?

Related: http://codegolf.stackexchange.com/questions/68967/how-many-peaks-in-my-mountain-range

I think you should mention somewhere that a _ counts as 100 feet lower than a slash on the same line. At least that's what your last test case suggests.

I can feel a Retina answer coming...

The spec seems thin... can we have a flat peat like / / / _ \ \ \  ? Also, I suppose that the highest point in the input should always be counted as a peak but this is not explicitly specified; one could start at a lower peak and end up with a different count.

Will it always be continous? Will it have at most one nonspace character for each column?

JavaScript (ES6), 133 bytes
s=>[...s].map((_,i)=>(c=s[i%h*w+i/h|0])=="/"?++a>2&&(p+=!d,d=a=3):c=="\\"&&--a<1&&(d=a=0),w=s.search`
`+1,h=-~s.length/w,a=3,d=p=1)|p

Explanation
Since the specifications are not stated clearly, this makes a couple of assumptions:

The bottom line is the 14,000ft mark (so all positions on the grid are high enough to count as a peak).
The grid starts at (or ascending) the first peak (since it's at least 14,000ft high already as per previous assumption).
A separate peak counts only after descending 300ft then ascending 300ft.

Iterates over the character c of each column (specifically, it iterates down each column until it finds a character). The current altitude is stored in a. It is clamped to a minimum of 0 and a maximum of 3. The direction needed to move to count the next peak is stored in d (false = up, true = down). If a reaches 3 and d is false, the number of peaks p is incremented and d is set to true (down). Once a reaches 0, d is set back to false (up).

var solution =

s=>
  [...s].map((_,i)=>   // loop
    (c=s[i%h*w+i/h|0]) // c = current character (moves down columns)
    =="/"?             // if c is '/'
      ++a>2&&          // increment a, if a equals 3 and d is true:
        (p+=!d,d=a=3)  // increment p, set d to true, clamp a to 3
    :c=="\\"&&         // if c is '\':
      --a<1&&          // decrement a, if a equals 0:
        (d=a=0),       // set d to false, clamp a to 0

    // Initialisation (happens BEFORE the above code)
    w=s.search`\n`+1,  // w = grid width
    h=-~s.length/w,    // h = grid height
    a=3,               // a = current altitude (min = 0, max = 3)
    d=                 // d = required direction (false = up, true = down)
    p=1                // p = number of found peaks
  )|p                  // output the number of peaks

var testCases = [`
/\\
`,`
/\\
  \\
   \\    /\\
    \\  /  \\
     \\/    \\
`,`
\\    /
 \\  /
  \\/
`,`
            /\\
         /\\/  \\/\\
      /\\/        \\/\\
   /\\/              \\/\\
/\\/                    \\/\\
`,`
  /\\__/\\
 /      \\
/        \\
`,`
   /\\    /\\
  /  \\  /  \\
 /    \\/    \\
/            \\
`,`
   /\\      /\\
  /  \\/\\  /  \\
 /      \\/    \\
/              \\
`,`
         /\\___/\\_
        /        \\    /\\
       /          \\  /  \\
   _/\\/            \\/    \\
  /                       \\
 /                         \\
/                           \\_
`,`
                  /\\    /\\
         /\\      /  \\  /
  /\\    /  \\    /    \\/
 /  \\  /    \\  /
/    \\/      \\/
`,`
       /\\
 _/\\__/  \\
/         \\
`,`
      /\\
     /  \\   /\\
    /    \\_/  \\
   /           \\
  /             \\
 /               \\
/                 \\
`,`
              /\\
    /\\_/\\    /  \\_
   /     \\  /     \\     /\\
  /       \\/       \\   /
 /                  \\_/
/
`];
result.textContent = testCases.map(c=>c+"\n"+solution(c.slice(1,-1))).join`\n\n`;
<textarea id="input" rows="6" cols="40"></textarea>
<button onclick="result.textContent=solution(input.value)">Go</button>

C, 174 bytes
a[99],c,p,j,M,m;main(i){for(i=j=1;c=getchar(),~c;i++)c<11?a[i]=j++,i=0:c&4?a[i]=j:0;for(m=j;c=a[i++];c>a[i-2]?M-m>1&&c-m>1?M=c,m=j,p++:M<c?M=m=c:M:m>c?m=c:0);printf("%d",p);}

Requires a trailing newline in the input, otherwise +4 bytes.

JavaScript (ES6), 154 bytes
s=>s.split`\n`.map((s,i)=>s.replace(/\S/g,(c,j)=>{e[j]=i+(c!='\\');e[j+1]=i+(c>'/')}),e=[])&&e.map(n=>h-n+d?h-n-d*3?0:(c++,d=-d,h=n):h=n,h=e[0],c=d=1)|c>>1

Where \n represents the literal newline character. Ungolfed:
function climb(string) {
    var heights = [];
    // Split the array into lines so that we know the offset of each char
    var array = string.split("\n");
    // Calculate the height (actually depth) before and after each char
    for (var i = 0; i < array.length; i++) {
        for (var j = 0; j < string.length; j++) {
            switch (array[i][j]) {
            case '\':
                heights[j] = i;
                heights[j+1] = i + 1;
                break;
            case '_':
                heights[j] = i + 1;
                heights[j+1] = i + 1;
                break;
            case '/':
                heights[j] = i + 1;
                heights[j+1] = i;
                break;
        }
    }
    var count = 1;
    // Start by looking for an upward direction
    var direction = 1;
    var height = heights[0];
    for (var k = 1; k < heights.length; k++) {
        if (heights[i] == height - direction * 3) { // peak or trough
            direction *= -1;
            count++; // we're counting changes of direction = peaks * 2
            height = heights[i];
        } else if (heights[i] == height + direction) {
            // Track the current peak or trough to the tip or base
            height = heights[i];
        }
    }
    return count >> 1;
}


text:
How much more reputation do I need?
Programming Puzzles and Code Golf has graduated from beta. Soon we will get a custom site design, and with that the reputation boundaries for privileges will go up. A lot of users will lose privileges on the site. So your task is to write a program that tells us how much extra reputation we'll need to keep our privileges.
Task
Your task is to write the shortest code to find the amount of extra reputation a user will need to keep their current privileges after the site design, given the number of reputation points.
Input / Output
You can accept input and give output in any way you like, so long as it follows these rules:
Input - An integer from 1 to 250000+ inclusive. Your program or function should be able to accept numbers bigger than this, but it must accept numbers in this range.
Output - An integer representing the number of reputation points the user will need to get to keep their current privileges after the graduation.
No standard loopholes, please.
Example algorithm

Set variable i to the input
Set variable r to variable i.
While r is not in list beta:

Subtract 1 from r.

Set n to the position of r in beta.
Set r to item n of graduated.
Set variable o to the result of r - i.
If o < 0:

Set variable o to 0.

Output variable o.

Tables
Table of privileges that will change
 | privilege name              | beta rep | graduation rep |
-+-----------------------------+----------+----------------+-
 | create tags                 |      150 |           1500 |
 | access review queues        |      350 |            500 |
 | cast close and reopen votes |      500 |           3000 |
 | established user            |      750 |           1000 |
 | edit questions and answers  |     1000 |           2000 |
 | create tag synonyms         |     1250 |           2500 |
 | approve tag wiki edits      |     1500 |           5000 |
 | access to moderator tools   |     2000 |          10000 |
 | protect questions           |     3500 |          15000 |
 | trusted user                |     4000 |          20000 |
 | access to site analytics    |     5000 |          25000 |
-+-----------------------------+----------+----------------+-
 | privilege name              | beta rep | graduation rep |

Table of privileges that won't change
 | privilege name               | reputation |
-+------------------------------+------------+-
 | create posts                 |          1 |
 | participate in meta          |          1 |
 | create wiki posts            |         10 |
 | remove new user restrictions |         10 |
 | vote up                      |         15 |
 | flag posts                   |         15 |
 | talk in chat                 |         20 |
 | comment everywhere           |         50 |
 | set bounties                 |         75 |
 | create chatrooms             |        100 |
 | edit community wiki          |        100 |
 | vote down                    |        125 |
-+------------------------------+------------+-
 | privilege name               | reputation |

Testcases
wizzwizz4                |   750 |  2250
cat                      |  2004 |  7996
Dennis ♦                 | 72950 |     0
Dr Green Eggs and Ham DJ |  4683 | 15317
New User                 |     1 |     0

Not all reputation counts are correct at time of writing
If you want your past or present reputation count here, just comment below and I'll maybe add it.

Related on meta: (When) do my mod tools go away?

You should include a few test cases.

Btw the participate on meta rep threshold in 5 for beta sites as well. PPCG had it customized so new users can use the sandbox. This shouldn't change when we graduate.

@cat I actually used that; thanks!

I only need (at time of commenting) 2601 more rep to keep the privilege that I want to keep.

@Neil I only need 2250 more reputation to keep mine. Although, considering I only have 750 at the moment...

@wizzwizz4 Thanks for that; there was a bug in my code and it said you only wanted 250 more rep.

@Neil Thanks for that; there was a typo in my edit and it said I only wanted 250 more rep.

@wizzwizz4 Thanks for that; my head is starting to explode and I only wanted 250 more rep.

Ooh, fun, I like the idea of including real users for test cases! I just got some privileges that I really like, so feel free to add me as a test case.

It looks like your 15137 output should be 15317.

@xnor Thanks; it would have been embarrassing if somebody didn't post because their code was outputting the "wrong value". Do you want your reputation count on the challenge?

@wizzwizz4 Nah, it would just look low next to Dennis :-)

Put mine on there - I have 776.

Python, 101 bytes
lambda n:max(0,eval("+(n>=%d)*%d"*7%(5e3,5e3,4e3,5e3,35e2,5e3,2e3,5e3,15e2,2e3,5e2,15e2,150,15e2))-n)

I think you're giving the new rep you need, not the increase. So, f(750) should be 1250, not 2000. Should be an easy fix.

@xnor Well, f(750) should be 2250, not 1250 :)

Still need to have f(72950) give 0.

Your eval trick is really good. Combining it with my list compression gives 83: lambda n:max(eval("+(n>=%s*500)*%s*500"*7%(.3,3,1,3,3,4,4,10,7,10,8,10,10,10))-n,0).

Do you think you could add a code explanation and breakdown?

@wizzwizz4 That is left as an excercise to the reader :)

Jelly, 40 37 bytes
19112203.3b11×ȷḞ>Ḥ¬×9999322D‘¤S×.ȷ_»0

Try it online! or verify all test cases.
How it works
19112203.3b11×ȷḞ>Ḥ¬×9999322D‘¤S×.ȷ_»0  Main link. Argument: n

19112203.3b11                          Convert the float to base 11. Yields
                                       [10, 8, 7, 4, 3, 1, 0.30000000074505806].
             ×ȷ                        Multiply each by 1000.
               Ḟ                       Floor. Yields
                                       [10000, 8000, 7000, 4000, 3000, 1000, 300].
                 Ḥ                     Unhalve; yield 2n.
                >                      Compare each integer in the list with 2n.
                  ¬                    Negate the resulting Booleans.
                             ¤         Chain the three links to the left:
                    9999322D           Convert the integer to base 10.
                            ‘          Increment each digit. Yields
                                       [10, 10, 10, 10, 4, 3, 3].
                   ×                   Multiply the Booleans with the corr. digits.
                              S        Compute the sum of the products.
                               ×.ȷ     Multiply the sum by 500.
                                  _    Subtract n.
                                   »0  Return the maximum of the difference and 0.

JavaScript (ES6), 137 135 102 81 bytes
n=>(n-=[5,0,.3,.6,1,2,3,4][[.3,1,3,4,7,8,10].findIndex(m=>m*500>n)+1]*5e3)<0?-n:0

If the user has 5000 or more reputation then findIndex fails, returning -1, so the result is incremented to that I can index into the array of new reputations needed. Edit: Saved 21 bytes by scaling the input and output array.
   [.3,1,3,4,7,8,10]        Old reputations of note, divided by 500
    .findIndex(m=>m*500>n)  Skip ones that have been achieved
     +1                     Normalise the return value
  [5,0,.3,.6,1,2,3,4][]     Index into new reputation needed
   *5e3                     Scaling factor
 n-=                        Compare to the current reputation
()<0?-n:0                   Negate to return the requirement

Some answers don't work with the New User testcase. If yours doesn't work, please fix it.

@wizzwizz4 Ah, the meta privilege change? Sure, that's a simple fix.

Do you think you could add a code explanation and breakdown?

CJam, 38 bytes
0000000: 72 69 5f 35 30 2f 22 64 50 46 28 1e 0a 03 22 66  ri_50/"dPF(..."f
0000010: 3c 3a 2b 22 fa c8 96 64 32 1e 0f 00 22 3d 69 65  <:+"...d2..."=ie
0000020: 32 5c 2d 55 65 3e                                2\-Ue>

Try it online! or verify all test cases.1
How it works
ri                        Read an integer n from STDIN.
  _50/                    Push a copy and divide it by 50.
     "…"                  Push the string with code points [100 80 70 40 30 10 3].
        f<                Compare each code point with n / 50.
          :+              Add the resulting Booleans.
            "…"           Push the string with code points
                          [250 200 150 100 50 30 15 0].
               =          Select the one at the index of the sum.
                i         Convert from character to integer.
                 e2       Multiply by 100.
                   \-     Subtract n from the product.
                     Ue>  Take the maximum of the difference and 0.

1 Note that the code contains a null byte, which causes problems in some browsers.

Python 156 152 bytes
s=str.split;n=input()
for k,v in map(s,s('5e3 5r4e3 5r3500 30./7r2e3 5r1500 10./3r500 6r1 1','r')):
 w=u(k);r=eval(v)*w
 if w<=n:print max(0,r-n);break

The data string (5e3 5r4e3 5r3500 30./7r2e3 5r1500 10./3r500 6r1 1) is a list with the format (old_rep1) (new_rep1/old_rep1)r(old_repr) (new_rep2/old_rep2) only including privleges which set the new max rep (users with >750 rep still need at least 3k rep post-graduation, even though they will be an established user at 1k. The list is sorted from highest rep first to lowest rep last.

Do you think you could add a code explanation and breakdown?

@wizzwizz4 Done.

Hmm... now that is a clever technique.

Python, 88 bytes
lambda n:max(sum(500*b*(n>=a*500)for a,b in zip([.3,1,3,4,7,8,10],[3,3,4]+[10]*4))-n,0)

For each new beta privilege exceeded, adds the rep amount needed to get to the next graduated privilege. Then, the additional rep needed is the new rep minus the current rep, but no less than 0.
Both rep boundary lists are shortened by rep in multiples of 500.

You might as well replace [3]*2+[4] with [3,3,4], 9 vs 8 bytes.

@CatsAreFluffy Thanks, I forgot I changed them from decimals where it's worth it.

Pyth - 71 70 69 77 75 77 bytes
eS,Z-@CM"\x00ǴϨלߐৄஸᎈ✐㪘丠憨"xKCM"\x00ŞˮϨӢǴלߐඬྠᎈ"e<#QK

Test Suite.

This doesn't work for the wizzwizz4 testcase.

Some answers don't work with the New User testcase. I've noticed that yours doesn't; please fix it!

Do you think you could add a code explanation and breakdown?

LiveCode 8, 318 bytes
function g c
    local b,g,r
    put c into r
    put "0.15,0.35,0.5,0.75,1,1.25,1.5,2,3.5,4,5" into b
    split b by ","
    put "0.3,0.1,0.6,0.2,0.4,0.5,1,2,3,4,5" into g
    split g by ","
    repeat with i=1 to 11
       if c>b[i]*1000 and not c>g[i]*5000 then put max(r,g[i]*5000) into r
    end repeat
    return r-c
 end g

As wizzwizz4 suggested, here is an explanation:
function g c

Create a function named g taking a single parameter c. c is the user's current reputation. Equivalent to def g(c) in Python.
local b,g,r

Create three local variables: b,g, and r. b will be the reputation cutoffs for privileges in beta, g will contain the new reputation cutoffs after graduation, and r will represent the total reputation the user will have to have after graduation to retain their privileges.
put c into r

This copies the value of c(the user's current reputation) into r. Equivalent to r=c in Python)
put "0.15,0.35,0.5,0.75,1,1.25,1.5,2,3.5,4,5" into b

Similar to above, this sets b to a string containing a comma-deliminated list of the reputation cutoffs in beta, divided by 1000. Equivalent to b="0.15,0.35,0.5,0.75,1,1.25,1.5,2,3.5,4,5" in Python.
split b by ","

This splits the local variable b into an array, using , as the delimiter. This array now contains the reputation cutoffs in beta, divided by 1000. Equivalent to b.split(",") in Python.
put "0.3,0.1,0.6,0.2,0.4,0.5,1,2,3,4,5" into g
split g by ","

Same as above, except that g now contains a list of the reputation cutoffs after graduation, divided by 5000
repeat with i=1 to 11

Similar to a for loop in other languages, this repeates 11 times, with i assigned the next value in the sequence 1 to 11 each time. Arrays in LiveCode start at index 1. In Python, this would be for i in range(11).
if c>b[i]*1000 and not c>g[i]*5000 then put max(r,g[i]*5000) into r

This is the main logic of the function. It checks to see if the user has enough reputation for the privilege in position i of the beta list, if so, and if they don't have enough reputation for the privilege after graduation, it sets the variable r(representing the total reputation that the user will have to have to retain their privileges after graduation) to the reputation cutoff after graduation for that privilege (only if the new reputation is higher than the previous one). The equivalent Python code would be if c>b[i]*1000 and not c>g[i]*5000:
        r=max(g[i]*5000,r)
    end repeat
Ends the repeat loop. Similar to C or Java's }. LiveCode uses the syntax end 'insert contruct name to end a repeat loop, an if, a switch etc...
return r-c

Fairly self-explanatory.
end g

Ends the function g.

A brand new user post an answer on my challenge? I'm honoured. +1 and welcome to the site.

You could improve this post by adding a code explanation and breakdown. (Explain what the code does, line by line, below your code.)

@wizzwizz4 Added explanation.