Skip to main content
deleted 2 characters in body
Source Link
guy777
  • 263
  • 1
  • 6

JavaScript 602600

usage with nodeJS: node code.js "7H 3S 7S 7D AC QH 7C"

function a(o){s="";for(k in o)s+=o[k];return s;s} b=process.argv[2];argv[2] c={S:0,H:0,D:0,C:0} v={A:0,K:0,Q:0,J:0,T:0,"9":0,"8":0,"7":0,"6":0,"5":0,"4":0,"3":0,"2":0} d=b.split(" ") for(i=d.length;i--;){e=d[i];c[e[1]]++;v[e[0]]++} c=a(c);v=a(v) f=g=h=j=k=l=m=false if((st=c.indexOf(5))!=-1)g=!g if(v.match(/[1-9]{5}/))h=!h if(st==0)f=!f if(v.indexOf(4)!=-1)j=!j if(v.indexOf(3)!=-1)k=!k if(n=v.match(/2/g))if(n)if(n.length>=2)m=!m;else l=!l p=" of a kind" q="Flush" r="Straight" console.log(f&&g?"Royal "+q:h&&g?r+" "+q:j?"Four"+p:k&&(l||m)?"Full House":g?q:h?r:k?"Three"+p:m?"Two pairs":l?"Pair":"High card") 

JavaScript 602

usage with nodeJS: node code.js "7H 3S 7S 7D AC QH 7C"

function a(o){s="";for(k in o)s+=o[k];return s;} b=process.argv[2]; c={S:0,H:0,D:0,C:0} v={A:0,K:0,Q:0,J:0,T:0,"9":0,"8":0,"7":0,"6":0,"5":0,"4":0,"3":0,"2":0} d=b.split(" ") for(i=d.length;i--;){e=d[i];c[e[1]]++;v[e[0]]++} c=a(c);v=a(v) f=g=h=j=k=l=m=false if((st=c.indexOf(5))!=-1)g=!g if(v.match(/[1-9]{5}/))h=!h if(st==0)f=!f if(v.indexOf(4)!=-1)j=!j if(v.indexOf(3)!=-1)k=!k if(n=v.match(/2/g))if(n)if(n.length>=2)m=!m;else l=!l p=" of a kind" q="Flush" r="Straight" console.log(f&&g?"Royal "+q:h&&g?r+" "+q:j?"Four"+p:k&&(l||m)?"Full House":g?q:h?r:k?"Three"+p:m?"Two pairs":l?"Pair":"High card") 

JavaScript 600

usage with nodeJS: node code.js "7H 3S 7S 7D AC QH 7C"

function a(o){s="";for(k in o)s+=o[k];return s} b=process.argv[2] c={S:0,H:0,D:0,C:0} v={A:0,K:0,Q:0,J:0,T:0,"9":0,"8":0,"7":0,"6":0,"5":0,"4":0,"3":0,"2":0} d=b.split(" ") for(i=d.length;i--;){e=d[i];c[e[1]]++;v[e[0]]++} c=a(c);v=a(v) f=g=h=j=k=l=m=false if((st=c.indexOf(5))!=-1)g=!g if(v.match(/[1-9]{5}/))h=!h if(st==0)f=!f if(v.indexOf(4)!=-1)j=!j if(v.indexOf(3)!=-1)k=!k if(n=v.match(/2/g))if(n)if(n.length>=2)m=!m;else l=!l p=" of a kind" q="Flush" r="Straight" console.log(f&&g?"Royal "+q:h&&g?r+" "+q:j?"Four"+p:k&&(l||m)?"Full House":g?q:h?r:k?"Three"+p:m?"Two pairs":l?"Pair":"High card") 
deleted 192 characters in body
Source Link
guy777
  • 263
  • 1
  • 6

JavaScript 696602

Here's a first version, not very optimized !

usage with nodeJS: node code.js "7H 3S 7S 7D AC QH 7C"

function a(o){s="";for(k in o)s+=o[k];return ss;} b=process.argv[2]; c={S:0,H:0,D:0,C:0} v={A:0,K:0,Q:0,J:0,T:0,"9":0,"8":0,"7":0,"6":0,"5":0,"4":0,"3":0,"2":0} d=b.split(" ") for(i=d.length;i--;){e=d[i];c[e[1]]++;v[e[0]]++} c=a(c);v=a(v) f=g=h=j=k=l=m=false if((st=c.indexOf(5))!=-1)g=!g if(v.match(/[1-9]{5}/))h=!h if(st==0)f=!f if(v.indexOf(4)!=-1)j=!j if(v.indexOf(3)!=-1)k=!k if(n=v.match(/2/g))if(n)if(n.length>=2)m=!m;else l=!l p=" of a kind" q="Flush" r="Straight" ifconsole.log(f&&g)o="Royal?"Royal "+q else if(:h&&g)o=r+"?r+" "+q else if(:j)o="Four"+p else if(?"Four"+p:k&&(l||m))o="Full?"Full House" else if(:g)o=q else if(?q:h)o=r else if(?r:k)o="Three"+p else if(?"Three"+p:m)o="Two?"Two pairs" else if(:l)o="Pair" else o="High?"Pair":"High card" console.log(o); 

JavaScript 696

Here's a first version, not very optimized !

usage with nodeJS: node code.js "7H 3S 7S 7D AC QH 7C"

function a(o){s="";for(k in o)s+=o[k];return s} b=process.argv[2]; c={S:0,H:0,D:0,C:0} v={A:0,K:0,Q:0,J:0,T:0,"9":0,"8":0,"7":0,"6":0,"5":0,"4":0,"3":0,"2":0} d=b.split(" ") for(i=d.length;i--;){e=d[i];c[e[1]]++;v[e[0]]++} c=a(c);v=a(v) f=g=h=j=k=l=m=false if((st=c.indexOf(5))!=-1)g=!g if(v.match(/[1-9]{5}/))h=!h if(st==0)f=!f if(v.indexOf(4)!=-1)j=!j if(v.indexOf(3)!=-1)k=!k if(n=v.match(/2/g))if(n)if(n.length>=2)m=!m;else l=!l p=" of a kind" q="Flush" r="Straight" if(f&&g)o="Royal "+q else if(h&&g)o=r+" "+q else if(j)o="Four"+p else if(k&&(l||m))o="Full House" else if(g)o=q else if(h)o=r else if(k)o="Three"+p else if(m)o="Two pairs" else if(l)o="Pair" else o="High card" console.log(o); 

JavaScript 602

usage with nodeJS: node code.js "7H 3S 7S 7D AC QH 7C"

function a(o){s="";for(k in o)s+=o[k];return s;} b=process.argv[2]; c={S:0,H:0,D:0,C:0} v={A:0,K:0,Q:0,J:0,T:0,"9":0,"8":0,"7":0,"6":0,"5":0,"4":0,"3":0,"2":0} d=b.split(" ") for(i=d.length;i--;){e=d[i];c[e[1]]++;v[e[0]]++} c=a(c);v=a(v) f=g=h=j=k=l=m=false if((st=c.indexOf(5))!=-1)g=!g if(v.match(/[1-9]{5}/))h=!h if(st==0)f=!f if(v.indexOf(4)!=-1)j=!j if(v.indexOf(3)!=-1)k=!k if(n=v.match(/2/g))if(n)if(n.length>=2)m=!m;else l=!l p=" of a kind" q="Flush" r="Straight" console.log(f&&g?"Royal "+q:h&&g?r+" "+q:j?"Four"+p:k&&(l||m)?"Full House":g?q:h?r:k?"Three"+p:m?"Two pairs":l?"Pair":"High card") 
added 60 characters in body
Source Link
guy777
  • 263
  • 1
  • 6

JavaScript 696

Here's a first version, not very optimized !

usage with nodeJS: node code.js "7H 3S 7S 7D AC QH 7C"

function a(o){s="";for(k in o)s+=o[k];return s} b=process.argv[2]; c={S:0,H:0,D:0,C:0} v={A:0,K:0,Q:0,J:0,T:0,"9":0,"8":0,"7":0,"6":0,"5":0,"4":0,"3":0,"2":0} d=b.split(" ") for(i=d.length;i--;){e=d[i];c[e[1]]++;v[e[0]]++} c=a(c);v=a(v) f=g=h=j=k=l=m=false if((st=c.indexOf(5))!=-1)g=!g if(v.match(/[1-9]{5}/))h=!h if(st==0)f=!f if(v.indexOf(4)!=-1)j=!j if(v.indexOf(3)!=-1)k=!k if(n=v.match(/2/g))if(n)if(n.length>=2)m=!m;else l=!l p=" of a kind" q="Flush" r="Straight" if(f&&g)o="Royal "+q else if(h&&g)o=r+" "+q else if(j)o="Four"+p else if(k&&(l||m))o="Full House" else if(g)o=q else if(h)o=r else if(k)o="Three"+p else if(m)o="Two pairs" else if(l)o="Pair" else o="High card" console.log(o); 

JavaScript 696

Here's a first version, not very optimized !

function a(o){s="";for(k in o)s+=o[k];return s} b=process.argv[2]; c={S:0,H:0,D:0,C:0} v={A:0,K:0,Q:0,J:0,T:0,"9":0,"8":0,"7":0,"6":0,"5":0,"4":0,"3":0,"2":0} d=b.split(" ") for(i=d.length;i--;){e=d[i];c[e[1]]++;v[e[0]]++} c=a(c);v=a(v) f=g=h=j=k=l=m=false if((st=c.indexOf(5))!=-1)g=!g if(v.match(/[1-9]{5}/))h=!h if(st==0)f=!f if(v.indexOf(4)!=-1)j=!j if(v.indexOf(3)!=-1)k=!k if(n=v.match(/2/g))if(n)if(n.length>=2)m=!m;else l=!l p=" of a kind" q="Flush" r="Straight" if(f&&g)o="Royal "+q else if(h&&g)o=r+" "+q else if(j)o="Four"+p else if(k&&(l||m))o="Full House" else if(g)o=q else if(h)o=r else if(k)o="Three"+p else if(m)o="Two pairs" else if(l)o="Pair" else o="High card" console.log(o); 

JavaScript 696

Here's a first version, not very optimized !

usage with nodeJS: node code.js "7H 3S 7S 7D AC QH 7C"

function a(o){s="";for(k in o)s+=o[k];return s} b=process.argv[2]; c={S:0,H:0,D:0,C:0} v={A:0,K:0,Q:0,J:0,T:0,"9":0,"8":0,"7":0,"6":0,"5":0,"4":0,"3":0,"2":0} d=b.split(" ") for(i=d.length;i--;){e=d[i];c[e[1]]++;v[e[0]]++} c=a(c);v=a(v) f=g=h=j=k=l=m=false if((st=c.indexOf(5))!=-1)g=!g if(v.match(/[1-9]{5}/))h=!h if(st==0)f=!f if(v.indexOf(4)!=-1)j=!j if(v.indexOf(3)!=-1)k=!k if(n=v.match(/2/g))if(n)if(n.length>=2)m=!m;else l=!l p=" of a kind" q="Flush" r="Straight" if(f&&g)o="Royal "+q else if(h&&g)o=r+" "+q else if(j)o="Four"+p else if(k&&(l||m))o="Full House" else if(g)o=q else if(h)o=r else if(k)o="Three"+p else if(m)o="Two pairs" else if(l)o="Pair" else o="High card" console.log(o); 
Source Link
guy777
  • 263
  • 1
  • 6
Loading