This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Die(object): | |
def __init__(self, n): | |
self.n = n | |
def roll(self): | |
return random.randint(1, self.n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Die(object): | |
def __init__(self, n): | |
self.n = n | |
def roll(self): | |
"""Niestety ta funkcja jest jeszcze mało losowa. Dopracować!""" | |
return n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fib(n): | |
"""Działa, ale tylko dla n równego 1 lub 2. Poprawność częściowa ;-)""" | |
return n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fib2(n): | |
a, b = 0, 1 | |
for x in range(n): | |
a, b = b, a + b | |
return a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fib(n): | |
if n < 2: | |
return n | |
else: | |
return fib(n - 1) + fib(n - 2) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ruby | |
[zuber@fish Projekty]$ ruby -v | |
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0] | |
[zuber@fish Projekty]$ time ruby test.rb > /dev/null | |
real 0m33.294s | |
user 0m31.745s | |
sys 0m0.303s |
NewerOlder