Help PPCG Claus Deliver his Presents!

JavaScript (ES6), 525 492 454 453 bytes

-71 bytes thanks to @Guedes -1 bit thanks to @Jake Cobb

P=(K,p)=>{y='charCodeAt';n=(C)=>C[y](0)%3>0;N=(C)=>C[y](0)%3<1;E=(C)=>C[y](0)%2>0;O=(C)=>C[y](0)%2<1;f=(U)=>U%2<1;F=(U)=>U%2;M=(U,C)=>C%s==S;s=S=0;a=new Array();G='filter';e=p[G](f);o=p[G](F);J=K[G](n);r=J[G](O);L='length';i=J[G](E);s=r[L];for(S=0;S<r[L];S++){a.push([r[S],e[G](M)]);}s=i[L];for(S=0;S<i[L];S++){a.push([i[S],o[G](M)]);}K=K[G](N);for(S=0;S<K[L];S++){a.push(K[S],[]);}return(e[L]<r[L]||o[L]<i[L]||(r[L]+i[L])<1)?"PPCGmas is Cancelled!":a;}

Try it online !

Non-golfed version

Can be more golfed I think. I just did a litteral translation of the non-golfed version.

This is now shorter than the sum of the CharCode composing "santa" (115 + 97 + 110 + 116 + 97 = 535). Yeay


Python 2, 334 355 354 bytes

k,p=input()
z=zip
l=len
e=[];o=[];g=[];b=[];q=[];r=[]
for x in k:[g,b][ord(x[0])%3<1]+=x,
for x in g:[e,o][ord(x[0])&1]+=x,
for x in p:[q,r][x&1]+=x,
v=l(e)
w=l(o)
t=v and l(q)/v
u=w and l(r)/w
if u:t=min(t,u+2)
if t:u=min(u,t+2)
if l(g)*(t or v<1)*(u or w<1)<1:exit('PPCGmas is cancelled!')
print z(e,z(*[iter(q)]*t))+z(o,z(*[iter(r)]*u))+z(b,[()]*l(b))

Lost 21 bytes to handle case of only-even or only-odd children.

Saved 1 byte thanks to @TuukkaX.


APL, 171 bytes

{D←{⍵=1:⊂⍺⋄0~⍨¨↓⍵↑⍉↑⍺⊂⍨1=⍵|⍳⍴⍺}⋄e←⍺~o←⍺/⍨2|⍺⋄(0=≢G)∨0∊≢¨P←P↑⍨¨(2+⌊/R)⌊R←≢¨P←(o D≢O),e D≢E←G~O←G/⍨2|⎕A⍳⊃¨G←⍵/⍨×3|⊃∘⎕UCS¨⍵:'PPCGmas is cancelled!'⋄(O,E,B),[⍟4]P,(≢B←⍵~G)↑⊂⍬}

This takes the presents as the left argument, the children as the right argument, and returns a matrix where the first column contains the names of the children and the second column contains the presents they get.

Testcases:

      P←{D←{⍵=1:⊂⍺⋄0~⍨¨↓⍵↑⍉↑⍺⊂⍨1=⍵|⍳⍴⍺}⋄e←⍺~o←⍺/⍨2|⍺⋄(0=≢G)∨0∊≢¨P←P↑⍨¨(2+⌊/R)⌊R←≢¨P←(o D≢O),e D≢E←G~O←G/⍨2|⎕A⍳⊃¨G←⍵/⍨×3|⊃∘⎕UCS¨⍵:'PPCGmas is cancelled!'⋄(O,E,B),[⍟4]P,(≢B←⍵~G)↑⊂⍬}
      (⍳14) P 'Amy' 'Betty' 'Clyde' 'Dave' 'Francine'
┌────────┬─────────┐
│Amy     │1 5 9 13 │
├────────┼─────────┤
│Clyde   │3 7 11   │
├────────┼─────────┤
│Dave    │2 6 10 14│
├────────┼─────────┤
│Francine│4 8 12   │
├────────┼─────────┤
│Betty   │         │
└────────┴─────────┘
      1 2 3 P ⍬
PPCGmas is cancelled!
      1 2 3 P ⊂'Betty'
PPCGmas is cancelled!
      ⍬ P 'Amy' 'Charles'
PPCGmas is cancelled!
      (,1) P 'Amy' 'Charles'
PPCGmas is cancelled!
      2 4 6 P 'Amy' 'Dave'
PPCGmas is cancelled!
      2 4 6 8 10 12 14 7 9 P 'Amy' 'Dave'
┌────┬───────┐
│Amy │7 9    │
├────┼───────┤
│Dave│2 4 6 8│
└────┴───────┘

Ungolfed version here.