From f867230642cf50008f3c8f6f3a1993a2880f51a2 Mon Sep 17 00:00:00 2001 From: Valentin Gehrke Date: Sun, 31 Aug 2014 06:14:41 +0200 Subject: [PATCH] sudoku --- azzzzz.py | 7 +++++++ deriver.py | 6 +++--- fb2 | Bin 0 -> 6860 bytes fibonacci_proof_of_concept.py | 22 ++++++++++++++++++++++ fibonacci_small.py | 7 +++++++ fizzbuzz | Bin 0 -> 7029 bytes fizzbuzz.c | 17 +++++++++++++++++ fizzbuzz.py | 21 +++++++++++++++++++++ fizzbuzz.sh.gz | Bin 0 -> 159 bytes fizzbuzz2.c | 11 +++++++++++ namegenerator.py | 19 +++++++++++++++++++ pascaltriangle.py | 24 ++++++++++++++++++++++++ pseudorandomquotes.py | 22 ++++++++++++++++++++++ sorter.py | 7 +++++++ 14 files changed, 160 insertions(+), 3 deletions(-) create mode 100644 azzzzz.py create mode 100755 fb2 create mode 100644 fibonacci_proof_of_concept.py create mode 100644 fibonacci_small.py create mode 100755 fizzbuzz create mode 100644 fizzbuzz.c create mode 100644 fizzbuzz.py create mode 100644 fizzbuzz.sh.gz create mode 100644 fizzbuzz2.c create mode 100644 namegenerator.py create mode 100644 pascaltriangle.py create mode 100644 pseudorandomquotes.py create mode 100644 sorter.py diff --git a/azzzzz.py b/azzzzz.py new file mode 100644 index 0000000..4df832e --- /dev/null +++ b/azzzzz.py @@ -0,0 +1,7 @@ + +def fn(pre,n): + p = (lambda c: print(pre+c),lambda c: fn(pre+c,n-1))[min(n,1)] + list(map(p,['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'])) + +p = lambda n: fn('',n) +list(map(p,[0,1,2,3,4])) diff --git a/deriver.py b/deriver.py index 125a0ab..a004394 100644 --- a/deriver.py +++ b/deriver.py @@ -241,9 +241,9 @@ class Deriver: Numeric(1) ), DRule( #d/dx (x^c) = c * x ^ (c-1) - Power( DeriveVarIdMark(), IdMark("c") ), - Multiplication( - IdMark("c"), + Power( DeriveVarIdMark(), IdMark("c",constant=True) ), + Multiplication( + IdMark("c"), Power( DeriveVarIdMark(), Subtraction( diff --git a/fb2 b/fb2 new file mode 100755 index 0000000000000000000000000000000000000000..f867580b5d74fa0b3e93d0506dd820567abb0a52 GIT binary patch literal 6860 zcmcIoYiv}<6`tMo3j=FoXk#A1s}>ZS%8N0M-8tucbH14~bLVmA{=gsTb2=P?lT$n;$f~cbUIqx@Wu6{I^A;M7b-$xWsuSaO6Usl8&-lxoUns!fxn5FQB- zk75m~@?dpP;w;-#998VS)W^P(hQ zN(ZiF!lZXlqf%<6Qd%fil6hYTPf=9Ke;4(tczZlH+}W``9&U}t64{B?iLTDp&JJ%n z>1~(slOJ_)&%VQw!QruHk9!utQ@`txTlQ2K>tRlJDp-Y6-#7Bg<%k6q%)yZ#uy955yloS{5RcPYsTX0+& zt!wHP;>^zw@L|36G=x5V$F1kCJm(xbe})>QK$nKjQc-@fu4#&}Gi0&<{2dqk_1rmq z{`zj+v7o5ZQ-Ag8 zU9URfkl9=aVcp@g zzMY$ynaN%H=k-$+wTLr!E_Z4EPE*Ud+`{}~Max3VeD3%9$OrmK|4js5_omS6ez#y+ z=T7?X<}T>D4`l>bC-3L;)2Mj*`Mcp4ekHN@&SUV7qa`7H-|*$~zNhnp-R?yl`E?)b)8`%f zS8rsm)5Q4pknb7aknf1kI6pe-W&c~4FLExaspC)^a8q5~+Pd{?k*|kRw>4ZV`eKul zwW2#qIq9Z`m>nBkPqabOKKu&=^nJ*WAp?-_p|`(;3}ATQg?tBc6$X{|2}+L1gTgUU z@7TDiy5_W_x}I>_<7dF%Mh+^K_ZMOd%E`YG{u=qZ>-*e|d+Sy{S2HDcZ+K$c&MjXe zn0$KiJc@WG3Glh=Uv&1Yu5xD4vRM`eJcaTIm3O=Af8_ML8((qx-JVkwes}ZBmAbp_ z#VXz1HC;X6*5d9ipS#WHZtiw_y4{WN?{?S7e!T(uEb6hYW2%zU0@e$qUn?mMWV{!! zT%`(TU7FNZD|-pcj?#LW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{1m2Uor-}|g_P`%}zcqpC5D>e*tiHDN< N%J00Sr*ibfe*kmITwMSF literal 0 HcmV?d00001 diff --git a/fibonacci_proof_of_concept.py b/fibonacci_proof_of_concept.py new file mode 100644 index 0000000..1ffe67c --- /dev/null +++ b/fibonacci_proof_of_concept.py @@ -0,0 +1,22 @@ +from math import sqrt + +def pq(p,q): + a = -p/2 + b = sqrt(a**2-q) + return (a+b,a-b) + +(l1,l2) = pq(-1,-1) +c2 = -l1/(l2-l1) +c1 = 1-c2 + +c1 *= l1 +c2 *= l2 + +fib = lambda k: int(c1*pow(l1,k) + c2*pow(l2,k)) + +if __name__ == '__main__': + print("fib(k) = (%f) * (%f)^k + (%f) * (%f)^k)" % (c1,l1,c2,l2)) + + for i in range(0,51): + print("%d: %d" %(i,fib(i))) +y \ No newline at end of file diff --git a/fibonacci_small.py b/fibonacci_small.py new file mode 100644 index 0000000..46e7bd8 --- /dev/null +++ b/fibonacci_small.py @@ -0,0 +1,7 @@ +from math import sqrt +psi = (1+sqrt(5))/2 +phi = 1/sqrt(5) +fib = lambda k: int(phi*(psi**k - (-1/psi)**k)) + +for i in range(100): + print(fib(i)) \ No newline at end of file diff --git a/fizzbuzz b/fizzbuzz new file mode 100755 index 0000000000000000000000000000000000000000..a316a43e5f9f56cd3d679165a5b4ded9c99a33ac GIT binary patch literal 7029 zcmcIpYiv}<6`sAje(+ka2?@`}s}>p@iNzS>xD6zC{o5V0aqBIQR_DNixdbOoyd+5L^ym_@ocB|toi z^_D8XRTh#s%LWyP&haQ7sl=OCym`fAIZcj{SaSQQZS>ou{B6>7Xr${TM6-M@O0uQY zc{?4U{5h&rO1(hVNlgfr%=;dAilQw3yYQ*v?L)EN`nv5yk!?ejUE*qkSvxNiOkKHzD`+ z5)HT2MNBE4V))u8;MKtW_$^6jcONygUW{bYDKV0a#nb)5Gzm9T>2NY_4u@lLAOpjR zxI#>^x4o^g$*c|326n-vCjZE{Oa2ML{hHYjTSny#s^ZCIA(^9h#P5uN8HL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HWO0!>+|999@Q<=~E7~i+~Uah(#KYn@q`~zHj{d~`wR4?8cFY7Gt zI{18!xTg3GD7Po(v84B7uU{+=S>|ft;5gX_^H~218N#^zbiJYEQ+%gA)n!jPD1_D6 zLFAeLoC9Y*%Sx1U-FDL#xPCTNg$`BL&12urpH!Fhka}_7K;d@$xIMhCQ8yQ>->(jy z-45r@`t5Z(^KObx)15Ht)AHY8?1gTW@cvhbd-CVkLcAn@ZY{)1vH$3HNao$xX?cIK z7rN0ayl)iZ%W$*S?U2m7aY`O9im%A8-*%FlR(?-0KdbWJ`3mj5g4fYPyh8B$Scv=Z zy{ef1O2O+{q5bOoI#q~2C3yWQ#MfXw3E3f;cjGp|>xI40EuIm)4iw^R^Y?^89HWuv zt*yW<)?*%pY>1V0FWD8XIp`7pqUpFK6~k#B6vLka?!xWP*?~_nvdLK_0zQpl&LjnE%fuYxR=x^QH8&beud^_Rjb#(IGC}5_unxW_UaYd^PpI8t1$$ zy#Uw}p3*k61@H*g8+*#n%KR(qzQH3u6_hG!PbNG3r?D@RMA$ZWSWbf<;A8_(d z-w!EG%cl@e1NW=ET~q_7_?>=sJ;DBf^j~ECq^o71PxK|zsdNS(uKMsrcwf^&v%T$5 zmuZR!?!*JJ6mGm`df4n6O2nfnQ3Nv0NWvT#O7w<@%t$(sOqt=#sK7OHWGI@BMgsLa zchwAS_1#FaC7OjsA%NM?BW7$`Q)q+kn8@hPnrpVDO5tp|f0EoRI9X2fkZ zg7XEuh%lRfus_(*)&whCiTo%o%)RXg8iVcTf!5YTEnQ|;u(7>`+{y3eeW{ELSD0;G z9p+-+bagaQ&vb=*hoXY6(bo5L`RQHP?cdbRsJvxcUaXJu4g=>GdS|iCz2n + +int main() { + int i; + for(i = 1; i <= 100; i++) { + if(i % 15 == 0) { + printf("FizzBuzz\n"); + } else if(i % 3 == 0) { + printf("Fizz\n"); + } else if(i % 5 == 0) { + printf("Buzz\n"); + } else { + printf("%d\n",i); + } + } + return 0; +} diff --git a/fizzbuzz.py b/fizzbuzz.py new file mode 100644 index 0000000..dd81e12 --- /dev/null +++ b/fizzbuzz.py @@ -0,0 +1,21 @@ +a = [ 3,0,0,1,0,2,1,0,0,1,2,0,1,0,0 ] + +b = [ "%d\n", "Fizz\n", "Buzz\n", "FizzBuzz\n" ] + +boff = [ 0 for z in b ] +for i in range(len(b)): + boff[i] = 0 + for j in range(i): + boff[i] += len(b[j]) + +s = "" + +for i in range(len(a)): + s += "\\x%x" % (a[i]+len(a)+boff[a[i]]) + +for n in b: + for c in n: + s += "\\x%x" % (ord(c)) + s += "\\x0" + +print s diff --git a/fizzbuzz.sh.gz b/fizzbuzz.sh.gz new file mode 100644 index 0000000000000000000000000000000000000000..715e571e521cb10ccfdcb2cdcc62075c4e27fc04 GIT binary patch literal 159 zcmV;Q0AT+giwFqxaoAG;17>M@dSZ2YdM!hqIjl000XrOPv4! literal 0 HcmV?d00001 diff --git a/fizzbuzz2.c b/fizzbuzz2.c new file mode 100644 index 0000000..7f3999d --- /dev/null +++ b/fizzbuzz2.c @@ -0,0 +1,11 @@ +#include + +int main() { + const char *d = "\x1f\xf\xf\x13\xf\x19\x13\xf\xf\x13\x19\xf\x13\xf\xf\x25\x64\xa\x0\x46\x69\x7a\x7a\xa\x0\x42\x75\x7a\x7a\xa\x0\x46\x69\x7a\x7a\x42\x75\x7a\x7a\xa\x0"; + int i; + + for(i = 1; i <= 100; i++) + printf(d+d[i%15],i); + + return 0; +} diff --git a/namegenerator.py b/namegenerator.py new file mode 100644 index 0000000..af253f5 --- /dev/null +++ b/namegenerator.py @@ -0,0 +1,19 @@ +import random as pseudorandom + +consonants = ['b','c','d','f','g','h','k','l','m','n','p','r','s','t','v','w','x','z'] +vocals = ['a','e','i','o','u','y'] + +both = [consonants,vocals] + +def generate_name(length=3): + gid = pseudorandom.randint(0,1) + name = "" + for i in range(length): + ch = pseudorandom.choice(both[gid]) + name += ch + gid = (gid + 111) % 2 + return name + +for i in range(10): + print(generate_name(pseudorandom.randint(3,10))) + diff --git a/pascaltriangle.py b/pascaltriangle.py new file mode 100644 index 0000000..467ac3c --- /dev/null +++ b/pascaltriangle.py @@ -0,0 +1,24 @@ +#python 3 + +def pascaltriangle(length): + l = [1] + yield l + for i in range(length-1): + nl = [1] + for j in range(len(l)-1): + nl.append(l[j]+l[j+1]) + nl.append(1) + yield nl + l = nl + +def prettyprint(l,w): + s = " ".join(map(str,l)) + indent = int((w - len(s))/2) + s = (indent * " ") + s + print(s) + +length = int(input('Length of pascal triangle: ')) + +for n in pascaltriangle(length): + prettyprint(n,length*3) + diff --git a/pseudorandomquotes.py b/pseudorandomquotes.py new file mode 100644 index 0000000..0619899 --- /dev/null +++ b/pseudorandomquotes.py @@ -0,0 +1,22 @@ +import random as pseudorandom + +subjects = [ + ("is",['A car','Technology','A woman','A person','A dog','A cat','My neighbor','My fiancee','4chan','Obama']), + ("am",['I']), + ("are",['People','My friends','Teachers','Policemen','Politicians','Things']) +] + +adjectives = ['dumb','gay','intelligent','evil','religious','sick','unhealthy','wrong','right','idiotic','lazy','green','black','whiny'] + +people = ['4chan','/g/','Anonymous','Random Citizen','That guy at school','My mother','My uncle'] + +def generate_quote(): + verb,subjectlist = pseudorandom.choice(subjects) + subject = pseudorandom.choice(subjectlist) + adjective = pseudorandom.choice(adjectives) + person = pseudorandom.choice(people) + + return '"%s %s %s" - %s' % (subject, verb, adjective, person) + +for i in range(10): + print(generate_quote()) diff --git a/sorter.py b/sorter.py new file mode 100644 index 0000000..424103d --- /dev/null +++ b/sorter.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python + +a = [ [5,2,3], [1], [6,1,9], [2,0] ] + +a = sorted(a, key = lambda item: sum(item)/len(item) ) + +print(a)