Created
June 30, 2010 03:24
-
-
Save therabidbanana/458199 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
# After two hours of reading the Daily WTF, I | |
# thought it was time to write some code. | |
# | |
# Can you guess what it does? | |
class Bool | |
attr_accessor :attr4 | |
def self.true | |
Bool.new(0) | |
end | |
def self.false | |
Bool.new(1) | |
end | |
def self.file_not_found | |
Bool.new(2) | |
end | |
def initialize(int9) | |
self.attr4 = int9 | |
end | |
end | |
def is_true?(bool1) | |
bool1.attr4 == Bool.true.attr4 | |
end | |
class Class2 | |
def self.function4(int4) | |
instance1 = self.new | |
instance2 = self.new | |
instance1.function3(int4) | |
int5 = self.new.function5(int4) | |
int6 = self.new.function6(int4) | |
[int5, int6] | |
end | |
def function3(int3) | |
for i in int3..100 | |
function5(i); function6(i); | |
end | |
end | |
def function5(int5) | |
int5 - 1 | |
end | |
def function6(int6) | |
int6 - 2 | |
end | |
end | |
class Class1 | |
attr_accessor :attr1, :attr2 | |
attr_reader :attr3 | |
def function2(int2, bool2) | |
int9, int10 = Class2.function4(int2) | |
if is_true?(bool2) | |
int9 | |
else | |
int10 | |
end | |
end | |
def function1(int1) | |
if(int1 == 1) | |
1 | |
elsif(int1 == 2) | |
1 | |
elsif(int1 == 3) | |
2 | |
elsif(int1 == 4) | |
3 | |
elsif(int1 == 5) | |
5 | |
elsif(int1 == 6) | |
8 | |
elsif(int1 == 7) | |
13 | |
elsif(int1 == 8) | |
21 | |
elsif(int1 == 9) | |
34 | |
else | |
function1(function2(int1, Bool.false)) + function1(function2(int1, Bool.true)) | |
end | |
end | |
end | |
puts Class1.new.function1(42) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment