[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
def findThis(number, memorySafe=True, singleDigits=True, upto=100):

You are currently reading a thread in /g/ - Technology

Thread replies: 6
Thread images: 4
File: 1424029811803.jpg (86 KB, 804x806) Image search: [Google]
1424029811803.jpg
86 KB, 804x806
def findThis(number, memorySafe=True, singleDigits=True, upto=100):
constructRetVal = lambda x_, y_, op_: "{} {} {} = {}".format(x_, op_, y_, number)
symbols = ["%", "^", "&", "*", "-", "+", ">>", "/"]
if not memorySafe:
symbols += ["<<", "**"]
iterRange = range(10) if singleDigits else range(upto)
found = []
for x in iterRange:
for y in iterRange:
for operator in symbols:
evalConstruct = "x {} y".format(operator)
try:
if eval(evalConstruct) == number:
found.append(constructRetVal(x, y, operator))
except ZeroDivisionError:
pass
return found


# Demonstration

# >>> findThis(69, singleDigits=False)
# ['0 ^ 69 = 69',
# '0 + 69 = 69',
# '1 ^ 68 = 69',
# '1 + 68 = 69',
# '1 * 69 = 69',
# '2 + 67 = 69',
# ...
# ...
# ...
# '87 ^ 18 = 69',
# '87 - 18 = 69',
# '87 & 69 = 69',
# '87 & 77 = 69',
# '88 - 19 = 69',
# '88 ^ 29 = 69',
# '89 - 20 = 69',
>>
// C++ is the same as C so whatevs
#include <cstdlib>
#include <iostream>
#define z std
#define a 5
#define f cout
#define g endl
#define n cin
#define o sizeof
#define p (int*)&c
#define r int
#define s const int*
#define t const void*
#define u size_t
#define v return
#define w main
#define x qsort
#define y "Later:"
void b(r c[a][a]){for(r d=0;d<a;d++){for(r e=0;e<a;e++){z::f<<c[d][e]<<' ';}z::f<<z::g;}}
r h(t i,t j){s k=(s)i;s l=(s)j;for(u m=0;m<a;m++){if(k[m]<l[m]){v -1;}if(k[m]>l[m]){v +1;}}v 0;}
r w(){r c[a][a];r d = 0;while(z::n>>c[d/a][d%a]&&++d<a*a);b(c);x(p,a,o(r[a]),h);z::f<<y<<z::g;b(c);v 0;}

>>
File: 1423802661417.jpg (53 KB, 294x406) Image search: [Google]
1423802661417.jpg
53 KB, 294x406
δ=0xffffffff
λ=ord
μ=lambda x,k:(((x)<<(k))|((x)>>(32-(k))))
def m_(a,b,c):
a&=δ;b&=δ;c&=δ
a-=c;a&=δ;a^=μ(c,4); a&=δ;c+=b;c&=δ
b-=a;b&=δ;b^=μ(a,6); b&=δ;a+=c;a&=δ
c-=b;c&=δ;c^=μ(b,8); c&=δ;b+=a;b&=δ
a-=c;a&=δ;a^=μ(c,16);a&=δ;c+=b;c&=δ
b-=a;b&=δ;b^=μ(a,19);b&=δ;a+=c;a&=δ
c-=b;c&=δ;c^=μ(b,4); c&=δ;b+=a;b&=δ
return a,b,c
def f_(a,b,c):
a&=δ;b&=δ;c&=δ
c^=b;c&=δ;c-=μ(b,14);c&=δ
a^=c;a&=δ;a-=μ(c,11);a&=δ
b^=a;b&=δ;b-=μ(a,25);b&=δ
c^=b;c&=δ;c-=μ(b,16);c&=δ
a^=c;a&=δ;a-=μ(c,4);a&=δ
b^=a;b&=δ;b-=μ(a,14);b&=δ
c^=b;c&=δ;c-=μ(b,24);c&=δ
return a,b,c
def h2_(ζ,iv=0,iv2=0):
_l=σ=len(ζ)
a=b=c=(0xdeadbeef+(_l)+iv)
c+=initval2;c&=δ
p=0
while σ > 12:
a+=(λ(ζ[p+0])+(λ(ζ[p+1])<<8)+(λ(ζ[p+2])<<16)+(λ(ζ[p+3])<<24));a&=δ
b+=(λ(ζ[p+4])+(λ(ζ[p+5])<<8)+(λ(ζ[p+6])<<16)+(λ(ζ[p+7])<<24));b&=δ
c+=(λ(ζ[p+8])+(λ(ζ[p+9])<<8)+(λ(ζ[p+10])<<16)+(λ(ζ[p+11])<<24));c&=δ
a,b,c=m_(a,b,c)
p+=12
σ-=12


1/?
>>
File: 1423802678466.jpg (61 KB, 480x744) Image search: [Google]
1423802678466.jpg
61 KB, 480x744
>>53892112
    if σ==12:c+=(λ(ζ[p+8])+(λ(ζ[p+9])<<8)+(λ(ζ[p+10])<<16)+(λ(ζ[p+11])<<24));b+=(λ(ζ[p+4])+(λ(ζ[p+5])<<8)+(λ(ζ[p+6])<<16)+(λ(ζ[p+7])<<24));a+=(λ(ζ[p+0])+(λ(ζ[p+1])<<8)+(λ(ζ[p+2])<<16)+(λ(ζ[p+3])<<24));
if σ==11:c+=(λ(ζ[p+8])+(λ(ζ[p+9])<<8)+(λ(ζ[p+10])<<16));b+=(λ(ζ[p+4])+(λ(ζ[p+5])<<8)+(λ(ζ[p+6])<<16)+(λ(ζ[p+7])<<24));a+=(λ(ζ[p+0])+(λ(ζ[p+1])<<8)+(λ(ζ[p+2])<<16)+(λ(ζ[p+3])<<24));
if σ==10:c+=(λ(ζ[p+8])+(λ(ζ[p+9])<<8));b+=(λ(ζ[p+4])+(λ(ζ[p+5])<<8)+(λ(ζ[p+6])<<16)+(λ(ζ[p+7])<<24));a+=(λ(ζ[p+0])+(λ(ζ[p+1])<<8)+(λ(ζ[p+2])<<16)+(λ(ζ[p+3])<<24));
if σ==9:c+=(λ(ζ[p+8]));b+=(λ(ζ[p+4])+(λ(ζ[p+5])<<8)+(λ(ζ[p+6])<<16)+(λ(ζ[p+7])<<24));a+=(λ(ζ[p+0])+(λ(ζ[p+1])<<8)+(λ(ζ[p+2])<<16)+(λ(ζ[p+3])<<24));
if σ==8:b+=(λ(ζ[p+4])+(λ(ζ[p+5])<<8)+(λ(ζ[p+6])<<16)+(λ(ζ[p+7])<<24));a+=(λ(ζ[p+0])+(λ(ζ[p+1])<<8)+(λ(ζ[p+2])<<16)+(λ(ζ[p+3])<<24));
if σ==7:b+=(λ(ζ[p+4])+(λ(ζ[p+5])<<8)+(λ(ζ[p+6])<<16));a+=(λ(ζ[p+0])+(λ(ζ[p+1])<<8)+(λ(ζ[p+2])<<16)+(λ(ζ[p+3])<<24));
if σ==6:b+=((λ(ζ[p+5])<<8)+λ(ζ[p+4]));a+=(λ(ζ[p+0])+(λ(ζ[p+1])<<8)+(λ(ζ[p+2])<<16)+(λ(ζ[p+3])<<24))
if σ==5:b+=(λ(ζ[p+4]));a+=(λ(ζ[p+0])+(λ(ζ[p+1])<<8)+(λ(ζ[p+2])<<16)+(λ(ζ[p+3])<<24));
if σ==4:a+=(λ(ζ[p+0])+(λ(ζ[p+1])<<8)+(λ(ζ[p+2])<<16)+(λ(ζ[p+3])<<24))
if σ==3:a+=(λ(ζ[p+0])+(λ(ζ[p+1])<<8)+(λ(ζ[p+2])<<16))
if σ==2:a+=(λ(ζ[p+0])+(λ(ζ[p+1])<<8))
if σ==1:a+=λ(ζ[p+0])
a&=δ;b&=δ;c&=δ
if σ==0:return c,b
a,b,c=f_(a,b,c)
return c,b
def h_(data,initval=0):
c,b=h2_(data,initval,0)
return c


2/3
>>
File: 1423802720711.png (132 KB, 329x354) Image search: [Google]
1423802720711.png
132 KB, 329x354
>>53892132
if __name__=="__main__":
import sys
hashstr ='the memes make me scream'
hashstr2='the meams make me creams'

hash,hash2=h2_(hashstr,0xdeadbeef,0xdeadbeef)
print('"%s": %x %x' % (hashstr,hash,hash2))

hash=h_(hashstr,0)
print('"%s": %x' % (hashstr,hash))

hash,hash2=h2_(hashstr2,0xdeadbeef,0xdeadbeef)
print('"%s": %x %x' % (hashstr2,hash,hash2))

hash=h_(hashstr2,0)
print('"%s": %x' % (hashstr2,hash))
>>
>>53891985
That's a pretty bad shoop of someone's knee
Thread replies: 6
Thread images: 4

[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK