Created
April 13, 2013 07:48
-
-
Save dtak1114/5377508 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include "stdio.h" | |
#include "time.h" | |
int main(int argc, char const *argv[]) | |
{ | |
clock_t t1, t2; | |
t1 = clock(); | |
tarai(13,5,0); | |
t2 = clock(); | |
printf("finished in %d ms\n",(int)(t2-t1)); | |
return 0; | |
} | |
int tarai(int x,int y,int z){ | |
if (x <= y){ | |
return y; | |
}else{ | |
tarai( | |
tarai(x-1,y,z), | |
tarai(y-1,z,x), | |
tarai(z-1,x,y) | |
); | |
} | |
} |
This file contains hidden or 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
t1 = Time.now | |
def tarai(x, y, z) | |
if x <= y | |
return y | |
else | |
tarai(tarai(x-1,y,z),tarai(y-1,z,x),tarai(z-1,x,y)) | |
end | |
end | |
tarai(13,5,0) | |
puts (Time.now - t1) + 'sec' |
This file contains hidden or 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
(define (tarai x y z) | |
(if (<= x y) | |
y | |
(tarai | |
(tarai (- x 1) y z) | |
(tarai (- y 1) z x) | |
(tarai (- z 1) x y)))) | |
(print (time (tarai 13 5 0))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment