Skip to content

Instantly share code, notes, and snippets.

Created June 21, 2014 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/a6daaedabf97d3b9171e to your computer and use it in GitHub Desktop.
Save anonymous/a6daaedabf97d3b9171e to your computer and use it in GitHub Desktop.
vst = [0 for i in range(0,31)]
ans = [0]
def dfs(last, cont, count):
if cont >= 5: return
if count == 13:
"""
for i in range(1, 31):
if vst[i] != 0:
print i,
print ''
"""
ans[0] = ans[0]+1
print ans[0]
return
if last == 30: return
vst[last+1] = 1
dfs(last+1, cont+1, count+1)
vst[last+1] = 0
tmp = last+5
if tmp > 30: tmp=30
for i in range(last+2, tmp):
vst[i] = 1
dfs(i, 1, count+1)
vst[i] = 0
for i in range(1, 30):
vst[i]=1
dfs(i, 1, 1)
vst[i]=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment