text:
Corrcey my Soellign
Introduciton
Some of you might have realised that I am a sloppy typer when using my phone. That's why I want you to write a program which corrects my typos.
Chalkrnge
Given a misspelled word, output all of the possible words which I meant to write.
Typso
The main cause of my typos is down to the fact that I hit the wrong keys and often hit the key next door. The following is my keyboard layout:
q w e r t y u i o p
 a s d f g h j k l
   z x c v b n m
   , [ space ] .

Note that the bottom row, , [ space ] . will never be used in this challenge
For some reason, I only make mistakes horizontally: I would never hit the n instead of the j, but I might hit an f instead of a d.
For example, I could end up spelling the word sloppy as:
akioot

Where I've gone left of each key.
However, don't forget that I may not necessarily make a mistake on every letter in the word.
Ezsmple
Let's say the input is:
vid

The possibilities that the word could have been are:
vid cid bid
vis cis bis
vif cif bif
vod cod bod
vos cos bos
vof cof bof
vud cud bud
vus cus bus
vuf cuf buf

Out of those, the following are in the dictionary:
cod
cud
bid
bud
bus

So that should be your output.
Rulws
You should only use the text file found here as your dictionary: http://mieliestronk.com/corncob_lowercase.txt. You do not have to count this file as part of your byte count.
All input will be a single word. You may display your output in any way you wish (as long as there is some kind of separator).
Assume that with all input, you will find a variant which is in the dictionary.
Wibninf
The shortest code in bytes wins.

When I saw the title, I thought this was gonna be another challenge about Welsh...

I presume that compressing the dictionary is part of the challenge, and that if I choose to read the dictionary from a file I should count its length towards my score, but that should be made explicit for the benefit of people who haven't read the whole of meta. PS If you're going to post something to the sandbox, leave it there long enough to get feedback.

@PeterTaylor Well not really, it's mainly just the parsing of the dictionary which can be done uncompressed.

So if I inline the file, what do I count? Two bytes for the delimiting ""?

@PeterTaylor Well yes

@BetaDecay May I take the dictionary as a large string argument to a function, or do I have to read it from a file? "You do not have to count this file as part of your byte count." <--- does this mean that I can exclude the part where I read the contents to a variable (probably not) in the byte count?

@TuukkaX Yes, it does mean you can exclude the reading of the contents

Japt, 50 47 bytes
;D=R+Dv;W=3pUl¹óW ®s3 s1 £DgDbUgY)-X+1}Ãf@~V·bX

Input is the word to fix, and the dictionary as a string. Test it online! (Note: you'll have to manually paste the dictionary into the string.)
How it works
;D=R+Dv;W=3pUl¹óW ®s3 s1 £DgDbUgY)-X+1}Ãf@~V·bX  // Implicit: U = input, V = dictionary, R = newline
;                                                // Re-assign preset variables. D = "QWERTYUIOP\nASDFGHJKL\nZXCVBNM";
 D=R+Dv;                                         // Convert D to lowercase and prepend a newline.
        W=3pUl¹                                  // Set W to 3 to the power of U.length.
               óW                                // Create the range [W, W+W).
                  ®                       Ã      // Map each item Z in the range by this function:
                   s3                            //  Take Z.toString(3).
                      s1                         //  Remove the first character.
                                                 //  If the input is two chars long, e.g. "id", the array is now
                                                 //  ["00", "01", "02", "10", "11", "12", "20", "21", "22"].
                         £            }          //  Map each char X and index Y in the string by this function:
                              UgY                //   Get the char at position Y in U.
                            Db   )               //   Take the index of the char in D.
                                  -X+1           //   Subtract X and add 1.
                          Dg                     //   Get the char at that position in D.
                                                 // This maps our array for "id" to:
                                                 // ["of", "od", "os", "if", "id", "is", "uf", "ud", "us"].
                                        f@       // Filter to only the items X where
                                             bX  //  the index of X in
                                           V·    //  the dictionary, split at newlines,
                                          ~      //  is not -1.
                                                 // This filters our array for "id" to:
                                                 // ["of", "if", "id", "is", "us"].
                                                 // Implicit: output last expression

Python 2.7, 161 159 bytes
from itertools import*
lambda a,k=' qwertyuiop asdfghjkl zxcvbnm ':set(map(''.join,product(*[k[k.index(l)-1:k.index(l)+2].strip()for l in a])))&set("<dictionary>".split())

readable version
from itertools import *
dictionary=set("<dictionary>".split())
keyboard=' qwertyuiop asdfghjkl zxcvbnm '
x=[]
for letter in input():
 index=keyboard.index(letter)
 x.append(keyboard[index-1:index+2].strip())

words=set(map(''.join,product(*x)))
print words&dictionary

 Saved 1 byte thanks to @TuukkaX

You have an useless whitespace at .strip() for.

source: Stack Exchange

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

sort: votes


text:
Is it a Bumpy Word?
(inspired by this challenge over on Puzzling -- SPOILERS for that puzzle are below, so stop reading here if you want to solve that puzzle on your own!)
If a letter in a word occurs alphabetically later than the previous letter in the word, we call that a rise between the two letters. Otherwise, including if it's the same letter, it's called a fall.
For example, the word ACE has two rises (A to C and C to E) and no falls, while THE has two falls (T to H and H to E) and no rises.
We call a word Bumpy if the sequence of rises and falls alternates. For example, BUMP goes rise (B to U), fall (U to M), rise (M to P). Note that the first sequence need not be a rise -- BALD goes fall-rise-fall and is also Bumpy.
The challenge
Given a word, output whether or not it's Bumpy.
Input

A word (not necessarily a dictionary word) consisting of ASCII alphabet ([A-Z] or [a-z]) letters only, in any suitable format.
Your choice if the input is all uppercase or all lowercase, but it must be consistent.
The word will be at least 3 characters in length.

Output
A truthy/falsey value for whether the input word is Bumpy (truthy) or not Bumpy (falsey).
The Rules

Either a full program or a function are acceptable.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Examples
Truthy:
ABA
ABB
BAB
BUMP
BALD
BALDY
UPWARD
EXAMINATION
AZBYCXDWEVFUGTHSIRJQKPLOMN

Falsey:
AAA
BBA
ACE
THE
BUMPY
BALDING
ABCDEFGHIJKLMNOPQRSTUVWXYZ

Leaderboards
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
# Language Name, N bytes

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

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

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

var QUESTION_ID=93005,OVERRIDE_USER=42963;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

Dangit. This would be easier if same letter was neither rise nor fall.

I don't understand provided examples: if BUMP is listed in Truthy (i.e. Bumpy), why BUMPY is in the Falsey list? What does "rises and falls alternates" means? Two rise s cannot be successively?

@VolAnd Yes, it means that a rise is always followed by a fall and vice versa. BUMPY is falsy because MPY gives two consecutive rises. In other words, no substring of length 3 must be sorted ascendingly or descendingly for a word to be bumpy (apart from the special case where two consecutive letters are identical).

Can you spoiler the answer to the Puzzling.SE question so others who wish to solve it themselves can do so?

@OldBunny2800 I won't put a full spoiler in (I don't want to make my challenge here hard to read by hiding crucial information behind a spoiler), but I'll add some additional text to the top as a warning. Thanks!

It would be interesting to also have a variation of this based on "visual bumpyness", where h, t, l, d, b, f, i, j, and k are 'taller' than the other letters, and must alternate with them.

@Skyler That sounds kinda neat -- sandbox it up!

MATL, 4 bytes
d0>d

Explanation:
d     % Implicitly take input. Take difference between each element
 0>   % Check whether diff's are positive. Should result in [0 1 0 1 ...] pattern.
   d  % Again take the difference. Any consecutive rises or falls results in a
      % difference of 0, which is a falsy value in MATL

This is my first MATL entry, so I wonder how much improvement there can be from this naive port from my MATLAB/Octave attempt (which would be @(a)all(diff(diff(a)>0))). Note that the all is not necessary because any zero makes an array false, so there's no A in the MATL port.

See the corrected challenge. There was a typo in a test case. Your approach was correct. In fact, d0>d should work (you don't need the A as per our definition of truthy/falsey)

Nice work, outgolfing Luis in his own language! I've tried before, and that's no easy task. ;)

@DJMcMayhem Haha. That's what I get for reading the challenge too quickly. In my defense, it's counter-intuitive that two equal letters are a fall. And the (now corrected) misleading test cases didn't help either :-)

@DJMcMayhem Thanks - although maybe I just got lucky, because I didn't actually think about consecutive equal letters, but that turned out to be exactly what was asked...

@sanchises You should remove that byte (d0>d) before someone else posts a 4-byte answer in some language...

@LuisMendo I never really liked that definition of truthy/falsy, but I guess you're right.

... so an array with any 0 elements in it is falsy?

@immibis In MATL(AB) and Octave, yes. See this Meta answer.

JavaScript (ES6), 75 69 63 46 43 bytes
Saved 3 bytes thanks to Neil:
f=([c,...s])=>s[1]?c<s[0]^s[0]<s[1]&&f(s):1

Destructuring the string parameter instead of s.slice(1).

Previous solution:
Saved 17 bytes thanks to ETHproductions:
f=s=>s[2]?s[0]<s[1]^s[1]<s[2]&&f(s.slice(1)):1

What happened from the previous solution step by step:
f=(s,i=0,a=s[i++]<s[i])=>s[i+1]&&(b=a^(a=s[i]<s[i+1]))?f(s,i):b // (63) Original
f=(s,i=0,a=s[i++]<s[i])=>s[i+1]&&(b=a^(s[i]<s[i+1]))?f(s,i):b   // (61) No point in reassigning `a`, it's not used again
f=(s,i=0,a=s[i++]<s[i])=>s[i+1]&&(b=a^s[i]<s[i+1])?f(s,i):b     // (59) Remove unnecessary parentheses
f=(s,i=0)=>s[i+2]&&(b=s[i++]<s[i]^s[i]<s[i+1])?f(s,i):b         // (55) `a` is now just a waste of bytes
f=(s,i=0)=>s[i+2]?(b=s[i++]<s[i]^s[i]<s[i+1])?f(s,i):b:1        // (56) Rearrange conditional expressions to allow for more golfing
f=(s,i=0)=>s[i+2]?(b=s[i++]<s[i]^s[i]<s[i+1])&&f(s,i):1         // (55) Rearrange conditional expression
f=(s,i=0)=>s[i+2]?(s[i++]<s[i]^s[i]<s[i+1])&&f(s,i):1           // (53) `b` is now also a waste of bytes
f=(s,i=0)=>s[i+2]?s[i++]<s[i]^s[i]<s[i+1]&&f(s,i):1             // (51) Remove unnecessary parentheses
f=s=>s[2]?s[0]<s[1]^s[1]<s[2]&&f(s.slice(1)):1                  // (46) Use `s.slice(1)` instead of `i`

Previous solutions:
63 bytes thanks to ETHproductions:
f=(s,i=0,a=s[i++]<s[i])=>s[i+1]&&(b=a^(a=s[i]<s[i+1]))?f(s,i):b

69 bytes:
f=(s,i=0,a=s[i++]<s[i])=>i+1<s.length&&(b=a^(a=s[i]<s[i+1]))?f(s,i):b

75 bytes:
f=(s,a=s[0]<s[1])=>{for(i=1;i+1<s.length&&(b=a^(a=s[i++]<s[i])););return b}

All letters in a word must have the same case.

You can golf it down quite a bit further: https://github.com/ETHproductions/golf/blob/gh-pages/misc/93014.js

@ETHproductions Should I post the content of your link ?

You can if you'd like :-)

Can !s[2]|... do the same as s[2]?...:1?

@Titus the recursion won't stop. If you mean !s[2]||... it's still 46 bytes

Have you tested it? When !s[2] is true, !s[2]|... is also true and (thanks to short-circuit evaluation) the function call will not be evaluated.

@Titus One pipe | is the bitwise operator whithout short-circuit evaluation. To use the short-circuit evaluation I need the boolean operator with two pipes ||.
With the boolean operator it works but I don't save any bytes.
With the bitwise operator I get InternalError: too much recursion at the execution.

Dread. Why does it work in PHP and not in JS? The short circuit should kick in at the &&.

@Titus I got the error with truthy values. I just tested falsy values and it works. For a truthy value, what should be the last recursive call is done with a string of only two char. !s[2] is true so !s[2]|... is true. The second operand of the &&f(s.slice(1)) is evaluated with a string less than 3 char again...

I like the face at the end: :1

Sorry for being late to the party, but for 43 bytes I give you: f=([c,...s])=>s[1]?c<s[0]^s[0]<s[1]&&f(s):1

LabVIEW, 36 equivalent bytes
Golfed down using logical equivalences:

Ungolfed:

First we convert to lowercase, then to byte array. Trim off the first element of the byte array as it has no precedent. Then, for each element in the array, check if it's greater than the previous one (U8 char maps to ASCII as you expect) and store the result for the next iteration, as well as in an array for viewing overall bumpiness. If the current and prior boolean check are equal, we terminate the loop and it's not bumpy. Else, it's bumpy!

What a cool language! Welcome to PPCG!

Thanks! I'll never compete with the 4 byte answers, but it's a nice way to improve my skills :)

See here. Your scoring is definitely wrong and overly excessive. I don't think your answer is really 246450 - 246549 bytes.

I was going off the Memory tab, as I didn't know there was a concept of equivalent bytes for LabVIEW. Will count them up and edit answer later today.

You can assume the input is given in lowercase, if that makes your code shorter. That's the second bullet point under Input.

It would save the very first node that the string goes into. There are some optimizations with the case structure that could rid the !=0 check, as well as the logical not on the bumpy Boolean, though I think I'd have to add wires to have the equivalent function. I can also get rid of the auto indexed node as that's just for debugging. Could probably shave it down to <30 equivalent bytes, but will have to look at this later.

@EriktheGolfer That link is broken.

@QPaysTaxes Here's the full URL: http://meta.codegolf.stackexchange.com/questions/7502/programming-in-labview-how-to-measure-program-size/7589#7589

@EriktheGolfer I clicked it, it didn't work when I clicked it. I still get "Problem loading page" when I try using it. Meanwhile, the question itself loads just fine.

@Erik I'm on Firefox on Windows, but opening it on mobile also breaks things. Just http://meta.ppcg.lol/ works. Anyway, this is out of scope for comments.

@QPaysTaxes Well, I think you might be using old software, or it is a problem with your ISP. I will open a chat-room if we continue discussion (I have deleted comments).

Python, 56 bytes
lambda s:all((x<y)^(y<z)for x,y,z in zip(s,s[1:],s[2:]))

All test cases are at ideone
Zips through triples of characters in s and tests that all such triples have left and right pairs with different rise/fall properties.
Works for either all uppercase or all lowercase.

C#, 64 63 55 bytes
unsafe bool B(char*s)=>1>s[2]||*s<s[1]!=*++s<s[1]&B(s);

-8 bytes from Scepheo's suggestions
This is a port of Hedi's solution to C#. I also came up with a recursive solution, but the recursion wasn't as good. My original solution is below.
My Original C#, 96 94 91 bytes
unsafe bool B(char*s,bool f=1>0,int i=0)=>1>s[1]||(s[0]<s[1]?f:1>i?!(f=!f):!f)&B(s+1,!f,1);

-2 bytes by using 1>0 instead of true.
-3 bytes from Scepheo's suggestions for the port solution above
Calls itself recursively checking that the rising/falling alternates each time.
Ungolfed:
// unsafe in order to golf some bytes from string operations.
// f alternates with each recursive call
// i is 0 for the first call, 1 for all subsequent calls
unsafe bool B(char* s, bool f = 1 > 0, int i = 0) =>
    1 > s[1] ? 1 > 0// (instead of 1 == s.Length) check if s[1] = NULL, and return true.
    : (
        s[0] < s[1] ? f // Rising, so use f...
        : // Else falling
            1 > i ? !(f=!f) // But this is the first call, so use true (but flip f)...
            : !f // Not first call, so use !f...
    )
    & B(s+1, !f, 1) // ...AND the previous value with a recursive call
                    // s+1 instead of s.Substring(1)
;

Seems like the last one can do without the ?: operator or parentheses: unsafe bool B(char*s)=>1>s[2]|s[0]<s[1]!=s[1]<s[2]&B(s+1);

Actually, although I can't test this, manipulating the pointer itself seems even terser: unsafe bool B(char*s)=>1>s[2]|*s<s[1]!=*++s<s[1]&B(s);

@Scepheo I got StackOverflowExceptions with those suggestions, but they work using boolean OR || instead of bitwise OR |. Updated the post, thanks.

C 59 Bytes
r;f(s)char*s;{for(r=0;r=*s?~r&1<<(*s>=*++s):0;);return!*s;}

The solution in 70 bytes returns 1 (True) for case AAA - the first "Falsey" in the examples

I'm testing using gcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) and I get false for aaa and excited.  In this version non-zero is falsey, and zero is truthy.  Actually wondering now if this is allowed.

Call f("ABCDEFGHIJKLMNOPQRSTUVWXYZ") compiled in Visual Studio 2012 returns value 23 that can be treated as True but in the question this value is in section "Falsey", so value 0 expected.

I misunderstood what was allowed for True and Falsey.  Now I've read the that post and it seems clear what the values must be for "C".

Here's our standard definitions for truthy and falsey, based on Meta consensus.

@cleblanc I tested your solution in 58 bytes (r;f(char*s){for(*++s;r=~r&1<<(*--s>*++s);++s);return !*s;}) and found that for strings from question answer is always 0 - perhaps, you forgot something

It seems that for input that's starting with a fall "bab" the terminating condition on the for loop goes past the end of the string.  It works every time for me with cygwin gcc even though I can see s incremented past the end of the string.  When I try with inputs that start with a rise "aba" the terminating condition seems correct as well as the output.  I'm looking into it now and hope to post a fix later.  Thanks!

I think this would be a lot clearer if you removed the previous versions. We'll still be able to see them in the revision history. Also, per meta consensus, functions have to be reusable. The second time the function is called, r may have a non-zero value, so you have to reset it from within the function.

I'm disappointed with the reusable function rule, I wasn't aware of it before.  Is it ok to pass the value as an additional parameter to the function?   For example this f(r,s)char*s;{for(;r=*s?~r&1<<(*s>=*++s):0;);return !*s;} is only 57 bytes but now the user needs to pass 0 as the first parameter.  Do I need to add additional bytes for this?  Similarly they could set the global r variable to zero before calling f(...) as well...

Just saw your xomment by accident (use @Dennis to reply), and no, that isn't allowed. You can leave r as a global though and put r=0 after for(, for only one extra byte. You can get it back by eliminating the space after return.

@Dennis thanks for the tip.

Ruby, 57 48 bytes
Expects input to be all uppercase.
->s{!s.gsub(/.(?=(.)(.))/){($&<$1)^($1<$2)}[?f]}

See it on repl.it: https://repl.it/D7SB
Explanation
The regular expression /.(?=(.)(.))/ matches each character that's followed by two more characters. (?=...) is a positive lookahead, meaning we match the subsequent two characters but don't "consume" them as part of the match. Inside the curly braces, $& is the matched text—the first character of the three—and $1 and $2 are the captured characters inside the lookahead. In other words, if the string is "BUMPY", it will first match "B" (and put it in $&) and capture "U" and "M" (and put them in $1 and $2). Next it will match "U" and capture "M" and "P", and so on.
Inside the block we check if the first pair of characters ($& and $1) is a rise and the second ($1 and $2) is a fall or vice versa, much like most of the other answers. This ^ expression returns true or false, which gets converted to a string and inserted in place of the match. As a result, our example "BUMPY" becomes this:
"truetruefalsePY"

Since we know the input is all uppercase, we know "f" will only occur as part of "false" and !result[?f] gives us our answer.

How does it work?

@GreenAsJade I've added an explanation to my answer.

Perl, 34 bytes
Includes +3 for -p (code contains ' so -e can't be used)
Give uppercase input on STDIN:
bump.pl <<< AAA

bump.pl
#!/usr/bin/perl -p
s%.%$&.z lt$'|0%eg;$_=!/(.)\1./

Jelly, 6 5 bytes
-1 byte thanks to @Dennis (use a cumulative reduction)
<2\IẠ

All test cases are at TryItOnline
How?
<2\IẠ - main link takes an argument, s,    e.g. "BUMP"    or "BUMPY"
<    - less than comparison (a dyad)
 2   - literal 2 (a nilad)
  \  - n-wise overlapping reduction when preceded by a dyad-nilad chain
       (i.e. reduce the list by pairs with less than)
                                           e.g. [1,0,1]   or [1,0,1,1]
   I  - consecutive differences,           e.g. [-1,1]    or [-1,1,0]
    Ạ - All, 0 if any values are 0 else 1, e.g. 1         or 0

Works for either all uppercase or all lowercase.

Python, 51 bytes
g=lambda a,b,c,*s:((a<b)^(b<c))*(s==()or g(b,c,*s))

Takes input like g('B','U','M','P') and outputs 1 or 0.
Uses argument unpacking to take the first three letters and check if the first two compare differently from the second two. Then, recurses on the remainder, using multiplication for and.

Nice input golf. ;-)

JavaScript (ES6), 65 bytes
s=>[...s].map(C=>(c?(R=c<C,i++?t&=r^R:0,r=R):t=1,c=C),c=r=i="")|t

.map is definitely not the best solution.

Python 2, 88 bytes
Simple solution.
s=input()
m=map(lambda x,y:y>x,s[:-1],s[1:])
print all(x-y for x,y in zip(m[:-1],m[1:]))

Try it online
If same letters in a row were neither a rise nor a fall, the solution would be 79 bytes:
s=input()
m=map(cmp,s[:-1],s[1:])
print all(x-y for x,y in zip(m[:-1],m[1:]))

Jelly, 6 bytes
OI>0IẠ

Based on @sanchises' answer.
Try it online! or Verify all.
Explanation
OI>0IẠ  Input: string S
O       Convert each char in S to an ordinal
 I      Get the increments between each pair
  >0    Test if each is positive, 1 if true else 0
    I   Get the increments between each pair
     Ạ  Test if the list doesn't contain a zero, 1 if true else 0

Haskell, 52 bytes
f x=and$g(/=)$g(>)x
  where g h y=zipWith h(tail y)y

I suspect I could get this a chunk smaller if I managed to get rid of the "where" construct, but I'm probably stuck with zipWith.
This works by making a list of the rises (True) and falls (False), then making a list of if the ajacent entries in this list are different

This is my first attempt at one of these, so I'll go through my thought process in case I've gone horribly wrong somewhere.
Ungolfed Version (168 bytes)
isBumpy :: [Char] -> Bool
isBumpy input = and $ areBumps $ riseFall input
  where
    riseFall ax@(x:xs) = zipWith (>) xs ax
    areBumps ax@(x:xs) = zipWith (/=) xs ax

Shorten names, remove type information (100 bytes)
f x = and $ g $ h x
  where
    h ax@(x:xs) = zipWith (>) xs ax
    g ax@(x:xs) = zipWith (/=) xs ax

Move h into the main function as it is only used once (86 bytes)
f ax@(x:xs) = and $ g $ zipWith (>) xs ax
  where
    g ax@(x:xs) = zipWith (/=) xs ax

Realise that areBumps and riseFall are similar enough to abstract (73 bytes)
f x  = and $ g (/=) $ g (>) x
  where
    g h ya@(y:ys) = zipWith h ys ya

Note that (tail y) is shorter than ya@(y:ys) (70 bytes)
f x  = and $ g (/=) $ g (>) x
  where
    g h y = zipWith h (tail y) y

Tidy up; remove unneeded spaces (52 bytes)
f x=and$g(/=)$g(>)x
  where g h y=zipWith h(tail y)y

... and I've just noticed a shorter Haskell answer that was posted before mine that does basically the same thing.  I am terrible at spotting things.

You mean the one that doesn't work? ;-) You may use g h=tail>>=zipWith h and make it a global function to avoid the where keyword.

@ChristianSievers Fixed it, and I just noticed this answer which now does exactly the same thing as mine, rendering my answer better suited as a comment to this one.

Java 7, 157 153 150 125 117 bytes
int c(char[]z){for(int i=2,a,b,c;i<z.length;i++)if(((a=z[i-1])<(c=z[i])&(b=z[i-2])=c&b>=a))return 0;return 1;}

Ungolfed & test cases:
Try it here.
class M{
  static int c(char[] z){
    for(int i = 2, a, b, c; i < z.length; i++){
      if(((a = z[i-1]) < (c = z[i]) & (b = z[i-2]) = c & b >= a)){
        return 0; //false
      }
    }
    return 1; //true
  }

  public static void main(String[] a){
    System.out.print(c("ABA".toCharArray()) + ", ");
    System.out.print(c("ABB".toCharArray()) + ", ");
    System.out.print(c("BAB".toCharArray()) + ", ");
    System.out.print(c("BUMP".toCharArray()) + ", ");
    System.out.print(c("BALD".toCharArray()) + ", ");
    System.out.print(c("BALDY".toCharArray()) + ", ");
    System.out.print(c("UPWARD".toCharArray()) + ", ");
    System.out.print(c("EXAMINATION".toCharArray()) + ", ");
    System.out.print(c("AZBYCXDWEVFUGTHSIRJQKPLOMN".toCharArray()) + ", ");

    System.out.print(c("AAA".toCharArray()) + ", ");
    System.out.print(c("ACE".toCharArray()) + ", ");
    System.out.print(c("THE".toCharArray()) + ", ");
    System.out.print(c("BUMPY".toCharArray()) + ", ");
    System.out.print(c("BALDING".toCharArray()) + ", ");
    System.out.print(c("ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray()) + ", ");
  }
}

Output:
1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0

@TimmyD Hmm, so it's rise when a > b, but fall when a <= b, instead of > and <?

@TimmyD Ok, it's fixed, and even saves 3 bytes. :)

you can redefine your method to accept char[] so you dont have to transform your input string to char array. that should save a few bytes.  PS: java ftw!

@peech Thanks.. sometimes I forget the most obvious golfing things.. Normally I always use char[] input when I can, but now I just forgot to.. Thanks for the reminder! It saved 25 bytes. ;p

Did you perhaps means to change String s --> char[]z?

You can return a truthy or falsey value, so make your method an int and return 1 or 0 :).. Puts you down to 117 bytes

Japt, 8 bytes
Uä> ä- e

Test it online!
How it works
Uä> ä- e  // Implicit: U = input string
Uä>       // Map each pair of chars X, Y in U to X > Y.
    ä-    // Map each pair of items in the result to X - Y.
          // If there are two consecutive rises or falls, the result contains a zero.
       e  // Check that every item is truthy (non-zero).
          // Implicit: output last expression

Same as my solution. Except 11x shorter. :P

C# 105 104 Bytes
bool f(char[]x){int t=1;for(int i=2,p=x[1],f=x[0]-p>>7;i<x.Length;)f^=t&=p<(p=x[i++])?1-f:f;return t>0;}

105 bytes Solution:
bool f(char[]x){bool t=1>0,f=x[0]<x[1];for(int i=2,p=x[1];i<x.Length;)f^=t&=p<(p=x[i++])?!f:f;return t;}

Try it online
Using an array of chars saved one byte since the space can be omitted after the brackets. f(string x) vs f(char[]x)
It is 101 bytes if I can return an int 1/0 instead of bool true/false
int f(char[]x){int t=1;for(int i=2,p=x[1],f=x[0]-p>>7;i<x.Length;)f^=t&=p<(p=x[i++])?1-f:f;return t;}

Python 2.7 (again, 84 83 bytes)
def a(s):x=s[1:];return[cmp(s[0],x)]+a(x) if x else []
print len(set(a(input())))>1

Or, 78 77 bytes without the print.
By the way, the above 56 byte Python 2.7 example breaks on, for example, "abbab" or any other input with repeated characters. Never mind, didn't read instructions. Revising.
Okay, down to 83. The triples one is nicer though.

Here's some tips for ya. 1. Remove some whitespace a(x)if x else[]. 2. Use a lambda instead a=lambda s:[cmp(s[0],s[1:])]+a(s[1:])if s[1:]else[] 3. Use a lambda at the end instead of printing. lambda s:len(set(a(s)))>1 4. if len(set(a(s))) isn't greater than 1, than it's already falsy, so you can take off >1

05AB1E, 9 bytes
SÇ¥0›¥_O_

Explanation
SÇ          # convert to list of ascii values
  ¥         # take delta's
   0›       # check if positive, giving a list of 1's and 0's
            # if they alternate, the word is bumpy
     ¥      # take delta's again, if we have any 0's in the list the word is not bumpy
      _     # logical negation, turning 0 into 1 and everything else to 0
       O    # sum, producing 0 for a bumpy word and 1 for a non-bumpy word
        _   # logical negation, inverting the previous 1 into 0 and vice versa

Try it online!

PowerShell v2+, 83 bytes
param($n)($a=-join(1..($n.Length-1)|%{+($n[$_-1]-lt$n[$_])}))-eq($a-replace'00|11')

A little bit of a different approach. This loops through the input $n, each iteration seeing whether the previous character $n[$_-1] is -lessthan the current character $n[$_], then casting the result of that Boolean operator to an int with +. Those are -joined together into a string, stored into $a. We then check whether $a is -equal to $a with any substrings of 00 or 11 removed.

Python 2.7, 84 bytes
s=input()
b=s[0]<s[1]
o=1
for i in range(len(s)-1):o&=(s[i]<s[i+1])==b;b^=1
print o

Returns 1 for bumpy, 0 for otherwise
Learned some cool stuff with bitwise & and ^.
Starts with boolean b defining first pair as up/down, then tests and flips b for each following pair.
o flips to false if test fails and sticks.
Requires quotes around input (+4 bytes for raw_input() if that breaks some rule)
Test It

CJam, 15 bytes
l2ew::<2ew::^:*

Try it online! (As a linefeed-separated test-suite.)
Explanation
l    e# Read input.
2ew  e# Get all (overlapping) pairs.
::<  e# Check whether each pair is strictly ascending (1) or not (0).
2ew  e# Get all (overlapping) pairs.
::^  e# Take the bitwise XOR of each pair, giving 1 if a rise and a fall alternate,
     e# and zero if there are two rises or two falls in succession.
:*   e# Product. Gives 1 only if the previous step yielded a list of 1s, meaning
     e# that any two consecutive rises/falls will turn this into a zero.

Haskell, 30 37 bytes
q f=tail>>=zipWith f;k=and.q(/=).q(>)

Usage:
Prelude> k <$> words "ABA ABB BAB BUMP BALD BALDY UPWARD EXAMINATION AZBYCXDWEVFUGTHSIRJQKPLOMN"
[True,True,True,True,True,True,True,True,True]

Prelude> k <$> words "AAA BBA ACE THE BUMPY BALDING ABCDEFGHIJKLMNOPQRSTUVWXYZ"
[False,False,False,False,False,False,False]

That doesn't accept "bald", foldl1(/=) doesn't do what you think it does.

@ChristianSievers Auch, you're right. Thanks for the heads up

PHP, 80 bytes
$s=$argv[1];for($c=$s[0];$n=$s[++$i];$c=$n,$d=$e)if($d===$e=$n>$c)break;echo!$n;

or
for($c=$argv[1][0];$n=$argv[1][++$i];$c=$n,$d=$e)if($d===$e=$n>$c)break;echo!$n;

empty output for false, 1 for true
or Hedi´s recursive approach ported and a little golfed for 70 bytes:
function f($s){return!$s[2]|$s[0]<$s[1]^$s[1]<$s[2]&&f(substr($s,1));}

Actually, this should recurse infinitely for bumpy words, but it does not!

PHP 7, 137 118 bytes
for($i=0;$i<strlen($argv[1])-2;$i++)if(((($s[$i]<=>$s[$i+1])<0)?1:0)==((($s[$i+1]<=>$s[$i+2])<0)?1:0)){echo"0";break;}

Empty output for Bumpy, 0 for Not Bumpy.
This is my first attempt at code golfing and I have to improve a lot, but it was a wonderful method to learn new things for me. I also wanted to challenge myself on that task by using the new PHP 7 Spaceship Operator which seems very interesting.
Anyway I'm not satisfied about it, first of all for the fact that I had to add an extra if(isset($s[$i+2])) to check if the variable exist because I did not find another workaround to the problem, but this is it for now. (Note: I fixed that simply by changing strlen($s)-1 to strlen($s)-2, I couldn't really see that before...).
Testing code:
$as = array("ABA", "ABB", "BAB", "BUMP", "BALD", "BALDY", "UPWARD",
            "EXAMINATION", "AZBYCXDWEVFUGTHSIRJQKPLOMN", "AAA", "BBA",
            "ACE", "THE", "BUMPY", "BALDING", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");

foreach ($as as $s) {
    for($i=0;$i<strlen($s)-2;$i++)if(((($s[$i]<=>$s[$i+1])<0)?1:0)==((($s[$i+1]<=>$s[$i+2])<0)?1:0)){echo"0";break;}
}

Test online

Hello, and welcome to PPCG! Great first post!

Welcome to PPCG! Nice first post. Check out Tips for PHP for some additional golfing suggestions.

Python 3, 148 139 127 bytes
def _(w):*r,=map(lambda a,b:0>ord(a)-ord(b)and-1or 1,w,w[1:]);s=len(r)%2==0and r+[r[0]]or r;return sum(s)in(-1,1)and s==s[::-1]

testing code
positives = ('ABA', 'ABB', 'BAB', 'BUMP', 'BALD', 'BALDY', 'UPWARD', 'EXAMINATION', 'AZBYCXDWEVFUGTHSIRJQKPLOMN')
negatives = ('AAA', 'BBA', 'ACE', 'THE', 'BUMPY', 'BALDING', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')

for w in positives:
    print(_(w), w)
    assert _(w)

for w in negatives:
    print(_(w), w)
    assert not _(w)

i really suck at this #facepalm

Welcome to PPCG! Check out Tips for Golfing in Python, and take inspiration from the other answers.

C, 65 57 60 bytes
 r;f(char*s){for(r=0;*++s&&(r=~r&1<<(*s>*(s-1))););return r;}

is fix of
r;f(char*s){for(;*++s&&(r=~r&1<<(*s>*(s-1))););return r;}

that works correctly with any data only at single function call (when the global variable r is initialized to zero).
But in any case this is shorter than previous solution (65 bytes) due to use of for instead of while. But previous (the following) is a little easier to understand:
r;f(char*s){while(*++s)if(!(r=~r&1<<(*s>*(s-1))))break;return r;}

My solution is based on bitwise & with inverted previous and current direction code, where direction code can be 2 (1<<1) for character code increase (*s > *(s-1)) or 1 (1<<0) otherwise. Result of this operation became 0 if we use the same direction code as previous and current, i.e. when word is not Bumpy.
UPDATE:
Code for testing:
#include <stdio.h>
#include <string.h>

r;f(char*s){for(;*++s&&(r=~r&1<<(*s>*(s-1))););return r;}

int main(void)
{
    char * Truthy[] = { "ABA",
                        "ABB",
                        "BAB",
                        "BUMP",
                        "BALD",
                        "BALDY",
                        "UPWARD",
                        "EXAMINATION",
                        "AZBYCXDWEVFUGTHSIRJQKPLOMN" };
    char * Falsey[] = { "AAA",
                        "BBA",
                        "ACE",
                        "THE",
                        "BUMPY",
                        "BALDING",
                        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
    int posTestNum = sizeof(Truthy) / sizeof(char *);
    int negTestNum = sizeof(Falsey) / sizeof(char *);
    int i;
    int rate = 0;
    int tests = 0;
    int res = 0;
    printf("Truthy (%d tests):\n", posTestNum);
    for (i = 0; i < posTestNum; i++)
    {
        tests++;
        printf("%s - %s\n", Truthy[i], f(Truthy[i]) ? (rate++, "OK") : "Fail");
        r = 0;
    }
    printf("\nFalsey (%d tests):\n", negTestNum);
    for (i = 0; i < negTestNum; i++)
    {
        tests++;
        printf("%s - %s\n", Falsey[i], f(Falsey[i]) ? "Fail" : (rate++, "OK"));
        r = 0;
    }
    printf("\n%d of %d tests passed\n", rate, tests);
    return 0;
}

Per meta consensus, functions have to be reusable. That means you cannot reset r to 0 for free, but must do so from within the function.

@Dennis You're right, initialization is required, but only for repeated calls. Let's assume that for a single call that works with any data because compiler provide initialisation for global variables

I think you should make the 60 byte solution your main one, since the 57 byte version isn't valid by that meta post I cited.

@Dennis Done! +3 bytes

Javascript ES6, 100 bytes
d="charCodeAt";a=b=>{f=r=0;for(i=1;i<b.length;i++){if(b[d](i)<=b[d](i-1)){f=1}else{r=1}}return f&&r}

Try it here:

d="charCodeAt";a=b=>{f=r=0;for(i=1;i<b.length;i++){if(b[d](i)<=b[d](i-1)){f=1}else{r=1}}return f&&r}
alert(a(prompt()));

Oh come on two people already beat me to it by 40 bytes... whatever

Hint: "A"<"B", so you don't need to get the chars' charcodes.

Also, this returns 1 for BUMPY (or anything else that contains both a rise and a fall).

This doesn't seem to quite work right.

PHP, 100 bytes
for($s=$argv[1];$i<strlen($s)-1;$i++)$s[$i]=$s[$i+1]>$s[$i]?r:f;echo str_replace([rr,ff],'',$s)==$s;

Replaces every char of the string (except the last one obviously) with an r for rise or an f for fall and then checks whether rr or ff occur in the string. To avoid that the last remaining character interfers with that, input must be all uppercase.
I'm very unsatisfied with the loop, for example I have a feeling that there must be a way to combine the $i++ into one of the several $is used in the loop, but I failed to find that way. Maybe someone else sees it.
(That's also why I posted my code, despite it being 20 (!) bytes longer than Titus' nice solution.)

Java 8, 114 90 bytes
(c,b)->{b=c[0]<c[1];for(int i=2;i<c.length;i++)if(c[i]>c[i-1]!=(b=!b))return 0;return 1;};

Ungolfed test program
public static void main(String[] args) {
    BiFunction<char[], Boolean, Integer> func = (c, b) -> {
        b = c[0] < c[1];
        for (int i = 2; i < c.length; i++) {
            if (c[i] > c[i - 1] != (b = !b)) {
                return 0;
            }
        }
        return 1;
    };

    System.out.println(func.apply("ABCDEFG".toCharArray(), false));
    System.out.println(func.apply("AZBYCXDGEF".toCharArray(), false));
    System.out.println(func.apply("ZXZXZX".toCharArray(), false));
    System.out.println(func.apply("ZXCYZ".toCharArray(), false));
    System.out.println(func.apply("AAA".toCharArray(), false));
}

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


text:
How long is a Welsh word?
Write a program or function which receives as input a string representing a Welsh word (UTF-8 unless otherwise specified by you).
The following are all single letters in Welsh:

a, b, c, ch, d, dd, e, f, ff, g, ng, h, i, j, l, ll, m, n, o, p, ph, r, rh, s, t, th, u, w, y

To quote Wikipedia,

While the digraphs ch, dd, ff, ng, ll, ph, rh, th are each written with two symbols, they are all considered to be single letters. This means, for example that Llanelli (a town in South Wales) is considered to have only six letters in Welsh, compared to eight letters in English.

These letters also exist in Welsh, though they are restricted to technical vocabulary borrowed from other languages:

k, q, v, x, z

Letters with diacritics are not regarded as separate letters, but your function must accept them and be able to count them. Possible such letters are:

â, ê, î, ô, û, ŷ, ŵ, á, é, í, ó, ú, ý, ẃ, ä, ë, ï, ö, ü, ÿ, ẅ, à, è, ì, ò, ù, ẁ

(This means that ASCII is not an acceptable input encoding, as it cannot encode these characters.)
Notes:

This is code golf.
You do not have to account for words like llongyfarch, in which the ng is not a digraph, but two separate letters. This word has nine letters, but you can miscount it as eight. (If you can account for such words, that's kind of awesome, but outside the scope of this challenge.)
The input is guaranteed to have no whitespace (unless you prefer it with a single trailing newline (or something more esoteric), in which case that can be provided). There will certainly be no internal whitespace.

Test cases:

Llandudno, 8
Llanelli, 6
Rhyl, 3
Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch, 50 (really 51, but we'll count 50)
Tŷr, 3
Cymru, 5
Glyndŵr, 7

Can the input be given in all lowercase?

My wife who is a native Welsh speaker would recommend that the J is added into the "Borrowed" letters section as it isn't actually part of the Welsh alphabet

@RichStarkie The Wikipedia article was a little vague on that front. My understanding is that j is used in borrowed words even when it's not present in the original word, so it's used phonologically, which implies that at this stage it's natualized into the language. I've seen similar arguments about v in Irish. It's widely considered not to be part of the Irish alphabet, but it exists in some Irish names, such as Ó Cuiv.

What is it with "Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch" that makes it 51?

@EriktheGolfer I think it's an ng which crosses a morpheme boundary, making it two separate letters, not a digraph.

@TRiG yngy is four letters?

@EriktheGolfer. Probably, but for the purpose of this question we'll call it three.

I seem to recall from my Welsh lessons that nh and ngh are single letters, too.  As in "fy nhadau" and "yng Nghymru".

@daiscog. I'm just relying on Wikipedia's article on Welsh orthography. That said, https://en.wikipedia.org/wiki/Nh_(digraph)#Welsh does list nh as a Welsh digraph, even if the other article doesn't. Interesting. Too late to change the question at this stage, though.

And a footnote in the Welsh orthography article lists mh, nh, and ngh as graphems. Methinks I need to open a question on Linguistics SE.

Shame it's too late; that triple-glyphed "ngh" might have made it a little more complicated.

@Rich Starkie, why does your wife not leave her own comment? Also you don't happen to be called Ringo do you?

05AB1E, 24 23 21 bytes
Code:
u•éÓœ°D¥M™ù>•30B2ô0:g

Explanation:
u                      # Convert the input to uppercase.
 •éÓœ°D¥M™ù>•30B       # Compressed version of CHDDFFNGLLPHRHTH.
                         It convert the text between the •'s from base 214 to
                         base 10 and converts that to base 30.
                2ô     # Split into pieces of 2.
                  0:   # Replace each element that also occurs in the input by 0.
                    g  # Get the length of the processed input.

Uses the CP-1252 encoding. Try it online!

Retina, 23 bytes
i`[cprt]h|dd|ff|ng|ll|.

Try it online!
Even moar regex.

It's probably my ignorance of Retina, but where is the outputting of the length of the input text? The documentation on Retina doesn't seem to explain how that's working in the "Try it online!" site.

The output is implicit, because the only line is a Match stage, returning the number of matches. Here, the regex matches every Welsh letter.

So by that logic, then every answer below where the length is explicitly called in the code can be shortened?

@XaeroDegreaz Retina is one of the only languages that automatically counts matches and prints them out. This is how Retina, the language, works. It is not how other languages work, and so those languages need to call their length functions explicitly to get the right output.

Thanks, I understand now. After reading more into the documentation I see the default "Match" stage performs this output.

JavaScript (ES6), 44 bytes
x=>x.match(/[cprt]h|dd|ff|ng|ll|./gi).length

The trivial answer may be the shortest.

BASH 52 50 (sed + wc) 41
-9 thanks to Jordan
sed -r 's,dd|ff|ng|ll|[cprt]h,1,gi'|wc -m

If uppercase letter are required this needs an i at the end of the sed command. (I left it out because all of the "single letters" in the question are lowercase even though some examples aren't).

Why grep -o .|wc -l instead of wc -c?

wc -c counts â through ẁ as two.

Ah, of course. FWIW if you use GNU or BSD wc you can use -m to count characters instead of bytes.

Can you move the c from ch in with the [prt]?  sed -r 's,dd|ff|ng|ll|[cprt]h,1,gi'|wc -m

@daiscog I thought i did that already... That's how I went from 52 to 50. It must have reverted somehow. Thanks

It's a shame ([dfl])\1 would longer than dd|ff|ll.  Just one more doubled-consonant would favour the clever version.

Straw, 30 58 35 33 bytes
<((?i:[cprt]h|dd|ff|ng|ll|.))0/$>

Replace each occurence of the regex by 0, and convert from unary to decimal.
Sadly, Straw can't pass flags to regexs. I forget about the ?flags: construct
Try it online! (The added code is to verify all test cases)

How does this language differ from something like Retina?

@Downgoat Straw is stack-based :P

Python 3, 64 bytes
import re
print(len(re.findall("[cprt]h|dd|ff|ng|ll|.",input())))

Uses regex again
Ideone it!

PowerShell v2+, 52 50 48 bytes
($args[0]-replace'dd|ff|ng|ll|[prtc]h',0).length

Does a -replace on all the two-symbol-single-letter letters, changes 'em to 0 (done because changing to a non-numeral would require quotes), then gets the .length of the resultant string.
Test cases
PS C:\Tools\Scripts\golfing> 'Llandudno','Llanelli','Rhyl','Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch','Tŷr','Cymru','Glyndŵr'|%{"$_ --> "+(.\how-long-is-a-welsh-word.ps1 $_)}
Llandudno --> 8
Llanelli --> 6
Rhyl --> 3
Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch --> 50
Tŷr --> 3
Cymru --> 5
Glyndŵr --> 7

I'm not familiar with PowerShell, but do you really need the parentheses around [prtc]h?

@Jordan No, I do not. That's not a PowerShell thing, that's a me-not-good-at-regex thing. :D Thanks for the golf!

V, 31 bytes
Íã[cprt]hüddüffüngüllü./
Dé0@"

Try it online, or Verify all test cases!
This contains some unprintable characters, so here is a hexdump:
0000000: cde3 5b63 7072 745d 68fc 6464 fc66 66fc  ..[cprt]h.dd.ff.
0000010: 6e67 fc6c 6cfc 2e2f 010a 44e9 3040 22    ng.ll../..D.0@"

PHP , 56 Bytes
<?=preg_match_all("#[cprt]h|dd|ff|ll|ng|.#iu",$argv[1]);

I believe [dfl]{2} matches df, ld, etc. as well as its intended matches. dd|ff|ll is the same length.

I know that your believe is true but I think that your believe s not a type of believe. it looks more than a type of kowledge

Instead of echo(space at the end), use <?=, which saves 2 bytes. Also, the $t isn't necessary there, saving you 3 more bytes.

Thnak You Ismael . I must be more then a little confused that I not remove the $t

Java 7, 156 73 bytes
Loads of bytes saved thanks to @OlivierGrégoire.
int c(String s){return s.replaceAll("[cprt]h|dd|ff|ng|ll","*").length();}

Ungolfed & test cases:
Try it here.
class M{
  static int c(String s){
    return s.replaceAll("[cprt]h|dd|ff|ng|ll", "*").length();
  }

  public static void main(String[] a){
    System.out.println(c("llandudno"));
    System.out.println(c("llanelli"));
    System.out.println(c("rhyl"));
    System.out.println(c("llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch"));
    System.out.println(c("tŷr"));
    System.out.println(c("cymru"));
    System.out.println(c("glyndŵr"));
  }
}

Output:
8
6
3
50
3
5
7

You import and then you don't use Matcher directly? :o Also, Matcher can be defined in the for loop.

I have the strong feeling that return s.replaceAll("[cprt]h|dd|ff|ng|ll","a").length() is way, way shorter. Can't this work?

Well, yes, it works, and it's 73 bytes for the Java 7 version (int c(String s){return s.replaceAll("[cprt]h|dd|ff|ng|ll","a").length();}). And only 51 for the Java 8 version (s->s.replaceAll("[cprt]h|dd|ff|ng|ll","a").length()).

@OlivierGrégoire Thanks. The Matcher was an accident. I had it correctly in the test code, but not in the golfed code.. >.> Your replaceAll works better though, thanks.

R, 54 bytes
Very similar to the other answers. Matches any of the two character letters and replaces them with @ and subsequently counts the number of characters. Reads input from stdin. Uses the option ignore.case = TRUE (third argument to gsub) to match both upper and lowercase characters.
nchar(gsub("ch|dd|ff|ng|ll|ph|rh|th","@",scan(,""),T))

Bonus
Both gsub and nchar are vectorized which means that this also works on a character vector, e.g.:
v=c("Llandudno","Llanelli","Rhyl","Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch","Tŷr","Cymru","Glyndŵr")
nchar(gsub("ch|dd|ff|ng|ll|ph|rh|th","@",v,T))

produces:
[1]  8  6  3 50  3  5  7

Perl 6, 36 bytes
+*.comb(/:i.|<[cprt]>h|dd|ff|ng|ll/)

Try it online!

XQuery, 77 bytes
declare variable$s external;count(tokenize($s,'[cprt]h|ff|dd|ll|ng|.','i'))-1

tcl, 71
proc L s {string le [regsub -all -nocase ch|dd|ff|ng|ll|ph|rh|th $s @]}

demo

Perl 5, 35 + 1 (-p) = 36 bytes
s/[cprt]h|dd|ff|ng|ll/a/gi;$_=y///c

Try it online!

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


text:
Parse the comments out of my esoteric code
Earlier this week, we learned about how to format esoteric languages for commenting. Today, we're going to do the inverse of that. I need you to write a program or function that parses some well-commented esoteric code and parses the comments out, returning just the code. Using some examples from the previous challenge, here is what well-commented code looks like:
a                #Explanation of what 'a' does
 bc              #Bc
   d             #d
    e            #Explanation of e
     fgh         #foobar
        ij       #hello world
          k      #etc.
           l     #so on
            mn   #and
              op #so forth

Here is what you need to do to extract the code out. First, remove the comment character (#), the space before it, and everything after the comment character.
a
 bc
   d
    e
     fgh
        ij
          k
           l
            mn
              op

Then, collapse each line upwards into a single line. For example, since b is in the second column on line two, once we collapse it up, it will be in the second column on line one. Similarly, c will be put in the third column of line one, and d will be put on the fourth. Repeat this for every character, and you get this:
abcdefghijklmnop

Important note: It seems like the trivial solution is to just remove the comments, remove every space, and join every line. This is not a valid approach! Because the original code might have spaces in it, these will get stripped out with this approach. For example, this is a perfectly valid input:
hello         #Line one
              #Line two
       world! #Line three

And the corresponding output should be:
hello  world!

The Challenge:
Write a program or function that takes commented code as input, and outputs or returns the code with all the comments parsed out of it. You should output the code without any trailing spaces, although one trailing newline is permissible. The comment character will always be #, and there will always be one extra space before the comments start. # will not appear in the comment section of the input. In order to keep the challenge simpler, here are some inputs you do not have to handle:

You can assume that the code will not have two characters in the same column. For example, this is an input that violates this rule:
a  #A character in column one
bc #Characters in columns one and two

You can also assume that all comment characters appear in the same column. For example, this input:
short       #this is a short line
      long        #This is a long line

violates this rule. This also means that # will not be in the code section.
And lastly, you do not have to handle code sections with leading or trailing spaces. For example,
  Hello,          #
         World!   #

You may also assume that the input only contains printable ASCII characters.
Examples:
Input:
hello         #Line one
              #Line two
       world! #Line three

Output:
hello  world!

Input:
E                                                   #This comment intentionally left blank
 ac                                                 #
   h s                                              #
      ecti                                          #
          on is                                     #
                one c                               #
                     haracte                        #
                            r longer                #
                                     than the       #
                                              last! #

Output:
Each section is one character longer than the last!

Input:
4          #This number is 7
 8         #
  15       #That last comment is wrong.
    16     #
      23   #
        42 #

Output:
4815162342

Input:
Hello                     #Comment 1
      world               #Comment 2
           ,              #Comment 3
             how          #Comment 4
                 are      #Comment 5
                     you? #Comment 6

Output:
Hello world, how are you?

Input:
Prepare                               #
        for...                        #
                        extra spaces! #

Output:
Prepare for...          extra spaces!

You may take input in whatever reasonable format you like, for example, a list of strings, a single string with newlines, a 2d list of characters, etc. The shortest answer in bytes wins!

Will we need to accept code with characters lower than the next?

Could you add the test case with the empty line with just two spaces (like the hello  world! you've showed)? Also, you state: "# will not appear in the comment section of the input.", but can it occur in the code-snippet itself?

@KevinCruijssen See my edits

@wizzwizz4 I'm not sure if I understand your question

@DJMcMayhem Example: do {stuff} while (condition); with the explanation in order do         while (condition); #Explainything then {stuff} #Explainything.

@wizzwizz4 I'm pretty sure that's covered under You can assume that the code will not have two characters in the same column. Does that answer your question?

@DJMcMayhem The HTML parser on your / my browser stripped the whitespace. Imagine a gap inbetween while and (condition), and a gap before / after {stuff}. (I'm not very good at explaining, am I?)

Jelly, 8 7 bytes
»/ṣ”#ḢṖ

Try it online!
How it works
»/ṣ”#ḢṖ  Main link. Argument: A (array of strings)

»/       Reduce the columns of A by maximum.
         Since the space is the lowest printable ASCII characters, this returns the
         non-space character (if any) of each column.
  ṣ”#    Split the result at occurrences of '#'.
     Ḣ   Head; extract the first chunk, i.e., everything before the (first) '#'.
      Ṗ  Pop; remove the trailing space.

That is just ...wow.

I am so jelly right now.

How do you even hack that into your phone?

@simbabque Patience and a lot of copy-pasting.

I'm always putting using a 9-iron, maybe it's time I learned how to use a putter when on the green...

Python 2, 48 43 bytes
lambda x:`map(max,*x)`[2::5].split(' #')[0]

Thanks to @xnor for golfing off 5 bytes!
Test it on Ideone.

I think you can just do map(max,*x) because max takes any number of arguments and None is small.

Right, I always forget that map can be used like that... Thanks!

How does the \...`[2::5]` trick work?

@smls \...`is equivalent torepr(...), so for the list of singleton strings ['a', 'b', 'c'], you get the string "['a', 'b', 'c']". Finally, [2::5] chops off the first two characters ("['"`) and takes every fifth character of the remaining string.

JavaScript (ES6), 97 75 60 bytes
Thanks to @Neil for helping golf off 22 bytes
a=>a.reduce((p,c)=>p.replace(/ /g,(m,o)=>c[o])).split` #`[0]

Input is an array of lines.

a is array input
p is previous item
c is current item
m is match string
o is offset

I count 96 bytes? Also, the m regexp flag is unnecessary (did you have a $ at one point?) as is the space in (p, c). Finally, I think replace will work out shorter than [...p].map().join.

97 for me, both from manual length and userscript, maybe you didn't count the newline, but only because I accidentally included the semicolon

I see now - I hadn't copied the ; which isn't required (JavaScript has ASI).

Yeah, sorry, I had it to make sure Chromium console puts the function call outside the function body (had it once on a badly written lambda)

Oh wow, I didn't realise replace would help so much, that's really neat!

Isn't there a g missing at the end of the first regex?

@CedricReichenbach Try it, it works perfectly fine, plus I explain its absence right after the snippet

Perl, 35 34 32 bytes
Includes +1 for -p
Give input on STDIN
eso.pl
#!/usr/bin/perl -p
y/ /\0/;/.#/;$\|=$`}{$\=~y;\0;

Notice that there is a space after the final ;. The code works as shown, but replace \0 by the literal character to get the claimed score.

Very nice code. That $a|=... is rather well done, it took me a while to figure out what you were doing! One question though : *_=a seems to be roughly equivalent to $_=$a, why is that?

*_=a is a very obscure glob assignment which aliases the _ globals and the a globals. So it's not so much a copy from $a to $_ but from that point on (global) $a and $_ are actually the same variable. All to save 1 byte...

Ok, thanks for the explanation! (and nice improvement thanks to $\\)

Python 2, 187 bytes
def f(x,o=""):
 l=[i[:i.index("#")-1]for i in x]
 for n in range(len(l[0])):
  c=[x[n]for x in l]
  if sum([1for x in c if x!=" "])<1:o+=" "
  else:o+=[x for x in c if x!=" "][0]
 print o

I'm gonna golf this more tomorrow I have school ;)

1 for can be reduced to 1for. Also, if the sum of the list (at line 5) can't be negative, you can just check for <1 instead of ==0. Happy school day! :D +1.

J, 30 bytes
(#~[:<./\'#'~:])@(>./&.(3&u:))

Takes a list of strings as input. Basically uses the same approach as Dennis in his Jelly answer.
Commented and explained
ord =: 3 & u:
under =: &.
max =: >./
over =: @
maxes =: max under ord
neq =: ~:
arg =: ]
runningMin =: <./\
magic =: #~ [: runningMin ('#' neq arg)

f =: magic over maxes

Intermediate steps:
   p
Hello                     #Comment 1
      world               #Comment 2
           ,              #Comment 3
             how          #Comment 4
                 are      #Comment 5
                     you? #Comment 6
   maxes p
Hello world, how are you? #Comment 6
   magic
#~ ([: runningMin '#' neq arg)
   3 neq 4
1
   '#' neq '~'
1
   '#' neq '#'
0
   '#' neq maxes p
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1
   runningMin 5 4 2 5 9 0 _3 4 _10
5 4 2 2 2 0 _3 _3 _10
   runningMin '#' neq maxes p
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
   0 1 0 1 1 0 # 'abcdef'
bde
   'abcdef' #~ 0 1 0 1 1 0
bde
   (maxes p) #~ runningMin '#' neq maxes p
Hello world, how are you?
   (#~ [: runningMin '#' neq arg) maxes p
Hello world, how are you?
   ((#~ [: runningMin '#' neq arg) over maxes) p
Hello world, how are you?
   (magic over maxes) p
Hello world, how are you?

Test case
   f =: (#~[:<./\'#'~:])@(>./&.(3&u:))
   a
Hello                     #Comment 1
      world               #Comment 2
           ,              #Comment 3
             how          #Comment 4
                 are      #Comment 5
                     you? #Comment 6
   $a
6 36
   f a
Hello world, how are you?

Ruby, 63 bytes
Basically a port of Dennis' Jelly answer. Takes input as an array of strings.
->a{l,=a
l.gsub(/./){a.map{|m|m[$`.size]||$/}.max}[/(.+) #/,1]}

See it on eval.in: https://eval.in/640757

CJam, 12 bytes
Thanks to Sp3000 for saving 2 bytes.
{:.e>_'##(<}

An unnamed block that takes a list of strings (one for each line) and replaces it with a single string.
Try it online!
Explanation
:.e>  e# Reduce the list of strings by elementwise maximum. This keeps non-spaces in
      e# favour of spaces. It'll also wreak havoc with the comments, but we'll discard
      e# those anyway.
_'##  e# Duplicate and find the index of '#'.
(<    e# Decrement that index and truncate the string to this length.

Javascript (ES6), 63 bytes
a=>a.reduce((p,c)=>p+/(.+?)\s+#/.exec(c)[1].slice(p.length),'')

Takes input as an array of strings.

F=a=>a.reduce((p,c)=>p+/(.+?)\s+#/.exec(c)[1].slice(p.length),'')

input.oninput = update;
update();

function update() {
  try {
    output.innerHTML = F(input.value.trim().split`
`);
  } catch(e) {
    output.innerHTML = 'ERROR: INVALID INPUT';
  }
}
textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: monospace;
}

Input:

<textarea id="input" rows="8">
a                #Explanation of what 'a' does
 bc              #Bc
   d             #d
    e            #Explanation of e
     fgh         #foobar
        ij       #hello world
          k      #etc.
           l     #so on
            mn   #and
              op #so forth
</textarea>

Output:

Retina, 32 bytes
Byte count assumes ISO 8859-1 encoding.
Rmr` #.+|(?<=^(?<-1>.)+).+?¶( )+

Try it online!

Pyke, 15 10 bytes
,FSe)s\#ch

Try it here!
Port of the Jelly answer
,          -     transpose()
 FSe)      -    map(min, ^)
     s     -   sum(^)
      \#c  -  ^.split("#")
         h - ^[0]

C# 157 122 Bytes
Golfed 35 bytes thanks to @milk -- though I swear I tried that earlier.
Takes input as a 2-d array of characters.
string f(char[][]s){int i=0;foreach(var x in s)for(i=0;x[i]!=35;i++)if(x[i]!=32)s[0][i]=x[i];return new string(s[0],0,i);}

157 bytes:
string g(char[][]s){var o=new char[s[0].Length];foreach(var x in s)for(int i=0;x[i]!=35;i++)if(x[i]!=32|o[i]<1)o[i]=x[i];return new string(o).TrimEnd('\0');}

Shouldn't Trim() work instead of TrimEnd()? Even better, I think you can save a lot of bytes by using s[0] as the output var and using return new string(s[0],0,i) where i is the index of the last code character. That idea may require two for loops instead of the foreach, I'll think about it more and try to write actual code later today.

Trim() will trim from the start as well, which I believe wouldn't be valid. I also was originally doing the loading into s[0] and I had int i; outside of the loop (to reuse it in the return) which I believe ultimately added bytes

sed, 126 bytes
:a;N;$!ba;s,#[^\n]*\n,#,g;s,^,#,;:;/#[^ ]/{/^# /s,^# *,,;t;H;s,#.,#,g}
t;/#[^ ]/!{H;s,#.,#,g};t;g;s,\n#(.)[^\n]*,\1,g;s,...$,,

Requires a newline at the end of the input.
I'm sure I can golf this a little more, but I'm just happy it works for now.

Pyth, 11 bytes
PhceCSMCQ\#

A program that takes input of a list of strings on STDIN and prints a string.
Try it online
How it works
PhceCSMCQ\#  Program. Input: Q
       CQ    Transpose Q
     SM      Sort each element of that lexicographically
    C        Transpose that
   e         Yield the last element of that, giving the program ending with ' #' and some
             parts of the comments
  c      \#  Split that on the character '#'
 h           Yield the first element of that, giving the program with a trailing space
P            All but the last element of that, removing the trailing space
             Implicitly print

Perl 6, 39 bytes
{[Zmax](@_».comb).join.split(' #')[0]}

Translation of the Python solution by Dennis.
Takes input as a list of strings, and returns a string.
(try it online)

Jelly, 27 bytes
żḟ€” ;€” Ḣ€
i€”#’©ḣ@"ç/ḣ®ṪṖ

Test it at TryItOnline
Uses the strictest spec - the extra space before the comment character is removed at the cost of a byte.
Input is a list of strings.

@Erik the Golfer - maybe so, but did you see the crushing he gave me here?

TSQL, 216 175 bytes
Golfed:
DECLARE @ varchar(max)=
'hello         #Line one
              #Line two
       world! #Line three'

DECLARE @i INT=1,@j INT=0WHILE @i<LEN(@)SELECT @=stuff(@,@j+1,len(x),x),@j=iif(x=char(10),0,@j+1),@i+=1FROM(SELECT ltrim(substring(@,@i,1))x)x PRINT LEFT(@,patindex('%_#%',@))

Ungolfed:
DECLARE @ varchar(max)=
'hello         #Line one
              #Line two
       world! #Line three'

DECLARE @i INT=1,@j INT=0
WHILE @i<LEN(@)
  SELECT @=stuff(@,@j+1,len(x),x),@j=iif(x=char(10),0,@j+1),@i+=1
  FROM(SELECT ltrim(substring(@,@i,1))x)x
PRINT LEFT(@,patindex('%_#%',@))

Fiddle

Dyalog APL, 22 bytes
Inspiration.
(⎕UCS¯2↓⍳∘35↑⊢)⌈⌿∘⎕UCS

(
 ⎕UCS character representation of
 ¯2↓ all but the last two of
 ⍳∘35↑ up until the position of the first 35 ("#"), in that which is outside the parenthesis, taken from
 ⊢ that which is outside the parenthesis
) namely...
⌈⌿ the columnar maximums
∘ of
⎕UCS the Unicode values
TryAPL online!

How many bytes?

Ruby, 77 bytes
puts File.readlines("stack.txt").join('').gsub(/\s{1}#.*\n/,'').gsub(/\s/,'')

Hardcoding an input filename is not an acceptable method of input.

@Mego, where can I find the rules of what's "acceptable"?

http://meta.codegolf.stackexchange.com/q/2447/45941


text:
Source code GO!
Let's use augmented reality to hunt small creatures hidden in source-code. Write a quine program that outputs its own code source, except for 5 consecutive characters that will be modified and that will display a PCG-mon : (^_^)
The 5 consecutive characters can be positioned anywhere in the source code (from position 0 to n-5, n being the source code length). The source code must have a minimum length of 5 characters. The string (^_^) or any of its substring of length >=2 must not appear in initial source code, only in output.
Example of valid submission:

source code my source code, output my (^_^)e code

Invalid:

source code (^_^) copy;, output (^_^) (^_^)

Winning criteria
The shortest code in bytes wins.

Not to be overly negative, but this is a generalised quine and a do x without y problem. In a language with a general quining method, this is rather dull. You also haven't specified what should happen if your source code is 5 bytes or fewer.

@Fry I don't think it's possible to display the 5 characters (^_^) with a source code with less than 5 characters ? maybe with specific encoding...

@SuperChafouin no, but it's possible in 5 characters.

While I'm not certain that it is possible in this case, it is rather trivial to create a program that prints more bytes than it contains. For example, the Pyth program G produces the output abcdefghijklmnopqrstuvwxyz.

I'd recommend that programs should be at least 6 characters, just so nobody tries, say, Bubblegum.

@FryAmTheEggman The line between a dull and an interesting generalised quine is rather fine. My meta answer is mostly referring to quines where the only viable solution is to obtain a string representing the entire source code and then processing that string. If there are solutions that can get away without constructing the full source code at some point, I think that usually already allows for interesting solutions (e.g. the currently leading CJam answer). As for the do X without Y, the restriction on substrings seems necessary to avoid trivial (quine) solutions.

@Sp3000 I don't think it would work, since (^_^) is alerady explicitly forbidden.

@EriktheGolfer \x30\xeb\x97\xaa (4 bytes) outputs (^_^) in Bubblegum

@Sp3000 Is it valid DEFLATE or LZMA 2?

@EriktheGolfer Neither - if it's not a valid compression scheme Bubblegum defaults to base 96 encoding

@Sp3000 I let you post it as an answer, although I don't think it's valid at all. You would need a filler byte, because the 5 bytes will be modified, not modified or added or both. Maybe a trailing newline would help here.

@EriktheGolfer I wasn't intending on posting it, I'm just demonstrating that Fry's initial question needs an answer.

@all added minimum source code size requirement.

@MartinEnder You're right, I spoke a bit too harshly in my comment. I think my second sentence could have been better ended with "this can be done easily". I more meant it as a warning that posts may devolve into generalised quines with basic restricted source workarounds.

Javascript ES6, 44 bytes
$=_=>`$=(\^\_\^\)${($+'').slice(5)};$()`;$()

Output:
$=(^_^)=(\^\_\^\)${($+'').slice(5)};$()`;$()

Still working on golfing, but it works for now.

+1 for having another face: =_=

Can't you do $=_=>\(^_^)${($+'').slice(3)};$()`;$()` (it actually looks even nicer because now it looks like you're waking up a sleeping face). :)

Vim, 33, 27 keystrokes
qqqqqS(<C-v>94_<C-v>94)q@q<esc>hh"qPq@q

Note that <C-v> means ctrl+v, and is byte 0x16 and <esc> is the escape character, and is byte 0x1B.
This just uses a slightly modified version of my Golf you a quine for great good! answer.
Outputs:
(^_^)S(^V94_^V94)q@q^[hh"qPq@q

This is valid since ^V is the way vim represents <C-v> and ^[ is the way vim represents <esc>.
The basic idea, is just to input the text (^_^) by its code points so we can avoid putting those characters in the source code. In insert mode, <C-v>number will insert the ASCII character of "number". However, since the challenge says:

The string (^_^) or any of its substring of length >=2 must not appear in initial source code, only in output.

This answer abuses the "substring" rule by only entering the codepoints of the ^ characters, and entering (, _, and ) directly.
Here's a gif that lets you see this solution in action, and puts the source code and output side by side for comparison:

pretty sneaky, using the ^ control char... +1

CJam, 13 11 bytes
"(_)"
_p'^*

Online interpreter (-2 bytes thanks to @MartinEnder).
"(_)"             Push string
      _p          Duplicate and print repr with newline
        '^*       Join string with '^'

CJAM, 16 15 bytes
Try it here.
{"^(_)"(*}_~sss

Python, 115 111 107 bytes
def f():s='def f():s=%r;print s%%s.replace(s[:5],"^".join("(_)"))';print s%s.replace(s[:5],"^".join("(_)"))

Call f() and the output is:
def f():s='(^_^)():s=%r;print s%%s.replace(s[:5],"^".join("(_)"))';print s%s.replace(s[:5],"^".join("(_)"))

Inspired in part by this answer to a similar question.

Welcome to the site!

JavaScript (ES6), 91 bytes
There's already a JavaScript answer, but there's not a non-source-reading JS answer:
a="a=%s;co%s.log(a,uneval(a),`(${'^'}_${'^'})`)";console.log(a,uneval(a),`(${'^'}_${'^'})`)

This is based on my non-source-reading answer to Golf you a quine for great good!. Outputs
a="a=%s;co%s.log(a,uneval(a),`(${'^'}_${'^'})`)";co(^_^).log(a,uneval(a),`(${'^'}_${'^'})`)

This can easily be modified by moving around the second %s in the string. For example,
a="a=%s;console.log(a,uneval(a),`($%s_${'^'})`)";console.log(a,uneval(a),`(${'^'}_${'^'})`)

outputs
a="a=%s;console.log(a,uneval(a),`($%s_${'^'})`)";console.log(a,uneval(a),`($(^_^)_${'^'})`)

Go (golang), 131 bytes
This challenge must have an answer in Go!
package main;import"fmt";func main(){a:="package main;import\"fmt\";func(%c_%[1]c)(){a:=%q;fmt.Printf(a,94,a)}";fmt.Printf(a,94,a)}

Try it online!

Jelly, 22 bytes
“4094959441b³ỌØV”ṘVabc

Available at TryItOnline
Uses the built-in payload capable quine “ØV”ṘV
The abc on the end is just filler to be replaced
b³ converts the integer into base 100, resulting in [40,94,95,94,41]
Ọ casts to characters, resulting in (^_^)
So the whole result is “4094959441b³ỌØV”(^_^)

C# 5.0, 715 bytes
I know, this is huge. Just wanted to add a C# solution.
/*^()_*/using System.CodeDom;namespace System{class P{static void Main(){var b="/*^()_*/using System.CodeDom;namespace System{{class P{{static void Main(){{var b={0};var f=new string(new[]{{b[3],b[2],b[5],b[2],b[4]}});var w=new IO.StringWriter();CodeDom.Compiler.CodeDomProvider.CreateProvider(\"CSharp\").GenerateCodeFromExpression(new CodePrimitiveExpression(b),w,null);Console.WriteLine(b.Replace(\"[4]}}}}}}}}\",f),w);Console.ReadKey();}}}}}}";var f=new string(new[]{b[3],b[2],b[5],b[2],b[4]});var w=new IO.StringWriter();CodeDom.Compiler.CodeDomProvider.CreateProvider("CSharp").GenerateCodeFromExpression(new CodePrimitiveExpression(b),w,null);Console.WriteLine(b.Replace("[4]}}}}",f),w);Console.ReadKey();}}}

The output is:
/*^()_*/using System.CodeDom;namespace System{class P{static void Main(){var b="/*^()_*/using System.CodeDom;namespace System{{class P{{static void Main(){{var b={0};var f=new string(new[]{{b[3],b[2],b[5],b[2],b[4]}});var w=new IO.StringWriter();CodeDom.Compiler.CodeDomProvider.CreateProvider(\"CSharp\").GenerateCodeFromExpression(new CodePrimitiveExpression(b),w,null);Console.WriteLine(b.Replace(\"[4]}}}}}}}}\",f),w);Console.ReadKey();}}}}}}";var f=new string(new[]{b[3],b[2],b[5],b[2],b[4]});var w=new IO.StringWriter();CodeDom.Compiler.CodeDomProvider.CreateProvider("CSharp").GenerateCodeFromExpression(new CodePrimitiveExpression(b),w,null);Console.WriteLine(b.Replace("(^_^)}}",f),w);Console.ReadKey();}}}

Available at Ideone.com

Bash, 178 bytes
Q='#(8_8)
printf "Q=\47"
echo -n "$Q"|sed -r "s~(_|\()8~\1^~g"
echo -e "\x27"
tail<<<"$Q" -n4'
printf "Q=\47"
echo -n "$Q"|sed -r "s~(_|\()8~\1^~g"
echo -e "\x27"
tail<<<"$Q" -n4

Pfff, I am not good at quines :/ Any suggestion to golf it more is more than welcome! :-)

MATL, 14 bytes
')_`_*i't&Dwqh

Produces the output ')_`_*i'(^_^)h.
Try it online!
Explanation
')_`_*i'  % Push this string
t&D       % Duplicate and get string representation (i.e. enclose with quotes)
w         % Swap
q         % Subtract 1. Transforms ')_`_*i' into the code points of '(^_^)h'
h         % Concatenate. Automatically casts code points to chars. Implicitly display

My first attempt at a quine!