diff --git a/sset/__init__.py b/sset/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sset/__main__.py b/sset/__main__.py new file mode 100644 index 0000000..a9b41fc --- /dev/null +++ b/sset/__main__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +""" +Given: A positive integer n (n≤1000). + +Return: The total number of subsets of {1,2,…,n} modulo 1,000,000. + +>>> problem(3) +8 +""" + +from ..util import binomial + + +def problem(n): + return sum([binomial(n, i) for i in range(n + 1)]) % 1000000 + + +if __name__ == '__main__': + import doctest + from os.path import dirname + + doctest.testmod() + + n = int(open(dirname(__file__) + "/rosalind_sset.txt").read().strip()) + print problem(n) diff --git a/sset/rosalind_sset.txt b/sset/rosalind_sset.txt new file mode 100644 index 0000000..d50bf78 --- /dev/null +++ b/sset/rosalind_sset.txt @@ -0,0 +1 @@ +835