commit 8e2ad7fa2a015a658d2841047a82e2f346761e4c Author: other Date: Fri Nov 2 01:14:58 2018 -0500 added files diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6a18ad4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,96 @@ +# ---> Python +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject + +# Rope project settings +.ropeproject + diff --git a/brute.py b/brute.py new file mode 100644 index 0000000..7a6147f --- /dev/null +++ b/brute.py @@ -0,0 +1,86 @@ +from funcs import * +from termcolor import colored +ops = ( + '+', + '-', + '*', + '/', + ) + +par = ( + '{n[0]}{o[0]}{n[1]}{o[1]}{n[2]}{o[2]}{n[3]}', + '({n[0]}{o[0]}{n[1]}){o[1]}({n[2]}{o[2]}{n[3]})', + '({n[0]}{o[0]}{n[1]}{o[1]}{n[2]}){o[2]}{n[3]}', + '({n[0]}{o[0]}{n[1]}){o[1]}{n[2]}{o[2]}{n[3]}', + ) +colors = [ + 'red', + 'green', + 'yellow', + 'blue', + 'magenta', + 'cyan' + ] +var = ('a','b','c','d') +ps = perms(4) + +def find(numbs,fast = False): + + answers = [[],[]] + + t = True + + for perm in ps: + perm = list( + map( + lambda x:x-1,perm + ) + ) + org = perm + perm = choose(numbs,perm) + + for o in range(4**3): + o = zp(con_base(o,4),3) + o = choose(ops,o) + + for p in par: + g = p.format(**{'n':perm,'o':o}) + + try: + if round(eval(g),2) == 10: + if fast: + return [g] + else: + var_subbed = choose(var,org) + org = p.format(**{ + 'n':var_subbed, + 'o':o + }) + + d = simplify(org) + if not (d in answers[0]): + answers[0].append(d) + answers[1].append(g) + except: + pass + return tuple(set(answers[1])) + +Strng0 = 'Fancy colors? (y or n):' +Strng1 = 'One or all solutions (one or all):' + +fancy_colors = input(Strng0) == 'y' +fast = input(Strng1) == 'all' +print( + find( + list(range(1,5)),False + ) + ) +while True: + if fancy_colors: + random.shuffle(colors) + for col in colors: + for ans in find(getInput(input('Numbers:')),fast): + print(colored(ans,col)) + else: + for ans in find(getInput(input('Numbers:')),fast): + print(ans) diff --git a/clipboard.py b/clipboard.py new file mode 100644 index 0000000..16787a0 --- /dev/null +++ b/clipboard.py @@ -0,0 +1,6 @@ +import sl4a +def copy(st): + sl4a.Android().setClipboard(st) + return +def paste(): + return sl4a.Android().getClipboard().result \ No newline at end of file diff --git a/funcs.py b/funcs.py new file mode 100644 index 0000000..eb13761 --- /dev/null +++ b/funcs.py @@ -0,0 +1,39 @@ +from uniPerm import perms +from math import log +import random +from sympy.core.sympify import sympify +from sympy.simplify.simplify import simplify +def con_base(n,b): + out = [] + if n == 0: + return [0] + for p in range(int(log(n,b)),-1,-1): + out.append(n//(b**p)) + n %= b**p + return out +def zp(lst,n): + l = [] + for i in range(n-len(lst)): + l.append(0) + return l + lst + +def getInput(blah): + sanitized = list( + filter( + lambda x: x,blah.split(' ') + ) + ) + return list( + map( + lambda x: int(x),sanitized + ) + ) + +def choose(lst,select): + return list(map(lambda x: lst[x],select)) + +def rand_4(): + l = [] + for i in range(4): + l.append(random.randint(0,20)) + return l \ No newline at end of file diff --git a/uniPerm.py b/uniPerm.py new file mode 100644 index 0000000..af47e11 --- /dev/null +++ b/uniPerm.py @@ -0,0 +1,21 @@ +def circle(l, n = 1): + return l[n:] + l[:n] + +def perms(n): + d = 3 + l = 2 + combs = [[1,2],[2,1]] + if n == 2: + return combs + else: + for d in range(3,n+1): + for i in range(l): + combs[i].append(d) + for i in range(l*(d-1)): + combs.append(circle(combs[i])) + l *= d + return combs +#import time +#for i in perms(3): +# time.sleep(1) +# print(i) \ No newline at end of file