text:
Find words that rhyme
Challenge
Joe the rapper is struggling with rhyming words in his lyrics. He needs your help.
For this situation, we will use rhymes where the last syllable in a word is the same as the other word (spelled the same).
When Joe inputs a word, the program will read a list of words from a file and output those that rhyme with Joe's word.
To show that the program works, we will only need to use a small list.
txt File:
hello
joe
crew
flow
time
apple
heart
glow
rhyme
art
jello
grew
doe
flue
blow
smart
dime
cat
slime
show
bedtime
clue
grime
toe
dart
cart
brew
snow
prime
hat
chart
lime
blue
knew
lunchtime
restart

Examples
Input: snow
Output: blow flow glow show Note- Should not output the input
Input: fart
Output: restart art dart cart chart smart heart Note- Should work for inputs not in list
Input: crime
Output: time slime prime grime dime lime bedtime lunchtime Note- Should work for all syllables
Rules

Should output all words that rhyme with input
does not need to output rhymes with different letters Ex: Crime should not output rhyme
Should not output the input
Should work with inputs not in the list
Should work will all syllables

Shortest Bytes Wins!

Define "rhyme". Does "bedtime" rhyme with "clue"?

See comments on http://meta.codegolf.stackexchange.com/a/7014/194 for a suggestion as to how to make "rhyme" well-specified.

@Peter I think JoshK is looking for something simpler than phonetic rhyming. does not need to output rhymes with differet letters and snow --> blow flow glow show (but not toe) Anyway, Josh, a proper definition is required. Given examples follow the rule of last vowel and all consonants after it (this works for chart & heart but would fail for chat & heat.) As shown by Kenny Lau's example,  matching the whole of the last vowel cluster (and any following  consonants) may be better but would make heart invalid. Voting to close until resolved. (personally I'd get rid of heart)

As you haven't been here that long, I'll point out that the reason for close voting is nothing personal, it's to temporarily stop the posting of answers before the rules have been fully clarified (as is happening right now.) You could try posting your next challeng in the sandbox for feedback first before posting on the main site http://meta.codegolf.stackexchange.com/q/2140/15599

Do though, through, and rough rhyme?

Ruby, 68 bytes
FGITW. Full program, takes file and word from command line: ruby script.rb words.txt "hello".
Assumes the last syllable (or rather, the section of the syllable to match against for the purposes of rhyming) is at least 2 characters long, or more if there are extra vowels before that.
f,w=$*
w=~/[aeiou]*..$/
puts open(f).map(&:chomp).grep(/#{$&}$/)-[w]

JavaScript (ES6), 67 bytes
(a,w)=>a.filter(s=>s!=w&s.endsWith(w.replace(/.*([aeiou].)/,"$1")))

Function that accepts an array of words and an input word as parameters. Uses the definition of rhyme as the substring of the word starting at the last vowel before the last letter.

a=
(a,w)=>a.filter(s=>s!=w&s.endsWith(w.replace(/.*([aeiou].)/,"$1")))
;
u=w=>r.value=a(f.value.split`\n`,w).join`\n`
File:
<textarea rows=5 id=f>
hello
joe
crew
flow
time
apple
heart
glow
rhyme
art
jello
grew
doe
flue
blow
smart
dime
cat
slime
show
bedtime
clue
grime
toe
dart
cart
brew
snow
prime
hat
chart
lime
blue
knew
lunchtime
restart
</textarea>

Word:
<input oninput="u(this.value)">

Rhymes:
<textarea rows=5 id=r>
</textarea>

What is your definition of rhyme? You should state it in English (not just code) in the answer. Better still, wait for the OP to clarify the rules before posting.


text:
Randomly Assign People to Tasks
The challenge is to assign people to tasks randomly~.
From stdin you get 2 lines. Line one is a comma-separated list of names. Line 2 is a comma-separated list of jobs.
The output required is one line per task person combo.
The line should be formatted as Name:task.
If there are not enough people for jobs or vice verse then they will not be output.
~ Randomly is defined as each run with the same input has a reasonably different output.
Example Input:
Bob,John,Susan,Josie,Kim,Tom
Bins,Floor,Windows

Example Output:
Bob:Windows
Susan:Bins
Kim:Floor

Can there be only two possible outputs?

Also, usually we don't like to restrict on the input format.

@KennyLau what makes you think there could only be two possible outputs?

@KennyLau Also, sorry about specifying the input format, I actually don't care just thought I should specify something. I am used to stack overflow being really precise about the details provide for questions assumed it might extend here :)

I mean, can we randomly choose one from only 2 possible outputs?

Is the output format strict? Or would something like ['Bob', 'Windows'] be okay?

05AB1E, 7 bytes
Code:
.r².r)ø

Try it online
Following the input/output spec strictly (16 bytes):
.r².r)øvy`r?':?,

Explained:
.r                # radomize first input
  ².r             # randomize second input
     )ø           # merge the lists to an array of pairs cutting out extras
       vy`r?':?,  # format output

Try it online

Java 7, 240 239 238 bytes
import java.util.*;class M{public static void main(String[]a){String[]p=a[0].split(",");List j=new ArrayList(Arrays.asList(a[1].split(",")));for(int i=0;j.size()>0;)System.out.println(p[i++]+":"+j.remove((int)(Math.random()*j.size())));}}

Can most likely be golfed more with some arrays magic, instead of List j=new ArrayList(Arrays.asList(a[1].split(",")));..
Ungolfed:
Try it here
import java.util.*;

class M{
    public static void main(String[] a){
        String[] p = a[0].split(",");
        List j = new ArrayList(Arrays.asList(a[1].split(",")));
        for(int i = 0; j.size() > 0;){
            System.out.println(p[i++] + ":" + j.remove((int)(Math.random() * j.size())));
        }
    }
}

Pyth, 6 bytes
CmO.pd

Try it online!
How it works:
CmO.pd
        (implicitly) takes the evaluated input
 m   d  for each "line":
   .p       generate all permutations
  O         choose one randomly
C       truncating transpose

Following strictly the input/output format:
(16 bytes)
jjL\:CmO.pcd\,.z

Try it online!
How it works:
jjL\:CmO.pcd\,.z
              .z  takes all lines
      m    d      for each line:
          c \,        split by ","
        .p            generate all permutations
       O              choose one randomly
     C            truncating transpose
 jL\:             join every pair by ":"
j                 join all pairs by newlines

Realy nice, I have only ever done golf in python, I should learn pyth

The last edit seems to break the random on each run part. but still cool :), ohh you updated again nvm

This edit should be random.

Jelly, 13 bytes
Œ!€X€ZL’$ÐfŒṘ

Try it online!

Mathcad, [tbd] bytes

csort(M,n) sorts matrix M on column n.
augment joins two arrays columnwise.
runif(n,a,b) returns a vector of n uniformly-distributed numbers over the range a..b.
concat(a,b) concatenates strings a and b.
With due apologies to Messrs Gilbert and Sullivan.

Mathcad scoring system yet to be determined (must get round to posting something on Meta ...).  However, this solution clearly wouldn't be a contender for anything other than a Programming Language specific leaderboard.   Taking a rough keyboard equivalence, and noting that Mathcad uses keyboard shortcuts for entering programming and some other operators, it takes around 100 "bytes".

JavaScript (Firefox 30-57), 82 bytes
(a,b,s=a=>a.sort(_=>Math.random()-.5),c=s(b))=>[for(x of s(a))if(c[0])[x,c.pop()]]

Uses bogus sort to shuffle. Version which accepts two string parameters of comma-separated names and returns lines of colon-separated matchups for 110 bytes, where \n represents the literal newline character:
(a,b,s=a=>a.sort(_=>Math.random()-.5),c=s(b.split`,`))=>[for(x of s(a.split`,`))if(c[0])x+':'+c.pop()].join`\n`

Q, 38 Bytes
t:{$[n:&/#:'x:{(-#x)?x}'x;+n#/:x;0N]}

NOTE.- input and output format not exactly as proposed (see test)
Test
."\\S ",$7h$.z.t    /To accomplish a random output we mofify seed based on internal clock
t(`Bob`John`Susan`Josie`Kim`Tom; `Bins`Floor`Windows)
/generates (`Susan`Windows;`Kim`Bins;`John`Floor) (a different result each run)

Explanation
(-seqLen)?seq Shuffles the sequence
x:{(-#x)?x}'x shuffles each sequence of x (argument with sequence of names and sequence of works) and reassign to x
n:&/#:'x Assigns to n the minimum over (&/) each sequence lengths (#:'x)
$[n;+n#/:x;0N] If n (if n is not 0), executes flip n take of each seq, Else returns null

Ruby, 69 bytes
n=gets.split(/,|\n/).shuffle;puts gets.split(',').map{|j|n.pop+':'+j}

Ungolfed:
names = gets.split(/,|\n/).shuffle
jobs = gets.split(',')
jobs.each do |job|
    name = names.pop
    puts "#{name}:#{job}"
end

source: Stack Exchange

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

sort: votes


text:
RegEx-golf: match all contents in a string
Your task is to write a RegEx that matches everything inside strings.
A string is defined as everything surrounded by (but not including) two unescaped ".
A " can be escaped by \, which can also be escaped again.
Testcases
string:  ab\c"defg\\\"hi"jkl"mn\\\\"opqrst""
matches:      ^^^^^^^^^^     ^^^^^^        ^ (the empty string)

Scoring
Shortest solution wins.
Specs

Please specify the flavour used.
The input will have balanced ".
There will be no \ that immediately precedes a string-beginning-delimiter. For example, you would not need to handle abc\"def"

Will there be \ before a string? For example abc\"def".

Should it match each string in one group? For example, could I write something that has two matches in abc"de", one is d and the other is e?

It is allowed .

Will there be empty strings?

Yes, there will be empty strings.

PCRE, 21 20 15 19 bytes
(.|^)"\K(\\.|[^"])*

Try it here.
This matches a character (or the beginning of the input) before the beginning double quote and then reset the match, to make sure the double quote isn't shared with another match.
PCRE, 25 23 bytes
Thanks to Martin Büttner for golfing off 2 bytes.
(\\.|[^"])*+(?!"(?R)|$)

Try it here.
Explanation
(
    \\.|[^"]     # An escaped character, or a character that isn't a double quote
)*+              # Possessive zero-or-more quantifier, which means backtracking
                 # could not happen after first match is found. That means if \\.
                 # matched, it would never switch to [^"], because it is always a
                 # match if it just stopped after the \\. without backtracking.
(?!"(?R)|$)      # Make sure it is not followed by a double quote and another
                 # match, or the end of the input.

Note that the possessive quantifier (*+) made sure the negative lookahead always begins after a whole string, or a whole segment of non-string.
There are 4 cases:

The match begins anywhere outside of a string. \\. would never match a double quote according to the clarification. It could only end just before the next double quote which begins a string, or the end of input. Both cases fails the negative lookahead.
The match begins at the beginning of a string. (\\.|[^"])*+ would match a complete string. The next character must be a double quote, and couldn't be the end of input. After the double quote it is outside of the string, so it couldn't be another match. So it passes the negative lookahead.
The match begins at the end of a string. It matches an empty string in the same way as the previous case. But it doesn't matter according to the clarification.
The match begins in the middle of a string. Impossible because matches don't overlap.

Would (\\.|[^"]) work?

@MartinBüttner that matches everything except "

@Bálint I meant in place of ([^\\"]|\\.), not as the complete solution.

@MartinBüttner Oh, ok

Martin's suggestion should work, since \\. only fails when there is no character after \ (or new line character, but that can be fixed with flag), and that case is covered by the negative look-behind. The possessive quantifier prevents backtracking, so we have no other case to look at.

@MartinBüttner Yes, it works thanks to the +. The quick reference on Regex101 "backtracking can't reduce the number of characters matched" seemed to be a lie.

Technically not wrong, since there aren't any backtracking at all.

I would love it if you could include an explanation. After all, the recursion obfuscates it.

@KennyLau Edited.

@mbomb007 The input will have balanced ".

JavaScript, 24 bytes
"([^"\\]*(?:\\.[^"\\]*)*)"
Group 1 is the contents of the string.

This doesn't at all work with escaped quotes, and thus fails to meet the spec.

Ah yes--sorry. How about that?

Close but no cigar, you shouldn't be matching the outer "s

Yeah, that's what I was afraid of. No way of doing it in JavaScript, I'm guessing?

You can capture it in a subgroup

But it would still match the whole thing, right?

The "Whole thing" may match it, but the contents needs to be in a distinguishable capture group separate from the "s.

So that would be okay? It was unclear from the original post, as it only talked about "matches."

To my knowledge, yes.

Basically, I knew how to group just the contents; I didn't know what was allowed to complete the task.

Cool. Thanks for your help, @ATaco!

JavaScript, 21 15 13 12 bytes
"((\\?.)*?)"
String contents are in group 1.
"   #start of string
(    #capturing group
 (
  \\?. #match character or escaped character
 )*?  #match as few as possible
)
"   #end of string

authors: n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳

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


text:
Toggle a string

The challenge involve simply toggling a string within another string.

Explanation
If the toggle string is a substring of the main string, remove all instances of the toggle string from the main string; otherwise, append the toggle string at the end of the main string.
Rules

All string are composed of printable ASCII characters
The function should take two parameters: the main string and the toggle string.
The main string can be empty.
The toggle string cannot be empty.
The result should be a string, which can be empty.
The shortest answer wins.

Examples
function toggle(main_string, toggle_string){ ... }

toggle('this string has 6 words ', 'now')
=> 'this string has 6 words now'

toggle('this string has 5 words now', ' now')
=> 'this string has 5 words'

Tests cases
'','a'          => 'a'
'a','a'         => ''

'b','a'         => 'ba'
'ab','a'        => 'b'

'aba','a'       => 'b'
'ababa', 'aba'  => 'ba'

And once it goes to the main namespace, you guys ask all sorts of questions

@KennyLau It was in the sandbox for all of 3 hours. The recommendation is 2 days.

The recommendation is actually 72 hours. The main page has much more visibility than the Sandbox, so more comments are guaranteed here. That said, this isn't a bad challenge, just has a few rough edges.

So you replace all non-overlapping instances?

You can break quite a few solutions with the test-case: 'abc.', '.', since quite a lot of them use some sort of regex.

@Jakube Yes, I should limit this to letters and number I think.

No, I think allow nonalphanumerics: it's more challenging that way.

Is the order of the function parameters fixed (main_string as first and toggle_string as second parameter) or it is allowed to change the order?

Yes, but you can propose your solution anyway, just for the challenge :)

Jelly, 7 bytes
œṣȮ⁸e⁹ẋ

Try it online!
How it works
œṣȮ⁸e⁹ẋ  Main link. Arguments: s (string), t (toggle string)

œṣ       Split s at occurrences of t.
  Ȯ      Print the result.
   ⁸e    Check if s occurs in the split s. Yields 1 (true) or 0 (false).
     ⁹ẋ  Repeat t that many times.

Java 8, 80 70 65 34 bytes
t->m->m==(m=m.replace(t,""))?m+t:m

Probably my shortest Java 'codegolf' so far.. xD
with some help from the comments.. ;)
Explanation:
Try it online.
t->m->                     // Method with two String parameters and String return-type
                           // (NOTE: Takes the toggle `t` and main `m` in reversed order)
  m==(m=m.replace(t,""))?  //  If `m` equals `m` with all `t`-substrings removed:
                           //  (And set `m` to `m` with all `t`-substrings removed)
   m+t                     //   Output this new `m` concatted with `t`
  :                        //  Else:
   m                       //   Output just this new `m`

You should be able to save quite a few by changing the if to a ternary. If nothing else, it'll get rid of the "extra" return.

@Geobits Ah, of course.. I was so enthusiastic that a single method had a 'low' byte count (in terms of java 'codegolfing') that I forgot one of the most obvious codegolfing for ifs and returns.. >.> Thanks, edited.

You can save a few more bytes by using a lambda instead of a regular function.

return m=m.replace(t,"")?m+t:m;

@KennyLau m=m.replace(t,"") isn't a boolean for the ternary if-operation.. :S And if you ment m==m.replace... instead, then the output is incorrect.

m==(m=m.replace...

@KennyLau Nice trick, thanks. I've edited the post.

MATL, 11 bytes
yyXf?''YX}h

Try it Online!
All test cases
Explanation
            % Implicitly grab the main string
            % Implicitly grab the toggle string
y           % Copy the main string
y           % Copy the toggle string
Xf          % Check to see if the toggle string is present in the main string
?           % If so
    ''YX    % Replace with an empty string
}           % else
    h       % Horizontally concatenate the two strings
            % Implicit end of if...else
            % Implicitly display the result

Python 3, 38 bytes
lambda s,t:(s+t,s.replace(t,""))[t in s]

JavaScript (ES6), 39 37 bytes
(s,t,u=s.split(t).join``)=>u==s?s+t:u

Pyke, 14 bytes
DX{iIXRk:)i!IJ

Try it here!
Given that Pyke has no else structure, I think this is pretty reasonable score
Explanation:
D              -    Duplicate input
 X             -   a,b = ^
  {            -  a in b
   i           - i = ^
    I          - if i:
     XRk:      -  a = b.replace(a,"")
         i!I   - if not i:
            J  -  a = "".join(input)
               - print a

CJam, 9
q~:B/2Be]

Try it online. Thanks jimmy23013 for chopping off 1 byte :)
Explanation:
q~     read and evaluate the input (given as 2 quoted strings)
:B     store the toggle string in B
/      split the main string by the toggle string
2Be]   pad the array of pieces to the right with B, up to length 2 (if shorter)

9 bytes: q~:B/2Be].

Pyth, 13 11 10 bytes
?/Qz:Qzk+z

Test suite.
Input format: first string in quotes, second string without quotes.
This is also 10 bytes:
?tJcQzsJ+z

Test suite.
This is 11 bytes:
pscQz*!}zQz

Test suite.
Previous 13-byte solution:
?:IQzk+Qz:Qzk

Test suite.

Also 11 bytes: ?}zQ:Qzk+Qz

Javascript (ECMAScript 6): 47 bytes
(a,b)=>(c=a.replace(RegExp(b,'g'),''))!=a?c:a+b

This can fail if the toggle string contains special characters. For example, ("a", ".") returns "" instead of "a.".

Retina, 38 31 bytes
Byte count assumes ISO 8859-1 encoding.
(.+)(?=.*¶\1$)
·
1>`·|¶.+

T`·¶

The trailing linefeed is significant. Input format is both strings separated with a linefeed.
Try it online! The first line allows running several test cases at once (for the test suite, use ; to separate the strings and linefeeds to separate test cases; the first line takes care of the conversion).
Explanation
(.+)(?=.*¶\1$)
·

In this first step we replace all occurrences of the toggle string in the main string with ·. We need to insert these markers so that we can determine afterwards if any substitution happened.
1>`·|¶.+

This is another substitution which removes a · marker, or the second line (including the separating linefeed). However, the 1> is a limit which means that only matches after the first are considered. Hence, if the toggle string did not occur in the main string, we won't have inserted any ·, so the second line will be the first match and won't be removed. Otherwise, we remove the second line along with all but the first marker.
T`·¶

While this uses a transliteration stage, it's also used simply for removing characters. In particular, we move both · and linefeeds. We need the first one, in case there was a match (because then the first · will have been left behind by the previous stage) and we need the second one in case there wasn't a match (to join the two lines together and thereby append the toggle string to the main string).

Python (3.4): 55 54 47 44 Bytes
lambda m,t:m.replace(t,'')if t in m else m+t

Testing:
toggle=lambda m,t:m.replace(t,'')if t in m else m+t
print('', 'a', toggle('','a'))
print('a', 'a', toggle('a','a'))
print('b', 'a', toggle('b','a'))
print('ab', 'a', toggle('ab','a'))
print('aba', 'a', toggle('aba','a'))
print('ababa', 'aba', toggle('ababa','aba'))

The Test output
 a a
a a
b a ba
ab a b
aba a b
ababa aba ba

Using a def would be longer because you have to use a return statement, if it were possible without return it would save 2 Bytes
Since explicit declaration of the function is not needed (sorry I didn't know that) 7 Bytes were saved.

Nice answer! For our rules, you don't need a name for the function. So you can remove the toggle=.

I just realized, my Test won't work if I don't name the function, but with the toggle= the Tests work

yes, the toggle is needed to test it. But you only need to count from lambda m,t: on.

You can change m+''+t to m+t to save 3 bytes, if I'm not mistaken.

You're right, I started with m+' '+t to enter a space between them, but after reading the description again I deleted the whitespace but not the '' and the +

Scala, 72 70 bytes
def x(m:String,s:String)={val r=m.replaceAll(s,"");if(r==m)m+s else r}

Online interpreter: www.tryscala.com

Welcome to Programming Puzzles & Code Golf! I don't know Scala, but I think you can remove the spaces around if(r==m).

Yeah you are right

C#, 63
string F(string s,string t)=>s.Contains(t)?s.Replace(t,""):s+t;

Better than Java :)
Test code:
public static void Main()
{
    Console.WriteLine(F("", "a"));
    Console.WriteLine(F("a", "a"));
    Console.WriteLine(F("b", "a"));
    Console.WriteLine(F("ab", "a"));
    Console.WriteLine(F("aba", "a"));
    Console.WriteLine(F("ababa", "aba"));
    Console.ReadLine();
}

Output:
a

ba
b
b
ba

Jolf, 12 bytes
?=iγρiIE+iIγ

Or, if we must include regex-sensitive chars:
?=iγρiLeIE+iIγ

Try it here!
Explanation
?=iγρiIE+iIγ    if(i === (γ = i.replace(I, E))) alert(i + I); else alert(γ);
  i                i
 =                   ===
    ρ                          .replace( ,  )
     iI                       i         I
       E                                   E
   γ                     (γ =                )
?               if(                           )
        +iI                                     alert(i + I);
                                                              else
           γ                                                       alert(γ);

JavaScript (ES6), 37 Bytes
(m,t)=>(w=m.split(t).join``)==m?m+t:w

Slightly shorter than @nobe4 's answer by taking advantage of split and join

Racket, 70 bytes
Pretty straight forward.
(λ(s t)((if(string-contains? s t)string-replace string-append)s t""))

Oracle SQL 11.2, 66 bytes
SELECT DECODE(:1,s,s||:2,s)FROM(SELECT REPLACE(:1,:2)s FROM DUAL);

Ruby, 35 37 28 bytes
->m,t{m[t]?m.gsub(t,''):m+t}

Hooray for string interpolation! It even works in regexes. The rest is simple: if the string in t matches to m, replace t with '', else return m+t.
Edit: Fixed a bug.
Edit: I applied Kevin Lau's suggestion, but it appears that I have reached the same algorithm as the one used in Luis Masuelli's answer.

This can fail if the toggle string contains special characters. For example, ("a", ".") returns "a" instead of "a.".

m[t] is much shorter than m.include?(t) and still checks for inclusion within strings.

Julia, 33 31 bytes
s|t=(r=replace(s,t,""))t^(s==r)

Try it online!

Ruby, 33 bytes 27 bytes (28 if using global subtitution) definitely 28 bytes
->u,v{u[v]?u.gsub(v,''):u+v}

Perl, 37 30 bytes
{$_=shift;s/\Q@_//g?$_:"$_@_"}

Regular expressions inside the toggle string are not evaluate because of the quoting with \Q...\E.
sub F and \E are  removed  according to the comment by  msh210.
It is not entirely free of side effects because of setting $_. Using a local variable will cost six additional bytes:
{my$a=shift;$a=~s/\Q@_//g?$a:"$a@_"}

On the other hand, with switched input parameters two bytes can be saved by using pop instead of shift (28 bytes):
{$_=pop;s/\Q@_//g?$_:"$_@_"}

Test file:
#!/usr/bin/env perl

sub F{$_=shift;s/\Q@_//g?$_:"$_@_"}

sub test ($$$) {
  my ($m, $t, $r) = @_;
  my $result = F($m, $t);
  print "F('$m', '$t') -> '$result' ",
    ($result eq $r ? '=OK=' : '<ERROR>'), " '$r'\n";
}
test '', 'a', 'a';
test 'a', 'a', '';
test 'b', 'a', 'ba';
test 'ab', 'a', 'b';
test 'aba', 'a', 'b';
test 'ababa', 'aba', 'ba';
test 'ababa', 'a*', 'ababaa*';
test 'foobar', '.', 'foobar.';
__END__

Test result:
F('', 'a') -> 'a' =OK= 'a'
F('a', 'a') -> '' =OK= ''
F('b', 'a') -> 'ba' =OK= 'ba'
F('ab', 'a') -> 'b' =OK= 'b'
F('aba', 'a') -> 'b' =OK= 'b'
F('ababa', 'aba') -> 'ba' =OK= 'ba'
F('ababa', 'a*') -> 'ababaa*' =OK= 'ababaa*'
F('foobar', '.') -> 'foobar.' =OK= 'foobar.'

perlsub says "The signature is part of a subroutine's body. Normally the body of a subroutine is simply a braced block of code." Thus, you can omit sub F from your byte count. Also, you should be able to use pop instead of shift (by reversing the order of the inputs, natch), saving two bytes. (Untested.) Finally, you should be able to omit the \E, saving two more bytes. (Also untested.)

@msh210 Thanks, your tips saved seven bytes. I do not see, how pop instead of shift can help, because $_ should be the first argument to avoid $_[1]=~s/.../. The order of input arguments is fixed by the question AFAIK.

The order of input arguments is not fixed by the question afaict.

C# (58 bytes)

string F(string s,string t)=>s==(s=s.Replace(t,""))?s+t:s;

It uses an inline assignment to shave a few bytes off

Hello, and welcome to PPCG! Great first post! I don't use C# much, but can't you do var s,t or var s,var t instead of string?

Thanks! Sadly var can only be used in places where the type is known at compile time, so it can't be used in method signatures. You could use dynamic, but it's 1 character longer that string

What about var F(string s, string t? That can be inferred...

bash + sed, 28 bytes
sed "s/$2//g;t;s/$/$2/"<<<$1

The script lives in a toggle-string.bash file, which we call with bash toggle-string.bash mainstring togglestring.
s/$2//g removes the toggle string from the main string
t jumps to the end if the previous substitution was successful (ie. the main string contained the toggle string)
/$/$2/ adds the toggle string at the end ($), if we didn't jump to the end
bash is required for the herestring

This won't work if the toggle string contains special characters.

PowerShell v2+, 47 bytes
param($a,$b)(($c=$a-replace$b),"$a$b")[$c-eq$a]

Takes input $a,$b and then uses a pseudo-ternary (... , ...)[...] statement to perform an if/else. The inner parts are evaluated first to form an array of two elements. The 0th is $a with all occurrences of $b -replaced with nothing, which is stored into $c. The 1st is just a string concatenation of $a and $b.
If $c is -equal to $a, meaning that $b wasn't found, that's Boolean $true or 1, and so the 1st element of the array (the concatenation) is chosen. Else, it's Boolean $false, so we output $c, the 0th element.
Note that -replace is greedy, so it will replace from the left first, meaning the ababa / aba test case will properly return ba.

Java 8, 65 bytes
BinaryOperator<String>l=(m,t)->m.contains(t)?m.replace(t,""):m+t;

The same logic as the Java 7 solution, written with a lambda.
Try it here

TSQL, 143 129 121 Bytes
DECLARE @1 VARCHAR(10)='',@2 VARCHAR(10)='a'SELECT CASE WHEN @1 LIKE'%'+@2+'%'THEN REPLACE(@1,@2,'')ELSE CONCAT(@1,@2)END

Readable:
   DECLARE @1 VARCHAR(10) = ''
    , @2 VARCHAR(10) = 'a'

SELECT CASE WHEN @1 LIKE '%' + @2 + '%'
            THEN REPLACE(@1, @2, '')
            ELSE CONCAT (@1, @2)
            END

Live Demo
114 Bytes with strictly 1 character input
DECLARE @1 CHAR(1) = 'a'
    , @2 CHAR(1) = '.'

SELECT CASE WHEN @1 LIKE '%' + @2 + '%'
            THEN REPLACE(@1, @2, '')
            ELSE CONCAT (@1, @2) END

Hello, and welcome to PPCG! Great answer!

Mathematica, 45 bytes
If[StringContainsQ@##,StringDelete@##,#<>#2]&

Anonymous function that takes the main string and the toggle string (in that order) and returns the result. Explanation:
                                            &  Anonymous function returning...

If[StringContainsQ@##,               ,     ]    if its first argument contains
                                                its second argument, then...
                      StringDelete@##            its first argument with its
                                                 second argument removed, else...
                                      #<>#2      its second argument appended to
                                                 its first argument.

TSQL(Sqlserver 2012), 49 bytes
DECLARE @ VARCHAR(10) = 'hello',@x VARCHAR(10) = 'o'

PRINT IIF(@ LIKE'%'+@x+'%',REPLACE(@,@x,''),@+@x)

Try it online!

k (23 bytes)
{$[#x ss y;,/y\:x;x,y]}

Examples:
k){$[#x ss y;,/y\:x;x,y]}["aba";"a"]
,"b"
k){$[#x ss y;,/y\:x;x,y]}["this string has 6 words ";"now"]
"this string has 6 words now"
k){$[#x ss y;,/y\:x;x,y]}["this string has 5 words now";"now"]
"this string has 5 words "
k){$[#x ss y;,/y\:x;x,y]}["ababa";"ba"]
,"a"
k){$[#x ss y;,/y\:x;x,y]}["";"a"]
,"a"

Kotlin, 61 Bytes
{m:String,t:String->var n=m.replace(t,"");if(m==n)m+t else n}

This is would be shorter if assignment was an expression in Kotlin,and parameters were mutable,and there was a ternary conditional operator, sadly this isn't the case :(
Try it Online!
UnGolfed
fun t(m:String, t:String):String{
    var n=m.replace(t, "")
    return if(m==n)m+t else n
}

Rust, 84 bytes
fn toggle(a:&str,b:&str)->String{let mut r=a.replace(b,"");if&r==a{r.push_str(b)}r}

Try it on play.rust-lang.org.

PHP 65
function f($s,$v){return($m=str_replace($v,'',$s))==$s?$s.$v:$m;}

Inspired from Kevin Cruijssen's java example.

PHP, 73 chars
<?$s=$argv[1];$t=$argv[2];echo!strpos($s,$t)?$s.$t:str_replace($t,'',$s);
Longer than the other php answer, but uninspired and fully working as a standalone in the console.


text:
Find the number I/O shortest algorithm
Find the shortest function/algorithm to translate these numbers to the ones after the dash:
0 - 0
1 - 10
2 - 20
3 - 30
4 - 40
5 - 50
6 - 60
7 - 70
8 - 80
9 - 90
10 - 100
11 - 115
12 - 130
13 - 150
14 - 175
15 - 200
16 - 230
17 - 260
18 - 300
19 - 350
20 - 400

Every integer higher than 20 is calculated by subtracting 10, calculating the corresponding number like done above and then multiplying that by 4.
Some examples (input will be between []):
[10] -> 100
[17] -> 260
[21] -> 4*115 -> 460
[32] -> 4*[22] -> 4*(4*130)) -> 2080

var QUESTION_ID=80271,OVERRIDE_USER=53878;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

Nice first challenge!

"Java answers are preferred?" D:

Some people just wanna watch the world burn.

To OP: I see what you did there...

@KennyLau I fail to see the relevance of that sequence.

This is a set of numbers someone gave me to implement as strenght to capacity for a hero in an rpg game, this way it is ballanced well, there is no mathematical sequence thats why I wanna see if anyone on here can come up with a good solution to this :)

@BaldBantha Any other language is accepted though

@orlp Please refer to my answer.

@SamApostel does input have to be in brackets? My answer is the only one that takes it that way.

@BaldBantha no sorry that was just to make the input clear in the question :)

While cleverly disguised as a question and answer site, we hold programming contests with objective winning criteria here. For code golf, that means shortest code in bytes, so please don't accept an arbitrary answer just because it uses a particular language.

This seems less like a codegolf quesiton, and more of a homework/"how can I accomplish this in code" question.

sorry @Dennis, I removed my answer vote. For me that was the answer because I was looking for a java solution and that was the shortest and only one

@Zymus do you really think I don't know how to use a simple switch statement? :) I was just looking for someone who could make my code les bulkier and I found these persons over here :)

@SamApostel While code golf may give you "less bulky" code it also give you literally unmaintainable and slow code because the sole purpose is to write it as short as possible with no concern for legibility or speed.

JavaScript (ES6), 64 51 bytes
f=n=>n>15?f(n-5)*2:n<11?n*10:f(n-1)+5*"22344"[n-11]

Much simpler now that I'm also using @xnor's observation.

Python 2, 57 bytes
lambda n:5*[2*n,4**(n/10-1)*ord('♥♥♥♥#(.4<F'[n%10])][n>9]

Replace the four hearts with the ASCII characters 20 (^T), 23 (^W), 26 (^Z), and 30 (^^).

Python 3, 45 bytes
lambda n:[16*n,b'(.4<F'[n%5]<<n//5][n>9]//8*5

Sticking to printable ASCII and int output. Uses that the values double every 5 steps, which can be computed with a bit shift.
10 - 100
11 - 115
12 - 130
13 - 150
14 - 175

15 - 200
16 - 230
17 - 260
18 - 300
19 - 350

So, for n>9, the output is [20,23,26,30,35][n%5]<<n/5-2. These values are doubled and packed in a printable ASCII bytearray. The -2 in the bit shift is pushed to the outside to avoid a negative shift error when n<=9 -- this is an ugly hack that can probably be handled better.

Java, 93 89 bytes
int f(int n){String x="!$(-28>FP";return n<11?n*10:n<20?(x.charAt(n-11)-10)*5:f(n-10)*4;}

A translation of the answer in Python combined with the answer in C++, also inspired by this answer in Python.
Full program:
public class Q80271 {
    int f(int n){String x="!$(-28>FP";return n<11?n*10:n<20?(x.charAt(n-11)-10)*5:f(n-10)*4;}
    public static void main(String args[]){
        int[] testcases = new int[]{
            0,1,2,3,4,5,6,7,8,9,
            10,11,12,13,14,15,16,17,18,19,
            20,21,32
        };
        for(int i=0;i<testcases.length;i++){
            System.out.println(new Q80271().f(testcases[i]));
        }
    }
}

Output:
0
10
20
30
40
50
60
70
80
90
100
115
130
150
175
200
230
260
300
350
400
460
2080

DANG! way to go java.

Also, it's funny that we came up with nearly the exact same code and I didn't look at yours.

@BaldBantha Because we both copied the C++ answer?

No, my lookup table is different. Technically, you are beating me, but If I use a more convenient input format than the one the OP said than I am 2 bytes shorter. Will golf later.

I copied the lookup table from the Python answer.

I think you can save 1 byte by doing x.charAt(n-11)*5-50 instead

you can save 10 bytes by inlining the string.

Pyth, 47 46 bytes
1 byte deletion inspired by Python's deletion of the final item in the lookup table.
J9L?gb20*4y-bT+?>bT*5@.u+NYj6045983J1-bhT0*Tby

Test suite.
Principle
The lookup table I built is [1, 2, 3, 3, 4, 4, 6, 8].
If we start from 1, and then add cumulatively that table:
1                   = 1
1+1                 = 2
1+1+2               = 4
1+1+2+3             = 7
1+1+2+3+3           = 10
1+1+2+3+3+4         = 14
1+1+2+3+3+4+4       = 18
1+1+2+3+3+4+4+6     = 24
1+1+2+3+3+4+4+6+8   = 32

Previous 53-byte solution:
L?tb+ytbeSmlf!%ydTSydStb1L?>b20*4'-bT+?>bT*5y-bT0*Tb'

This needs to be golf... very further. Maybe it would cost less to build a lookup table directly.
Test suite.
Principle
If we subtract ten times the first number from the second number:
115-110 = 5   = 5*1
130-120 = 10  = 5*2
150-130 = 20  = 5*4
175-140 = 35  = 5*7
200-150 = 50  = 5*10
230-160 = 70  = 5*14
260-170 = 90  = 5*18
300-180 = 120 = 5*24
350-190 = 160 = 5*32
400-200 = 200 = 5*40

It corresponds with A120679: 1,2,4,7,10,14,18,24,32,40,...

Genius, now I'll have to convert this principle into java, wish me luck

It is probably shorter to directly build a look-up table. I'll write an answer in Java though.

You're on to something verry amazing

Input not like OP said, must be enclosed in brackets. Great program though!

how on earth did u find this relation for a pseudo-random sequence-progress ?

PHP, 101 bytes
function f($i){$a=array(23,26,30,35,40,46,52,60,70);return $i<11?$i*10:$i<20?$a[$i-11]*5:f($i-10)*4;}

Huzzah for nested conditional operator!

Jelly, 32 31 30 22 bytes
ị“.4<F(”Oæ«Ḥ:¥:⁴×µ×>?⁵

Uses the astute observation from @xnor's answer, which saved 8 bytes.
Try it online! or verify all test cases.
How it works
ị“.4<F(”Oæ«Ḥ:¥:⁴×µ×>?⁵  Main link. Argument: n (integer)

                   >?⁵  If n is greater than 10:
                 µ   ⁵    Execute the chain to µ's left dyadically, with arguments
                          n (left) and 10 (right).
 “.4<F(”                    Yield the string of code points [46, 52, 60, 70, 40].
ị                           Retrieve the character at index n.
                            Indexing is modular and 1-based, so 1, 6, 11, etc. map
                            to the first character, 0, 5, 10, etc. to the last.
        O                   Ordinal; yield the code point of the character.
             ¥              Combine the two links to the left into a dyadic chain.
           Ḥ                  Yield 2n.
            :                 Divide 2n by 10, flooring the result.
                            This yields n : 5 (integer division).
         æ«                 Shift the code point n : 5 bits to the left.
              :⁴            Divide the result by 16.
                ×           Multiply the result by 10.
                        Else:
                  ×  ⁵    Multiply n by 10.

Python, 81 bytes
f=lambda n:n>19and 4*f(n-10)or n>10and[23,26,30,35,40,46,52,60,70][n-11]*5or 10*n

C++11, 104 95 91 bytes
int f(int n){int x={23,26,30,35,40,46,52,60,70};return n<11?n*10:n<20?x[n-11]*5:f(n-10)*4;}

Simple lookup table and ternary operator fun.
[edit]Thanks!
[edit2]I'm feeling extra stoopid today. Thanks again!

You can shorten the lookup table if you divide every element by 5 and then multiply it back after indexing.

You could also chop off the last item in your lookup table and set the threshold to n<20, just like what Python did.

Java, 62 bytes
i->' '9?i-10:0)%41*5

Javascript ES6, 104 103 100 97 93 bytes
 h=a=>{return a<11?a*10:a<20?a*10+c[a-11][1/2,1,2,7/2,5,7,9,12,16]*10:4*h(a-10);},u=p=>h(p[0])

usage: call u with the input enclosed in brackets like the OP said. Will golf later.
84 bytes if input is not enclosed in brackets and h() is called directly
thanks to kenny lau -6 bytes

@KennyLau var is required by babel, what do you run it in? es6 is not supported by apple safari

s/c[a-11][1/2,1,2,7/2,5,7,9,12,16]/[1/2,1,2,7/2,5,7,9,12,16][a-11]/g

java is shorter, you're doing something wrong

For example: you don't need the ; and you can leave out the return statement, if you use 1-liner lambdas

Jelly, 42 bytes
7568b3+\+\
_⁵ị¢×5+×⁵$
Çµ_⁵ß4×µ20>$?×⁵$>⁵$?

Try it online!
Test suite.
Uses the same principle as my answer in Pyth, just that the array is further reduced to [1, 1, 0, 1, 0, 2, 2], which can generate [1, 2, 3, 3, 4, 4, 6, 8], which can generate [1, 2, 4, 7, 10, 14, 18, 24, 32].

Haskell, 71 66 bytes
h n|n<11=n*10|n<20=sum$5<$['.'.."DGKPU[ais"!!(n-11)]|1<2=4*h(n-10)

Usage example: h 32 -> 2080.
The Haskell version of the algorithm found in many other answers. The results in the middle part for the numbers 11..19 are encoded as strings of consecutive ASCII characters:
11:   from . to D  (23 chars)
12:   from . to G  (26 chars)
13:   from . to K  (30 chars)
...

Every character in the string is mapped to a 5 and summed up.
Edit: @Lynn helped saving 4 bytes. Thanks!

f n|n<11=n*10|n<20=5*length['.'.."DGKPU[ais"!!(n-11)]|1<2=4*f(n-10) is 4 bytes shorter.

@Lynn: Nice. I managed to squeeze out one further byte by mapping the string to const 5 and taking the sum.

Oh, I completely forgot about <$! Nice job! ^^

Julia 0.4, 49 42 bytes
n->n>9?5Int("(.4<F"[n%5+1])*2^(n÷5)/8:10n

Uses the astute observation from @xnor's answer, which saved 7 bytes. Try it online!

Julia 0.3, 38 bytes
n->2.5max("(.4<F"[n%5+1]<<(n÷5-2),4n)

This requires a call to Int in Julia 0.4, which makes it longer than the other approach.


text:
Find all the Solutions to this Number Puzzle in the Shortest Time Possible
History
My company sends out a weekly newsletter to everyone within the company. Included in these newsletters is a riddle, along with a shoutout to whomever in the company was the first to email/provide a solution to last week's riddle. Most of these riddles are quite trivial, and honestly pretty dull for a tech company, but there was one, several months back, that caught my attention.
The Original Riddle:
Given the shape below:

You have the Natural Numbers from 1 to 16. Fit them all into this shape, such that all the contiguous rows and contiguous columns sum up to 29.
For example, one such solution to this puzzle (which was the "canonical" solution I submitted to the newsletter) was the following:

However, in the course of solving it, I found some rather interesting information:

There are significantly more solutions than just that one; in fact, there are 9,368 Solutions.
If you expand the ruleset to only require that rows and columns be equal to each other, not necessarily 29, you get 33,608 solutions:

4,440 Solutions for a sum of 27.
7,400 Solutions for a sum of 28.
9,368 Solutions for a sum of 29.
6,096 Solutions for a sum of 30.
5,104 Solutions for a sum of 31.
1,200 Solutions for a sum of 32.

So me and my coworkers (though mostly just my manager, since he was the only other person than me with "General Purpose" programming skills) set out on a challenge, that lasted for most of the month—we had other, actual job-related obligations we had to attend to—to try to write a program which would find every single solution in the fastest way possible.
Original Statistics
The very first program I wrote to solve the problem simply checked random solutions over and over, and stopped when it found a solution. If you've done Mathematical analysis on this problem, you probably already know that this shouldn't have worked; but somehow I got lucky, and it took the program only a minute to find a single solution (the one I posted above). Repeat runs of the program often took as much as 10 or 20 minutes, so obviously this wasn't a rigorous solution to the problem.
I switched over to a Recursive Solution which iterated through every possible permutation of the puzzle, and discarded lots of solutions at once by eliminating sums that weren't adding up. I.E. if the first row/column I was comparing already weren't equal, I could stop checking that branch immediately, knowing that nothing else permuted into the puzzle would change that.
Using this algorithm, I got the first "proper" success: the program could generate and spit out all 33,608 solutions in about 5 minutes.
My manager had a different approach: knowing based on my work that the only possible solutions had sums of 27, 28, 29, 30, 31, or 32, he wrote a multi-threaded solution which checked possible sums only for those specific values. He managed to get his program to run in only 2 minutes. So I iterated again; I hashed all possible 3/4 digit sums (at the start of the program; it's counted in the total runtime) and used the "partial sum" of a row to look-up the remaining value based on a previously completed row, rather than testing all remaining values, and brought the time down to 72 seconds. Then with some multi-threading logic, I got it down to 40 seconds. My manager took the program home, performed some optimizations on how the program ran, and got his down to 12 seconds. I reordered the evaluation of the rows and columns, and got mine down to 8 seconds.
The fastest either of us got our programs after a month was 0.15 seconds for my manager, and 0.33 seconds for me. I ended up claiming that my program was faster though, since my manager's program, while it did find all solutions, wasn't printing them out into a text file. If he added that logic to his code, it often took upwards of 0.4-0.5 seconds.
We've since allowed our intra-personal challenge to subsist, but of course, the question remains: can this program be made faster?
That's the challenge I'm going to pose to you guys.
Your Challenge
The parameters we worked under relaxed the "sum of 29" rule to instead be "all rows/columns' sums equal", and I'm going to set that rule for you guys too. The Challenge, therefore, is: Write a program that finds (and Prints!) all solutions to this riddle in the shortest time possible. I'm going to set a ceiling on submitted solutions: If the program takes more than 10 seconds on a relatively decent computer (<8 years old), it's probably too slow to be counted.
Also, I have a few Bonuses for the puzzle:

Can you generalize the solution so that it works for any set of 16 numbers, not just int[1,16]? Timing score would be evaluated based on the original prompt number set, but passed through this codepath. (-10%)
Can you write the code in a way that it gracefully handles and solves with duplicate numbers? This isn't as straightforward as it might seem! Solutions which are "visually identical" should be unique in the result set. (-5%)
Can you handle negative numbers? (-5%)

You can also try to generate a solution that handles Floating-Point Numbers, but of course, don't be shocked if that fails utterly. If you do find a robust solution though, that might be worth a large bonus!
For all intents and purposes, "Rotations" are considered to be unique solutions. So a solution that is just a rotation of a different solution counts as its own solution.
The IDEs I have working on my computer are Java and C++. I can accept answers from other languages, but you may need to also provide a link to where I can get an easy-to-setup runtime environment for your code.

Holy cats, nice first question! ...except for the bonuses, which we sorta-discourage (mostly on [tag:code-golf] questions, so they should be fine here)

@cat I think the bonuses make sense here, because when I solved those issues in my own code, they tended to cause the code to slow down in a significant manner. So I think a bonus is in order to justify inclusion.

Do or do not; there is no try. Either add the floating-point version (as a bonus, most likely), or don't mention it at all. These bonuses seem like they would be better as separate challenges, since they substantially differ from the original challenge.

BTW, are there any jobs going at your place? it sounds like you have an easygoing boss and plenty of time on your hands :-)

With duplicate numbers, is it OK to print duplicate solutions where the two identical numbers are exchanged? that would make a big difference as to how that bonus is interpreted. Please clarify, but I'd consider eliminating that bonus altogether.

Also, are 180 degree rotations considered the same solution or different solutions?

@LevelRiverSt I've updated the post. To each of your inquiries: Rotations are considered unique solutions (so you don't have to remove them) but duplicates that are identical in appearance are not considered unique (so you do need to remove them).

BTW, another puzzle altogether: how many ways are there to divide that shape into two congruent pieces (along the dotted lines)?

What should the format of the output solutions be? Each solution separated from each other in an array, with each "row" and "column" in separate arrays within that array? A string with the solution in the same format as the riddle?

@JoeZ. I think it's seven, if the pieces have to be contiguous. Disjoint pieces make it a much bigger, but still easy to calculate, number.

Fastest code doesn't really work when the times are so low.

@Xirema, would you consider posting your (and/or your manager's) solutions? I'd definitely be interested to see the specifics of the techniques you mentioned using.

@AndrewEpstein I've added my code.

C - near 0.5 sec
This very naive program give all the solutions in half a second on my 4 years old laptop. No multithread, no hashing.
Windows 10, Visual Studio 2010, CPU core I7 64 bit
Try online on ideone
#include <stdio.h>
#include <time.h>

int inuse[16];
int results[16+15+14];

FILE *fout;

int check(int number)
{
    if (number > 0 && number < 17 && !inuse[number-1])
    {
        return inuse[number-1]=1;
    }
    return 0;
}

void free(int number)
{
    inuse[number-1]=0;
}

void out(int t, int* p)
{
    int i;
    fprintf(fout, "\n%d",t);
    for(i=0; i< 16; i++) fprintf(fout, " %d",*p++);
}

void scan()
{
    int p[16];
    int t,i;
    for (p[0]=0; p[0]++<16;) if (check(p[0]))
    {
        for (p[1]=0; p[1]++<16;) if (check(p[1]))
        {
            for (p[2]=0; p[2]++<16;) if (check(p[2]))
            {
                t = p[0]+p[1]+p[2]; // top horiz: 0,1,2
                for (p[7]=0; p[7]++<16;) if (check(p[7]))
                {
                    if (check(p[11] = t-p[7]-p[2])) // right vert: 2,7,11
                    {
                        for(p[9]=0; p[9]++<16;) if (check(p[9]))
                        {
                            for (p[10]=0; p[10]++<16;) if (check(p[10]))
                            {
                                if (check(p[12] = t-p[9]-p[10]-p[11])) // right horiz: 9,10,11,12
                                {
                                    for(p[6]=0; p[6]++<16;) if (check(p[6]))
                                    {
                                        if (check(p[15] = t-p[0]-p[6]-p[9])) // middle vert: 0,6,9,15
                                        {
                                            for(p[13]=0; p[13]++<16;) if (check(p[13]))
                                            {
                                                if (check(p[14] = t-p[13]-p[15])) // bottom horiz:  13,14,15
                                                {
                                                    for(p[4]=0; p[4]++<16;) if (check(p[4]))
                                                    {
                                                        if (check(p[8] = t-p[4]-p[13])) // left vert: 4,8,13
                                                        {
                                                            for(p[3]=0; p[3]++<16;) if (check(p[3]))
                                                            {
                                                                if (check(p[5] = t-p[3]-p[4]-p[6])) // left horiz: 3,4,5,6
                                                                {
                                                                    ++results[t];
                                                                    out(t,p);
                                                                    free(p[5]);
                                                                }
                                                                free(p[3]);
                                                            }
                                                            free(p[8]);
                                                        }
                                                        free(p[4]);
                                                    }
                                                    free(p[14]);
                                                }
                                                free(p[13]);
                                            }
                                            free(p[15]);
                                        }
                                        free(p[6]);
                                    }
                                    free(p[12]);
                                }
                                free(p[10]);
                            }
                            free(p[9]);
                        }
                        free(p[11]);
                    }
                    free(p[7]);
                }
                free(p[2]);
            }
            free(p[1]);
        }
        free(p[0]);
    }
    for(i=0;i<15+16+14;i++)
    {
        if(results[i]) printf("%d %d\n", i, results[i]);
    }
}

void main()
{
    clock_t begin, end;
    double time_spent;
    begin = clock();

    fout = fopen("c:\\temp\\puzzle29.txt", "w");
    scan();
    fclose(fout);

    end = clock();
    time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
    printf("Time %g sec\n", time_spent);
}

Holy sweet Evil Vampiric Jesus, those nested for loops. I bet that made your compiler really happy though. XD

@edc65, FYI you can replace int inuse[16]; with just int inuse; and then use bitwise operators to manipulate it. It doesn't seem to increase the speed that much, but it helps a little.

@AndrewEpstein it could even become slower - bitshift vs indexing

@edc65, I took the liberty of using dumbbench to test your original version vs. the bitshift version. Here are the results:
Indexing: 0.2253 +/- 5.7590e-05
Bitshifting: 0.2093 +/- 6.6595e-05
So, approximately a 16ms speedup on my machine. The command I used was: dumbbench --precision=.01 -vvv --initial=500 ./solve

C++ - 300 Milliseconds
Per request, I've added my own code to solve this puzzle. On my computer, it clocks in at an average of 0.310 seconds (310 milliseconds) but depending on variance can run as quickly as 287 milliseconds. I very rarely see it rise above 350 milliseconds, usually only if my system is bogged down with a different task.
These times are based on the self-reporting used in the program, but I also tested using an external timer and get similar results. Overhead in the program seems to add about 10 milliseconds.
Also, my code doesn't quite handle duplicates correctly. It can solve using them, but it doesn't eliminate "visually identical" solutions from the solution set.
#include<iostream>
#include<vector>
#include<random>
#include<functional>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<thread>
#include<chrono>
#include<fstream>
#include<iomanip>
#include<string>
#include<mutex>
#include<queue>
#include<sstream>
#include<utility>
#include<atomic>
#include<algorithm>

//#define REDUCE_MEMORY_USE

typedef std::pair<int, std::vector<std::pair<int, int>>> sumlist;
typedef std::unordered_map<int, std::vector<std::pair<int, int>>> summap;
typedef std::array<int, 16> solution_space;

class static_solution_state {
public:
    std::array<int, 16> validNumbers;
    summap twosums;
    size_t padding;
    std::string spacing;

    static_solution_state(const std::array<int, 16> & _valid);

    summap gettwovaluesums();
    std::vector<sumlist> gettwovaluesumsvector();
};

static_solution_state::static_solution_state(const std::array<int, 16> & _valid)
    : validNumbers(_valid) {
    twosums = gettwovaluesums();
    padding = 0;
    for (int i = 0; i < 16; i++) {
        size_t count = std::to_string(validNumbers[i]).size();
        if (padding <= count) padding = count + 1;
    }
    spacing.resize(padding, ' ');
}

class solution_state {
private:
    const static_solution_state * static_state;
public:
    std::array<int, 16> currentSolution;
    std::array<bool, 16> used;
    std::array<int, 7> sums;
    size_t solutions_found;
    size_t permutations_found;
    size_t level;
    std::ostream * log;

    solution_state(const static_solution_state & _sstate);
    solution_state(static_solution_state & _sstate) = delete;
    void setLog(std::ostream & out);
    const int & operator[](size_t index) const;

};

solution_state::solution_state(const static_solution_state & _sstate) {
    static_state = &_sstate;
    sums = { 0 };
    used = { false };
    currentSolution = { -1 };
    solutions_found = 0;
    permutations_found = 0;
    level = 0;
}

void solution_state::setLog(std::ostream & out) {
    log = &out;
}

const int & solution_state::operator[](size_t index) const {
    return static_state->validNumbers[currentSolution[index]];
}

int getincompletetwosum(const static_solution_state & static_state, const solution_state & state);
void permute(const static_solution_state & static_state, solution_state & state, volatile bool & reportProgress, const volatile size_t & total_tests, volatile bool & done);
void setupOutput(std::fstream & out);
void printSolution(const static_solution_state & static_state, const solution_state & state);
constexpr size_t factorial(const size_t iter);

const bool findnext2digits[16]{
    false, false, false,
    true, false,
    false, true, false,
    true, false,
    true, false,
    true, false,
    true, false
};

const int currentsum[16]{
    0, 0, 0,
    1, 1,
    2, 2, 2,
    3, 3,
    4, 4,
    5, 5,
    6, 6
};

const int twosumindexes[7][2]{
    { 0, -1},
    { 2, -1},
    { 5, -1},
    { 5, -1},
    { 0,  7},
    { 11, 4},
    { 10, 9}
};

const std::array<size_t, 17> facttable = [] {
    std::array<size_t, 17> table;
    for (int i = 0; i < 17; i++) table[i] = factorial(i);
    return table;
}();

const int adj = 1;

std::thread::id t1id;

int main(int argc, char** argv) {
    //std::ios_base::sync_with_stdio(false);
    std::array<int, 16> values = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 };
    if (argc == 17) {
        for (int i = 0; i < 16; i++) {
            values[i] = atoi(argv[i + 1]);
        }
    }
    auto start = std::chrono::high_resolution_clock::now();
    const static_solution_state static_state(values);
#if defined(REDUCE_MEMORY_USE)
    const int num_of_threads = max(1u, min(thread::hardware_concurrency(), 16u));
#else
    const int num_of_threads = 16;
#endif
    std::vector<solution_state> states(num_of_threads, static_state);
    for (int i = 0; i < num_of_threads; i++) {
        int start = i * 16 / num_of_threads;
        states[i].permutations_found += start * factorial(16) / 16;
    }
    std::fstream out;
    setupOutput(out);
    std::locale loc("");
    std::cout.imbue(loc);
    volatile bool report = false;
    volatile bool done = false;
    volatile size_t tests = 0;

    std::thread progress([&]() {
        auto now = std::chrono::steady_clock::now();
        while (!done) {
            if (std::chrono::steady_clock::now() - now > std::chrono::seconds(1)) {
                now += std::chrono::seconds(1);

                size_t t_tests = 0;
                for (int i = 0; i < num_of_threads; i++) t_tests += states[i].permutations_found - i * factorial(16) / num_of_threads;
                tests = t_tests;
                report = true;
            }
            std::this_thread::yield();
        }
    });

    if (num_of_threads <= 1) {

        states[0].setLog(out);
        permute(static_state, states[0], report, tests, done);

    }
    else {
        std::vector<std::thread> threads;
#if defined(REDUCE_MEMORY_USE)
        std::vector<std::fstream> logs(num_of_threads);
#else
        std::vector<std::stringstream> logs(num_of_threads);
#endif
        for (int i = 0; i < num_of_threads; i++) {
            threads.emplace_back([&, i]() {
                if (i == 0) t1id = std::this_thread::get_id();
                int start = i * 16 / num_of_threads;
                int end = (i + 1) * 16 / num_of_threads;
#if defined(REDUCE_MEMORY_USE)
                logs[i].open("T"s + to_string(i) + "log.tmp", ios::out);
#endif
                logs[i].imbue(loc);
                states[i].setLog(logs[i]);

                for (int j = start; j < end; j++) {

                    states[i].currentSolution = { j };
                    states[i].level = 1;
                    states[i].used[j] = true;
                    permute(static_state, states[i], report, tests, done);

                }
            });
        }

        std::string buffer;
        for (int i = 0; i < num_of_threads; i++) {
            threads[i].join();
#if defined(REDUCE_MEMORY_USE)
            logs[i].close();
            logs[i].open("T"s + to_string(i) + "log.tmp", ios::in);
            logs[i].seekg(0, ios::end);
            auto length = logs[i].tellg();
            logs[i].seekg(0, ios::beg);
            buffer.resize(length);
            logs[i].read(&buffer[0], length);
            logs[i].close();
            remove(("T"s + to_string(i) + "log.tmp").c_str());
            out << buffer;
#else
            out << logs[i].str();
#endif
        }
    }
    done = true;
    out.close();

    if (num_of_threads > 1) {
        size_t t_tests = 0;
        for (int i = 0; i < num_of_threads; i++) t_tests += states[i].permutations_found - i * factorial(16) / num_of_threads;
        tests = t_tests;
    }

    size_t solutions = 0;
    for (const auto & state : states) {
        solutions += state.solutions_found;
    }

    auto end = std::chrono::high_resolution_clock::now();

    progress.join();

    auto duration = end - start;
    auto secondsDuration = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
    std::cout << "Total time to process all " << tests << " results: " << std::setprecision(3) << std::setiosflags(std::ostream::fixed) << (secondsDuration.count()/1000.0) << "s" << "\n";
    std::cout << "Solutions found: " << solutions << std::endl;
    //system("pause");
    return 0;
}

void permute(const static_solution_state & static_state, solution_state & state, volatile bool & reportProgress, const volatile size_t & total_tests, volatile bool & done) {
    if (done) return;
    if (state.level >= 16) {
        if (reportProgress) {
            reportProgress = false;
            std::cout << "Current Status:" << "\n";
            std::cout << "Test " << total_tests << "\n";
            std::cout << "Contents: {";
            for (int i = 0; i < 15; i++) std::cout << std::setw(static_state.padding - 1) << state[i] << ",";
            std::cout << std::setw(static_state.padding - 1) << state[15] << "}" << "(Partial Sum: " << state.sums[0] << ")" << "\n";
            std::cout << "=====================" << "\n";
        }
        printSolution(static_state,state);
        state.solutions_found++;
        state.permutations_found++;
    }
    else {
        if (state.level == 3) state.sums[0] = state[0] + state[1] + state[2];

        if (!findnext2digits[state.level]) {
            for (int i = 0; i < 16; i++) {
                if (!state.used[i]) {
                    state.currentSolution[state.level] = i;
                    state.used[i] = true;
                    state.level++;
                    permute(static_state, state, reportProgress, total_tests, done);
                    state.level--;
                    state.used[i] = false;
                }
            }
        }
        else {
            int incompletetwosum = getincompletetwosum(static_state, state);
            if (static_state.twosums.find(incompletetwosum) == static_state.twosums.end()) {
                state.permutations_found += facttable[16 - state.level];
            }
            else {
                size_t successes = 0;
                const std::vector<std::pair<int, int>> & potentialpairs = static_state.twosums.at(incompletetwosum);
                for (const std::pair<int, int> & values : potentialpairs) {
                    if (!state.used[values.first] && !state.used[values.second]) {
                        state.currentSolution[state.level] = values.first;
                        state.currentSolution[state.level + 1] = values.second;
                        state.used[values.first] = true;
                        state.used[values.second] = true;
                        state.level += 2;
                        permute(static_state, state, reportProgress, total_tests, done);
                        state.level -= 2;
                        state.used[values.first] = false;
                        state.used[values.second] = false;

                        successes++;
                    }
                }
                state.permutations_found += facttable[16 - state.level - 2] * ((16 - state.level) * (15 - state.level) - successes);
            }
        }
    }
}

int getincompletetwosum(const static_solution_state & static_state, const solution_state & state) {
    int retvalue = state.sums[0];
    int thissum = currentsum[state.level];
    for (int i = 0; i < 2 && twosumindexes[thissum][i] >= 0; i++) {
        retvalue -= state[twosumindexes[thissum][i]];
    }
    return retvalue;
}

constexpr size_t factorial(size_t iter) {
    return (iter <= 0) ? 1 : iter * factorial(iter - 1);
}

void setupOutput(std::fstream & out) {
    out.open("puzzle.txt", std::ios::out | std::ios::trunc);
    std::locale loc("");
    out.imbue(loc);
}

void printSolution(const static_solution_state & static_state, const solution_state & state) {
    std::ostream & out = *state.log;
    out << "Test " << state.permutations_found << "\n";
    static const auto format = [](std::ostream & out, const static_solution_state & static_state, const solution_state & state, const std::vector<int> & inputs) {
        for (const int & index : inputs) {
            if (index < 0 || index >= 16) out << static_state.spacing;
            else out
                << std::setw(static_state.padding)
                << state[index];
        }
        out << "\n";
    };
    format(out, static_state, state, { -1, -1, -1,  0,  1,  2 });
    format(out, static_state, state, { 15,  9, 14, 10, -1,  3 });
    format(out, static_state, state, { -1,  8, -1, 11, 12,  4, 13 });
    format(out, static_state, state, { -1,  5,  6,  7});

    out << "Partial Sum: " << (state.sums[0]) << "\n";
    out << "=============================" << "\n";
}

summap static_solution_state::gettwovaluesums() {
    summap sums;
    for (int i = 0; i < 16; i++) {
        for (int j = 0; j < 16; j++) {
            if (i == j) continue;
            std::pair<int,int> values( i, j );
            int sum = validNumbers[values.first] + validNumbers[values.second];
            sums[sum].push_back(values);
        }
    }
    return sums;
}

std::vector<sumlist> static_solution_state::gettwovaluesumsvector() {
    std::vector<sumlist> sums;
    for (auto & key : twosums) {
        sums.push_back(key);
    }

    std::sort(sums.begin(), sums.end(), [](sumlist a, sumlist b) {
        return a.first < b.first;
    });
    return sums;
}

As I'm sure you're aware, if you simplify your output a little bit, you can shave off a decent amount of time. Here's the time for your code:
0.1038s +/- 0.0002
And here's the time for your code with simplified output:
0.0850s +/- 0.0001
So, you can save ~18ms, at least on my machine. I ran both versions 500+ times with outliers thrown out, using dumbbench

Prolog - 3 minutes
This kind of puzzle seems like a perfect use-case for Prolog. So, I coded up a solution in Prolog! Here it is:
:- use_module(library(clpfd)).

puzzle(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15) :-
    Vars = [P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15],
    Vars ins 1..16,
    all_different(Vars),
    29 #= P0 + P1 + P2,
    29 #= P3 + P4 + P5 + P6,
    29 #= P9 + P10 + P11 + P12,
    29 #= P13 + P14 + P15,
    29 #= P0 + P6 + P9 + P15,
    29 #= P2 + P7 + P11,
    29 #= P4 + P8 + P13.

Unfortunately, it's not as fast as I expected. Maybe someone more well-versed in declarative programming (or Prolog specifically) can offer some optimization tips. You can invoke the rule puzzle with the following command:
time(aggregate_all(count, (puzzle(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15), labeling([leftmost, up, enum], [P9, P15, P13, P0, P4, P2, P6, P11, P1, P5, P3, P7, P14, P12, P10, P8])), Count)).

Try it out online here.
You can substitute any number in place of the 29s in the code to generate all solutions. As it stands, all 29-solutions are found in approximately 30 seconds, so to find all possible solutions should be approximately 3 minutes.


text:
Output the alphabet using the alphabet
The title is pretty self-explanatory, isn't it?
Your task is to output the alphabet (the string "abcdefghijklmnopqrstuvwxyz") to STDOUT, using each and every letter of the alphabet in your program once and only once.
Oh, and for a bit of extra fun?
The letters "g", "o", "l" and "f" must be in order (just for the code to be a bit more code-y).
Rules:

Only standard letters of the alphabet from ASCII count as letters (ë != e).
Both uppercase and lowercase characters count as letters (if you have E, you are not allowed to have e).
You are allowed to use comments, but every character in the comment is equal to 2 bytes.
Your final score will be the byte-count of your program, subtracted by 26.

This is code-golf, so shortest code in bytes wins.

May I take any input?

@KennyLau Why would you want to take input? But, yes if you want.

I didn't think the question through, did I?

I downvoted because it is too straight-forward.

Dammit, can I delete the question? I might want some revisions of it in the sandbox.

Well, it is interesting in languages like Python, though.

Let us continue this discussion in chat.

Why the arbitrary "one answer per person" rule?

I see that this question has some rather arbitrary rules and the community in general seems to punish that, but I think this challenge might have some interesting optimizations in some languages. And I don't think it deserves quite the negative score that it has

@Doorknob That was because LeakyNun had 5 answers, and it was kinda cluttery.

@DerpfacePython If someone is posting a lot of answers, the reaction should be "this challenge is too trivial" rather than "I need to forbid multiple answers"

@Mego Ah, I understand. So should I delete the question and move on? Or should I leave it?

Since it has answers, you cannot delete it. Your best bet would be to remove the "one answer per person" rule and move on.

If I revise this question and repost it, it'll still be unpopular, right?

@DerpfacePython It's unethical to repost here. It will be most probably mod-deleted.

@LeakyNun I upvoted the question because it is quite interesting to solve in dc as well.

This was a fun challenge in SmileBASIC.

05AB1E, 27 26 - 26 = 0 bytes
Thanks to Katenkyo for saving 1 byte :). Code:
golfAqbcdehijkmnprstuvwxyz

Try it online!.

How does this work?

@DrGreenEggsandHamDJ The golf part is just a bunch of no-ops. The A pushes the lowercase alphabet and the q after that quits the program, which then implicitly prints the lowercase alphabet.

"Both uppercase and lowercase characters count as letters (if you have E, you are not allowed to have e)." so you can technically use golfAqbcdehijkmnprstuvwxyz which scores 0 :)

@Katenkyo Thanks :), updated.

Faster code (from what I've read): Aqgolfbcdehijkmnprstuvwxyz

Brainfuck, 67 - 26 + 26 (comment) = 41 67 bytes
golfabcdehijkmnpqrstuvwxyz++++++++[>++++++++++++>+++<<-]>>++[-<+.>]

Try it online!

I think that the golfabcdehijkmnpqrstuvwxyz part is a comment!

There's a slight difference between a no-op and a comment...

+- or <> would be a no-op. Characters not in the brainfuck alphabet are comments.

Actually, you would need to add 52 bytes to your score, as each comment character counts twice.

Count twice, and then minus 26, which is the same as what we have now.

Batch, 36  + 13 + 9 - 26 = 32 bytes
:g
@echo ab%0pqrstuvwxyz
:lfdijkmn

Requires that the batch file itself be named cdefghijklmno. Scored as 36 (size of file cdefghijklmno) + 13 (size of filename cdefghijklmno) + 9 (commented letters) - 26.
Edit: Saved 29 bytes even under my scoring scheme thanks to @ΈρικΚωνσταντόπουλος.

If I do not miscomprehend, your task is to output "abcdefghijklmnopqrstuvwxyz" to STDOUT.

@KennyLau Sorry I misunderstood the question. Let me think about it.

Read the rules again, please. You will delete this answer out of shame.

@ΈρικΚωνσταντόπουλος I'll be in good company!

They're not comments, they're labels, so I think you don't have to count comment characters.

There are no rules about the file being named abcdefghijklmnopqrstuvwxyz. So your score is 10. Also, if you use the code here, your score is 8, and you have to name your file cdefghijklmno. It's a win/win situation.

Actually, you must count every commented byte twice, so you add +18 instead of +9, and still save 20 bytes.

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ But I already counted them once as part of the original 36 byte size of the file cdefghijklmno.

@Neil Good... ...morning?

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ I'm awake, so it can't be morning!

@Neil I just said a good evening, since it's evening...

Jolf, 27 - 26 = 1 byte
goΔaplfbcdehijkmnqrstuvwxyz

o assigns Δ to apl, which alerts pl, which is the lowercase alphabet. I take it that "in order" does not mean "adjacent to". You can see that f follows l which follows o which follows g. Try it out here!

CJam, 29 - 26 = 3 bytes
"golfabcdehijkmnpqrstuvwxyz"$

Try it online!

Pyke, 29 - 26 = 3 bytes
"golfabcdehijkmnpqrstuvwxyz"S

MATL, 29-26 = 3 bytes
'abcdehijkmnpqrstuvwxyzgolf'S

Try it Online!

J, 36 - 26 = 10 bytes
'golfabcdehjkmnpqrstvwxyz']u:97+i.26

Not a comment, just a string that's discarded. u: converts numbers to ASCII chars, and 97+i.26 is a range from 0..25 with vectorized addition over 97, the char code of a. Here's an alternative (albeit longer) solution using a.:
'golfbcdehjkmnpqrstvwxyz']a.{~97+i.26

dc, 111 - 26 = 85 bytes
[gol][P]s@[abcdef]1 1=@103 1 1=@[hijk]1 1=@108 1 1=@[mn]1 1=@111
1 1=@112 1 1=@[qr]1 1=@115 1 1=@[tuvwxyz]1 1=@

Run: dc -f alphabet_letters.dc
Output:
abcdefghijklmnopqrstuvwxyz

I use 1 1=@ as a trick to simulate l@x, that executes the print command P stored in register @. This is one example of a language that entailed a non-trivial solution for this task.

The output is supposed to be the alphabet in, er, alphabetical order.

@Jordan I wasn't sure, because the statement said that the g, o, l and f letters must be in order so I thought the rest could be in any order. I'll correct my entry.

I believe OP intends for the output to be abcdefghijklmnopqrstuvwxyz, and for the g, o l, and f letters to be in that order in the source code, not the output.

@Jordan thanks for clarifying things up for me. My updated answer should be correct now.

Jelly, 29 - 26 = 3 bytes
“golfabcdehijkmnpqrstuvwxyz”Ṣ

Try it online!

Dammit, Kenny... all the good solutions, gone like that.

What encoding are you using? I see some non-ascii characters.

Updated, thanks for reminding.

Actually, 29 - 26 = 3 bytes
"golfabcdehijkmnpqrstuvwxyz"S

Try it online!

Ruby, 57 37 47 - 26 = 21 bytes
I'm ashamed it took me that many tries to arrive at this super obvious solution.
"gol";$><<"abcdef\147hijk\154mnp\157qrstuvwxyz"

See it on ideone: http://ideone.com/FAtiy3

SmileBASIC, 68 61 bytes -26 = 35
_=97@V?CHR$(_);
_=_+1GOSUB"@"+KEY(3)[2]*(_<123)@ADLIJFMNPQTWXZ

Explained:
_=97 'set variable _ to 97 (ascii value of "a")
@V 'label
 ?CHR$(_) 'convert _ to a character and print
 _=_+1 'add 1 to _
GOSUB"@"+KEY(3)[2]*(_<123) 'jump to @V (KEY(3) is "SAVE") if _ is less than 123 (ascii code for z +1)
@ADLIJFMNPQTWXZ 'create a label with the unused letters


text:
Judge Some Titrations
In chemistry class, we were learning about titrations, and attempting one as a lab. We were using phenolphthalein as the indicator for the titration, so on top of grading the lab normally, my teacher held a little contest to see who had the lightest shade of pink, and thus the most accurate transition.
Your task is to write a program that acts like the teacher and judges the titrations.
Specs
As input, you take a list of RGB triples in any sane format representing the titration of each student. ex: ["D966FF", "ECB3FF", "AC00E6"]. You will be guaranteed that if converted to HSL, the hue is 285 and the saturation is 100.
The conversion for RGB to HSL lightness is the average of the max and min of the normalized RGB components (*100 for a percentage).
Now the teacher is a human being and therefore cannot measure the lightness of the solution perfectly, so before you do any of the things described below, randomly change the lightness value of each of the titrations by ±3, uniformly distributed.
If a titration has a lightness value greater than 94, it is too light to  visibly see that all the acid has neutralized. Therefore, the first output is a list, sorted in descending order, of all the titrations whose RGB triples, when converted to HSL, yield a lightness value less than 94. This represents the results of the contest.
The other output is a list of all the people who have failed the lab. This includes the people with the lightness values greater than 94, but also people whose lightness values are less than or equal to 65 because these people's titrations are too inaccurate.
This is code-golf, so shortest code in bytes win.
Test Cases
These test cases all assume that the error is always 0 for ease in checking if your program is correct. The results from your program should be different each time you run it.
["D966FF", "ECB3FF", "AC00E6"] -> ["ECB3FF", "D966FF", "AC00E6"], ["AC00E6"]
["EDB8FF", "D761FF", "9100C2", "FBEFFF"] -> ["EDB8FF", "D761FF", "9100C2"], ["FBEFFF", "9100C2"]
["F5D6FF"] -> ["F5D6FF"], []

@PeterTyler Actually, only one of them is wrong invalid, and that is the fourth element in the 2nd test case, which evaluates to 284º instead of 285º when converted to HSL.

@PeterTaylor It's fixed now.

Pyth, 35 34 bytes
Input already converted to decimal.
L+O32+eSbhSbf<yTJ495Qf|gyTJ<yT347Q

Test suite.
Previous 35-byte version:
Input already converted to decimal.
L+O32+eSbhSbf<yT495Qf|gyT495<yT347Q

Test suite.
Verify that the third testcase is not the same for each run.
Sample input/output:
input:
[[217, 102, 255], [236, 179, 255], [172, 0, 230]]
output:
[[217, 102, 255], [236, 179, 255], [172, 0, 230]]
[[172, 0, 230]]

Explanation
(max/255 + min/255)/2 + random[-0.03 .. 0.03] >= 0.94
(max/255 + min/255) + random[-0.06 .. 0.06] >= 1.88
max + min + random[-15 .. 15] >= 479.4
max + min + random[0 .. 31] >= 494.4
max + min + random[0 .. 31] >= 495

(max/255 + min/255)/2 + random[-0.03 .. 0.03] <= 0.65
(max/255 + min/255) + random[-0.06 .. 0.06] <= 1.30
max + min + random[-15 .. 15] <= 331.5
max + min + random[0 .. 31] <= 346.4
max + min + random[0 .. 31] < 347

L+O32+eSbhSbf<yT495Qf|gyT495<yT347Q
                                     @memoized
L                                    def y(b):
 +O32                                    return random(range(32)) +
     +eSb                                b.sort[-1] +
         hSb                             b.sort[0]
            f      Q                 filter for elements in Q as T:
             <yT495                      y(T) < 495
                                     (implicitly printed)
                    f             Q  filter for elements in Q as T
                     |gyT495             y(T) >= 495 or
                            <yT347       y(T) < 347
                                     (implicitly printed)

Before you complain that it calls random three times, hence having inconsistent outputs from the function, note that the function is memoized.
Before you complain that different students with the same colour always produce the same outcome, note that the question never said that the random generator must be independent. It must only be uniform.


text:
Calculate the Numpad Taxicab
Credit goes where credit is due

Given two digits, x, and y, calculate the shortest number of horizontal or vertical jumps to get from x to y on a standard numpad, e.g.
789
456
123
00

You can safely assume that all inputs will be 0-9, and you do not have to handle invalid inputs. The input may be the same number twice, which has a distance of 0.
IO can be in any reasonable format, and standard loopholes are forbidden. Shortest answer in bytes wins!
Sample IO:
1, 4: 1
1, 8: 3
3, 7: 4
8, 2: 2
6, 1: 3
0, 9: 4
4, 4: 0
0, 4: 2

Related.

Jelly, 11 bytes
o-1.’d3ạ/ḞS

Try it online! or verify all test cases.
How it works
o-1.’d3ạ/ḞS  Main link. Argument: [a, b] (list of integers)

 -1.         Yield -1.5.
o            Take the logical OR of a and b with -1.5.
             This maps 0 to -1.5, and all other integers to themselves.
    ’        Decrement the results.
     d3      Divmod; compute quotient and remainder of each result divided by 3.
       ạ/    Reduce by absolute difference across columns.
         Ḟ   Floor; round all differences down to the nearest integer.
          S  Sum; add the rounded absolute differences.

Nice comeback .

Python, 140 114 bytes
I am a first timer, so please help. Here's my code.
def f(x,y):x,y,k=x-1,y-1,abs;return x!=-1 and y!=-1 and k(y//3-x//3)+k(y%3-x%3) or k(y//3-x//3)+int(max(x,y)%3==2)

Some tips: 1) use single spaces for indents, 2) drop the parentheses around the if condition, 3) get rid of the space in the argument list, 4) divmod may help you, 5) instead of if cond:return A\nelse:return B, do return cond and A or B.

@Mego How does divmod help? I don't think I've ever saved bytes with that

@Sp3000 Perhaps Mego means that by defining (for example) p,q=divmod(x,3);r,s=divmod(y,3), Dhruv could save bytes in k(y//3-x//3)+k(y%3-x%3 by changing to k(r-p)+k(s-q). In addition, I think you can remove int and just have (max(x,y)%3==2)

@Sherlock9 The thing is, p,q=x//3,x%3 is always better than p,q=divmod(x,3), even in Python 3

@Sp3000 Ah, that's what you mean. Yeah, do that, Dhruv.

@DrGreenEggsandHamDJ Python lambdas don't support multiple assignment. He'd lose a lot of bytes without those definitions.

Jelly, 13 bytes
+2$.¹?€d3ạ/SḞ

Try it online!
Port of my Pyth answer.
Test suite.

JavaScript (ES6), 59
Unfortunately, no divmod in javascript. In fact, no integer div, and no mod either: the % is not exactly mod. But for once, the weird behaviour of % with negative numbers is useful.
(a,b,A=Math.abs)=>A(~(--a/3)-~(--b/3))+A(a%3-b%3)-(a*b%3<0)

Test

f=(a,b,A=Math.abs)=>A(~(--a/3)-~(--b/3))+A(a%3-b%3)-(a*b%3<0)

for(i=0;i<10;console.log(r),i++)
  for(r='',j=0;j<10;j++)
    r+=[i,j,f(i,j)]+' '

So, this ends up calculating as if 0 is to the left of 1 instead of below it, and then the (a*b%3<0) is the sneaky adjustment for the second 0. Nice!

Pyth, 22 21 19 bytes
FGITW.
L.D?b+2b.5 3ssaMCyM

Test suite.
Conversion table:
0: [0.0, 0.5]
1: [1, 0]
2: [1, 1]
3: [1, 2]
4: [2, 0]
5: [2, 1]
6: [2, 2]
7: [3, 0]
8: [3, 1]
9: [3, 2]

Python 2, 61 bytes
lambda x,y:abs(x/-3-y/-3)+abs((x or 1.5)%-3-(y or 1.5)%-3)//1

Test it on Ideone.
How it works

Vertical distance
Integer division always round down to the nearest integer in Python, yielding the following results for the 10 possible dividends divided by -3.
 0  1  2  3  4  5  6  7  8  9
 0 -1 -1 -1 -2 -2 -2 -3 -3 -3

Thus, we can compute the vertical distance between x and y as abs(x/-3-y/-3).
Horizontal distance
For columns, we can avoid treating 0 as a special case by replacing it with 1.5, thus placing it "between" the first and second column.
Modulus (%) always has the sign of the divisor in Python, yielding the following results for the 10 possible dividend modulo -3.
   0  1  2  3  4  5  6  7  8  9
-1.5 -2 -1  0 -2 -1  0 -2 -1  0

Thus, by rounding down (//1) the result of abs((x or 1.5)%-3-(y or 1.5)%-3), we can compute the horizontal difference between x and y.

Julia, 56 bytes
x->sum(abs(-([[divrem(t>0?t+2:.5,3)...]for t=x]...)))÷1

Try it online!

Java 149 160 chars
The obligatory: Because... you know... Java!
Having fun with Java in under 150 161 chars:
int d(int f,int t){if(f==t)return 0;if(Math.min(f,t)==0){int m=Math.max(f,t);return Math.min(d(1,m),d(2,m))+1;}return Math.abs(--t%3- --f%3)+Math.abs(t/3-f/3);}

Ungolfed into a class:
public class Q80357 {

    static int distance(int from, int to) {
        if (from == to)
            return 0;
        if (Math.min(from, to) == 0) {
            int max = Math.max(from, to);
            return Math.min(distance(1, max), distance(2, max)) + 1;
        }
        return Math.abs(--to % 3 - --from % 3) + Math.abs(to / 3 - from / 3);
    }
}

How it works
First it catches the standard case where we don't have to move anywhere.
Now we can assume that both integers differ, thus only the smaller one can be 0. If this is the case we calculate the distance from key 1 and 2 to the other key. We will use the one with the shorter distance and add one step to get from 1 or 2 to 0.
If we don't want to go to/from zero we only have to move in the 3x3 grid. We can determine the column and row of the key by using mod or div respectively. Then we calculate the column and row distance and add them. This is the distance we need to get from one key to another.
I hope the explanation could be understood, feel free to golf :)
Updates
Had to change it into an actual function as it uses recursion which isn't possible with lambdas :,(


text:
Chaining Words Together
Given two words and a list as input, your program must (in as few characters as possible, of course) find the shortest way to "chain" the first word to the last using the ones in the list. Two words are "chained" if their first and last letters are the same, e.g. "Food" and "Door".
Your program will take input as a string with words separated by spaces, and output a list (in whatever format is most convenient: string, array/list type, etc) of the completed chain.
Examples:
Input: joke corn tan disc need eat
Output: joke eat tan need disc corn
The first two words in the input list are the first and last words in the chain, and the rest are the constituent words.
Input: best fry easy elf mean tame yam nice
Output: best tame elf fry
NOT: best tame easy yam mean nice elf fry
Input: rug gunned orange purple gains pore soup emo ending
Output: rug gunned
Input: %3gioxl? 6699-4 !f!!&+ ?4; ;78! +6
Output: %3gioxl? ?4; ;78! !f!!&+ +6 6699-4
The "words" don't have to be real words; for the purpose of the challenge, any ASCII character except the space will count as part of a word.
Input: mouth rich frame inspire item sold
Output when the first and last word are impossible to chain is undefined, so handle it however's shortest.

Will the words have hyphens?

@LeakyNun Count hyphenated words as one word. I forgot to address "words" with symbols in them, however - I'll add a usage example for it.

Could you define "word" in your challenge?

Related: 1, 2, 3

@LeakyNun does the second-to-last example (edited in now) work?

Hardly a definition. Did you mean /[^ ,|]+/?

Referring to the delimiters? I tried to address that above, check the bolded bit.

Is the definition of "word" /[^ ,|]+/? Also, your delimiter is two characters long.

Alright، I'm rusty with regex and had forgotten what the carer means, my bad. I reworked the whole delimiter situation, is this better?

{Why do / Do} we need to use delimiters rather than input and/or output as arrays (ordered tuples)?

That was an oversight - input must be taken as a string with words separated by spaces, but the output may be in any format you wish.

Pyth - 42 bytes
Complete brute force. Surprisingly fast, finishes all possible the test cases in seconds. Will run forever with impossible inputs.
Acczd]2.VZIJf.Amqhedehd,VTtTm++hGdeG^HbhJB

Test Suite.

Impoosible Is that like a mongoose?

@EᴀsᴛᴇʀʟʏIʀᴋ :/

"Imøøsible" is the only valid choice here.

Pyth, 51 48 bytes
FGITW.
=cQdMqeGhHL++hQb@Q1holN{+Fmf.AgVTtTyM+]Y._d.p>Q2

Test suite.