from voters import *
from voter import *
from copy import deepcopy

class voter_permutations:
    num_cands = None
    cands = None
    perms = None
    wcuts = None

    def __init__(self, cands):
        self.num_cands = cands.num_cands
        self.cands = cands.candidates
        self.perms = self.perm(self.cands)
        self.wcuts = []

    def generate_voters(self):
        votes = []
        perms = self.perm(self.cands)
        for p in perms:
            for i in range(1, self.num_cands):
                votes.append(voter(None,self.cands,p,i))
        return voters(self.cands, None, votes)

    def print_cut(self):
        perms = self.perm(self.cands)
        for p in perms:
            for i in range(1, self.num_cands):
                a = deepcopy(p)            
                a.insert(i,'%')
                self.wcuts.append(a)
        return self.wcuts

    def perm(self, cands):
        size = len(cands)
        if size <= 1:
            return [cands]
        return [p[:i]+[cands[0]]+p[i:] for i in xrange(size) for p in self.perm(cands[1:])]
    


