text:
Text Processing #1: Hyphenation
Background
This is the first part of a 3-hole golf course on text processing.
The over-arching idea is that if you take an input text and pipe it through the solutions to all three challenges (with a small amount of glue code), it will spit out a beautifully formatted paragraph.
In this first challenge, your task is a hyphenate a piece of text using given hyphenation patterns.
Input
Your program shall take two string inputs: a piece of text and a list of hyphenation patterns.
The first input is simply a non-empty string of printable ASCII characters and spaces; it will not contain line breaks or tildes ~.
The second input is a comma-delimited list of words, which consist of tilde-delimited syllables of lowercase ASCII characters.
An example is ex~cel~lent,pro~gram~ming,abil~i~ties.
Output
Your program shall modify the first input in the following way.
Any word (maximal substring of alphabetical ASCII characters) whose hyphenated lowercase version is found in the second input shall be replaced by that hyphenated version, but its case shall be preserved.
With the above example list, if the text contains the word Excellent, it shall be replaced by Ex~cel~lent; however, Excellently shall not be modified.
Your output shall be this modified string.
Detailed Rules and Scoring
You can assume the following about the inputs:

The first input contains no tildes, and no leading, trailing or repeated spaces. It is not empty.
The second input contains at least one word, and each word in it contains at least two syllables. Each syllable is non-empty.
The second input does not contain a word that occurs as a syllable in another word.

You can change the order of the two inputs, if desired, and optionally add one trailing newline to the output.
You can write a function or a full program.
The lowest byte count wins, and standard loopholes are disallowed.
Test Cases
These are listed in the format 1st input [newline] 2nd input [newline] output.
Excellent programming abilities, you work excellently!
ex~cel~lent,pro~gram~ming,abil~i~ties
Ex~cel~lent pro~gram~ming abil~i~ties, you work excellently!

Superman (sometimes incorrectly spelled "Super-man") is super #&%@ing strong.
su~per,some~times,in~cor~rectly,spell~ing
Superman (some~times in~cor~rectly spelled "Su~per-man") is su~per #&%@ing strong.

IncONsISTent caPItalizATIon!
in~con~sis~tent,cap~i~tal~iza~tion
In~cON~sIS~Tent caP~I~tal~izA~TIon!

Such short words.
awk~ward
Such short words.

Digits123 are456cool789.
dig~its,dig~i~tal,are~cool
Dig~its123 are456cool789.

magic magic
ma~gic
ma~gic ma~gic

Any possible hyphenation error in this challenge is due to this hyphenation tool.

I assume the input is standard 7-bit ASCII, and not some extended 8-bit version?

Is it okay to assume that any non-alphanumerical character will not count as a change to a word (e.g. a first input like #programming! will be still be affected by a second input of pro~gram~ming)? Do numbers also not count (i.e. are only alphabetical characters allowed)?

@orlp Yes, input consists of standard printable ASCII characters as listed here.

@Cole Non-alphabetical characters are not part of words (see the second test case). Digits count as non-alphabetical, I'll add a test case about that.

Can I assume some maximum number of syllables in one word?

Actually I was wrong - I don't need this.

Please, add a test case: magic magic ma~gic ma~gic ma~gic.

@Qwertiy Thanks, I'll do that. Also, for the record, there is no limit for the number of syllables.

Where are Part 2 and Part 3 of this? Can you link from the question?

Pip, 60 54 bytes
Fwa^`([A-Za-z]+)`O{aQ'~?'~w@++y}M(LCwQ_RM'~FIb^',Yv)|w

GitHub repository for Pip
Takes inputs as command-line arguments (which necessitates quotes around input 1, assuming it contains spaces). No trailing newline is printed (add an x to the end of the program to add one).
Somewhat ungolfed, with comments:
 ; Split 1st input on runs of letters, including the separators in the results
a^:`([A-Za-z]+)`
 ; Split 2nd input on commas
b^:',
 ; Iterate over the words w in that list
Fwa {
  ; Filter b for entries that match the current word (lowercase, with tildes removed)
 m:(LCw EQ _RM'~)FIb
  ; We expect this to be a list of 0 or 1 elements
  ; If it has one, m gets that element (the hyphenation pattern); if it's empty, m gets nil
 i:-1
 m:m@i
  ; Map this function to each character of pattern m: if it's tilde, return tilde;
  ; otherwise, return corresponding character of w
 m:{aEQ'~ ? '~ w@++i}Mm
  ; Output the result, unless it was nil (falsey), in which case output the original word
 Om|w
}

Sample run:
C:\Users\dlosc> pip.py hyphens.pip "IncONsISTent caPItalizATIon!" in~con~sis~tent,cap~i~tal~iza~tion
In~cON~sIS~Tent caP~I~tal~izA~TIon!

Retina, 88 bytes
+is`(?<![a-z~])([a-z~]+)(?=([a-z]+)+[^a-z~].*(?<=[\n,]\1(?(2)!)(?<-2>~\2)+[\n,]))
$1~
\n.*
<empty>

For counting purposes, each line goes into a separate file, \n are replaced with actual newline characters and <empty> is an empty file. For convenience, you can run the above code from a single file (where <empty> is an empty line) if you use the -s interpreter flag.

Javascript ES6, 117 141 chars
f=(t,p)=>p.split`,`.map(p=>t=t.replace(RegExp("((?:^|[^a-z])"+p.replace(/~/g,")(")+")(?=$|[^a-z])","ig"),(...x)=>x.slice(1,-2).join("~")))&&t

Test:
document.querySelector(".question pre").textContent.split("\n\n").map(t=>(t=t.split("\n"))&&f(t[0],t[1])==t[2])
// Array [ true, true, true, true, true ]

You can use eval instead of RegExp constructor. String templates may also save a few bytes

Javascript (ES6), 173 169
Basic regex search and replace
(a,b)=>(b.split`,`.map(s=>a=a.replace(eval(`/(^|[^a-z])(${s.replace(/~/g,"")})(?=[^a-z]|$)/gi`),(_,n,o)=>(x=0,n+s.split``.map((q,i)=>(q=='~'&&++x?q:o[i-x])).join``))),a)

Fiddle
Edit: Fixed bug for test case magic magic, ma~gic

Wrong: f("magic magic", "ma~gic") returns "ma~gic magic"

@Qwertiy fixed. Somehow fixing it saved me 4 bytes too!

Perl, 146
$a=<>;$d=$_=~s/~//rg,$a=~s/(?<!\pL)$d(?!\pL)/h($&,$_)/gie for(split/,|\n/,<>);
print$a;
sub h{($g,$h)=@_;while($h=~/~/g){substr($g,"@-",0)='~'}$g}

Just a first attempt, lots of things can be shortened - will continue tomorrow!


text:
Output optimal trill fingerings
Note: all array references in this post are zero-indexed.
When playing the piano, two notes on the same key must be pressed with two different fingers. You could use the same finger, but it doesn't sound as good. At least, according to my piano teacher. I can't hear any difference.
The challenge is to take a space-separated list of 3 integers: Starting finger, ending finger, and length of repeating notes, and output the optimal sequence of finger numbers to match the input.
All piano jargon aside, output a string of numbers based on the input, where each number is +1/-1 the one before it, all numbers are between 1 and 5, the sequence is args[2] digits long, starting with args[0] and ending with args[1], and is formatted as below.
The input can be command line arguments, values on the stack (for ><> users), STDIN, or any other conventional method.
Output will be a list of numbers, with these being valid outputs.

[1, 2, 3, 4, 5]
(1 2 3 4 5)
"12345"
12345*
1-2-3-4-5**
1 2 3 4 5**

For each asterisk on the style above, compute the following to calculate your score:
final-score = code.length * (1.00 - (asterisks * 0.05));

You can assume the first two params will be between 1 and 5, but if it handles at least 0-9, multiply your code by 95%.
If the last digit is less than 2, or the input parameters are impossible, error however you like, or just exit.

Finger numbers on the piano work like this, however this is not integral to the challenge.
1 | Thumb
2 | Index finger
3 | Middle finger
4 | Ring finger
5 | Pinky (finger)

Sample input and output:
Input: 1 2 2
Output: 1 2
Input: 1 4 8
Output: 1 2 3 2 3 2 3 4
Input: 2 3 10
Output: 2 3 2 3 2 3 2 3 2 3
Input: 5 2 1
Output: Error
Input: 1 2 5
Output: Error
Input: 5 1 5
Output: 5 4 3 2 1
Input: 1 1 1
Output: 1

These do not have to be handled correctly.
Input: 1 6 6
Output: 1 2 3 4 5 6
Input: 0 9 8
Output: Error

I had the scoring wrong, everyone who's posted an answer please fix it. I'm really sorry D:

You can just divide your score by 100 to get the new score, at least with no bonuses

You may want to add an example where the end value is smaller than the start value (which seems legal based on the description). For example, 4 1 8, with possible solution 4 3 2 3 2 3 2 1.

yes, that's legal, I just forgot. thanks

Pyth, 36 * .95 * .90 = 30.78
jd+JrFAQ<*vz,H.xeJhH?&%K-vzlJ2>K0K.q

Test suite
Outputs space separated integers and can handle arbitrary integer inputs, so it qualifies for both bonuses.
Input format:
length
starting finger, ending finger

The output is constructed by starting with a range from the starting finger to the ending finger, then repeating the end of that range and the ending finger the necessary number of times. Exiting is done via explicit checks for the length of the second step being odd and positive, or else .q, Pyth's exit function is called.

I get part of the output in square brackets when I run the examples using the test link.

It was a bug with the update to the Pyth interpreter. I fixed it. @RetoKoradi

Javascript (ES6), 148 146 * 0.95 * (1.00 - (0 * 0.05)) = 138.7
(a,b,c)=>c<(m=Math.abs(a-b))?0:eval('l=a,q=Array(m+1).fill().map(_=>a<b?l++:l--);while(q.length-c)q=q.concat(q.slice(-2,-1));q[q.length-1]-b?0:q')

Note: My way of indicating an "error" is returning 0 (chosen to save bytes of course).
The normal return type is a Javascript array. I'm not sure if that's an acceptable output format. If it isn't, I guess I'll have to add JSON.stringify(...).
I think I get the 5% reduction since this can technically handle any range of numbers you want.
Edit: Saved 2 bytes thanks to @Ypnypn

You can replace each >= with < by reversing the arguments.

I can't run this with node, what am I doing wrong? It doesn't error, and the prompt goes from > to ...

@ConfusedMr_C Even node --harmony doesn't yet support lambdas afaik. Try it in the latest version of Firefox.

CJam, 50 bytes * 0.9 * 0.95 = 42.75
q~_$_@<\~),>@1$,-_0<1$2%e|{];}{2/1$-2>*+S*\{W%}&}?

Try it online
Code length is 50 bytes. If I understand them correctly, it qualifies for all bonuses. It outputs space separated values (-10%), and works for values outside the range 1 to 5 (-5%).
The input format is:
length [startValue endValue]

The sequence produced is first the range from start value to end value, then the last 2 values repeated until the specified length is reached.
Explanation:
q~    Get and interpret input.
_$    Copy and sort start/end value pair.
_@<   Copy and compare sorted and unsorted start/end values. Will use the
      sorted one, but reverse the entire sequence at the end if the start
      value was larger than the end value.
\~    Get sorted start/end value to top, and unwrap it.
),    Generate range [0 .. endValue].
>     Slice off values to get range [startValue .. endValue].
@     Get specified number of values to top.
1$,   Get list length of values we already generated.
-     Subtract. This gives the number of values that still need to be generated.
_0<   Check if number is less than 0.
1$2%  Check if number is odd.
e|    Logical or. If one of the two conditions is true, there is no solution.
{     If branch for no solution.
  ];    Clear stack. Will produce empty output for no solution.
}     End of branch for no solution.
{     If branch for producing solution.
  2/    Divide remaining count by 2. Will repeat last two values this many times.
  1$    Copy already produced values to top.
  -2>   Slice off last 2 values.
  *     Repeat them.
  +     Add to already produced sequence.
  S*    Join with spaces.
  \     Swap condition for start value greater than end value to top.
  {W%}& Reverse sequence if needed.
}?    End of if for solution vs. no solution.

source: Stack Exchange

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

sort: votes


text:
The Swift Make-It-Compile Challenge #4
This is a challenge for the people using Swift 2.0 beta 6, it's not code golf, but it's a programming puzzle so I'm pretty sure this belongs here. The basic idea is: Make it compile. There are more details and a very nicely formatted playground at the Github project. Previous challenges are there as well, all set up to tinker. Solutions are included for the previous challenges, as they all have been solved.
Rules

You can't modify the given lines
You can't insert anything between the given lines
You can't provide custom functions for ones that are in the standard library, according to the syntax-hightlighed picture. This applies to the inverse as well.
The given lines are not allowed to produce a warning (on default warning settings). However the code you append is allowed to produce warnings.
The code may or may not crash at runtime, it only has to compile

The Code
func doIt(inout s: D) {
    if case self = isUniquelyReferenced(&s),
        self.`self` = true where self {
        self.`self` = { [unowned x = [self, 7] as Self] n in
            print(x + n)
        } as () -> ()
    }
}

The Picture

Winner
The first one posting an answer that compiles and conforms to all the rules above wins and gets an entry in the projects Hall of Fame.
EDIT: Hint
Upon submission of Chris Goldsby's 99% solution, he received the following hint:

The syntax highlighting of

protocol P {
    typealias P
    var p : P { get }
}

Instead of just saying "latest swift beta version", could you specify which version that is, so that updates to swift don't break anything?

@isaacg Changed it, thanks :)

What's to stop me from commenting out all the lines?

@feersum The third rule, picture has to match

I believe this could be edited to fix it... but I don't know Swift, so I can't do it. Future reviewers , please try.

I'm posting this answer on behalf of Chris Goldsby who managed to submit a
99% Solution (Gist):
typealias D = NonObjectiveCBase

func ~=(left: Any, right: Bool) -> BooleanType {
    return true
}

func +(left: Any, right: Any) -> String {
    return ""
}

protocol 🐢: class, BooleanType, ArrayLiteralConvertible {

    var `self` : () -> () { get set }
}

extension 🐢 {

    typealias Element = Any

    internal init(arrayLiteral elements: Any...) {
        self.init()
    }

    //

    func doIt(inout s: D) {
        if case self = isUniquelyReferenced(&s),
            self.`self` = true where self {
            self.`self` = { [unowned x = [self, 7] as Self] n in
                print(x + n)
            } as () -> ()
        }
    }

    //

}

Only the snytax highlighting of D doesn't match. That's remarkable as it is!
100% Solution
EDIT: Two days later he submitted the following full solution, congrats!:
private func ~=(left: Any, right: Bool) -> BooleanType {
    return true
}

private func +(left: Any, right: Any) -> String {
    return ""
}

protocol Challenge4: class, BooleanType, ArrayLiteralConvertible {

    typealias D

    var `self` : () -> () { get set }

    func doIt(inout s: D)
}

private extension Challenge4 where D == NonObjectiveCBase {

    typealias Element = Any

    init(arrayLiteral elements: Any...) {
        self.init()
    }

    //

    func doIt(inout s: D) {
        if case self = isUniquelyReferenced(&s),
            self.`self` = true where self {
            self.`self` = { [unowned x = [self, 7] as Self] n in
                print(x + n)
            } as () -> ()
        }
    }

    //

}

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