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 1 | |
else | |
return (fib(n-1)+fib(n-2)) | |
end | |
end |
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 rev_str(a) | |
rev = '' | |
for i in 1..a.length | |
puts a[i] | |
rev += a[a.length - i] | |
end | |
puts rev | |
end |
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
Write a function that parses following input and prints date in your local timezone: | |
input = "{\"time\":\"2022-06-17T05:52:39.787Z\"}" | |
parser(input) => "2022-06-17 07:54:13 +0200" | |
def local_time(t) | |
t.local | |
end |