• API
• FAQ
• Tools
• Trends
• Archive
SHARE
TWEET

# Coordinate arithmetic experimentation

aepokh Nov 5th, 2011 37 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. x_range = 20
2. y_range = 20
3.
4. def pow(a, b):
5.         if b == 0: return 1
6.         elif b == 1: return a
7.         elif b%2 == 1: return a*pow(a, b-1)
8.         else:
9.                 c = pow(a, b/2)
10.                 return c*c
11.
12. def tet(a, b):
13.         if a <= 0: return 0
14.         elif a == 1: return b
15.         else: return tet(a-1, pow(b, b))
16.
17. def t(n):
18.         divs = 1
19.         for d in range(2, n+1):
20.                 if n%d == 0: divs += 1
21.         return divs
22.
23. def s(n):
24.         divs = 1
25.         for d in range(2, n+1):
26.                 if n%d == 0: divs += d
27.         return divs
28.
29. def graph():
30.         # x_range = int(raw_input("Enter range for x: "))
31.         # y_range = int(raw_input("Enter range for y: "))
32.         condition = raw_input("Enter a condition: ")
33.
34.         with file('out.txt', 'w') as output:
35.                 for y in range(1, y_range+1):
36.                         line = ""
37.                         for x in range(1, x_range+1):
38.                                 if (eval(condition)): line += 'x '
39.                                 else: line += '  '
40.                         print line
41.                         output.write(line+"\n")
42.
43. while (True):
44.         try: graph()
45.         except: break
46.
RAW Paste Data
Top