text:
Find imperfect anagrams
The goal of this challenge is to write a program which takes a string (of any length) as input and displays anagrams (see these examples of anagrams) of this string, made by taking words in a dictionary (either individually or in pairs), but the anagrams don't need to be perfect.
An anagram is the result of a rearrangement of a set of characters:

ABCD and CADB are perfect anagrams, all the characters are present in both strings
ABCD and CADBEF are imperfect anagrams because the characters ABCD are present in both strings but the characters EF only exist in the second string

The dictionary contains 1949 words:
ability
able
aboard
etc.

By taking each word and each pair of distinct words we generate a list of candidates to compare against the input:
ability
ability able
ability aboard
ability ...
able
able aboard
able ...
...

The program must display only the strings from the previous list which are anagrams of the input string. In other words, the program needs to filter the candidates down to the imperfect anagrams of the input.
Examples
Input
Sample:
> your_program 85 "Meta Code Golf" ./dict.txt

You may take input from any method you like, be it command line arguments or stdin.
Expected output
ExCLAiMED FOOT
FrEEDOM LOCATe

(if I didn't make any mistake in my code)
Rules
Input:
n string filepath

(You may take input from any method you like, be it command line arguments or stdin)

The first input will be an integer n. This is a threshold to define the minimum percentage of characters which must be present in the string input and the anagrams. n will be between 0 and 100, inclusive
The second input will be a string (a string with one or more words)
The path to a file containing one word per line. The dictionary to use is available here (**), it contains 1949 common words (source). You have to save this file without the comments to keep one word per line

**: I chose to use only 1949 common words because the dictionaries like wamerican package (with Ubuntu it adds the /usr/share/dict/american-english file) contains about 100,000 words, this would lead to 10,000,000,000 possible combinations of 2 words. It may take to much time to compute in the context of code golfing. But a program which works with 2,000 words may still work with 100,000 words if someone wants to use all the words from a complete dictionary.
Output:

One matching anagram string per line. The matching letters between the input string and the anagram must be displayed in uppercase, and the non-matching letters must be lowercase. In the example, only 2 of the 3 e are in uppercase, because there are only 2 e in Meta Code Golf
You must not display the same anagram twice (eg. ExCLAiMED FOOT and FOOT ExCLAiMED are both valid but they are only the result of a swap between the 2 words)

Other rules:

Comparison between input string and anagrams:

Lower and upper-case characters are considered as the same character when searching the anagrams
Non-letter characters  (space), -, etc. are considered as one character

Standard “loopholes” are forbidden
Shortest code wins

Similarity index and threshold
Similarity index:
The similarity index (SI) is calculated by counting the number of times each character from a string appear in another string. So we have to compute 2 SIs if the 2 strings have different lengths.
Examples
ABCD and CADB are perfect anagrams, the characters are identical, the SI is 100%
ABCD and CADBEF:
 - ABCD in CADBEF: the SI is 100% because all the characters of the first string exist in the second string
 - CADBEF in ABCD: the SI is 4/6 because ABCD are present in the second string (and not E and F)
You have to ensure that you compare the input with the word and the word with the input, otherwise the word AAABBBCCCDDDEEE (etc.) may match the vast majority of the words. So we have to check that the 2 SIs are greater or equal than the threshold in order to accept an anagram.
Example of SI function (pseudo-code):
function SI(a, b) {
    s_i = 0

    foreach (character in a) {
        if (character exists in b) {
            remove the character in b /* avoid to find several times "AAAA" in "A" */
            s_i++
        }
    }

    return(s_i / length(a))
}

Threshold
The threshold acts as a filter to display only the anagrams which SI is greater or equal than the threshold.
To apply the threshold, we must use this function twice:
if ((SI(input, candidate) >= threshold) && (SI(candidate, input) >= threshold)) {/* anagram is ok */}

Examples:
Threshold = 100
> program 100 "explanation" ./dict.txt
EXPLANATION

There is only one result because there is no perfect anagram for Explanation, except the word itself.
Threshold = 90
> program 90 "explanation" ./dict.txt
ALONE PAINT
EXPLAIN NOT
EXPLANATION
NATION PALE

Threshold = 75
> program 75 "explanation" ./dict.txt
AbLE cONTAIN
AbLE NATION
AbOuT EXPLAIN
AcT EXPLAIN
AcTION ALoNE
AcTION ANgLE
...

Threshold = 0
> program 0 "Meta Code Golf" ./dict.txt
AbILiTy
AbILiTy AblE
AbILiTy AbOard
AbILiTy AbOut
...

It will display all the words and all the combination of words from the dictionary (because all the SIs are greater or equal than the threshold).
Random example
> program 85 "Beyonce Knowles" ./dict.txt
BEtWEEN COLONY
COWBOY SENtENcE

I was inspired by a french TV program named Le Complot where they make funny correlations between two unrelated persons, ideas, etc. For example, they showed that the soccer player Pastore is an anagram of Apotres (the french word for Apostles) in order to link Zlatan Ibrahimovic to Catholic Church.

Is it just me or even after reading the whole question, I am unsure of what the question is asking ? :|

@Optimizer: the question is about creating a program to find fuzzy anagrams of an input string in a dictionary file.

The explanation of what the percentage match means seems to assume that the original and the value being compared are the same length, but that's not the case in the examples. What precisely is the test?

Seems like the threshold needs to be clarified more.

IIRC, I had a function which count characters in common, I had to use it on input vs compared string, and compared vs input string then check if the 2 results were both greater than the threshold.

I updated the question by adding examples. If you have a better wording than "fuzzy anagrams" feel free to post it, I didn't found any better expression. Do you prefer "imperfect anagrams"?

@BetaDecay: can you please explain what part you don't understand?

@A.L I don't understand how you validate that something is a fuzzy anagram of a string

@BetaDecay: please see the "Score and threshold" part.

OK, so as I understand it: Let n be the number of alpha characters (AC) in the second argument; let N be the number of AC that appear in a candidate word sequence (CWS); let c be the number of AC in the second argument that also appear in the CWS, respecting multiplicity; let C be the number of AC in the CWS that also appear in the AC, respecting multiplicity. Let t be the first argument (the threshold). Then we accept a CWS iff 100*C/n >= t && 100*c/N >= t. And since C = c, we can simplify this to accepting a CWS iff 100*C/max(n,N) >= t. Is this a correct understanding?

@COTO: yes I think it's correct, but it should be min() and not max() at the end, because you apply the threshold to the 2 scores. I'll use your comment to improve my question.

The more restrictive of the two conditions is the one with the larger denominator. If you use min(n,N), the acceptance criterion effectively becomes that 100*C/n >= t or 100*c/N >= t must hold true for the CWS to be accepted. This would cause, e.g. "apple" to be accepted as a fuzzygram for input "a" at a 100% threshold since n = 1, N = 5, c = C = 1, and thus 100*C/min(n,N) >= t.

@COTO: I'm sorry but for me using min() will be the same as &&. See: "a" in "apple" has a score of 100%, but "apple" in "a" has a score of 20%. So the minimum is 20%, and it may be rejected, depending on the threshold.

Your pseudocode makes the condition clearer. I'd suggest changing "score" to "similarity", e.g. "similarity function", since "score" generally pertains to criteria on how to win the challenge. Also, note that the problem is prone to combinatorial explosion for low t. You might want to set a lower bound of t = 50. Just some suggestions. ;)

Don't worry about the min/max thing. The pseudocode is clear enough.

@COTO: thanks a lot, now I see why people are confused, I just realised that people thought score was a winning criterion.

I've replaced the score by Similarity Index. I hope it will be clearer now.

@Quincunx: I'll see tomorrow about the SI thing. You're free to accept input by commandline or any other method as long as the input is not hard-coded.

@Quincunx: thanks, I just saw that. It's greater than or equal, not greater only.

Can I get more explanation on "Non-letter characters (space), -, etc. are considered as one letter"? I am not sure what that means. From the examples I gather that they are treated as letters (but different non alpha characters are not equal to each other) that are lower and upper case of themselves.
If this is the case that is confusing because in anagrams normally non letter characters are not ignored and you use 'letter' often in the task description when in the end it should read character. Also in the comment above you did not correct COTO defining length in alpha characters.

@nutki : I wanted to say that spaces must not be ignored, but the formulation is not very clear. So space must be treated as a character : must be found in input and anagram to accept the anagram. I'll replace "letter" with "character" in the question.

Perl 5 -  166 158 146  143
4 of the new line characters are added for clarity (those following a semicolon).
$s.=lc"+s/$_/uc\$&/e"for($i=pop)=~/[a-z]| (?!.* )/ig;
$/=pop;
$_=<>;
s!.+!"$&".join"
$& ",$'=~/^|.+/g!ge;
100*eval$s<$/*length($_|$i)||print"$_
"for split'
'

The array based candidate generation actually proved to be shorter than my original string substitution one. Kept the previous 153 version as its output order is exactly as in the examples (though it is not required).
$s.=lc"+s/$_/uc\$&/e"for($i=pop)=~/[a-z]| (?!.* )/ig;
$z=pop;
100*eval$s<$z*length($_|$i)||print"$_
"for map{map$&." $_"x!/^$&$/,@s=(@s,/.+/g)}<>

Usage:
perl ./a.pl 90 "explanation" <dict.txt

Edit
This version should conform to the specification with regard to non letter characters.

I tested it successfully, you win! Is there a reason it uses so much space (up to 400 MB)?

Python 2, 375 ... 313
S=lambda a,b:1.*len([b.remove(q)for q in a if q in b])/len(a)
T=lambda a,b:min(S(a,b[:]),S(b,a[:]))
t,s,d=input()
d=open(d).read().split()
for x in{' '.join(sorted([a,b]))for a in d for b in d}|set(d):
 q=list(s.lower())
 if T(list(x),q)*100>=t:print''.join([w,w.upper()][q.count(w)and not q.remove(w)]for w in x)

This expects slightly different input; like so: 90, "explanation", "dict.txt". If that's not allowed, I'll fix it.
Sample run, with stdin 90, "explanation", "dict.txt":
EXPLANATION
NATION PALE
EXPLAIN NOT
ALONE PAINT

This works by iterating through a set of all the possibilities, checking them. This is what makes it so slow.
S=lambda a,b:1.*len([b.remove(q)for q in a if q in b])/len(a) # define the SI function
  lambda a,b:                                                 # define a lambda with 2 inputs
                     b.remove(q)for q in a if q in b          # for q in a, if q is in b, remove q from b
                len([                               ])        # list.remove returns None, so collect all the removes and the resulting list will have len of the number of times we removed things
             1.*len([b.remove(q)for q in a if q in b])/len(a) # 1.* converts the len to a float, so that when we divide by len(a), we get a float

T=lambda a,b:min(S(a,b[:]),S(b,a[:])) # Determine the min SI for both possibilities
                 S(a,b[:]),           # run S with a and a copy of b; since b gets removes called in S
                           S(b,a[:])  # run S with b and a copy of a
             min(S(a,b[:]),S(b,a[:])) # get the min of those values

t,s,d=input()
d=open(d).read().split() # read the dict file and split it on newlines, creating a list of words

for x in{' '.join(sorted([a,b]))for a in d for b in d}|set(d): # iterate over possible word choices
                         [a,b]  for a in d for b in d          # create all possible pairs of words
                  sorted(     )                                # sort the list, making it so that ['exclaimed', 'foot'] and ['foot', 'exclaimed'] make the same element
         ' '.join(             )                               # combine the words with a space between
        {                                            }         # turn into set; this is a set comprehension
                                                      |set(d)  # take the union of that set and the set of single words.
for x in                                                     : # this is what we iterate over

 q=list(s.lower()) # we want to convert our string to lowercase, but we also want it as a list of characters because str doesn't have a remove function.

 if T(list(x),q)*100>=t: # decide if the element of the set matches the threshold
                        print''.join([w,w.upper()][q.count(w)and not q.remove(w)]for w in x) # it does; now we print the correct output
                                     [w,w.upper()]                               for w in x) # consider both the lower/uppercase versions of the char in the string
                                                  [q.count(w)and not q.remove(w)]            # if w appears at least once in the target string, we remove it from the target string, and do a logical negation on the None, resulting in True ie 1, so we choose uppercase
                             ''.join(                                                      ) # join these elements back into a string
                        print                                                                # print the result

Do you use a round function for the threshold? 90% * 11 = 9,9. So 10 characters must be present in input and anagram, so you can change only one letter. Did you count the space as a character? For example in EXPLAIN TOrN you have 2 differences: space and r.

@A.L That might be my problem; I was under the impression spaces were to be stripped before putting it into the SI.

Is there a reason the results are displayed in descending order? I didn't mentioned in the rule so it's OK but I'm just wondering.

@A.L Yes, although descending is coincidence; it could easily be in any order. I specifically didn't put it any order. This happens because I'm using Python's set, which is unordered, meaning ordered according to a hash.

I can actually think of a (probably, definitely with big dictionaries) much more time-efficient method of doing this: start with the string we want to make, and generate all close anagrams, then check to see if each word in each close anagram is in the dictionary.

Python 3 - 447
Again, this is one of these programs that takes a long time to test, but I'll add one of the test cases once it's done.
from sys import*
l=argv
e=''
t=[]
v=list
n='\n'
g=open(l[3]).read()
def s(a,b):
 m=0;a=list(a)
 for i in a:
  if i in b:b.remove(i);m+=1
 return m/len(a)*100
for i in g.split(n):
 for j in(n+g).split(n):
  a=i+' '+j if j!=''else i
  b=l[2].lower();c='';d=v(b);w=set(b.split(' '))
  t=l[1]
  if(s(a,d)>=t)and(s(d,v(a))>=t):
   if not w in t:
    for k in a:
     if k in d:d.remove(k);c+=k.upper()
     else:c+=k
    t.append(w)
    e+=c+n
print(e)

Edit
The latest edit accounts for the rule that states that you must not print different arrangements of the two words.

R - 512 (= 29!)
v=function(a){unlist(strsplit(tolower(a),""))}
s=function(a,b){
s=0;for(l in a){if(l%in%b){b=b[-(which(l==b)[1])];s=(s+1)}};s/length(a)}
r=function(v,j){p=c();for(l in v){if(l%in%j){j=j[-(which(l==j)[1])]
o=toupper(l)}else{o=tolower(l)};p=c(p,o)};cat(p,"\n",sep="")}
a=commandArgs(T);j=v(a[2]);k=(as.integer(a[1])/100);
d=scan(a[3],what='raw',sep="\n",quiet=T);
for(w in d){t=v(w);if((s(t,j)>=k)&&(s(j,t)>=k)){r(t,j)};
for(x in d[-1]){w2=paste(w,x,sep=" ");t=v(w2)
if((s(t,j)>=k)&&(s(j,t)>=k)){r(t,j)}};d=d[-1]}

Ungolfed
get_array = function (a) {unlist(strsplit(tolower(a),""))}

# calculate similarity index of 2 strings
get_s = function (a, b) {
    s = 0
    for (letter in a) {
        if (letter %in% b) {
            b = b[-(which(letter == b)[1])]
            s = (s + 1)
        }
    }
    return(s / length(a))
}

# output
get_result = function (var_string, input) {
    output = c()

    for (letter in var_string) {
        if (letter %in% input) {
            input = input[-(which(letter == input)[1])]
            o = toupper(letter)
        }
        else
        {
            o = tolower(letter)
        }
        output = c(output, o)
    }
    cat(o, "\n",sep="")
}

# get arguments
a = commandArgs(T)
input = get_array(a[2])
threshold = (as.integer(a[1]) / 100)
dict = scan(a[3], what='raw', sep="\n", quiet=T)

# iterate through all the words from the dictionary
for (w in dict)
{
    t = get_array(w)

    # the word only
    if (
        (get_s(t, input) >= threshold)
        &&
        (get_s(input, t) >= threshold)
    )
    {
        get_result(t, input)
    }

    # the word + another word
    for (x in dict[-1]) {
        w2 = paste(w, x, sep=" ")
        t = get_array(w2)
        if (
            (get_s(t, input) >= threshold)
            &&
            (get_s(input, t) >= threshold)
        )
        {
            get_result(t, input)
        }
    }

    dict = dict[-1] # remove the word once it has be permuted with all the other words
}


text:
Four color theorem
The Four color theorem States that no more than four colors are required to color the regions of a map.
The challenge
Given a list of State borders assign each state ID a color so that no two adjacent states have the same color. The output Should be a CSS stylesheet assigning the color to the state's 2 letter ID code.  Here is a SVG map which the stylesheet could be applied to. http://upload.wikimedia.org/wikipedia/commons/3/32/Blank_US_Map.svg
The rules

Shortest code wins
any state border list can be used
only 4 colors can be used.
the state list can be hardcoded

Advice:  Use the CSS fill: property to change the color, For example #AL{fill:green}
Here is a list of state borders
AL-FL
AL-GA
AL-MS
AL-TN
AR-LA
AR-MO
AR-MS
AR-OK
AR-TN
AR-TX
AZ-CA
AZ-CO
AZ-NM
AZ-NV
AZ-UT
CA-NV
CA-OR
CO-KS
CO-NE
CO-NM
CO-OK
CO-UT
CO-WY
CT-MA
CT-NY
CT-RI
DC-MD
DC-VA
DE-MD
DE-NJ
DE-PA
FL-GA
GA-NC
GA-SC
GA-TN
IA-MN
IA-MO
IA-NE
IA-SD
IA-WI
ID-MT
ID-NV
ID-OR
ID-UT
ID-WA
ID-WY
IL-IA
IL-IN
IL-KY
IL-MO
IL-WI
IN-KY
IN-MI
IN-OH
KS-MO
KS-NE
KS-OK
KY-MO
KY-OH
KY-TN
KY-VA
KY-WV
LA-MS
LA-TX
MA-NH
MA-NY
MA-RI
MA-VT
MD-PA
MD-VA
MD-WV
ME-NH
MI-OH
MI-WI
MN-ND
MN-SD
MN-WI
MO-NE
MO-OK
MO-TN
MS-TN
MT-ND
MT-SD
MT-WY
NC-SC
NC-TN
NC-VA
ND-SD
NE-SD
NE-WY
NH-VT
NJ-NY
NJ-PA
NM-OK
NM-TX
NM-UT
NV-OR
NV-UT
NY-PA
NY-VT
OH-PA
OH-WV
OK-TX
OR-WA
PA-WV
SD-WY
TN-VA
UT-WY
VA-WV

Can we hardcode the list of state borders?

@hsl yes, it is ok to hardcode state borders.

@steveverrill if you can think of a better method of changing colors that would be great. I added an example showing how to use CSS.

Wouldn't this require reproducing the proof the Four Color Theorem itself? Since you have to handle every possible case?

Wouldn't this Theorem prove wrong if a state's border is touching more than 3 other states ?

My mathematical pedantry forces me to point out that your explanation of the 4 colour theorem isn't right, one colour is enough if you don't put constrains on the colouring!

Oh wow, I was just thinking of this as a challenge!

Ok the CSS is clear, you have my upvote now. I deleted my previous comment about hardcoding as it wasnt your intention. I guess you mean that if it's read in the state data doesn't count in your byte count but if it's hardcoded it does? Allowing hardcoding data on problems like this is a slippery slope towards hardcoding solutions. Anyway, the existing answer uses 60 bytes to parse the data, while hardcoded data would need 6 bits for each of the 109 borders just to hold a numeric value for one state (without even considering the other state or the letter codes) so I don't think its worth it.

@Optimizer TN borders 7 other states and yet the US can still be 4-colored. Just because two states border TN doesn't mean they border each other.

Python, 320 chars
import sys,random
S=[]
E={}
for x in sys.stdin:a=x[:2];b=x[3:5];S+=[a,b];E[a,b]=E[b,a]=1
C={0:0}
while any(1>C[s]for s in C):
 C={s:0for s in S};random.shuffle(S)
 for s in S:
    A=set([1,2,3,4])-set(C[y]for x,y in E if x==s)
    if A:C[s]=random.choice(list(A))
for s in C:print'#%s{fill:%s}'%(s,' bglrloieulmdede'[C[s]::4])

Uses a randomized algorithm.  Assign colors to states in random order by selecting a color that doesn't conflict with adjacent states that have already been colored.
Seems to work in a tenth of a second or so on the given input.
Example output:
$ 4color.py < stategraph
#WA{fill:red}
#DE{fill:gold}
#DC{fill:blue}
#WI{fill:blue}
#WV{fill:red}
#FL{fill:lime}
#WY{fill:gold}
#NH{fill:red}
#NJ{fill:lime}
#NM{fill:gold}
#TX{fill:red}
#LA{fill:blue}
#NC{fill:blue}
#ND{fill:gold}
#NE{fill:blue}
#TN{fill:red}
#NY{fill:gold}
#PA{fill:blue}
#RI{fill:gold}
#NV{fill:red}
#VA{fill:gold}
#CO{fill:red}
#CA{fill:gold}
#AL{fill:blue}
#AR{fill:gold}
#VT{fill:lime}
#IL{fill:red}
#GA{fill:gold}
#IN{fill:lime}
#IA{fill:gold}
#OK{fill:blue}
#AZ{fill:lime}
#ID{fill:lime}
#CT{fill:red}
#ME{fill:blue}
#MD{fill:lime}
#MA{fill:blue}
#OH{fill:gold}
#UT{fill:blue}
#MO{fill:lime}
#MN{fill:red}
#MI{fill:red}
#KS{fill:gold}
#MT{fill:blue}
#MS{fill:lime}
#SC{fill:red}
#KY{fill:blue}
#OR{fill:blue}
#SD{fill:lime}

Example pasted into svg.

tan is apparently a supported SVG colour. Shame that you can only get one three-colour one with the ::4 trick.

@PeterTaylor: tan looks awful.  Totally worth 1 character to use gold instead.

Can you guarantee this algorithm will always finish in finite time provided a 4-color solution exists? :)

@barrycarter: It is guaranteed to finish with probability 1.  It might take time exponential in the size of the map, though.

@KeithRandall I was sort of teasing, but... if you check for repeats, it could take 4^(n-1) steps to find the right coloring (n-1 because of symmetry of the colors). If you don't check for repeats, it could take longer still. I just found the solution unsatisfying, since it's not "really" a "proper" algorithm.

Prolog, 309 307 283 chars
:-initialization m.
a-X:-assert(X);retract(X),1=0.
r:-maplist(get_char,[A,B,E,C,D,F]),(E=F;X=[A,B],Y=[C,D],a-X/Y,a-Y/X,(s/X;a-s/X),(s/Y;a-s/Y),r).
s+[]:- \+ (X*C,writef('#%s{fill:#%w}',[X,C]),1=0).
s+[X|T]:-member(C,[911,191,119,991]),a-X*C,\+ (X/Y,Y*C),s+T.
m:-r,bagof(X,s/X,L),s+L.

The algorithm uses backtracking / depth-first search to fill out the map.
A bit more readable:
:- initialization(main).

% Found on http://awarth.blogspot.de/2008/08/asserts-and-retracts-with-automatic.html
assert2(X) :- assert(X).
assert2(X) :- retract(X), fail.

% Reads all states into clauses "state-State",
% and all connections into "State-Neighbor" and "Neighbor-State".
read_states :-
    % Read a line "AB-CD\n"
    maplist(get_char, [A,B,E,C,D,F]),
    (   A = F;
        State = [A, B],
        Neighbor = [C, D],
        % Memorize the connection between State and Neighbor in both directions.
        assert(State/Neighbor),
        assert(Neighbor/State),
        % Memorize State and Neighbor for the list of states.
        (state/State; assert(state/State)),
        (state/Neighbor; assert(state/Neighbor)),
        % Continue for all lines.
        read_states
    ).

% Print out all colors.
solve([]) :-
    once((
        State*Color,
        writef('#%s{fill:%w}', [State, Color]),
        fail
    )); !.

% Use depth-first search to color the map.
solve([State|FurtherStates]) :-
    member(Color, ['#911', '#191', '#119', '#991']),
    assert2(State*Color),
    \+ (State/Neighbor, Neighbor*Color),
    solve(FurtherStates).

main :-
    read_states,
    bagof(State, state/State, States),
    solve(States).

Invocation:
cat borders.txt | swipl -q ./fourcolors.pl

Result (newlines are not needed):
#AL{fill:#911}#FL{fill:#191}#GA{fill:#119}#MS{fill:#191}#TN{fill:#991}#AR{fill:#911}#LA{fill:#119}#MO{fill:#191}#OK{fill:#119}#TX{fill:#191}#AZ{fill:#911}#CA{fill:#191}#CO{fill:#191}#NM{fill:#991}#NV{fill:#991}#UT{fill:#119}#OR{fill:#911}#KS{fill:#911}#NE{fill:#119}#WY{fill:#911}#CT{fill:#911}#MA{fill:#191}#NY{fill:#119}#RI{fill:#119}#DC{fill:#911}#MD{fill:#191}#VA{fill:#119}#DE{fill:#119}#NJ{fill:#191}#PA{fill:#911}#NC{fill:#911}#SC{fill:#191}#IA{fill:#911}#MN{fill:#191}#SD{fill:#991}#WI{fill:#119}#ID{fill:#191}#MT{fill:#119}#WA{fill:#119}#IL{fill:#991}#IN{fill:#191}#KY{fill:#911}#MI{fill:#911}#OH{fill:#119}#WV{fill:#991}#NH{fill:#911}#VT{fill:#991}#ME{fill:#191}#ND{fill:#911}

Pasted into an SVG: http://jsbin.com/toniseqaqi/

JavaScript (ES6) 269 279
Recursive search with backtracking. ~80 bytes spent for state list parsing.
 F=l=>{
   S=(a,b)=>S[a]=(S[a]||[]).concat(b),
   l.replace(/(..)-(..)/g,(_,a,b)=>S(a,b)+S(b,a)),
   k=Object.keys(S),
   R=(p,c=k[p])=>!c||['blue','gold','red','tan'].some(i=>!c.some(t=>S[t].c==i)&&(c.c=i,R(p+1)||(c.c='')),c=S[c]),
   R(0),
   k.map(k=>console.log('#'+k+'{fill:'+S[k].c+'}'))
 }

Ungolfed
F=l=>{
  var states = {}; // hash table with adiacent list for each state
  S=(a,b)=>states[a]=(states[a]||[]).concat(b);
  l.replace(/(..)-(..)/g,(_,a,b)=>S(a,b)+S(b,a)); // build the hash table from the param list

  keys = Object.keys(states); // get the list of hashtable keys as an array (the 49 states id)
  Scan=(p)=> // Recursive scan function
  {
    var sId = keys[p]; // in sid the current state id, or undefined if passed last key
    if (!sId) return true; // end of keys, recursive search is finished
    var sInfo = states[sId]; // in sInfo the aarray of adiacent states id + the color property

    return ['blue','gold','red','tan'].some( (color) => // check the four avaialabe colors
      {
        var colorInUse = sInfo.some( (t) => states[t].color == color); // true if an adiacent state already has the currnet color
        if (!colorInUse) // if the color is usable
        {
          sInfo.color = color; // assign the current color to the current state
          var ok = Scan(p+1); // proceed with the recursive scan on the next state
          if (!ok) // if recursive scan failed, backtrack
          {
            sInfo.color = ''; // remove the assigned color for the current state
          }
          return ok;
        }
      }
    )
  },
  Scan(0), // start scan
  keys.forEach( (sId) => console.log('#'+sId+'{fill:'+states[sId].color+'}')) // output color list
}

Test in FireFox/FireBug console
list = "AL-FL AL-GA AL-MS AL-TN AR-LA AR-MO AR-MS AR-OK AR-TN AR-TX AZ-CA AZ-CO AZ-NM "+
"AZ-NV AZ-UT CA-NV CA-OR CO-KS CO-NE CO-NM CO-OK CO-UT CO-WY CT-MA CT-NY CT-RI "+
"DC-MD DC-VA DE-MD DE-NJ DE-PA FL-GA GA-NC GA-SC GA-TN IA-MN IA-MO IA-NE IA-SD "+
"IA-WI ID-MT ID-NV ID-OR ID-UT ID-WA ID-WY IL-IA IL-IN IL-KY IL-MO IL-WI IN-KY "+
"IN-MI IN-OH KS-MO KS-NE KS-OK KY-MO KY-OH KY-TN KY-VA KY-WV LA-MS LA-TX MA-NH "+
"MA-NY MA-RI MA-VT MD-PA MD-VA MD-WV ME-NH MI-OH MI-WI MN-ND MN-SD MN-WI MO-NE "+
"MO-OK MO-TN MS-TN MT-ND MT-SD MT-WY NC-SC NC-TN NC-VA ND-SD NE-SD NE-WY NH-VT "+
"NJ-NY NJ-PA NM-OK NM-TX NM-UT NV-OR NV-UT NY-PA NY-VT OH-PA OH-WV OK-TX OR-WA "+
"PA-WV SD-WY TN-VA UT-WY VA-WV";
F(list);

Output
#AL{fill:blue}
#FL{fill:gold}
#GA{fill:red}
#MS{fill:gold}
#TN{fill:tan}
#AR{fill:blue}
#LA{fill:red}
#MO{fill:gold}
#OK{fill:red}
#TX{fill:gold}
#AZ{fill:blue}
#CA{fill:gold}
#CO{fill:gold}
#NM{fill:tan}
#NV{fill:tan}
#UT{fill:red}
#OR{fill:blue}
#KS{fill:blue}
#NE{fill:red}
#WY{fill:blue}
#CT{fill:blue}
#MA{fill:gold}
#NY{fill:red}
#RI{fill:red}
#DC{fill:blue}
#MD{fill:gold}
#VA{fill:red}
#DE{fill:red}
#NJ{fill:gold}
#PA{fill:blue}
#NC{fill:blue}
#SC{fill:gold}
#IA{fill:blue}
#MN{fill:gold}
#SD{fill:tan}
#WI{fill:red}
#ID{fill:gold}
#MT{fill:red}
#WA{fill:red}
#IL{fill:tan}
#IN{fill:gold}
#KY{fill:blue}
#MI{fill:blue}
#OH{fill:red}
#WV{fill:tan}
#NH{fill:blue}
#VT{fill:tan}
#ME{fill:gold}
#ND{fill:blue}

source: Stack Exchange

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

sort: votes


text:
Triangular battleships (A computational geometry problem)
You are the captain of a battleship. The engineering department's been cutting corners with designs this year, so the ship you're on takes the shape of a simple triangle.
You walk out onto the deck and enjoy the sea breeze... though not for long. An enemy has fired at you! — but will the shot hit?
Input
You may write either a function or a full program for this challenge.
Your program will take in 11 integers, ten of which are paired:

The first three pairs of integers (x1, y1), (x2, y2), (x3, y3) will specify the vertices of your ship. The triangle formed will have nonzero area.
The next pair of integers (ex, ey) specifies the location of the enemy's cannon. The enemy cannon will never lie on, or within the boundary of your ship.*
The pair (ax, ay) after that specifies where the enemy aimed at. This will be distinct from (ex, ey).
The final positive integer R specifies the range of the enemy's shot

*You'd be a terrible captain if you didn't even notice that happening!
Output
You must print/return a truthy value (e.g. true, 1) if the battleship will be hit, otherwise a falsy value (e.g. false, 0).
What is a hit?
The enemy shot is a straight line segment of length R from (ex, ey) in the direction of (ax, ay). If this line segment overlaps any part of the interior of your triangular battleship, then this counts as a hit. Otherwise it is not a hit.
Shots which graze along or only reach up to the boundary of the triangle do not count as a hit.
Examples
0 0 0 1 1 0
1 1
0 0
2

Hit: The enemy has shot right through the centre of your ship!

2 0 0 2 4 4
0 0
1 1
1

No hit: The enemy's range is too short, so you are safe.

0 0 1 2 3 0
-4 0
0 0
8

No hit: The enemy has grazed the side of your ship, so this does not count as a hit. Lucky!

0 0 -1 3 4 -1
-3 -4
3 4
5

No hit: The enemy shot just stops short of the ship, so you are safe. If the enemy's cannon had even slightly better range, then you would have been hit! Phew!

-2 -3 -3 6 7 -2
-6 2
1 -4
7

Hit: Even though the shot didn't penetrate to the other side, this is still a hit.

-3 2 2 -4 7 -3
-3 -4
-3 0
10

No hit: For the record, this is another close miss.

Additional test cases
0 0 6 0 6 8
-6 -8
6 8
20

No hit: This is another graze, but at an angle.

0 0 -2 -5 5 3
-3 4
0 0
6

Hit: The shot entered via a vertex of the ship.
Scoring
This is code-golf, so the shortest code in bytes wins. Standard loopholes apply.

Just to make sure we can't: can we assume the ship has no bottom and that there's a tiny gap between each two sides, so that if the shot manages to enter the ship through its corner, we count it as a miss?

@JanDvorak If a shot cuts through the ship by entering through a vertex, then this would be a hit because the line segment overlaps the interior of the ship. So in the 4th example, if the range was greater than 5, then this would be a hit.

How much are we allowed to play with the arguments? Are we allowed to group them, change the order, or require that they be floats?

@FryAmTheEggman You may group or reorder the arguments as necessary. You can use floats, but the program needs to work correctly for small grids (say, up to 20x20) without worrying about precision.

I think the examples are missing one important case that make my intended solution fail: when the ship is penetrated through a corner, for example 0 0 -1 3 4 -1 -3 -4 3 4 6.

@nutki Indeed, the cases seem to be a bit lacking - I've added two more trickier ones. (I was hoping to see programs which worked in rationals without having to worry about precision, hence the restriction to integer coordinates.)

I was working on a solution checking if any of the 3 sides are crossing the cannon line segment. This could be done completely in the integer domain, so no precision loss. But since touching a side is not a hit it will not work with my example.

Python 3, 252 bytes
This is certainly the most variables I've ever used in code golf. :^P
from math import*;A=atan2
def h(a,b,c,d,e,f,g,h,i,j,R):
 r=R;_=0
 while r>0:Q=A(j-h,i-g);k,l=g+r*cos(Q),h+r*sin(Q);D=A(d-b,c-a);E=A(f-b,e-a);F=A(l-b,k-a);G=A(b-d,a-c);H=A(f-d,e-c);I=A(l-d,k-c);_=_ or(D<F<E or E<F<D)and(G<I<H or H<I<G);r-=.001
 return _

Slightly ungolfed, with comments:
from math import*
# Parameters:
#  (a,b) (c,d) (e,f) - vertices of the triangle
#  (g,h) - location of cannon
#  (i,j) - aim of cannon
#  R - range of cannon
# Variables within function:
#  _ - was this shot a hit?
#  r - distance 0 < r <= R that we're testing
#  Q - angle between cannon source and destination
#  (k,l) - point that we're testing
#  D,E,F - angles between point 1 and 2,3,test
#  G,H,I - angles between point 2 and 1,3,test
def h(a,b,c,d,e,f,g,h,i,j,R):
    r=R;_=0
    while r>0:
        Q=atan2(j-h,i-g)
        k,l=g+r*cos(Q),h+r*sin(Q)
        D=atan2(d-b,c-a)
        E=atan2(f-b,e-a)
        F=atan2(l-b,k-a)
        G=atan2(b-d,a-c)
        H=atan2(f-d,e-c)
        I=atan2(l-d,k-c)
        _=_ or(D<F<E or E<F<D)and(G<I<H or H<I<G)
        r-=.001
    return _

How it works:

Calculate the endpoint of the shot.
Test lots of points along the line from the endpoint to the cannon's location:

Calculate angles from vertex 1 to other two vertices and to test point;
Calculate angles from vertex 2 to other two vertices and to test point;
If the test point angle is between the other two angles, in both cases, then the test point is within the triangle and the ship has been hit.

Sample runs:
>>> h(0,0,0,1,1,0,1,1,0,0,2)
True
>>> h(0,0,1,2,3,0,-4,0,0,0,8)
False
>>> h(0,0,-1,3,4,-1,-3,-4,3,4,5)
False
>>> h(-2,-3,-3,6,7,-2,-6,2,1,-4,7)
True

Python 2.7, 235 bytes
from numpy import*
X=cross
h=lambda q,w,a,s,y,x,c,v,d,f,r:max([(X([a-q,s-w],[c+k*(d-c)-q,v+k*(f-v)-w])>0)==(X([y-a,x-s],[c+k*(d-c)-a,v+k*(f-v)-s])>0)==(X([q-y,w-x],[c+k*(d-c)-y,v+k*(f-v)-x])>0)for k in arange(0,r/hypot(d-c,f-v),1e-4)])

Computes the cross product AB x AP between the corners A,B and the point P. If all three have the same sign, then the point is inside the triangle.
Ungolfed:
from numpy import *
def i(q,w,a,s,y,x,e,r): # helper-function, checks whether ER is inside the triangle QW-AS-YX
  t=cross([a-q,s-w],[e-q,r-w])>0
  g=cross([y-a,x-s],[e-a,r-s])>0
  b=cross([q-y,w-x],[e-y,r-x])>0
  return t==g==b

def h(q,w,a,s,y,x,c,v,d,f,r):
  R=arange(0,r/hypot(d-c,f-v),1e-3)
  return max([i(q,w,a,s,y,x,c+k*(d-c),v+k*(f-v)) for k in R])

Tests:
In : h(0,0,0,1,1,0,1,1,0,0,2)
Out: True

In : h(-3,2,2,-4,7,-3,-3,-4,-3,0,10)
Out: False

In : h(0,0,1,2,3,0,-4,0,0,0,8)
Out: True
     Grazes may count as hits...
In : h(1,2,0,0,3,0,-4,0,0,0,8)
Out: False
     ...or not, depending on the order of edges

C, 247 bytes
Definitely not quite golfed yet.
#include<math.h>
int z(float*k){float s=1e-3,t=s,p=k[8]-k[6],q=k[9]-k[7],r=k[10]/hypot(p,q);int w=0;for(;t<1;t+=s){float x=k[6]-k[0]+p*r*t,y=k[7]-k[1]+q*r*t,b=k[2]*k[5]-k[3]*k[4],d=(x*k[5]-y*k[4])/b,e=(x*k[3]-y*k[2])/b;w|=d>0&e<0&d-e<1;}return w;}

Currently this uses an approach similar to DLosc's solution, i.e. iterates through all possible coordinates on the line segment to determine if it intersects with the triangle. (So it will fail if the range is over 1000) However, it uses the formula from http://mathworld.wolfram.com/TriangleInterior.html to determine if a point is inside the triangle. This avoids a bunch of trigonometric functions.

Example check, should print 1 0 0 0 1 0.
#include <stdio.h>
int main() {
    {
        float arr[] = {0,0,0,1,1,0,1,1,0,0,2};
        printf("%d\n", z(arr));
    }

    {
        float arr[] = {2,0,0,2,4,4,0,0,1,1,1};
        printf("%d\n", z(arr));
    }

    {
        float arr[] = {0,0,1,2,3,0,-4,0,0,0,8};
        printf("%d\n", z(arr));
    }

    {
        float arr[] = {0,0,-1,3,4,-1,-3,-4,3,4,5};
        printf("%d\n", z(arr));
    }

    {
        float arr[] = {-2,-3,-3,6,7,-2,-6,2,1,-4,7};
        printf("%d\n", z(arr));
    }

    {
        float arr[] = {-3,2,2,-4,7,-3,-3,-4,-3,0,10};
        printf("%d\n", z(arr));
    }
}

JavaScript (ES6) 320 448 522 627
(Could still be golfed more?)
Steps:

Find the actual hit target (point at distance r on the line from enemy to aim)
Hit: if the segment from enemy to target intersect any of the sides of the ship, but not at the endpoints
Hit too: if the target is inside the ship - even if the shot entered at a vertex - test case 8

Ref:
Segment intersection
Point inside triangle
Point in a segment given a distance
Test in Firefox

C=(i,j,k,l,m,n,g,h,a,b,r,
  d=a-g,e=b-h,f=r/Math.sqrt(d*d+e*e),
  p=g+f*d,q=h+f*e,
  z=j*(m-k)+i*(l-n)+k*n-l*m,
  s=(j*m-i*n+(n-j)*p+(i-m)*q)/z,
  t=(i*l-j*k+(j-l)*p+(k-i)*q)/z,
  S=(i,j,k,l,
     a=k-i,b=l-j,c=p-g,d=q-h,e=i-g,f=j-h,
     s=a*f-b*e,t=c*f-d*e,m=a*d-c*b)=>
     m&&((s/=m)>0&s<1&(t/=m)>0&t<1)
)=>s>0&t>0&s+t<1|S(i,j,k,l)|S(i,j,m,n)|S(m,n,k,l)

// Test
MyOutput.innerHTML = ['Test1', C(0,0, 0,1, 1,0, 1,1, 0,0, 2),
'
Test2', C(2,0, 0,2, 4,4, 0,0, 1,1, 1),
'
Test3', C(0,0, 1,2, 3,0, -4,0, 0,0, 8),
'
Test4', C(0,0, -1,3, 4,-1, -3,-4, 3,4, 5),
'
Test5', C(-2,-3, -3,6, 7,-2, -6,2, 1,-4, 7),
'
Test6', C(-3,2, 2,-4, 7,-3, -3,-4, -3,0 ,10),
'
Test7', C(0,0, 6,0, 6,8, -6,-8, 6,8, 20),
'
Test8', C(0,0,-2,-5, 5,3, -3,4, 0,0, 6)];

Ungolfed

function check(p0x, p0y, p1x, p1y, p2x, p2y, ex, ey, ax, xy, r)
{
  var sec = function(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y)
  {
      var s10x = p1x - p0x, s10y = p1y - p0y,
          s32x = p3x - p2x, s32y = p3y - p2y,
          s02x = p0x - p2x, s02y = p0y - p2y,
          s = s10x * s02y - s10y * s02x, t = s32x * s02y - s32y * s02x,
          d = s10x * s32y - s32x * s10y;
      return d && (s/=d) > 0 && s<1 && (t/=d) > 0 && t < 1 && [p0x + (t * s10x), p0y + (t * s10y)];
  }
  var pr = function(p0x, p0y, p1x, p1y, r)
  {
      var dx = (p1x-p0x), dy = (p1y-p0y), f = r/Math.sqrt(dx*dx+dy*dy);
      return [p0x + f*dx, p0y+f*dy];
  }
  var inside = function(p0x, p0y, p1x, p1y, p2x, p2y, px, py)
  {
      var area2 = (-p1y*p2x + p0y*(-p1x + p2x) + p0x*(p1y - p2y) + p1x*p2y),
          s = (p0y*p2x - p0x*p2y + (p2y - p0y)*px + (p0x - p2x)*py)/area2,
          t = (p0x*p1y - p0y*p1x + (p0y - p1y)*px + (p1x - p0x)*py)/area2;
      return s > 0 && t > 0 && s+t < 1;
  }
  var tx, xy;
  [tx, ty] = pr(ex, ey, ax, ay, r);

  return inside(p0x, p0y, p1x, p1y, p2x, p2y, tx,ty)
  || sec(p0x, p0y, p1x, p1y, ex, ey, tx, ty)
  || sec(p0x, p0y, p2x, p2y, ex, ey, tx, ty)
  || sec(p2x, p2y, p1x, p1y, ex, ey, tx, ty);
}

Scala, 349 328 bytes
Saved 21 bytes thanks to the comment of @ceilingcat

Golfed version. Try it online!
import scala.math.{atan2=>A,_};type Q=Double;def h(a:Q,b:Q,c:Q,d:Q,e:Q,f:Q,g:Q,h:Q,i:Q,j:Q,R:Q)={var r=R;var Z=1>1;while(r>0){val Q=A(j-h,i-g);val k=g+r*cos(Q);val l=h+r*sin(Q);val D=A(d-b,c-a);val E=A(f-b,e-a);val F=A(l-b,k-a);val G=A(b-d,a-c);val H=A(f-d,e-c);val I=A(l-d,k-c);Z=Z||D<F&F<E|E<F&F<D&&G<I&I<H|H<I&I<G;r-=1e-3};Z}

Ungolfed version. Try it online!
import scala.math.{atan2 => A, _}
object Main {
  type Q = Double
  def h(a: Q, b: Q, c: Q, d: Q, e: Q, f: Q, g: Q, h: Q, i: Q, j: Q, R: Q) = {
    var r = R
    var Z = false
    while (r > 0) {
      val Q = A(j - h, i - g)
      val k = g + r * cos(Q)
      val l = h + r * sin(Q)
      val D = A(d - b, c - a)
      val E = A(f - b, e - a)
      val F = A(l - b, k - a)
      val G = A(b - d, a - c)
      val H = A(f - d, e - c)
      val I = A(l - d, k - c)
      Z =
        Z || ((D < F && F < E) || (E < F && F < D)) && ((G < I && I < H) || (H < I && I < G))
      r -= 0.001
    }
    Z
  }

  def main(args: Array[String]): Unit = {
    println(h(0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 2)) // Output: true
    println(h(0, 0, 1, 2, 3, 0, -4, 0, 0, 0, 8)) // Output: false
    println(h(0, 0, -1, 3, 4, -1, -3, -4, 3, 4, 5)) // Output: false
    println(h(-2, -3, -3, 6, 7, -2, -6, 2, 1, -4, 7)) // Output: true
  }
}

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

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


text:
Reassuring parables
Quite a few people here are probably avid XKCD readers. So, I figure I'd challenge you guys to do something that Megan can do easily: make a script that generates thousands of reassuring parables about what computers can never do.

Your script

Can be written in any language
Must be code-golfed
Must take an input (on stdin or your language equivalent) on the number of parables it will spit out (you can assume this will not exceed MAX_INT or equivalent).
Will output a number of randomly generated parables.

The parables are as follows

Starts with 'Computers will never '
Next, one of 16 unique English verbs which you can choose freely to optimize your program, but must include code-golf and understand.
Next, one of 16 unique English nouns which again, you can choose freely to optimize your program, but must include a salad and an octopus.
Next, one of 16 unique English clauses which you can choose freely to optimize your program, but must include for fun and after lunch.
Ends with a newline (\n or equivalent) character

So, for example, if the input is 2, a valid output would be
Computers will never code-golf a salad for lunch
Computers will never hug a tree in vain

Program size is counted in bytes, not characters (so no unicode gibberish). Standard loopholes are not allowed.
This is my first challenge, so if I should make some obvious changes, please comment.
Edit: I am contemplating to substract the dictionary size from the byte count, to encourage dictionary 'compression'. I will see from future answers if this is remotely feasible ; if it is, you can count on a bonus.

You might want to add that size is counted in bytes, and that standard loopholes are not allowed.

Do we get to choose the remaining 14 verbs/nouns/clauses ourselves ?

@Optimizer "... which you can choose freely to optimize your program ..."

@Optimizer Yes, I'm hoping for creative ways to make a set of words without hardcoding all of them...

You might want to clarify if (which I assume) nouns, verbs and additional clauses should by chosen independently and not already combined to 16 complete phrases. (Well, "randomly generated" is actually pretty clear.)

I'd support subtracting the dictionary size to prevent using ultra-short but completely unknown words (like here).

@matsjoyce: Counting bytes is the default. The point of having standard loopholes is that it's not necessary to mention them.

Do the N random parables have to be different?

"Must take an input (on stdin or your language equivalent)" Is input on command-line arguments fine? (shorter in many languages)

CJam, 238 232 (or 209) bytes
ri{'C"!fmQ$h/q6fW*LC*hBd11(kA>.TfqJ0++#<>A]XThJkY b~os;vMg_D-}zYX%_,PozNxe5_8`}$H;2IUZ]&$c+m~HJ*|!n\A^:W-*O\"V-/8Kg ,_b(N#M/1Zh6*%\#t22'#|\"BJN=Za2_.R"32f-96b28b" -"'{,W%+f=)/(\[G/~["for ""after "]\m*\(a\"a "f{\+}+\]{mr0=}%S*N}*

This uses many verbs/nouns/clauses from already posted answers but some are new too. I have base converted the characters to shave off some extra bytes.
The base converted string can be golfed 24 more bytes (to get a 209 byte solution; Note that you have to consider the character count instead of byte count as all characters have an ASCII code of less than 255 but the site still consider some has unicode) but I wanted the string to consist only printable ASCII characters.
Just for reference, here is the 209 bytes version:
ri{'C"9óßÂ/ÃC eG?dcÅoø£gaC#Yä©Ï¡áq¶hm)ðaâ%ØNo=óÏrbÁz´¾;q·u¬&ñ*±äô©@6W±U¹¥¢)Â·«Åx¶óV¬¬dhja¼ ª\"r[çË74ÄãÐ³î,ó3gÈ$AïL"32f-222b28b" -"'{,W%+f=)/(\[G/~["for ""after "]\m*\(a\"a "f{\+}+\]{mr0=}%S*N}*

Takes the number of lines to print from STDIN like:
12

Output:
Computers will never code-golf an octopus for fun
Computers will never code-golf a bag after za
Computers will never eat a hem after tip
Computers will never eat an octopus for tip
Computers will never get a fax for you
Computers will never dry a gym for za
Computers will never get a guy for tip
Computers will never do a pen for fun
Computers will never see a bar after you
Computers will never tax a pen for ex
Computers will never get a hem for lunch
Computers will never win a pen for ex

Try it online here

Here's a slightly different approach:
Python, 368 308 297 bytes
EDIT, I actually golfed it this time. Shaved off 60 characters.
from random import*
from en import*
C=choice
v=["code-golf","understand","go","do"]
n=["salad","octopus","fun","lunch"]
for f,l in("verbs",v),("nouns",n):exec"l.append(str(C(wordnet.all_"+f+"()))[:-4]);"*12
exec'print"Computers will never",C(v),noun.article(C(n)),C(("for","after")),C(n);'*input()

Here is the golf-trick that I'm most proud of:
for f,l in("all_verbs",v),("all_nouns",n):

I didn't even know python could do that! Here's a simpler explanation:
for (a, b) in ((0, 1), (1, 2), (2, 3)):

assigns a and b to 0 and 1, and then to 1 and 2, and then to 2 and 3.

This uses NodeBox's linguistics library to generate a list of verbs/nouns/clauses, and then randomly selects from them.
This library is not that great for generating random words (hence the 368 bytes), but the nice thing about this approach is you get some pretty random reassuring parables with it. Here is what I mean.
Computers will never attempt a syria for synchronization.
Computers will never understand a salad for change of mind.
Computers will never brim an electric company for synchronization.
Computers will never pivot a dusk for fun.
Computers will never bedaze an electric company for genus osmerus.
Computers will never brim a salad for vital principle.
Computers will never attempt an erythroxylum after lunch.
Computers will never understand an uuq for water birch.
Computers will never brim an ictiobus for change of mind.
Computers will never brim an ictiobus for 17.
Computers will never lie in an octopus for change of mind.
Computers will never happen upon a toothpowder for water birch.
Computers will never typeset an electric company for change of mind.
Computers will never brim a french oceania after lunch.
Computers will never bring out an ictiobus for glossodia.
Computers will never bedazzle an animal fancier for ash cake.
Computers will never attempt a dusk for genus osmerus.
Computers will never understand an animal fancier for genus osmerus.
Computers will never accredit a prickly pear cactus for 17.
Computers will never typeset an erythroxylum for water birch.

But hey, I don't think anybody else's program will generate the saying: "Computers will never bedazzle an animal fancier for ash cake."
Here's an ungolfed version (574 bytes):
import random
import en

v = ["code-golf", "understand"]#list of verbs
n = ["a salad", "an octopus"]#list of nouns
c = ["for fun", "after lunch"]#list of clauses
for i in range(14):
    v.append(str(random.choice(en.wordnet.all_verbs()))[:-4])
    n.append(en.noun.article(str(random.choice(en.wordnet.all_nouns()))[:-4]))
    c.append("for "+str(random.choice(en.wordnet.all_verbs()))[:-4])

N=input("Enter the number of reassuring phrases you want: ")
for i in range(N):
    print "Computers will never"+' '+random.choice(v)+' '+random.choice(n)+' '+random.choice(c )+'.'

And lastly but definitely not leastly, here are some of my favorite reassuring parables, that I predict will become really popular catch-phrases in the next 10-15 years.
Computers will never move around a methenamine for godwin austen.
Computers will never conk an adzuki bean for bitterwood tree.
Computers will never jaywalk a cross-dresser for fun.
Computers will never hyperbolize an accessory after the fact for norfolk island pine.
Computers will never dissolve a salad for earth wax.
Computers will never acetylise an incontrovertibility for dictatorship.
Computers will never reciprocate a strizostedion vitreum glaucum for commelinaceae.
Computers will never goose an action replay for star chamber.
Computers will never veto a bottom lurkers for jackboot.
Computers will never reciprocate a visual cortex for oleaginousness.
Computers will never baptise a special relativity after lunch.
Computers will never understand a gipsywort for citrus tangelo.
Computers will never get it a brand-name drug for electronic computer.
Computers will never deforest a paperboy after lunch.
Computers will never bundle up a nazi for repurchase.
Computers will never elapse a bernhard riemann for counterproposal.

and my personal favorite:
Computers will never romanticise a cockatoo parrot for cross-fertilization.

I certainly find it reassuring that computers will never bundle up a nazi for repurchase...

haven't gone over this one with a fine-toothed comb or anything yet, but unless i'm mistaken from random import choice as C could be from random import*;C=choice

also twice you have for i in ' '*(something) so you can trivially save two bytes from removing the space between in and ' '

Yeah, I'm sure this can be golfed down further. I didn't put a whole lot of effort into compressing it. I think of I really wanted to squish it down, I'd need to find a library more suited towards random word selection.

JavaScript ES6, 331 336 bytes
n=prompt(a='')
r=s=>s+Math.random()*16>>0
p=q=>'OctopusSaladCutCueBatJamKidPenDogFanHemDotTaxSowDyeDigCode-golfUnderstandLunchFunMeYouUsItAdsPaZaMenTwoIceJamWarRumWax'.match(/[A-Z][^A-Z]+/g)[q].toLowerCase()
while(n-->0)y=r(0),z=r(18),a+=`Computers will never ${p(r(2))} a${y?'':'n'} ${p(y)} ${z<18?'afte':'fo'}r ${p(z)}
`
alert(a)

n=prompt()
a=''
function r(s){return s+Math.random()*16>>0}
function p(q){return' '+'OctopusSaladCutCueBatJamKidPenDogFanHemDotTaxSowDyeDigCode-golf\
UnderstandLunchFunMeYouUsItAds\
PaZaMenTwoIceJamWarRumWax'.match(/[A-Z][^A-Z]+/g)[q].toLowerCase()}
while(n-->0)
  y=r(0),z=r(18),
  a+='Computers will never'+p(r(2))+(y?' a':' an')+p(y)+(z<18?' after':' for')+p(z)+'\n'
alert(a)

I picked words that work as both verbs and nouns to shorten the list, but let me know if that is not allowed. Try it out above using Stack Snippets (The code there has been formatted to use ES5) or at http://jsfiddle.net/5eq4knp3/2/. Here is an example output:
Computers will never hem a cut for ads
Computers will never dot a pen after lunch
Computers will never code-golf a bat for free
Computers will never sow a dog for me
Computers will never cut an octopus for fun

What on Earth is a za?!

@BetaDecay Slang for pizza.

Can you explain this line for me? r=s=>~~(Math.random()*16)+s

@MarkGabriel It's a function that returns a random number between 0 and 16 with offset s to jump past the other parts of speech in the list. The two tildes are bitwise NOT operators, and they just function as a shorter way to do Math.floor().

Brilliant. Thanks. Last thing though, what's the => mean? I'd like to think of myself as quite apt in JavaScript but I'm baffled to see that there's still a lot I don't understand.

@MarkGabriel That's how ECMAScript 6 represents functions. r=s=>12 is the same as function r(s){return 12}, only shorter. Also see the docs on MDN.

@MarkGabriel For comeplte in-depth answers, see SO's What does ~~ (“double tilde”) do in Javascript? and What does F=a=> mean in Javascript? ~~ is sort of like a Math.floor (but behaves differently for negative numbers), and => is an ES6-style function definition with a bound this.

Python - 390 385 383
from pylab import*
S=str.split
n=input()
while n:n-=1;i,j,k=randint(0,16,3);print"Computers will never",S("buy cut dry eat fax get pay rob see sue tax tow wax win code-golf understand")[i],"a"+"n"*(j<1),S("octopus salad bag bar bee bow boy bra dad fax gym guy hat man mom pet")[j],"for "*(k>2)+S("after lunch,naked,ever,fun,me,you,us,tip,gas,cash,air,oil,beer,love,food,dope",",")[k]

Random example output:
Computers will never pay an octopus for oil
Computers will never cut a bra for beer
Computers will never eat a bee for us
Computers will never rob a pet for you
Computers will never tax a pet for tip
Computers will never buy a salad for cash
Computers will never sue a boy naked
Computers will never see a bar for you
Computers will never wax a bra for beer
Computers will never sue an octopus for us

umm... ion is not a verb.

@JanDvorak: Oooops... Fixed it!

Why not use a shorter verb? Say, sew...

@JanDvorak: Yeah, I replaced it. However, I'm not sure how far I would golf the content, since there are many even shorter words that one could use. But the result would be sooo boring.

"be" seems reasonable as a transitive verb, although I agree that no other two letter word is suitable.

Nice touch to include both 'for + ...' as well as adverbs (naked) in one list. This is what I was hoping for - I find it very reassuring that my computer will never undress.

Perl - 366
@w="Code-golfUnderstandBeDoTieSeeSawEatCutCapSitSetHateZapSipLoveSaladOctopusSeaBeeCatDogHatBatJobManLapCapRapMapDotAnt0fun1that1noon1work0good0sure0reason0nothing0you1you1lunch1all0me0nowToday1me"=~s/\d/("For ","After ")[$&]/reg=~/([A-Z][^A-Z]+)/g;print"Computers will never ".lc"$w[rand 16] a".$w[16+rand 16]=~s/^[AO]?/(n)[!$&]." $&"/re." $w[32+rand 16]
"for 1..<>

Here is a test:
$ perl ./parables.pl <<<3
Computers will never do an ant after noon
Computers will never do a lap after all
Computers will never love an octopus for sure

CJam, 353 317 301 bytes
I'm using Falko's word list, for fairness, so that the only difference in golfing is due to the languages and not the content (I might change the word list if people start golfing the content as well).
"Computers will never ""buy
cut
dry
eat
fax
get
pay
rob
see
sue
tax
tow
wax
win
code-golf
understand"N/[" an octopus"" a ""salad
bag
bar
bee
bow
boy
bra
dad
fax
gym
guy
hat
man
mom
pet"{N/\f{\+}~]}:F~S["after lunch""naked""ever""for ""fun
me
you
us
tip
gas
cash
air
oil
beer
love
food
dope"Fm*m*m*mr0=

You are not reading the input for printing N number of times.

@Optimizer Oh, I totally overlooked that. Fixing in a second.

NetLogo, 396
I also used Falko's word list, with two exceptions (which don't change the length of program).
to f let a["after lunch""ever""alone"]type(word"Computers will never "one-of["buy""cut""dry""eat""fax""get""pay""rob""see""sue""tax""tow""wax""win""code-golf""understand"]" a"one-of["n ocotpus"" salad"" bag"" bar"" bee"" bow"" boy"" bun"" dad"" fax"" gym"" guy"" hat"" man"" mom"" pet"]" "one-of fput word"for "one-of["fun""me""you""us""tip""gas""cash""air""oil""beer""love""food""dope"]a"\n")end

Depending on how you define "program", you can remove the first five and last three characters, thus a score of 388.


text:
Program an Artistically Rich Comic Strip
The Challenge
Program a comic strip. As artistically rich and detailed as you can possibly make it, so long as it complies with the following rules:

the comic must be your own original work, not a duplicate or approximation of an existing comic (you may however use characters from an existing strip as an homage, if you desire)
the comic must contain at least one panel, and all panels must be surrounded by a clear border
the comic must contain at least one blurb of readable text with ≥ 10 characters that is clearly recognizable as text; this may come in the form of a caption, a text bubble, a thought bubble, a sign, etc.
the comic may be graphic-based or text-based (more on this below)

if text-based, the comic must have dimensions of at least 30x25 chars, and no greater than 160x80 chars
if graphic-based, the comic must have dimensions of at least 300x300 pixels, but no greater than 1600x1000 pixels

the comic must be generated by a program whose core code contains at most 512 bytes
the comic must comply with the StackExchange content policy

What is "Core Code"?
This is a somewhat novel concept, hence please bear with me in patience.
For programming language X, consider the most elementary code that outputs a single (black) circle or ASCII letter o at coordinates (10,10) on a (white) canvas and then terminates. The colours black and white above may refer to any two colours. "Output" refers to text being printed to stdout/console, text being outputted to a file, a graphic being drawn to a window, or a graphic being saved to a file. The two key points are that

the code is able to render this most basic output
the code contains nothing nonessential (within reason, and subject to reader scrutiny) for rendering this specific output, which includes comments (whitespace is fine)

This elementary program is called your shell. From the shell, delete as many or as few commands as you wish and identify at most two insertion points where new code can/will go. Any code inserted at these points is called your core code. The length of your core code is the total length (in bytes) of code inserted at these points.
The following are six representative examples of acceptable shells:
--- Text Output with C (type 1) ---

#include <stdio.h>
#include <Windows.h>

void P( int x, int y, char c ) {
    COORD p = { x, y };

    SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), p );
    printf( "%c", c );
}

int main() {
    system( "cls" );
    P( 10, 10, 'o' );
    return 0;
}

--- Text Output with C (type 2) ---

int main() {
    puts( "\n\n\n\n\n\n\n\n\n         o" );
    return 0;
}

--- Graphical Output with Javascript ---

(function(){
    document.body.innerHTML = '<canvas id="cvs1" width="300" height="300"></canvas>';

    with( document.getElementById('cvs1').getContext('2d') ) {
        fillStyle = 'rgb(192,192,192)';
        strokeStyle = 'rgb(0,0,0)';
        fillRect( 0, 0, 300, 300 );
        beginPath();
        arc( 10, 10, 5, 0, 2*Math.PI );
        stroke();
    }
})();

--- Text Output with HTML ---

             o

--- Graphical Output with Python (Turtle Library) ---

from turtle import*

fd( 10 );
rt( 90 );
fd( 10 );
circle( 5, 360 );

--- Text Output with MATLAB ---

G = repmat( ' ', 30, 30 );
G(10,10) = 'o';
disp( G );

If you prefer, your shell may be empty.
I have started a discussion here for readers unsure of what the community considers appropriate in this respect. Note that this is a popularity contest, so making sure the community doesn't consider you to be breaking the rules is important.
What To Present

your core code, either as a single block or as two separate blocks if you have two separate insertion points
your shell, using the distinctive ✰ character (Unicode U+2730) to mark any insertion points (or simply say "no shell")
your comic in a text block, or as an image, or as a link to either of the aforementioned. If your comic is text-based and looks better in a different font, charset, etc., you can provide a screenshot or a link to an online environment where the text can be viewed.

Scoring
This is a popularity contest and hence your score is at the whim of the voters.
This is a competition about artistically rich comic book (or graphic novel) style artwork. Humour is a nice touch, but should not be used as a principle criterion for judging entries.
Voters can of course vote any way they want, but as a rough set of guidelines they (you) might wish to consider:

artistry (whether the comic is especially artful within the artist's chosen medium), with emphasis on features such as

beautiful art
texturing
detailed and/or recognizable characters
rich embellishments such as call-outs, fancy borders, shading effects, etc.

complexity (whether the artist/programmer really gets his/her money's worth out of 512 characters)
creativity (special additional "wow" factors that make the comic stand out in some way)

Feel free to raise questions or concerns in the comments section.

What's with the [code-golf] tag?

@Quincunx: Your core code is limited to 512 bytes. That's an incredibly tight restriction. [code-golf] seemed appropriate. Maybe [restricted-source]?

This seems to be a contest about art and writing, and not about programming. I understand there's a strict character requirement that forces efficient code, but that's likely to be a question of limiting the number and type of shape used in the comic, making it an "art golf". Previous meta discussion about art. I'm leaning towards close voting, but will discuss in chat.

@xnor: No artist who isn't also an incredibly competent programmer could undertake this challenge. And besides that, we have dozens if not hundreds of art-based challenges on PPCG.

code-golf is for challenges where you solve a problem with the fewest bytes. restricted-source is for restricting what characters you are allowed to use in your program. I don't think this falls into either of those. http://codegolf.stackexchange.com/questions/35569/tweetable-mathematical-art imposes a similar restriction and doesn't have a tag for that part.

@chilemagic: I've dropped the tag. If readers can think of one that applies to "artificially restricted source length", please feel free to add this tag.

Readers may be interested in a lengthy discussion between @xnor and myself in the "Nineteenth Byte" chatroom. I'm out for the night, but additional input is of course welcome.

Link to start of chat discussion.

The size requirements need rewording. Is 500 x 200 pixels smaller or greater than 300 x 300 pixels?

This question appears to be off-topic because its focus is on art, not programming

To any interested parties, I've voiced some frustrations in the art meta discussion.

HTML (with JS)
Shell
<canvas id='cnv' width=410 height=300></canvas>

Full code (511 characters of core code)
It's a runnable Stack Snippet! You can try it yourself, right here, from your own browser. (Note: text may overflow if you have a different font than me.)

<canvas id='cnv' width=410 height=300></canvas>

XKCD-style! (The hand-drawn effect is a bit subtle; I might make it more pronounced later.)

Whew, that was fun! I don't have any more time though, since I have to go, so edits coming some time in the future.

If I understood the size requirements correctly, your comic isn't tall enough.

@Dennis Ah, good point. I'm on mobile right now so I can't fix it, but I guess I could make it a bit taller tomorrow.


text:
Underground geek rock band names
We have a group of stealthy computer-savvy geeks who are also musicians with a very subversive element to their songs that the authorities in their totalitarian country just can't stand, and are itching to show up at one of the concerts, fire off rubber bullets and tear gas at the audience, and arrest the band members and as may other fans as their paddy vans can carry and "disappear" them.
However, the authorities are a bit slow to act, and will only show up to the second concert held under the same band name (case, accent and whitespace-length insensitive).  They are also not very tech-savvy, so can't reverse-engineer the decoder (see later).  Since they are working from memory, they'll forget a name after five years, so a repeat after that time won't attract their attention.
One of these tech-savvy band members comes up with an algorithm that - given the date of a concert - generates a (hopefully) unique cool-sounding and pronounceable band name using the latin alphabet (A-Z) plus Space.  They also create a decoder that they distribute to fans, which, given a band name and a date, returns some output indicating that this is indeed a code-generated name of our subversive band, or some other output indicating that the band name entered is that of some other band (or a sting set up by the authorities to catch fans they want to arrest).
The decoder does not output any valid names, as the authorities are just tech-savvy enough themselves to obtain a copy and use that to generate possible names if it can output them, but don't have time to check all the names of the hundreds of other bands that appear and disappear (sometimes with their assistance) from time to time against it.
Your Task:
Produce these two complementary pieces of code - the name generator and the name checker.
As this is a popularity contest, we're looking for cool-sounding, pronounceable band names for the English-speaking world, not random unpronounceable text.  Any programming language is OK, as the fans are all very tech-savvy like us.  Please provide a sample of the cool names your generator generates.
If it can be shown that an algorithm produces a duplicate for any two dates in a 5-calendar-year period, then that will be considered a disqualification. (Disqualification is a far better fate than what the authorities would do to them).

What's the point of requesting a separate decoder? All it should be is a call to the encoder followed by an equality check. And you can't be serious about wanting a list of 260 names. No-one's going to want to verify their distinctiveness without using a computer program anyway, so why not just write your own test framework?

@PeterTaylor, I've edited the question to show why a decoder is needed.  As to a list of names, you're right, I can check myself, so just a few to demonstrate the "cool" factor will suffice.

Pyth
Encoder:
Jf-\'T'jdm@JdjswlJ

Takes two arguments: a dictionary on one line, and the date, in DDMMYYYY form on the next.
Filters out words with apostrophes from the dictionary, then converts the current date into a number with base equal to the dictionary length, and then chooses words from the filtered dictionary with indexes of the digits, and prints them out, space separated.
Today's result:
$ pyth -c "Jf-\'T'jdm@JdjswlJ" <<< '/usr/share/dict/words
30102014'
Annam pals

Future results:
31102014
Antarctica economical

01112014
Abernathy carousels

02112014
Acadia unsnarled

03112014
Actaeon oversimplifying

04112014
Adela dugouts

0511204
Adolph Maude

To decode, run the date through the program and see if the output matches the name given. I'm not going to list any more band names, but from how the program works it should be clear there are no repeats.

Encoder
{18+65}%

Expects input in the form YYYYMMDD. Online demo
Decoder
n/~{18+65}%=

Expects input in the form
BANDNAME
YYYYMMDD

Online demo
I'm not going to post a list of 260 names because a) that would be a complete waste of space; b) it's easy to convince yourself that the encoder is an injection.

Fails on cool-sounding, in my opinion.

And pronounceable?

@BillWoodger, if you can pronounce taramasalata I don't think you should have problems with any of these names. English phonotactics isn't overly restrictive.

Ah. G(r)eek rock band. I suppose I tied "pronounceable" to being actual words. Nicely fineses the need for a dictionary.

Python 3
Generator
This generates shorter names so they seem a little less obscure.
import string

date = input()
vowels = 'aeiou'
name = ''
consonants = ''.join(i for i in string.ascii_lowercase if not i in vowels)
for i in range(0,len(date),2):
    name += vowels[int(date[i])%len(vowels)]+consonants[int(date[i])%len(consonants)]
print(name)

Example
Input:  30102014
Output: ofecidec

Validator
Just performs the above and compares the result with the supplied name.
import string

date, name = input().split(',')
vowels = 'aeiou'
tname = ''
consonants = ''.join(i for i in string.ascii_lowercase if not i in vowels)
for i in range(0,len(date),2):
    tname += vowels[int(date[i])%len(vowels)]+consonants[int(date[i])%len(consonants)]
print(tname == name)

Examples
Input:  30102014,ofecidec
Output: True

Input:  30102014,ofocidoc
Output: False

Input should be in the format:
DDMMYYYY,NAME

Javascript
Since the authorities forget names after 5 years, we can leave the millennium, century, and decade digits out of the year. We can also use day of year (DoY). This program accepts input in the form of YDoY

Encoder
The encoder converts the base 10 date to a base 26 string, then shifts it over 10 characters to remove any numbers. Then we add vowels, spaces, and capitalization to make the words look like english.
function encodeName(date){
    var alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
    var vowels = 'aeiou';
    var rebased = date.toString(26);
    var shifted = '';
    var name = '';
    for(var c in rebased){
        var i = alphabet.indexOf(rebased[c]);
        shifted += alphabet.substring(i+10, i+11)
    }
    for(var a in shifted)
            name += a%2 == 0 ? shifted[a].toUpperCase() + vowels[a%vowels.length] : shifted[a] + ' ';

    return name.trim();
}

Decoder
function decodeName(name){
    var alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
    var vowels = 'aeiou';
    var stripped = '';
    var shifted = '';

    for(var n in name)
        stripped += vowels.indexOf(name[n]) >= 0 || name[n] == ' ' ? '' : name[n].toLowerCase();

    for(var n in stripped)
        shifted += alphabet[alphabet.indexOf(stripped[n])-10];

    return parseInt(shifted, 26);
}

Examples

function encodeName(b){b=b.toString(26);var a="",d="",c;for(c in b)var f="0123456789abcdefghijklmnopqrstuvwxyz".indexOf(b[c]),a=a+"0123456789abcdefghijklmnopqrstuvwxyz".substring(f+10,f+11);for(var e in a)d+=0==e%2?a[e].toUpperCase()+"aeiou"[e%5]:a[e]+" ";return d.trim()}
function decodeName(b){var a="",d="",c;for(c in b)a+=0<="aeiou".indexOf(b[c])||" "==b[c]?"":b[c].toLowerCase();for(c in a)d+="0123456789abcdefghijklmnopqrstuvwxyz"["0123456789abcdefghijklmnopqrstuvwxyz".indexOf(a[c])-10];return parseInt(d,26)};

var date = 1003;
alert(encodeName(date) + ' -- ' + decodeName(encodeName(date)));
var date = 9123;
alert(encodeName(date) + ' -- ' + decodeName(encodeName(date)));
var date = 3333;
alert(encodeName(date) + ' -- ' + decodeName(encodeName(date)));
var date = 2321;
alert(encodeName(date) + ' -- ' + decodeName(encodeName(date)));
var date = 0345;
alert(encodeName(date) + ' -- ' + decodeName(encodeName(date)));

0345 is an octal number.


text:
Onion Programming
Using only printable ASCII (hex codes 20 to 7E), write a square N×N core program without comments that is surrounded by 4 more layers, creating a (N+8)×(N+8) square program (N > 0). For N = 3 the layout (to be replaced by actual code) looks like this:
44444444444
43333333334
43222222234
43211111234
4321CCC1234
4321CCC1234
4321CCC1234
43211111234
43222222234
43333333334
44444444444

The C's represent the core 3×3 program.
The 1`s represent the first layer, the 2's represent the second layer, etc.

The program always takes a string of space separated integers such as 0 -1 31 -1 2 2 2 via stdin or similar (it should just be the plain numbers, no quotes or brackets or anything). The output depends on what parts of the layout were run.
There are five ways to run the program (newlines are included in the run). Each does something different to the list:

Run just the core:
CCC
CCC
CCC

This computes the maximum of the absolute values of the input list elements, and prints CORE on a new line that many times. If the max is 0 nothing is output (a newline is fine).

The output for 0 -1 31 -1 2 2 2 would be
CORE
CORE
...

31 times.

Run the core with layer 1:
11111
1CCC1
1CCC1
1CCC1
11111

This outputs the average (arithmetic mean) of the list values to standard floating point precision.

The output for 0 -1 31 -1 2 2 2 would be 35 / 7 = 5 (5.0 is fine).

Run the core with layers 1 and 2:
2222222
2111112
21CCC12
21CCC12
21CCC12
2111112
2222222

This outputs a space separated list of the input list reversed.

The output for 0 -1 31 -1 2 2 2 would be 2 2 2 -1 31 -1 0.

Run the core with layers 1, 2, and 3 (the pattern should be obvious).
This outputs a space separated list of the sorted input list.

The output for 0 -1 31 -1 2 2 2 would be -1 -1 0 2 2 2 31.

Run the core with layers 1, 2, 3, and 4.
This outputs a space separated list of the input list with duplicates removed, the ordering doesn't matter.

The output for 0 -1 31 -1 2 2 2 could be -1 0 2 31.

All output is to stdout or a similar alternative.
Only these 5 layout combinations have specified behavior.
Notes

Comments are not allowed in the core or layers or combinations thereof. Code that is a no-op or does nothing constructive does not count as a comment.
Remember that the core can have any (positive) N×N dimensions, but the layers are only one character thick.
You may assume the input has no leading or trailing spaces and exactly one space between numbers. It will always contain at least one number. (The output lists should be formatted like this too.)
You may assume the list and calculations necessary for output won't have values that overflow (or underflow) your integers (as long as their max is something reasonable like 216).

Scoring
Writing this program normally would be easy. Writing it with a small core is hard.
The program with the smallest core size (the smallest N) wins. In case of ties the winner is the full program (the (N+8)×(N+8) square) with the fewest distinct characters (not counting newlines).
Please report your N value at the top of your answer.

I thought that this would also be another one of those new types

Can I use a language that ignores everything after a newline?

@isaacg Yes (as long as newline isn't considered the comment character, which would be weird).

@Optimizer Don't tempt me... "Each answer adds a new layer to the code onion so it does something new with the list..."

Can the input require to be surrounded with [ ] ?

@feersum No. It should be the plain space separated list that you get in as a string.

Can my output for the last 3 layers be like [1 2 3] instead of 1 2 3 ?

@Optimizer No. (I know these i/o rules are kinda harsh but that's to keep things consistent across languages.)

Are comments only forbidden in the core, or is it also forbidden to render part of the core as comment by the surrounding onion layers? Or are comments generally forbidden everywhere?

@M.Herzkamp Forbidden everywhere.

Completion of this challenge requires that I update my language spec. There is no way to sort a stack using only stack operations without access to a second stack. Time to squeeze in another codepoint for List commands! (I got up through layer 3, but 4 and 5 aren't possible).

CJam, N = 5, 27 (26) unique characters
It's 26 characters if I don't count the spaces. The program could actually be converted to one that doesn't use spaces, by just filling up all empty spaces with no-ops (e.g. _; which duplicates the top stack element and then discards, or by sorting the array again and again), but it would just distract from the actual code.
l~]_|S*
{l~]$S*
 {l~]W%S*
  {l~]_,\
   {l~]{z
    }%$W=
    "CORE
    "*
         }
   ;:+d\/ }
  ;        }
 ;          }
;

Test it here.
The core is
l~]{z
}%$W=
"CORE
"*

(Plus an empty line.)
I'm fairly sure that N = 4 can't be done in CJam (and I'm sure Dennis will convince me otherwise :D). The above has 17 characters, and while it might be possible to get it down to 16 (e.g. if CJam didn't have a bug to choke on :z, which requires {z}%, or by using ARGV), I don't think you can fit it in the layout without introducing a line break within CORE.
All of the implementations are very straightforward solutions to the given tasks. All of them start with l~] which reads STDIN, evaluates it, and puts it in an array.
The previous layer is always surrounded in {...}, which makes it a block that isn't automatically executed. And instead of executing it, I just discard it from the stack with ;, so no layer depends on code in the previous layer. In the Layer 1, the code didn't fit into the first line, so I continued it after discarding the core block.
Now for the actual programs:

Core:
{z}%$W="CORE
"*

Map abs onto the list, sort it, take the last element, repeat CORE (and a line break) that many times.
Layer 1:
_,\:+d\/

Duplicate the list, take the length, swap the stack elements, get the sum, cast to double, swap the stack elements, divide. I think this can be shorter, but there's no incentive to do so.
Layer 2:
W%S*

Reverse the array, riffle with spaces.
Layer 3:
$S*

Sort the array, riffle with spaces.
Layer 4:
Duplicate, take set union, riffle with spaces.

Some other optimisations are also possible, like reusing the ; and *S of Layer 2, but again, but it doesn't affect the score.

Python 2 - N = 17, 53 characters
Oh I love source-layout challenges with Python...
i=4                     ;
ii=3                    ;
iii=2                   ;
iiii=1                  ;
iiiii=0;R=raw_input     ;
iiiii;w=R().split()     ;
iiiii;n=map(int,w)      ;
iiiii;S=set(n);M=max    ;
iiiii;s=sorted(n)       ;
iiiii;J="\n".join       ;
iiiii;j=" ".join        ;
iiiii;k=M(map(abs,n))   ;
iiiii;A=J(["CORE"]*k)   ;
iiiii;B=sum(n)/len(n)   ;
iiiii;C=j(w[::-1])      ;
iiiii;D=j(map(str,s))   ;
iiiii;E=j(map(str,S))   ;
iiiii;P=A,B,C,D,E       ;
iiiii;print P[i]        ;
iiiii;" /__----__\  "   ;
iiiii;"|/ (')(') \| "   ;
iiii;"  \   __   /  "   ;
iii;"   ,'--__--'.   "  ;
ii;"   /    :|    \   " ;
i;"   (_)   :|   (_)   ";

There's still some unused whitespace, though.
I could still improve the unique character count, but I'll stick with better readability - if there is any at all.
Edit: Oh, it's Stan again!

You probably can save some lines by aliasing print instead of the i=* trick

@M.Herzkamp: Aliasing print is not possible with Python 2. But sure, there's probably room for improvement - maybe using Python 3.

I don't know Python, but isn't this missing absolute value in the core code output - c*max(n)

@nutki: You're right! I didn't read carefully. But I was able to fix it.

Python 3: N=11, 40 distinct characters
if 1:
 if 1:
  if 1:
   if 1:
    p=print;R=0
    a=input()
    b=a.split()
    m=map;a=abs
    E=max;l=len
    n=m(int,b);
    C=['CORE']
   "R=E(m(a,n))"
   OO=C*R;s=sum
   "x='\n'.join"
   "p(x(O))    "
  "p(s(n)/l(b)) "
 "p(*b[::-1])    "
"p(*sorted(n))    "
p(*set(n))

Thanks to @Falko for being my muse. This works, because Python does not create a new scope for each if statement, so the variables persist in the outer print statements. One annoying thing was that a map object (in our case n) can be used only once. So it was necessary to string out the R=E(...) line, but then R was not defined. Therefore I was lucky that there were four spaces left in the first line!
The output can be solved by providing multiple elements *b[::-1] instead of the list. The alternative ' '.join(...) would have been too long.

Beautiful! Nice to see an alternative approach to deal with variable line beginnings in python. Just some short if-statements and all those spaces are just fine. :)

@Falko: The downside is: there is no space for Stan :(

C (gcc), N = 15, 47 unique characters
Assumes sizeof(int) == 4 and sizeof(int*) >= sizeof(int).
;                     ;
 ;                   ;
  ;                 ;
   ;           float
    s;c(a,b)int*a,*
    b;{b=*b-*a;}i,n
    ,*f;*q,*R,C,E ;
    main(a){for(;0<
    scanf("%i",&a);
    i=i<abs(a)?a:i,
    s+=f[n-!0]=a)f=
    realloc(f,++n*4
    );qsort(f,n*C,4
    ,c);for(i=q?R?n
    :!0:i;i--;a=f[i
    ])!E|n-i<2|a!=f
    [i]&&printf(q?R
    ?R:q:"CORE\n",!
    q+R?f[i]:s/n);}
   ;*q="%f";       ;
  ;*R="%.0f ";      ;
 ;C=!0;              ;
;E=!0;                ;

4 Layers
3 layers
2 layers
1 layer
Core

Runic Enchantments, N=9 N=8, 38 Characters
/ o/\  \     \S\
" //RiU\      \}
@            q "
"        }+1\r @
}   ^U \    {q "
     \{\?)}\+  }
  o\/'|A:{:/R' S
 //r/Ril2=?\?R :
   ,A~/"OC"/=? {
   @| \"RE"\3= =
 D$\' /rqka/l2S?
    i \*@   il\/
   'R1i     Ui ~
 R$/Rak      U \
 ?!D  Rlril1-{=
R   R: }S:{=?\~

Try it online!
Turns out I was wrong, I forgot I had an explicit sort command already, due to having encountered the "sort a list" problem before. This does, however, limit the size of inputs that the final program can take (8 values) due to the internal costs of the sort command. A slight tweak can increase the input size to 13 at the cost of 1 unique character or to 19 for two unique characters (all additional characters are on Layer 1 and added at the same time, but the increased capacity of the IP's stack isn't needed until Layer 3, as C, L1, and L2 can perform their calculations without holding the entire input in memory).
Core: Try it online!
Layer 1: Try it online!
Layer 2: Try it online!
Layer 3: Try it online!
Layer 4: Try it online!
Further compression is highly unlikely, due to the smaller space necessitating an increase in the number of flow control characters. I found an arrangement that gave 9 empty spaces in the core program, but that is not enough, as we need (a correctly arranged) 15.
Explaining how any of these programs work is difficult without a visual map of the path the IP takes, which is cumbersome and time consuming to construct. The initial entry point is the upper left corner of the Core program (^) which allows for consistent flow control as new layers are added, as each layer has an opportunity to intercept on the newly added line at the top or the bottom.
Layers 1 and 2 intercept at the bottom (so that the top line remains empty for future layers) and then perform their operations along the right hand edge (a loop arranged vertically). Layer 1 is slightly too long and takes 3 characters along the top edge as well, but the diagonal reflector (\) in the top right realigns the IP with the next loop iteration.
Layer 3 intercepts along the top edge in order to grab the first input value before redirecting to the bottom edge (Layer 4 leaves a NOP in this column on its bottom line) and reads the full input using the bottom edge loop, redirecting on the Down command (D) in the lower left. From there the IP bounces a few times before ending up in an output ($) loop in the lower left in order to space-separate the values.
Layer 4 utilizes all of the functionality of layer 3 (hence the blank space), but intercepts on its own new top edge (upper left) in order to perform its own functionality at the end of Layer 3's processing. The top left corner inserts a string "@" which is used to denote the end of the array before entering the processing loop along the bottom. If a duplicate value is found, it's popped (~, lower right corner) otherwise the branch is taken that consumes the new right hand edge. This side branch checks to see if the end of the array has been reached, and if so, break out and head to the same space-separated output loop from Layer 3. Otherwise use the blank space on Layer 3 to return back to the main loop.

JavaScript (Node.js), N=14, C=44 N=13, C=40

    (s,a=s.split
    ` `)=>[[`CORE
    `.repeat(Math
    .max(...a.map
    (Math.abs)))]
    ,a.reverse(),
    [a.reduce((i,
    j)=>i- -j,2-2
    )/a.length],[
    ...new Set(a)
    ],[...a].sort
    ((i,j)=>i-j)]
[[[[[2-2].join` `
   - -2].join` `
  -2/2].join` `
 - -2-2/-2].join` `
-2/2].join` `

Try it online!
JavaScript (Browsers), N=15, C=52
Full program.
The TIO uses process.argv[2] for prompt()
(r=4)?r:
 (r=3)?r:
  (r=2)?r:
   (r=1)?r:
    r=0;p=prompt().
    split` `;m=p.
    reduce((i,j)=>i
    - -j)/p.length
    v=p.reverse().
    join` `;t=[...p
    ].sort((i,j)=>i
    -j).join` `;s
    =new Set(p);
    console.log(
((((r==0?Array(Math
    .max(...p.map(
    Math.abs)))
    .fill(`CORE`)
    .join`\n`:``)  +
   (r==1?m:``))     +
  (r==2?v:``))       +
 (r==3?t:``))         +
[...s].join` `)

Try it online!

TlanG 177 bytes N=4 (*3)
############
############
############
####CORE####
####||||####
####CORE####
############
############
############

prints CORE
Explaination on the github linked in title
Not quite the requested but i think its fine!

Welcome to CGCC, but this challenge requires 5 different actions to be done on a string, one for each size of the code, not just printing CORE once. Moreover, the code is not in a square shape. Your core should have a square shape, so do the other 4 layers.


text:
Code to toggle a program
Challenge
Write a program that toggles another. Your program should accept exactly two command arguments. Specifically, your two tasks are:

If the names of any running processes are identical to argument one, close them and exit
If the names of zero running processes are named identical to argument one, spawn one with that name, pass it the second command arg, and exit

The life of the spawned process must be completely independent of your own (think Daemon threads in Java, or Background threads in C#). You are responsible for closing programs that you didn't necessarily start in a past life.
Example
Here are two separate examples of how your program might be called.
python YourToggler.py Notepad.exe C:\MyTextFile.txt
java MyToggler.java cmd "echo hello world"

In the first example, if Notepad.exe is currently running, you should close all processes named Notepad.exe. Otherwise, you should start one with the argument C:\MyTextFile.txt.
Assumptions
You can sleep better knowing the following:

The name passed to you will be a valid program
You are not responsible for name discrepancies

If you are asked to find Notepad, you are not responsible for closing Notepad.exe

You will be run with the privileges you need to carry out your duty

Can we can assume no whitespace in the program name and arg?

Bash+common Linux utilities, 12 or 16 bytes
pkill "$1"||"$@"

If we can assume no whitespace in the program name and arg, then we can drop the quotes for a score of 12:
pkill $1||$@

killall "$1"||"$@"

@user23013 Yes - thanks!

pkill would probably work instead of killall.

@user23013 nice!

Bash (+ pgrep & xargs) - 83 chars
p="$(pgrep -x "$1")";if [ $? = 0 ];then echo "$p"|xargs -n 1 kill;else "$1" "$2";fi

Would pkill "$p" work here? Saves you 15 characters.

AutoIt v3 - 102 chars (97 chars)
$a=$CmdLine
If ProcessExists($a[1]) Then
ProcessClose($a[1])
Else
ShellExecute($a[1],$a[2])
EndIf

Tried my best to golf it down but there is no shorter function for ProcessExists(), ProcessClose() and ShellExecute().
Good thing is, that it is working on Windows unlike the Bash answers.
FYI: Using Run() instead of ShellExecute() requires the full path because it does not take into account executables in your PATH.

If we assume that the path is given absolutely like
toggle.exe C:\Windows\System32\Notepad.exe C:\MyTestFile.txt
Then that code can be golfed down to 97 chars:
$a=$CmdLine
If ProcessExists($a[1]) Then
ProcessClose($a[1])
Else
Run($a[1]&" "&$a[2])
EndIf

Note: You have to pass a string to the Run()-function like you would type into your Command Prompt but it does not work like it. As written before it is like the Command Prompt without Environment variables.

authors: 麒麟网2娱乐代理--平台总代