text:
Properties of Binary Functions
Many important topics in abstract algebra involve a binary function acting on a set. A number of properties of such functions have been defined in the investigation of such topics.
Your challenge will be to determine whether a given binary function on a given domain possesses five of these properties.
Properties
Closure
A binary function is closed if every possible output is in the domain.
Associativity
A binary function is associative if the order in which the function is applied to a series of inputs doesn't affect the result. That is, $ is associative if (a $ b) $ c always equals a $ (b $ c). Note that since the value (a $ b) is used as an input, associative functions must be closed.
Commutativity
A binary function is commutative if swapping the order of the inputs doesn't change the result. In other words, if a $ b always equals b $ a.
Identity
A binary function has an identity element if there exists some element e in the domain such that a $ e = a = e $ a for all a in the domain.
Idempotence
A binary function is idempotent if applying it to two identical inputs gives that number as the output. In other words, if a $ a = a for all a in the domain.
Input
You will be given a function in the form of a matrix, and the domain of the function will be the numbers 0 ... n-1, where n is the side length of the matrix.
The value (a $ b) is encoded in the matrix as the ath row's bth element. If the input matrix is Q, then a $ b = Q[a][b]
For example, the exponentiation function (** in Python) on the domain [0, 1, 2] is encoded as:
[[1, 0, 0]
 [1, 1, 1]
 [1, 2, 4]]

The left and right domains are the same, so the matrix will always be square.
You may use any convenient matrix format as input, such as a list of lists, a single list in row- or column- major order, your language's native matrix object, etc. However, you may not take a function directly as input.
For simplicity, the matrix entries will all be integers. You may assume that they fit in your language's native integer type.
Output
You may indicate which of the above properties hold in any format you choose, including a list of booleans, a string with a different character for each property, etc. However, there must be a distinct, unique output for each of the 24 possible subsets of the properties. This output must be easily human-readable.
Examples
The maximum function on domain n=4:
[[0, 1, 2, 3]
 [1, 1, 2, 3]
 [2, 2, 2, 3]
 [3, 3, 3, 3]]

This function has the properties of closure, associativity, commutativity, identity and idempotence.
The exponentiation function on domain n=3:
[[1, 0, 0]
 [1, 1, 1]
 [1, 2, 4]]

This function has none of the above properties.
The addition function on domain n=3:
[[0, 1, 2]
 [1, 2, 3]
 [2, 3, 4]]

This function has the properties of commutativity and identity.
The K combinator on domain n=3:
[[0, 0, 0]
 [1, 1, 1]
 [2, 2, 2]]

This function has the properties of closure, associativity and idempotence.
The absolute difference function on domain n=3:
[[0, 1, 2]
 [1, 0, 1]
 [2, 1, 0]]

This function has the properties of closure, commutativity and identity.
The average function, rounding towards even, on domain n=3:
[[0, 0, 1]
 [0, 1, 2]
 [1, 2, 2]]

This function has the properties of closure, commutativity, identity and idempotence.
The equality function on domain n=3:
[[1, 0, 0]
 [0, 1, 0]
 [0, 0, 1]]

This function has the properties of closure and commutativity.
Challenge
This is code golf. Standard loopholes apply. Least bytes wins.

Pyth, 51 bytes
[qKUQ@VQKCIQ}]Km{@RdCBQKJ!-sQK&JqF.bsm@L@QdYN.p,sQK

Try it online: Demonstration or Test Suite
This prints a list of 5 boolean values. They indicate the properties in the order:
[Idempotence, Commutativity, Identity, Closure, Associativity]

Here is a better output format: Demonstration or Test Suite
Explanation:
Idempotence:
qKUQ@VQK
   Q       Q = input matrix
  UQ       [0, 1, ..., len(matrix)-1]
 K         assign to K
    @VQK   vectorized lookup of Q and K //gets the diagonal elements
qK         check, if this is equal to K

Commutativity:
CIQ   check if transpose(Q) is equal to Q

Identity:
}]Km{@RdCBQK
   m       K   map each d in K to:
        CBQ       the list [Q, transpose(Q)]
     @Rd          take the d-th element of each ^
    {             remove duplicates
}]K            check if [K] is in ^

Closure:
J!-sQK
   sQ    sum(Q) //all elements of Q
  -  K   remove the elements, that also appear in K
 !       ckeck, if the results in an empty list
J        store the result in J

Associativity:
&JqF.bsm@L@QdYN.p,sQK
               .p,sQK  all permutations of [sum(Q), K] //all 2 ;-)
    .b                 map each pair (N,Y) of ^ to:
       m      N           map each d of N to:
          @Qd                the row Q[d]
        @L   Y               map each element of Y to the corr. element in ^
      s                   unfold this 2-d list
  qF                   check if they result in identically lists
&J                     and J

Haskell, 178 171 bytes
import Data.List
f x=[c,c&&and[(m%n)%o==m%(n%o)|m<-b,n<-b,o<-b],x==t,all(elem b)[x,t],b==[i%i|i<-b]]where c=all(l>)(id=<<x);b=[0..l-1];a%b=x!!a!!b;l=length x;t=transpose x

Returns a list with five booleans, which are in order closure, associativity, commutativity, identity and idempotence.
Usage example: f [[1, 0, 0],[0, 1, 0],[0, 0, 1]] -> [True,False,True,False,False].
How it works:
f x=[
  c,                         -- closure (see below)
  c&&and[(m%n)%o==m%(n%o)|   -- assoc: make sure it's closed, then check the
          m<-b,n<-b,o<-b],   --        assoc rule for all possible combinations
  x==t,                      -- comm: x must equal it's transposition
  all(elem b)[x,t],          -- identity: b must be a row and a column
  b==[i%i|i<-b]              -- idemp: element at (i,i) must equal i
  ]
  where                      -- some helper functions
  c=all(l>)(id=<<x);         -- closure: all elements of the input must be < l
  b=[0..l-1];                -- a list with the numbers from 0 to l-1
  a%b=x!!a!!b;               -- % is an access function for index (a,b)
  l=length x;                -- l is the number of rows of the input matrix
  t=transpose x

Edit @xnor found some bytes to save. Thanks!

How about c=all(l>)?

Also, [i%i|i<-b]==b.

Very readable for code-golf - nice!

CJam, 95 bytes
q~:Ae_A,:Bf<:*'**B3m*{_{A==}*\W%{Az==}*=}%:*'A*A_z='C*B{aB*ee_Wf%+{A==}f*B,2*='1*}%Ae_B)%B,='I*

Prints a subsequence of *AC1I. * is the symbol for closure, A is for associative, C is for commutative, 1 is for identity and I is for idempotent.

The input array is read q~ and stored in A (:A).
Closure
Ae_A,:Bf<:*'**

If all (:*) elements in the matrix (Ae_) are smaller f< than B=size(A) (A,:B), print a * ('**).
Associativity
B3m*{_{A==}*\W%{Az==}*=}%:*'A*

Generate all triples in the domain (B3m*). We print A if they all satisfy a condition ({...}%:*'A*).
The condition is that, for some triple [i j k], left-folding that list with A (_{A==}*) and left-folding its reverse [k j i] (\W%) with Aop ({Az==}*), the flipped version of A, are equal (=).
Commutativity
A must equal its transpose: A_z=. If so, we print C ('C=).
Identity
B{                         }%   For each element X in the domain (0..N-1):
  aB*                           Make N copies.
     ee                         [[0 X] [1 X] ...]
       _Wf%+                    [[0 X] [1 X] ... [X 0] [X 1] ...]
            {A==}f*             [A(0, X) A(1, X) ... A(X, 0) A(X, 1)]
                   B,2*=        This list should equal the domain list repeated twice.
                        '1*     If so, X is an identity: print a 1.

The identity is necessarily unique, so we can only print one 1.
Idempotent
Ae_B)%B,='I*

Check if the diagonal equals B,. If so, print an I.

Matlab, 226
a=input('');n=size(a,1);v=1:n;c=all(0<=a(:)&a(:)<n);A=c;for i=v;for j=v(1:n*c);for k=v(1:n*c);A=A&a(a(i,j)+1,k)==a(i,a(j,k)+1);end;end;b(i)=all(a(i,:)==v-1 & a(:,i)'==v-1);end;disp([c,A,~norm(a-a'),any(b),all(diag(a)'==v-1)])

An important thing to notice is that non-closed implies non-associative. Many of those properties can easily be checked using some properties of the matrix:

Closure: All all matrix entries in the given range?
Associativity: As always the most difficult one to check
Commutativity: Is the matrix symmetric?
Identity: Is there an index k such that the k-th row and k-th column are exactly the list of the indices?
Idempotence: Does the diagonal correspond to the list of indices?

Input via standar Matlab notation: [a,b;c,d] or [[a,b];[c,d]] or [a b;c d] e.t.c.
Output is a vector of ones a zeros, 1 = true, 0 = false, for each of the properties in the given order.
Full code:
a=input('');
n=size(a,1);
v=1:n;
c=all(0<=a(:)&a(:)<n);               %check for closedness
A=c;
for i=v;
   for j=v(1:n*c);
      for k=v(1:n*c);
          A=A&a(a(i,j)+1,k)==a(i,a(j,k)+1);   %check for associativity (only if closed)
      end;
   end;
   b(i)=all(a(i,:)==v-1 & a(:,i)'==v-1);      %check for commutativity
end
%closure, assoc, commut, identity, idempotence
disp([c,A,~norm(a-a'),any(b),all(diag(a)'==v-1)]);

JavaScript (ES6) 165
An anonymous function returning an array with five 0/1 values, which are in order Closure, Associativity, Commutativity, Identity and Idempotence.
q=>q.map((p,i)=>(p.map((v,j)=>(w=q[j][i],v-w?h=C=0:v-j?h=0:0,q[v]?A&=!q[v].some((v,k)=>v-q[i][q[j][k]]):A=K=0),h=1,p[i]-i?P=0:0),h?I=1:0),A=P=K=C=1,I=0)&&[K,A,C,I,P]

Less golfed
f=q=>(
  // A associativity, P idempotence, K closure, C commuativity
  // assumed true until proved false
  A=P=K=C=1,
  I=0, // Identity assumed false until an identity element is found
  q.map((p,i)=> (
      h=1, // assume current i is identity until proved false
      p[i]-i? P=0 :0, // not idempotent if q[i][i]!=i for any i
      p.map((v,j)=> (
          w=q[j][i], // and v is q[i][j]
          v-w // check if q[j][i] != q[i][j]
          ? h=C=0 // if so, not commutative and i is not identity element too
          : v-j // else, check again for identity
            ? h=0 // i is not identity element if v!=j or w!=j
            : 0,
          q[v] // check if q[i][j] in domain
            ? A&=!q[v].some((v,k)=>v-q[i][q[j][k]]) // loop for associativity check
            : A=K=0 // q[i][j] out of domain, not close and not associative
        )
      ),
      h ? I=1 : 0 // if i is the identity element the identity = true
    )
  ),
  [K,A,C,I,P] // return all as an array
)

Test

f=q=>
  q.map((p,i)=>(
    p.map((v,j)=>(
      w=q[j][i],
      v-w?h=C=0:v-j?h=0:0,
      q[v]?A&=!q[v].some((v,k)=>v-q[i][q[j][k]]):A=K=0
    ),h=1,p[i]-i?P=0:0),
    h?I=1:0
  ),A=P=K=C=1,I=0)
  &&[K,A,C,I,P]

// test

console.log=x=>O.textContent+=x+'\n';

T=[
 [
  [[0, 1, 2, 3],
   [1, 1, 2, 3],
   [2, 2, 2, 3],
   [3, 3, 3, 3]]
 ,[1,1,1,1,1]] // has the properties of closure, associativity, commutativity, identity and idempotence.
,[ // exponentiation function on domain n=3:
  [[1, 0, 0],
   [1, 1, 1],
   [1, 2, 4]]
 ,[0,0,0,0,0]] // has none of the above properties.
,[ // addition function on domain n=3:
  [[0, 1, 2],
   [1, 2, 3],
   [2, 3, 4]]
 ,[0,0,1,1,0]] // has the properties of commutativity and identity.
,[ // K combinator on domain n=3:
  [[0, 0, 0],
   [1, 1, 1],
   [2, 2, 2]]
 ,[1,1,0,0,1]] // has the properties of closure, associativity and idempotence.
,[ // absolute difference function on domain n=3:
  [[0, 1, 2],
   [1, 0, 1],
   [2, 1, 0]]
 ,[1,0,1,1,0]] // has the properties of closure, commutativity and identity.
,[ // average function, rounding towards even, on domain n=3:
  [[0, 0, 1],
   [0, 1, 2],
   [1, 2, 2]]
 ,[1,0,1,1,1]] // has the properties of closure, commutativity, identity and idempotence.
,[ // equality function on domain n=3:
  [[1, 0, 0],
   [0, 1, 0],
   [0, 0, 1]]
 ,[1,0,1,0,0]] // has the properties of closure, commutativity,
]

T.forEach(t=>{
  F=t[0],X=t[1]+'',R=f(F)+'',console.log(F.join`\n`+'\n'+R+' (expected '+X+') '+(X==R?'OK\n':'Fail\n'))
  })


text:
Does the string contain 2016?
Given a string input, your task is to write a program that prints a truthy value to STDOUT or equivalent if the input contains "2016" anywhere in it without using any built-in contains, match, replace, split or other functions that use patterns or regexes.
A truthy value also must be printed if the input contains "2016" with the same number of spaces between each number.
Test Cases
2016
    => true
"2016"
    => true
2202012016016166
      ^^^^ => true
220201 2 0 1 6 016166
    => true
Happy New Year! It's 2016!
    => true
2016 is coming!
    => true

2_0_1_6
    => false
22001166
    => false
It's not 2015 any more
    => false
6102
    => false
201.6
    => false
20 16
    => false
2 0  1   6
    => false

Rules

Regexes and pattern matching cannot be used
Built-in contains, match, and replace cannot be used
Built-in split functions cannot be used (the only exception is when splitting the string into individual characters for looping through them, such as input.split(""))
The code cannot contain the string "2016" in any form (unicode literals and constructing the string included - that doesn't mean that the characters 0, 1, 2, or 6 can't be used)
The input may either be taken from STDIN or as an argument to a function
It is safe to assume that the input will not contain linefeeds or newlines.
The input may contain any printable ASCII characters (spaces included)
A truthy value  must be printed to STDOUT or equivalent if the input contains 2016.
A falsey value  must be printed to STDOUT or equivalent if the input does not contain 2016
If using a function, instead of using STDOUT, the output can be the return value of the function
The truthy/falsey value cannot be printed to STDERR.
Standard loopholes apply
This is code-golf, so the shortest program in bytes wins. Good luck!

Bonus
-30 Bytes if the input also returns a truthy value if the spaces between the characters in 2016 are the same.
Happy 2 0 1 6
    => true
I can't wait for  2   0   1   6
    => true
It's almost 2 0  1   6
    => false

Leaderboard
This is a Stack Snippet that generates both a leaderboard and an overview of winners by language.
To ensure your answer shows up, please start your answer with a headline using the following Markdown template
## Language Name, N bytes

Where N is the size, in bytes, of your submission
If you want to include multiple numbers in your header (for example, striking through old scores, or including flags in the byte count), just make sure that the actual score is the last number in your header
## Language Name, <s>K</s> X + 2 = N bytes

var QUESTION_ID=67575;var OVERRIDE_USER=20634;function answersUrl(e){return"http://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"http://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

It's too vague what built ins are allowed. For example, can I split on 2016 and check if the result has multiple parts? What about a builtin that checks if a string is a prefix of another string?

So that means a.split("") is invalid?

I don't know what that means for my examples. I was thinking of split on a fixed string

@CᴏɴᴏʀO'Bʀɪᴇɴ I updated the challange - I assumed that all languages had a function to get the individual characters of a string

Ok, then can I use join to intersperse a string with spaces? Slice a string at some position? Check if strings are equal? It would be nice to have a criterion for the boundary rather than checking case by case.

@xnor You can do all of those things, because they are not disallowed in the rules (join can only be used if it doesn't use a regex though, again, like stated in the rules)

Are we allowed to, for example, do str(2016) (string representation of 2016)? Technically that doesn't contain the string 2016.

@Pietu1998 I included that part only to close any loopholes that may appear - but no, as it is constructing the string "2016"

Can I construct the string "2 0 1 6"?

@Mauris You found a loophole in the loophole closer... Anyways, I don't see any reason why you shouldn't be able to, so yes, you can construct 2 0 1 6

This challenge has a close vote for Unclear what you're asking? I feel like its very clear what this challenge is asking - check if a string contains another string without directly using built-in functions that make it easy

I think they mean it's unclear what code you're asking them to produce because of the vague rules about what built-ins are allowed, no string constructing, etc...

"pattern matching cannot be used" - that rules out Haskell. I was working on a solution, but now I'm out.

"pattern matching cannot be used" - pattern matching is the entire premise of Mathematica. Expressions are matched with patterns, then evaluated.

@LegionMammal978 I can't tell if you're being serious or not... You're taking it way too literally - "pattern matching can't be used" doesn't mean that the language can't be pattern matched, it means that you can't use pattern matching in your code

-1; rules are ad-hoc and arbitrary

@ThomasKwa I guess that's opinion, but I don't see how they're arbitrary - the rules all enforce that users can't just do if(input.contains("2016")){return true;} - I didn't just through random rules in there for no reason

The addition of many arbitrary-looking rules often means that a challenge is uninteresting or flawed.

@ThomasKwa I didn't really think that there were that many rules, but I guess if that many people agree with you, I should probably update the challenge... The "spaces" part is now a bonus, and is not required

The main problem is that the rules are not "black-and-white" for every language. I thought it was an interesting challenge (for my preferred language, JavaScript, at least) but for others that rely heavily on pattern-matching the rules become less clear. The only time that challenges with arbitrary rules (rules that prevent something which would normally not be an issue) work is when they are clear across all languages. Unfortunately the pattern matching rule here may only be clear if it is spelled out for each individual language (which is not feasible).

@user81655 Yes, the rules have a lot of grey area. I had the same pattern matching restriction on another one of my challenges, but I assume that went over well because the objective was much more clear.

Maybe the challenge would have been better received if it had a simple rule like "No regular expressions" like the other one had, but there are other loopholes (like the reasons you disallowed the "2016" literal and certain built-ins). Too many arbitrary rules to prevent loopholes and people won't like the challenge.

CJam, 35 - 30 = 5 bytes
qS*_,,_Sf*{"2 0 1 6"\*}%\:)@few:+&`

Explanation
qS*                                   Push s p a c e d   i n p u t.
   _,,                                Push [0..N-1] where N = len(input).
      _Sf*                            Push ["", " ", "  ", "   ", ...].
          {"2 0 1 6"\*}%              Make it ["2 0 1 6", "2   0   1   6", ...].
                        \             Swap [0..N-1] to top of stack.
                         :)           Increment each, giving [1..N].
                           @          Rotate spaced input I to top of stack.
                            few       Push [I1ew I2ew .. INew], i.e.
                               :+      when concatenated, all substrings of I.
                                 &    Intersect sets.
                                  `   Print as CJam syntax.

Essentially, given an input string abcd, this executes a "substring search" by intersecting the sets:

2 0 1 6, 2   0   1   6, ... up to 2*len(input())-1 = more than enough spaces,
a, , b, ..., a b, ... a b c d.

If a result is found, such a spaced 2016 string appeared as a substring of the input, and a truthy list containing this result is printed, like ["2 0 1 6"]. Otherwise, the empty list is printed.
The string "2016" is never constructed as the code runs; only its spaced-out versions are.

JavaScript (ES6), 125 - 30 = 95 bytes
x=>(y=[...x]).map((_,i)=>y.map((_,j)=>r?0:(n=x.substr(j,a.length),r=nb),s=" ".repeat(i),a=2+s+0+s+1+s,b=a+5,a+=7),r=0)|r

Explanation
Returns 1 if it matched, otherwise 0.
Brute forces every possible combination of spaces between 2016 and checks for a match at each substring. Note that it never constructs the string 2016 because it generates a as 2017 and b as 2015 (both with spaces) and checks if b < substring                              // x = input string
  (y=[...x])                    // y = input as array
  .map((_,i)=>                  // loop over every possible amount of spaces between digits
    y.map((_,j)=>               // loop over every character to check for a match
      r?0:(                     // if r is set we don't have to do anything, if not:
        n=x.substr(j,t.length), // n = substring to compare
        r=nb               // check if r is 2016
      ),
      s=" ".repeat(i),          // s = spaces between letters
      a=2+s+0+s+1+s,            // get string to compare with
      b=a+5,                    // b = 2015 (with spaces)
      a+=7                      // a = 2017 (with spaces)
    ),
    r=0                         // r = result
  )
  |r                            // return result

Test

var solution = x=>(y=[...x]).map((_,i)=>y.map((_,j)=>r?0:(n=x.substr(j,a.length),r=nb),s=" ".repeat(i),a=2+s+0+s+1+s,b=a+5,a+=7),r=0)|r
<input type="text" id="input" value="I can't wait for  2   0   1   6" />
<button onclick="result.textContent=solution(input.value)">Go</button>

It looks like this returns false for the input "220201 2 0 1 6 016166" - I should probably add that as a test case

@Jojodmo You're right. I changed to a brute-force approach because it was shorter than fixing my old method.

Swift 2, 307 297 - 30 = 267 Bytes
func d(s:String)->Int{var c=0;var n=0;var l=0;for v in s.characters{if(v=="2"){c=1;l=0;n=0};if(c==1&&v=="0"){c=2;l=n;n=0};if(c==2&&v=="1"){c=(l==n ?3:0);l=n;n=0};if(c==3&&v=="6"){if(l==n){return 1}else{c=0}};if(!(v=="2" || v=="0" || v=="1" || v=="6")){if(v==" "){n++}else{c=0;l=0;n=0;}}};return 0}

Ungolfed
func d(s: String) -> Int{
    var c=0
    var n=0
    var l=0
    for v in s.characters{
        if(v == "2"){
            c = 1
            l = 0
            n = 0
        }
        if(c == 1 && v == "0"){
            c = 2
            l = n
            n = 0
        }
        if(c == 2 && v == "1"){
            c = (l == n ? 3 : 0)
            l = n
            n = 0
        }
        if(c == 3 && v == "6"){
            if(l == n){
                return 1
            }
            else{
                c = 0
            }
        }
        //you may be wondering why I didn't use &&. It's because
        //using && would require me to use !=, which needs spaces
        //on both sides
        if(!(v == "2" || v == "0" || v == "1" || v == "6")){
            if(v == " "){
                n++
            }
            else{
                c=0
                l=0
                n=0
            }
        }
    }
    return 0
}

source: Stack Exchange

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

sort: votes


text:
Draw a Christmas Star / Stellated Dodecahedron
Paper stars are a big thing in my family at christmas, so I thought a virtual one would be cool.
Below is an image of a regular dodecahedron (from https://en.wikipedia.org/wiki/Dodecahedron, attributed to the author mentioned there.)

The process of stellation (wikipedia) when applied to a polyhedron involves extending the faces until they cross other faces. Thus starting with the regular dodecahedron, we obtain the following shapes:
Small Stellated Dodecahedron, Great Dodecahedron and Great Stellated Dodecahedron
Image from http://jwilson.coe.uga.edu/emat6680fa07/thrash/asn1/stellations.html

These are the three possible Stellations of the dodecahedron (Wolfram). They form a natural progression from the dodecahedron, to the small stellated dodecahedron, great dodecahedron and great stellated dodecahedron, as we extend the faces further and further out.
Task
Your program or function should
display or output to an image file one of the following polyhedra: Regular dodecahedron, Small stellated dodecahedron, Great dodecahedron or Great Stellated Dodecahedron.
The colour scheme should be as the second image above. Each of the six pairs of opposite faces shall be one of the six colours Red, Yellow, Green, Cyan, Blue, and Magenta. You may use default colours with these names in your language or its documentation, or use the colours FF0000, FFFF00, 00FF00, 00FFFF, 0000FF, and FF00FF (you may tone these down by reducing the intensity to a minimum of 75% if desired, for example by reducing the F's to C's.)
Note that we define a "face" as being all areas in the same plane. Thus in the images above the front face is yellow (and the parallel back face would also be yellow.)
Background should be black, grey, or white. Edges may be omitted, but should be black if drawn.
Rules
The displayed polyhedron must be between 500 and 1000 pixels in width (width is defined as the maximum distance between any two displayed vertices.)
The displayed polyhedron must be in perspective projection (viewpoint at least 5 widths away from the polyhedron), or orthographic projection (effectively a perspective projection with the viewpoint at infinity).
The polyhedron must be displayable from any angle. (It is not acceptable to pick the easiest possible angle and making a hardcoded 2D shape.) The angle can be specified by the user in either of the following ways:

Input of three angles corresponding to three rotations, from stdin, or as function or commandline parameters. These can be either Euler angles (where the first and last rotations are about the same axis) or Tait-Bryan angles (where there is one rotation each about the x, y and z axis) https://en.wikipedia.org/wiki/Euler_angles (simply put, anything goes so long as each rotation is about the  x, y, or z axis and consecutive rotations are about perpendicular axes.)
Facility for the user to rotate the polyhedron in steps of not more than 10 degrees about the x and y axes and refresh the display, any arbitrary number of times (assuming z axis perpendicular to the screen).

The polyhedron must be solid, not wireframe.
No builtins for drawing polyhedra are allowed (I'm looking at you, Mathematica!)
Scoring
This is codegolf. Shortest code in bytes wins.
Bonuses
Multiply your score by 0.5 if you do not use builtins for 3D drawing.
Multiply your score by 0.7 if you can display all three of the stellations of the dodecahedron, selectable by the user by an integer 1-3 entered from stdin, or by function or commandline parameter.
If you go for both bonuses your score will be multiplied by 0.5*0.7=0.35
Useful info (sources as below)
https://en.wikipedia.org/wiki/Regular_dodecahedron
https://en.wikipedia.org/wiki/Regular_icosahedron
The dodecahedron has 20 vertices. 8 of them form the vertices of a cube with the following cartesian (x,y,z) coordinates:
(±1, ±1, ±1)
The remaining 12 are as follows (phi is the golden ratio)
(0, ±
1
/
φ
, ±φ)
(±
1
/
φ
, ±φ, 0)
(±φ, 0, ±
1
/
φ
)
The convex hull of the small stellated dodecahedron and great dodecahedron is obviously a regular dodecahedron. The outer vertices describe an icosahedron.
According to Wikipedia an icosahedron's 12 vertices can be described in a similar manner as cyclic permutations of (0, ±1, ±φ). The outer vertices of the small stellated dodecaheron and great dodechahedron (on the same scale as the dodecahedron above) form a larger icosahedron, where the coordinates of the vertices are cyclic permutations of (0, ±φ^2, ±φ).
The angles between faces for the dodecahedron and icosahedron are 2 arctan(phi) and arccos(-(√5)/3) respectively.
For tips on rotating, see https://en.wikipedia.org/wiki/Rotation_matrix
EDIT: By mistake I have allowed the regular dodecahedron, and can't retract it now. The x0.7 bonus for drawing all three of the stellated polyhedra remains. On New Year's Day I will issue a bounty of 100 for the answer that can display the most of the four polyhedra, with shortest code as the tie break.

@LegionMammal978 builtins for drawing polyhedra (eg dodecahedron) are disallowed. Some languages have facilities for building 3D models with commands like triangle[[a,b,c],[p,q,r],[x,y,z]]. These languages generally have builtins for rotating and displaying the model, automatically taking care of not displaying hidden faces, etc. Solutions such as these are allowed but will not attract the bonus. The purpose of the bonus is to allow languages that do not have these facilities to be competitive, and also to attract more interesting solutions.

@LegionMammal978 haha, I knew Mathematica would be the language that caused problems. Polyhedrondata is disallowed as it is clearly a builtin for drawing polyhedra. If your answer does not use builtins for drawing polyhedra, and complies with the other rules, then it is acceptable. Your point seems to be that given the fact that you have to colour the faces correctly, Polyhedrondata wouldn't save you much anyway, so it may in practice be a somewhat arbitrary restriction. I agree to an extent, but It's fairer to all if I avoid changing rules after posting.

Mathematica, 426 424 bytes
Graphics3D[{Red,Yellow,Green,Cyan,Blue,Magenta}~Riffle~(a=Partition)[Polygon/@Uncompress@"1:eJxtkjEKwkAURNeoySYgeAVP4QFsrcTGTiyUBcEith7A2wgKgpVH8/vgs2TYZmAyw9/5k784XDbHVwihnxisU39N9SiEdI8GO/uWHpXBtjFAgJ7HToFl5WabEdJ+anCqDb6dU9RP65NR59EnI0CZDAWYjFmomBmPCn3/hVVwc9s4xYd66wYqFJVvhMz75vWlHIkhG2HBDJ1V3kYps7z7jG6GomIu/QUJKTGkdtlX2pDM8m6pydyzHIOElBhyG6V9cxulzPldaVJ6lpuUkKUTzWcm+0obkrn0f3OT0rMc0jDkD37nlUo="~a~3~a~5,2],Boxed->1<0]

Uses the built-in Graphics3D to display the shape. Most of the bytes are taken up by the compressed vertex locations, however, which are then Partitioned into a form usable by Polygon. Finally:

Note that this shape can be rotated by clicking and dragging.

OMG, I was going to delete regular dodecahedron! As far as I can tell (I don't know or have Mathematica) this complies with the rules, so +1.

@steveverrill I don't think that it would change the size too much, but I would prefer not to have to rewrite this from scratch.

Your answer remains valid, I'm not going to change the rules, it would be bad form. However, in addition to the 0.7 bonus for the three stellated polyhedra, I've offered a bounty for the answer that can produce the most of the four polyhedra. If you did decide to update your answer, I reckon you might save a lot of bytes by generating the coordinates algorithmically (see the useful info section of the question.)

@steveverrill, I would, but apparently, the vertex locations involve the roots of quartics, and I cannot find a pattern.

Python 2.7, 949 bytes
Here is the solution for the regular dodecahedron plotted using matplotlib.
The rough outline for the ungolfed code (not shown here) was is outlined below:

Make vertices Make edges (based on 3 nearest neighbours, module
scipy.spatial.KDtree)
Make faces based on graph cycles with length 5 (module networkx)
Make facenormals (and select those with outward facing normal, numpy.cross)
Generate coloring based on face normals
Plotting using matplotlib

import itertools as it
import numpy as np
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
import matplotlib.pyplot as plt
v=[p for p in it.product((-1,1),(-1,1),(-1,1))]
g=.5+.5*5**.5
v.extend([p for p in it.product((0,),(-1/g,1/g),(-g,g))])
v.extend([p for p in it.product((-1/g,1/g),(-g,g),(0,))])
v.extend([p for p in it.product((-g,g),(0,),(-1/g,1/g))])
v=np.array(v)
g=[[12,14,5,9,1],[12,1,17,16,0],[12,0,8,4,14],[4,18,19,5,14],[4,8,10,6,18],[5,19,7,11,9],[7,15,13,3,11],[7,19,18,6,15],[6,10,2,13,15],[13,2,16,17,3],[3,17,1,9,11],[16,2,10,8,0]]
a=[2,1,0,3,4,5,0,1,2,3,4,5]
fig = plt.figure()
ax = fig.add_subplot((111),aspect='equal',projection='3d')
ax.set_xlim3d(-2, 2)
ax.set_ylim3d(-2, 2)
ax.set_zlim3d(-2, 2)
for f in range(12):
 c=Poly3DCollection([[tuple(y) for y in v[g[f],:]]], linewidths=1, alpha=1)
 c.set_facecolor([(0,0,1),(0,1,0),(0,1,1),(1,0,0),(1,0,1),(1,1,0)][a[f]])
 ax.add_collection3d(c)
ax.auto_scale_xyz
plt.show()

Ruby, 784 bytes * 0.5 * 0.7 = 274.4
My own answer, therefore not eligible for my bounty.
Eligible for both the non-3D builtin bonus and the drawing all stellations bonus.
->t,n{o=[]
g=->a{a.reduce(:+)/5}
f=->u,v,w,m{x=u.dup;y=v.dup;z=w.dup
15.times{|i|k,l=("i".to_c**(n[i/5]/90.0)).rect
j=i%5
x[j],y[j],z[j]=y[j],x[j]*k+z[j]*l,z[j]*k-x[j]*l}
p=g[x];q=g[y];r=g[z]
a=[0,1,-i=0.382,-1][t]*e=r<=>0
b=[j=1+i,0,j,j][t]*e
c=[-i*j,-i,1,i][t]*e
d=[j*j,j,0,0][t]*e
5.times{|i|o<<"<path id=\"#{"%9.0f"%(z[i]*a+r*b+(z[i-2]+z[i-3])*c+2*r*d+999)}\"
d=\"M#{(x[i]*a+p*b)} #{(y[i]*a+q*b)}L#{(x[i-2]*c+p*d)} #{(y[i-2]*c+q*d)}L#{(x[i-3]*c+p*d)} #{(y[i-3]*c+q*d)}\"
fill=\"##{m}\"/>"}}
a=233
b=377
z=[0,a,b,a,0]
y=[a,b,0,-b,-a]
x=[b,0,-a,0,b]
w=[-b,0,a,0,-b]
f[x,y,z,'F0F']
f[w,y,z,'0F0']
f[y,z,x,'00F']
f[y,z,w,'FF0']
f[z,x,y,'F00']
f[z,w,y,'0FF']
s=File.open("p.svg","w")
s.puts'<svg xmlns="http://www.w3.org/2000/svg" viewBox="-450 -450 900 900">',o.sort,'</svg>'
s.close}

Input as function parameters
An integer 0..3 corresponding to regular dodecahedron, small stellated dodecahedron, great stellated dodecahedron
An array of three integers corresponding to degree angles for rotations about the x, y and x (again) axes (proper Euler angles, enabling any rotation to be achieved.)
Output
a file p.svg that can be displayed in a web browser.
Explanation
the arrays x,y,z at the bottom of the code contain the coordinates of the outer points of one face of a small stellated dodecahedron. This can be inscribed in the icosahedron whose 12 vertices are defined by the cyclic permutations of (+/-377,+/-233,+/-0). Note that 377 and 233 are consecutive Fibonacci numbers and therefore 377/233 is an excellent approximation to the golden ratio.
an additional array w contains the x coordinates multiplied by -1, equivalent to reflection in the x plane. Function f is called 6 times, once for each colour, with the different cyclic permutations of x,y,z and w,y,z.
The three rotations are passed as parameters in n[]. to use sin and cos in Ruby, it is necessary to do include Math. to avoid this, the cosine and sine of the angle are obtained by raising the square root of -1 "i" to a power of (angle in degrees / 90) The real and imaginary parts of this number are stored in k (cosine) and l (sine)
Prior to rotation, x and y values are exchanged. Then matrix multiplication is applied to the y and z values to give a rotation about the x axis. The exchanging of values enables the three rotations to be carried out in a loop.
So far, we only have one ring of points. To obtain the rest, we need to find the centre of the pentagon/star. This is done by finding the average of coordinates of the 5 vertices, which are stored in p,q,r.
As mentioned before, only one function call per colour is made. The sign of r (the average of the z coordinates, and therefore the coordinate of the face) is tested. If it is positive, the face is a front face and therefore visible. If it is negative, the face is a back face. It is invisible, and we have no function call for the opposite face. Therefore, all three coordinates must be inverted. The sign of r is stored in e to facilitate this.
The face is constructed of 5 triangles, whose vertices are linear combinations of the outer vertices of the small stellated dodecahedron and the centre of the face. In the case of the small stellated dodecahedron, for the tips of the triangles we set a=1 and b=0 (contribution 1 from x,y,z and 0 from p,q,r). For the 2 base vertices of the triangle we set c=-0.382 (contribution 1/golden ratio^2 from x,y,z) and  d=1.382 (contribution from p,q,r.) The reason for the negative contribution is that the base vertices of the triangle are defined in terms of the opposing tips, which are on the opposite side of the face. The obtained coordinates are multiplied by e as necessary.
The four unnamed arrays whose values are assigned to a,b,c,d contain the required values for the regular dodecahedron, small stellated dodecahedron, great dodecahedron and great stellated dodecahedron, selected according to variable t Note that for the small stellated dodecahedron and great dodecahedron, a+b=c+d=1. The relation a+b=c+d applies to the other shapes, but a different scale is applied.
A line of svg code is created for each triangle. This contains an ID derived from the sum of the z coordinates of the 3 vertices of the triangle, a description of the vertices of the three coordinates of the triangle, and a colour. note that we view straight down the z axis in orthographic projection. Thus 2D x = 3D x and 2D y = 3D y. The line is added to h.
finally, after all the function calls are finished, h is sorted so that the triangles of highest z value (in front) are plotted last, and the whole thing is saved as an svg file with the appropriate header and footer text.
Ungolfed in test program
h=->t,n{                                              #t=type of polygon,n=angles of rotation
o=[]                                                  #array for output
g=->a{a.reduce(:+)/5}                                 #auxiliary function for finding average of 5 points

f=->u,v,w,m{x=u.dup;y=v.dup;z=w.dup                   #function to take 5 points u,v,w and plot one face (5 triangles) of the output in colour m

  15.times{|i|                                        #for each of 3 rotation angle and 5 points
    k,l=("i".to_c**(n[i/5]/90.0)).rect                #calculate the cos and sine of the angle, by raising sqrt(-1)="i" to a power
    j=i%5                                             #for each of the 5 points
    x[j],y[j],z[j]=y[j],x[j]*k+z[j]*l,z[j]*k-x[j]*l}  #swap x and y, then perform maxtrix rotation on (new) y and z.

  p=g[x];q=g[y];r=g[z]                                #find centre p,q,r of the face whose 5 points (in the case of small stellated dodecahedron) are in x,y,z

  e=r<=>0                                             #if r is positive, face is front. if negative, face is back, so we need to transform it to opposite face.
  a=[0,              1,    -0.382,    -1][t]*e        #contribution of 5 points x,y,z to triangle tip vertex coordinates
  b=[1.382,          0,     1.382,     1.382][t]*e    #contribution of centre p,q,r to triangle tip vertex coordinates
  c=[-0.528,        -0.382, 1,         0.382][t]*e    #contribution of 5 points x,y,z to coordinates of each triangle base vertex
  d=[1.901,          1.382, 0,         0][t]*e        #contribution of centre p,q,r to coordinates of each triangle base vertex

  5.times{|i|
  o<<"<path id=\"#{"%9.0f"%(z[i]*a+r*b+(z[i-2]+z[i-3])*c+2*r*d+999)}\"
d=\"M#{(x[i]*a+p*b)} #{(y[i]*a+q*b)}L#{(x[i-2]*c+p*d)} #{(y[i-2]*c+q*d)}L#{(x[i-3]*c+p*d)} #{(y[i-3]*c+q*d)}\"
fill=\"##{m}\"/>"}                                    #write svg code for this triangle
}

  a=233                                               #a,b =coordinate standard values
  b=377
  z=[0,a,b,a,0]                                       #z coordinates for one face of stellated dodecahedron
  y=[a,b,0,-b,-a]                                     #y coordinates
  x=[b,0,-a,0,b]                                      #x coordinates
  w=[-b,0,a,0,-b]                                     #alternate  x coordinates

  f[x,y,z,'F0F']                                      #call f
  f[w,y,z,'0F0']                                      #to plot
  f[y,z,x,'00F']                                      #each
  f[y,z,w,'FF0']                                      #face
  f[z,x,y,'F00']                                      #in
  f[z,w,y,'0FF']                                      #turn

  s=File.open("p.svg","w")                            #sort output in o, plot front triangles last
  s.puts'<svg xmlns="http://www.w3.org/2000/svg" viewBox="-450 -450 900 900">',o.sort,'</svg>'
  s.close                                             #add header and footer, and save as svg
}

t=gets.to_i
n=[]
3.times{n<<gets.to_i}
h[t,n]

Output
for small stellated dodecahedron (will add some images of the other polygons soon)
1,0,0,0 home position

1,30,0,0 rotate down 30 degrees

1,0,30,0 rotate right 30 degrees (note: for a perfect side view, the rotation would be atan(1/golden ratio)=31.7 degrees, hence we can still see a small sliver of blue)

1,0,20,0 rotate right 20 degrees

1,60,10,-63 rotate down, right and up (example of orientation only possible with 3 rotations)

0,30,0,0 regular dodecahedron

2,0,20,0 great dodecahedron

3,45,45,45 great stellated dodecahedron

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


text:
How many elves does Santa need to deliver gifts?
Santa needs some help determining how many elves he will need to help him deliver gifts to each house.
Coal is considerably heavier than presents, so santa will need three elves for every naughty person in the house. Only two elves are needed to help santa carry presents.
On santa's map, a house is represented by a *, and each house is split by a +.
There will be a number on either side of the house - the one on the left representing the number of naughty people in the house, and the one on the right representing the number of nice people in the house. If there is no number on one side it is interpreted as a 0.
Santa doesn't visit those who are not in the christmas spirit (they don't even deserve coal), so sometimes, a house may not have a number on either side of it. In this case, santa doesn't need help from any elves
For example, one of santa's maps may look like this
1*3+2*2+1*+*2

In the first house there is 1 naughty and 3 nice, santa will need nine elves. In the second, there are 2 naughty and 2 nice, santa will need ten elves. In the third house there is 1 naughty and 0 nice, santa will need three elves, and in the last house there are 0 naughty and 2 nice, santa will need four elves.
This is an over-simplified version of one of santa's maps, though. Normally, santa's maps have multiple lines, and are in a square shape as to better fit on his list. A normal map might look something like this (a \n at the end of each line)
1*2+*+*4+1*
2*4+3*+1*6+*
*+*+4*2+1*1
*4+*3+1*+2*3
3*10+2*+*5+*

In this map, santa needs ((1 + 0 + 0 + 1 + 2 + 3 + 1 + 0 + 0 + 0 + 4 + 1 + 0 + 0 + 1 + 2 + 3 + 2 + 0 + 0) * 3) + ((2 + 0 + 4 + 0 + 4 + 0 + 6 + 0 + 0 + 0 + 2 + 1 + 4 + 3 + 0 + 3 + 10 + 0 + 5 + 0) * 2) = 151 elves
Challenge
Help santa determine how many elves he needs to deliver goods to each house!
Houses

A house is represented by a *
Houses are split by +
The number on the left of the house symbolizes the number of naughty people (no number means 0)
The number on the right symbolizes the number of nice people (no number means 0)
There may be newlines (\n) in the input, which should also be handled as a split

Elves

Santa needs help from three elves for naughty people (coal is much heavier than presents)
Santa needs help from two elves for nice people
If there is no number on either side, santa will not visit that house, and therefor does not need any elves

What to do
Print the number of elves santa needs to help him deliver presents to the houses to. Because all Santa needs to know is how many elves to bring, you only need to print the added number of elves he needs for the list of houses
Test Cases
1*1 => 5
1*2 => 7
2*1 => 8
1* => 3
*1 => 2
* => 0

1*1+1*1 => 10
1*2+2*1 => 15
1*+*1 => 5
1*1+*+1*1 => 10
*+*+*+* => 0

Rules

The input can be either taken as an argument in a function, or from STDIN or equivalent
The output can either be the return value of a function, or printed to STDOUT or equivalent
The input will only contain numbers, +, *, and newlines \n
The output should be only the total number of elves that Santa needs help from to deliver on Christmas
Standard loopholes apply

Scoring
Santa's sleigh is full of gifts giving him less space to run code, so he needs the shortest code he can get (don't worry if this doesn't make sense. If you question Santa's logic you'll end up on the naughty list). Due to Santa's CORRECT reasoning, the shortest submission in bytes wins!
Leaderboard
This is a Stack Snippet that generates both a leaderboard and an overview of winners by language.
To ensure your answer shows up, please start your answer with a headline using the following Markdown template
## Language Name, N bytes

Where N is the size, in bytes, of your submission
If you want to include multiple numbers in your header (for example, striking through old scores, or including flags in the byte count), just make sure that the actual score is the last number in your header
## Language Name, <s>K</s> X + 2 = N bytes

var QUESTION_ID=67600;var OVERRIDE_USER=20634;function answersUrl(e){return"http://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"http://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

I wonder, as Santa will stop by at any house, wouldn't he just need a maximum of max(naughty) + max(nice) elves for the whole route? I thought he has a bunch of elves flying with him, but maybe you have insider information on that and I need to look closer this year. :)

@insertusernamehere I currently work at Santa Inc. and I can tell you our infrastructure  operates in a heavily async fashion. He doesn't want his resources to starve, so we allocate as many workers as needed. In case we need an extra ELF, we can compile one in few seconds from hello-world.c. Worker elves are eagerly allocated to targets as Jojodmo said (I am sure I know Jojodmo, he must be our sysadm) and then use a callback for notifying when it's time to be reinserted in the sleigh pool or when a child saw them.

@StefanoSanfilippo Ah, I see. Thanks for all the detailed insights of this classified information. And Merry Christmas. :)

This totally makes sense. Santa needs the shortest code because he prints out every character of the code with a printer and then puts them on his sleigh before he executes them.

Pyth, 21 bytes
ssMs*VCcR\*scR\+.z_S3

Multi-line example
Single-line test suite
ssMs*VCcR\*scR\+.z_S3
                .z        Take a input, as a list of lines.
            cR\+          Chop each line on '+'.
           s              Flatten into list of strings.
       cR\*               Chop each line on '*'.
      C                   Transpose, into a list of naughty and nice.
    *V            _S3     Vectorized multiplication with [3, 2, 1]. This replicates
                          the naughty list 3 times and the nice list 2 times.
   s                      Flatten.
 sM                       Convert each string to an int.
s                         Sum.

Seriously... Is there anything Pyth can't do in under 30 bytes?

@Jojodmo Not if I can help it ...

JavaScript (ES6), 52 bytes
s=>eval(s.replace(/\D|$/g,m=>`.0*${m=="*"?3:2}+`)+0)

Explanation
Converts the input into a valid JavaScript statement. Replaces all * with .0*3+ and all other (non-digit) symbols with .0*2+. For example 8*9+*10 becomes 8.0*3+9.0*2+.0*3+10. Finally it appends .0*2 to the end for the last nice count. This works because n.0 = n and .0 = 0.
s=>
  eval(                      // execute the formed equation
    s.replace(/\D|$/g,       // replace each symbol (and also add to the end) with:
      m=>`.0*${m=="*"?3:2}+` // case * = ".0*3+", else replace with ".0*2+"
    )
    +0                       // add "0" to the end for the trailing "+"
  )

Test

var solution = s=>eval(s.replace(/\D|$/g,m=>`.0*${m=="*"?3:2}+`)+0)
<textarea id="input" rows="6" cols="30">1*2+*+*4+1*
2*4+3*+1*6+*
*+*+4*2+1*1
*4+*3+1*+2*3
3*10+2*+*5+*</textarea>

<button onclick="result.textContent=solution(input.value)">Go</button>

+1 for the .0 idea.

Flex+C, 112 90 bytes
 m=3,t;
%%
[0-9]+ t+=m*atoi(yytext);
\* m=2;
[+\n] m=3;
%%
main(){yylex();printf("%d",t);}

The first character is a space. Compile with:
flex -o santa.c santa.l
cc santa.c -o santa -ll

Reads from STDIN, writes to STDOUT. Input is terminated by EOF (Ctrl+D in console).

PowerShell, 52 bytes
Using variation of user81655's .0 trick
$OFS='+';"$("$args"-replace'\*','.0*3+2*0'|iex)"|iex

Ungolfed version
$OFS='+' # Set Output Field Separator to '+'
         # So if $arr = 1,2,3 then "$arr" will output 1+2+3

" # Cast result of subexpression to string using $OFS

    $( # Subexpression

        "$args" # Input is an array of arguments. Casting it to string using "$args"
                # is shorter then acessing the first element using $args[0]
                # $OFS wouldn't affect this, because input has only 1 element.

        -replace '\*' , '.0*3+2*0' # Replace every * with .0*3+2*0
                                   # Example: 1*+*1 becomes 1.0*3+2*0+.0*3+2*01

    ) | Invoke-Expression # Execute a result of subexpression as PS code.
                          # This will execute resulting multiline string line-by line
                          # and return an array of values, e.g.: 18,38,21,29,45

" Cast the aray above to string using '+' as Output Field Separator, e.g: 18+38+21+29+45

| Invoke-Expression # Execute the string above as PS code to get final result.
                    # E.g.: 18+38+21+29+45 = 151

Usage example
$Map = @'
1*2+*+*4+1*
2*4+3*+1*6+*
*+*+4*2+1*1
*4+*3+1*+2*3
3*10+2*+*5+*
'@

PS > .\SantaMap.ps1 $Map
151

Mathematica, 70 bytes
a=Tr[FromDigits/@StringExtract[#,"
"|"+"->;;,"*"->#2]]&;3#~a~1+2#~a~2&

Uses StringExtract to extract the individual numbers.

CJam, 23 bytes
q'+NerN/{'*/3*5<:~~}%1b

Test it here.
Explanation
q      e# Read all input.
'+Ner  e# Replaces all "+" with linefeeds.
N/     e# Split the string around linefeeds (i.e. into houses).
{      e# Map this block over the list of house...
  '*/  e#   Split the string around the "*".
  3*   e#   Repeat the times.
  5<   e#   Truncate to 5 elements, keeping 3 copies of the naughty number and 2 copies of
       e#   the nice number.
  :~   e#   Evaluate each number (which may be an empty string which pushes nothing).
  ~    e#   Dump the list of numbers on the stack.
}%
1b     e# Sum all the numbers.

Seriously, 38 30 bytes
'*Ws`'0+'*@s'≈£M4rR*`MΣ+'+,WXX

Hex Dump:
272a57736027302b272a407327f79c4d3472522a604de42b272b2c575858

This new version breaks the online interpreter, but works fine locally. Here's an example run:
$ python2 seriously.py -f elves.srs
1*2+*+*4+1*
2*4+3*+1*6+*
*+*+4*2+1*1
*4+*3+1*+2*3
3*10+2*+*5+*

151

Explanation:
'*                              Push a "*" to make the stack truthy
  W                        W    Repeat while the top of stack is truthy
                                  (A whole bunch of instructions just turn the "*" into a
                                  zero on the first pass, so I'll list them here in the
                                  order they actually accomplish useful things:)
                          ,     Read in a line of input
   s                    '+      Split it on occurrence of "+"
    `               `M          Map this function over the list of strings.
     '0+                        Prepend a "0" to ensure a naughty number exists
        '*@s                    Split the string on "*"
            '≈£M                Map over the string with int() to convert it to int
                4rR             Push [3,2,1,0]
                   *            Dot product
                      Σ+        Sum all the houses, and add it to the results
                                  from the previous line of input
                            XX  Pop the "" and '+ from the stack, leaving only the
                                result to be implicitly output.

Old Version:
'+ε'*`+'++,`╬Xs`≈`╗`'0+'*@s╜M[3,2]*`MΣ

Hex Dump:
272bee272a602b272b2b2c60ce587360f760bb6027302b272a4073bd4d5b332c325d2a604de4

Try It Online
Explanation:
  ε'*                                   Initialize with two strings so the first + works
     `+'++,`╬                           Read in strings and compile them until "" is read
             X                          Throw away the ""
'+            s                         Split on +
               `≈`╗                     Chuck int function into reg0 to use within function
                   `               `M   Map this function over the list of houses
                    '0+                 Prepend a "0" to ensure a naughty number exists
                       '*@s             Split on *
                           ╜M           Convert the resulting list to ints with stored func
                             [3,2]*     Dot product with [3,2]
                                     Σ  Sum all houses

This maybe could be shorter if I just converted each line separately and summed them all at the end. I'll look into it later.

Vyxal Dad, 12 bytes
ƛ‛\Wṡ⌊:ż∷2+*

Try it Online!
ƛ            # Map (multiline input) to...
 ‛\Wṡ        # Split on non-word chars
     ⌊       # parse an integer from each
      :ż     # 1...x.length
        ∷2+  # Modulo 2, + 1 results in array of 2s and 3s
           * # Multiply these
             # (d flag) deep sum of result

D makes sure the backslash in ‛\W doesn't get removed, a is necessary for multiline input and d takes the deep sum of the result.

Python 3, 141 114 112 bytes
Takes multi-line inputs like this c("1*2+*+*4+1*\n2*4+3*+1*6+*\n*+*+4*2+1*1\n*4+*3+1*+2*3\n3*10+2*+*5+*")
lambda s:sum(a and(3-z)*int(a)or 0for j in s.split("\n")for i in j.split("+")for z,a in enumerate(i.split("*")))

Ungolfed:
def c(s):
    t = 0
    for j in s.split("\n"):
        for i in j.split("+"):
            for z,a in enumerate(i.split("*"))
                if a == "":
                    a = 0
                else:
                    a = int(a)
                t += (3-z) * a  # alternate a*3 and a*2
    return t

Swift 2, 283 211 Bytes
func f(s:String)->Int{var r=0;for p in(s.characters.split{$0=="\n"}.map(String.init)){for v in p.utf8.split(43){let k="0\(v)".utf8.split(42);r+=(Int("\(k[0])")!)*3;r+=(k.count<2 ?0:Int("\(k[1])")!)*2}};return r}

This can be tested on SwiftStub, here
Ungolfed
func f(s: String) -> Int{
    var r = 0

    //for every value in the input, split every "\n" and mapped
    //to a String array
    for p in (s.characters.split{$0=="\n"}.map(String.init)){

        //for every value in the split input, split again at every + (Decimal 43)
        for v in p.utf8.split(43){
            //change the value to "0" + v, which doesn't change the
            //input, but in the event that there is no input on the
            //left side, a "0" will be used
            //
            //then split on every * (Decimal 42)
            let k = "0\(v)".utf8.split(42)

           //add to the total count of elves the number on the left * 3
            r+=(Int("\(k[0])")!) * 3

            //add to the total count of elves the number on the left * 2
            r+=(k.count < 2 ? 0 : Int("\(k[1])")!) * 2
        }

        //return the number of elves
        return r
    }
}

I'm super late, but I wanted to give it a shot anyways.
Ruby, 84 55 bytes
I found this question again after so many years and was thinking up a fresh answer before I realized I'd already answered this before. Whoops! Anyways, here's a drastically improved answer.
->m{m.scan(/(\d*)\*(\d*)/).sum{|a,b|3*a.to_i+2*b.to_i}}

Try it online!
Old 84-byte answer from when I first answered this 2 years ago:
->m{m.split(/[+\n]/).map{|h|b,g=h.split(?*).map &:to_i
3*(b||0)+2*(g||0)}.inject :+}

Try it online!

Python 3, 96 bytes
lambda s:sum(int('0'+n)*(3-i%2)for i,n in enumerate(re.sub('[*\s]','+',s).split('+')));import re

Try it online!
101 bytes without regex
lambda s:sum(int('0'+n)*(3-i%2)for i,n in enumerate(s.replace('*','+').replace('\n','+').split('+')))

Try it online!

JavaScript (ES6), 47 bytes
x=>x.split(/\W/).reduce((y,x,i)=>y+x*(3-i%2),0)

Try it online!
Beats the winning JS answer!
How does it work?
x =>            // Defining a function taking an argument x
  x.split(      // Split x on...
    /\W/        // The regex \W, matching non-word characters
  )
  .reduce((     // Reduce by a function taking...
      y,        // y - current total value
      x,        // x - value of this one
      i         // i - index in input
    ) =>        // and returning
    y + x *     // y, plus x times...
    (3 - i % 2) // 3 if index is even (naughty) otherwise 2
  , 0)          // With initial value 0.

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