Revision 457c58d3-4e9a-4b4e-a29f-a580248a6f3e - Code Golf Stack Exchange

#Python - <s>774</s> <s>722</s> 707 chars

	import sys
	t,q,e,u='--23456789TJQKA','SDCH',enumerate,len
	_=lambda c:chr(97+c)
	def j(s):
	 v,g,l=[0]*15,[0]*4,''
	 for c in s:
	 r,s=c[0],c[1];v[t.find(r)]+=1;g[q.find(s)]+=1
	 c,h,k,m,f=0,0,[0,0,[],[],[]],0,0
	 for x,i in e(v):
	 for b in [2,3,4]:
	 if i==b:k[b]+=[x]
	 v[1]=v[14]
	 for x,i in e(v):
	 if i:
	 c+=1;
	 if c==5:m,h=1,x
	 if i==1:l+=_(x)
	 else:c=0
	 f,l,d=2*(max(g)//5),l[::-1],''
	 z=f+m
	 if z==3:d='z'+l
	 if k[4]:d='y'+_(k[4][0])+l
	 if k[2] and k[3]:d='x'+_(k[3][0])+_(k[2][0])
	 if z==2:d='w'+l
	 if z==1:d='v'+_(h)
	 if k[3]:d='u'+_(k[3][0])+l
	 if u(k[2])>1:d='t'+_(k[2][1])+_(k[2][0])+l
	 if u(k[2])==1>u(k[3]):d='s'+_(k[2][0])+l
	 if d=='':d=l
	 return d
	p=sys.argv
	print(1+(j(p[1:6])<j(p[6:])))

I chose to generate a string for each hand that represents it, starting with a character for the type of hand, followed by characters describing the particular variation of the type (for example, which card did you just have 4 of?), followed by the values of the remaining cards in case of a tie (if both players have the same double pair, the 5th card will have to decide who wins). I've tested it quite extensively, but I don't actually play poker, so I hope I got it right. Also, I know it's not fully golfed yet, I can probably shave off a few dozen chars later on. 

AltStyle によって変換されたページ (->オリジナル) /