forked from Shivi91/Rosalind-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
044_SSET.py
28 lines (23 loc) · 908 Bytes
/
044_SSET.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python
'''
A solution to a ROSALIND bioinformatics problem.
Problem Title: Counting Subsets
Rosalind ID: SSET
Rosalind #: 044
URL: http://rosalind.info/problems/sset/
'''
# This problem is somewhat trivial, as it is well known that for a set with n elements,
# the order of the power set is 2**n.
#
# Let each element of a set take on the value of 0 or 1. Then, with the convention that 0 = excluded
# and 1 = included, all possible combinations of 0's and 1's yields all possible subsets.
# Clearly there are 2**n combinations.
with open('data/rosalind_sset.txt') as input_data:
n = int(input_data.read().strip())
# The answer is supposed to be modulo 1000000, so in case n is very large take the remainder after every multiplication.
sset = 1
for i in xrange(n):
sset = (sset*2)%1000000
print sset
with open('output/044_SSET.txt', 'w') as output_data:
output_data.write(str(sset))