def solution(expression): cals = ["+","-","*"] perms = list(pmt(cals,3)) mathBasket = [] exBasket = [] myDigit = '' answer = 0 for i in range(len(expression)): if i == len(expression) - 1: myDigit += expression[i] myDigit = int(myDigit) mathBasket.append(myDigit) elif expression[i].isdigit(): myDigit += expression[i] else: myDigit = int(myDigit) mathBasket.append(myDigit) myDigit = '' exBasket.append(expression[i]) for i in range(6): cal = perms[i] myExpress = exBasket[:] myMath = mathBasket[:] for j in range(3): mathEx = cal[j] while myExpress and mathEx in myExpress: idx = myExpress.index(mathEx) A = myMath.pop(idx) B = myMath.pop(idx) C = myExpress.pop(idx) result = calculation(A,B,C) myMath.insert(idx, result) if answer < abs(myMath[0]): answer = abs(myMath[0]) return answer
def maximumPermutation(w, s): l = [] p = list(pmt(w, len(w))) p.sort() permut = set(p) [l.append("".join(i)) for i in permut] m = [] for i in l: count = 0 for j in range(len(s)): st = s[j:j + len(i)] if i in st: count += 1 m.append(count) if m.count(max(m)) > 1: l2 = [] l3 = [] for i in m: if max(m) == i: l2.append(m.index(i)) for i in l2: l3.append(l[i]) l3.sort() return l3[0] if max(m) == 0: return ('-1') else: return (l[m.index(max(m))])
def text_to_leet(text, leet_dict=Leet_Dict): #Now, #The thing is, it's not necessary that every text is converted to leet, #it's possible that words are like this: 4nm0L or A|\|M0L, so, what we gotta do #in order to cover every possible permutation is, loop from 1 to len(text) and then, select #That number of letters, and convert them into leet, for example, if i == 1, we'll just convert one letter to leet. Permutations = [text] #When we don't convert anything into leet. for i in range(1, len(text) + 1): possible_Is = list(pmt(range(len(text)), i)) #Possible Is is the list of all the indexs that are leet-ed at a certain point if that makes sense #For example, #If possible_Is = [(1, 2), (3, 4)] what it means is, the possiblities are that at a certain time, 1 is leeted along with 2 or the second time, 3 is leet-ed with 4th character. for curr_possible in possible_Is: temp = replace_char(text, curr_possible, leet_dict) Permutations.append(temp) return list(set(Permutations))
import pprint import binascii import mnemonic import bip32utils from itertools import permutations as pmt solution = "" match = "1h8BNZkhsPiu6EKazP19WkGxDw3jHf9aT" partial = 27 words = {"0": "BTC", "1": "ETH", "2": "XRP", "3": "Phemex"} prime = "957496696762772407663" base = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" perm = pmt(words) def bip39(ss: str): mobj = mnemonic.Mnemonic("english") seed = bytes(ss, "utf-8") bip32_root_key_obj = bip32utils.BIP32Key.fromEntropy(seed) for i in range(10): bip32_child_key_obj = bip32_root_key_obj.ChildKey( 44 + bip32utils.BIP32_HARDEN).ChildKey( 0 + bip32utils.BIP32_HARDEN).ChildKey( 0 + bip32utils.BIP32_HARDEN).ChildKey(0).ChildKey(i) priv_key = { 'seed': seed, 'bip32_root_key': bip32_root_key_obj.ExtendedKey(), 'bip32_extended_private_key': bip32_child_key_obj.ExtendedKey(), 'path': "m/44'/0'/0'/{}".format(i), 'addr': bip32_child_key_obj.Address(), 'publickey': binascii.hexlify(bip32_child_key_obj.PublicKey()).decode(),
def perm_gen(limit, pos): return sorted(pmt(range(limit)))[pos - 1]
if len(argv) > 1: if argv[1] == 'game': print('Use qweasdzxc and Enter keys to make a turn') field = Field() while(not field.is_game_finished()): field.accept_turn() field.show() print('O wins' if field.Owins() else 'X wins' if field.Xwins() else 'draw') elif argv[1] == 'stat': start = now() cntr, next_limit = 0, 0 stats = dict() total_combinations = 120960 # 3 * 8! for first_turn in range(3): # 0,1,2 only (normalized turn) for other_turns in pmt({0,1,2,3,4,5,6,7,8} - {first_turn}): cntr += 1 turns = (first_turn,) + other_turns game = Field(turns) h, w = game.history(), game.who_wins() stats[h] = w if cntr >= next_limit: print('.', end='', flush=True) next_limit += total_combinations // 10 - 1 #if cntr >= 100: break #@@@ print() with open('tiqtaq.json', 'w') as f: json.dump(stats, f, indent=2, sort_keys=True) print('elapsed %.3f seconds' % (now() - start)) print('dict len:', len(stats)) print(' X won:', filter(stats, 1))