Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Python - (削除) 774 (削除ここまで)(削除) 722 (削除ここまで)(削除) 707 (削除ここまで)(削除) 698 (削除ここまで) 685 chars

Python - (削除) 774 (削除ここまで)(削除) 722 (削除ここまで)(削除) 707 (削除ここまで)(削除) 698 (削除ここまで) 685 chars

import sys
t,q,e,u='--23456789TJQKA','SDCH',enumerate,len
_=lambda c,i=0:chr(97+c[i])
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=max(g)//5*2,l[::-1],'';z=f+m
 if z==3:d='z'+l
 if k[4]:d='y'+_(k[4])+l
 if k[2] and k[3]:d='x'+_(k[3])+_(k[2])
 if z==2:d='w'+l
 if z==1:d='v'+_([h])
 if k[3]:d='u'+_(k[3])+l
 if u(k[2])>1:d='t'+_(k[2],1)+_(k[2])+l
 if u(k[2])==1>u(k[3]):d='s'+_(k[2])+l
 return d or l
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.

#Python - (削除) 774 (削除ここまで)(削除) 722 (削除ここまで)(削除) 707 (削除ここまで)(削除) 698 (削除ここまで) 685 chars

import sys
t,q,e,u='--23456789TJQKA','SDCH',enumerate,len
_=lambda c,i=0:chr(97+c[i])
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=max(g)//5*2,l[::-1],'';z=f+m
 if z==3:d='z'+l
 if k[4]:d='y'+_(k[4])+l
 if k[2] and k[3]:d='x'+_(k[3])+_(k[2])
 if z==2:d='w'+l
 if z==1:d='v'+_([h])
 if k[3]:d='u'+_(k[3])+l
 if u(k[2])>1:d='t'+_(k[2],1)+_(k[2])+l
 if u(k[2])==1>u(k[3]):d='s'+_(k[2])+l
 return d or l
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.

Python - (削除) 774 (削除ここまで)(削除) 722 (削除ここまで)(削除) 707 (削除ここまで)(削除) 698 (削除ここまで) 685 chars

import sys
t,q,e,u='--23456789TJQKA','SDCH',enumerate,len
_=lambda c,i=0:chr(97+c[i])
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=max(g)//5*2,l[::-1],'';z=f+m
 if z==3:d='z'+l
 if k[4]:d='y'+_(k[4])+l
 if k[2] and k[3]:d='x'+_(k[3])+_(k[2])
 if z==2:d='w'+l
 if z==1:d='v'+_([h])
 if k[3]:d='u'+_(k[3])+l
 if u(k[2])>1:d='t'+_(k[2],1)+_(k[2])+l
 if u(k[2])==1>u(k[3]):d='s'+_(k[2])+l
 return d or l
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.

such golf. very variable. wow.
Source Link
Tal
  • 1.4k
  • 8
  • 14

#Python - (削除) 774 (削除ここまで) (削除) 722 (削除ここまで) (削除) 707 (削除ここまで) 698(削除) 698 (削除ここまで) 685 chars

import sys
t,q,e,u='--23456789TJQKA','SDCH',enumerate,len
_=lambda c,i=0:chr(97+c[i])
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 [2in[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*(maxd=max(g)//5)5*2,l[::-1],''
 z=f+m'';z=f+m
 if z==3:d='z'+l
 if k[4]:d='y'+_(k[4])+l
 if k[2] and k[3]:d='x'+_(k[3])+_(k[2])
 if z==2:d='w'+l
 if z==1:d='v'+_([h])
 if k[3]:d='u'+_(k[3])+l
 if u(k[2])>1:d='t'+_(k[2],1)+_(k[2])+l
 if u(k[2])==1>u(k[3]):d='s'+_(k[2])+l
 if d=='':d=l
 return d or l
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.

#Python - (削除) 774 (削除ここまで) (削除) 722 (削除ここまで) (削除) 707 (削除ここまで) 698 chars

import sys
t,q,e,u='--23456789TJQKA','SDCH',enumerate,len
_=lambda c,i=0:chr(97+c[i])
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])+l
 if k[2] and k[3]:d='x'+_(k[3])+_(k[2])
 if z==2:d='w'+l
 if z==1:d='v'+_([h])
 if k[3]:d='u'+_(k[3])+l
 if u(k[2])>1:d='t'+_(k[2],1)+_(k[2])+l
 if u(k[2])==1>u(k[3]):d='s'+_(k[2])+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.

#Python - (削除) 774 (削除ここまで) (削除) 722 (削除ここまで) (削除) 707 (削除ここまで) (削除) 698 (削除ここまで) 685 chars

import sys
t,q,e,u='--23456789TJQKA','SDCH',enumerate,len
_=lambda c,i=0:chr(97+c[i])
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=max(g)//5*2,l[::-1],'';z=f+m
 if z==3:d='z'+l
 if k[4]:d='y'+_(k[4])+l
 if k[2] and k[3]:d='x'+_(k[3])+_(k[2])
 if z==2:d='w'+l
 if z==1:d='v'+_([h])
 if k[3]:d='u'+_(k[3])+l
 if u(k[2])>1:d='t'+_(k[2],1)+_(k[2])+l
 if u(k[2])==1>u(k[3]):d='s'+_(k[2])+l
 return d or l
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.

Hurray for default arguments in lambda
Source Link
Tal
  • 1.4k
  • 8
  • 14

#Python - (削除) 774 (削除ここまで) (削除) 722 (削除ここまで) 707(削除) 707 (削除ここまで) 698 chars

import sys
t,q,e,u='--23456789TJQKA','SDCH',enumerate,len
_=lambda c,i=0:chr(97+c97+c[i])
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;c+=1
 if c==5:m,h=1,x
 if i==1:l+=_(x[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]k[4])+l
 if k[2] and k[3]:d='x'+_(k[3][0]k[3])+_(k[2][0]k[2])
 if z==2:d='w'+l
 if z==1:d='v'+_(h[h])
 if k[3]:d='u'+_(k[3][0]k[3])+l
 if u(k[2])>1:d='t'+_(k[2][1]k[2],1)+_(k[2][0]k[2])+l
 if u(k[2])==1>u(k[3]):d='s'+_(k[2][0]k[2])+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.

#Python - (削除) 774 (削除ここまで) (削除) 722 (削除ここまで) 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.

#Python - (削除) 774 (削除ここまで) (削除) 722 (削除ここまで) (削除) 707 (削除ここまで) 698 chars

import sys
t,q,e,u='--23456789TJQKA','SDCH',enumerate,len
_=lambda c,i=0:chr(97+c[i])
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])+l
 if k[2] and k[3]:d='x'+_(k[3])+_(k[2])
 if z==2:d='w'+l
 if z==1:d='v'+_([h])
 if k[3]:d='u'+_(k[3])+l
 if u(k[2])>1:d='t'+_(k[2],1)+_(k[2])+l
 if u(k[2])==1>u(k[3]):d='s'+_(k[2])+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.

deleted 6 characters in body
Source Link
Tal
  • 1.4k
  • 8
  • 14
Loading
Made sure all var names are a single char
Source Link
Tal
  • 1.4k
  • 8
  • 14
Loading
Source Link
Tal
  • 1.4k
  • 8
  • 14
Loading

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