Skip to content

Instantly share code, notes, and snippets.

@krrrr38
Created January 13, 2012 09:17
Show Gist options
  • Save krrrr38/1605252 to your computer and use it in GitHub Desktop.
Save krrrr38/1605252 to your computer and use it in GitHub Desktop.
年俸1000万!!
#!/usr/bin/python
# -*- coding:utf-8 -*-
'''年俸1000万がどうとか
http://alpha.cgios.net/alpha/cgios
'''
import sys
def makeWords(n, chars):
if n <= 0:
return [""]
r = []
for char in chars:
for words in makeWords(n-1, chars):
r.append(char+words)
return r
def makeYieldWords(n, chars):
if n <= 0:
yield ""
return
for char in chars:
for words in makeYieldWords(n-1, chars):
yield char + words
if __name__ == '__main__':
if len(sys.argv) != 2 or sys.argv[1] < 4:
print "usage: %s num>3" % sys.argv[0]
sys.exit(1)
print filter(lambda x: "AAG" in x, makeWords(int(sys.argv[1]), "AGCT"))
print [chars for chars in makeYieldWords(int(sys.argv[1]), "AGCT") if "AAG" in chars]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment