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 0000000..f867580 Binary files /dev/null and b/fb2 differ 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 0000000..a316a43 Binary files /dev/null and b/fizzbuzz differ diff --git a/fizzbuzz.c b/fizzbuzz.c new file mode 100644 index 0000000..757ffd5 --- /dev/null +++ b/fizzbuzz.c @@ -0,0 +1,17 @@ +#include + +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 0000000..715e571 Binary files /dev/null and b/fizzbuzz.sh.gz differ 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)