Search found 5 matches

by Taurath
Tue Mar 20, 2012 2:22 am
Forum: Challenges Solved
Topic: Pi Hates Nines
Replies: 26
Views: 3141

Mine in Ruby: file = File.open("millionpi", "r") line = file.gets bigdist = 0 n = 0 a = (0 .. line.length - 1).find_all {|i| line[i,1] == '9'} ##gives the location of each 9 in line for i in 1..a.length - 1 do dist = a[i] - a[i-1] if bigdist < dist bigdist = dist n = a[i-1] end e...
by Taurath
Wed Mar 14, 2012 3:22 am
Forum: Challenges Solved
Topic: Valuation
Replies: 103
Views: 8869

In Ruby: I needed practice opening files so I made 2 of them, vsource (containing the challenge code) and vsource2 (containing the same but with x's removed). file = File.open("vsource", "r") file2 = File.open("vsource2", "r") count = 0 total = 0 line = file.g...
by Taurath
Thu Feb 16, 2012 1:48 am
Forum: Challenges Solved
Topic: V.I.L.E.
Replies: 12
Views: 941

The title gave it all away for me. The pluses before each number along with the Carmen Sandiego reference ('Where in the world is...') made me jump immediately to looking up country codes, and the first three "Turkey Haiti Egypt" (T H E) made me giggle with delight.
by Taurath
Tue Feb 14, 2012 7:59 am
Forum: Challenges Solved
Topic: Delegates
Replies: 17
Views: 2031

Mine in Ruby (which I learned today, be gentle) :P

Code: Select all

x = 0
y = 1
while y < 2119 do
	x = x + y
	#machine to check if whole number
	def whole?(x)
		(x - x.floor) == 0
		end
	z = Math.sqrt(y)
	if whole?(z) == true
		x = x + y
		end
	y = y + 1
	end
puts x
by Taurath
Tue Feb 14, 2012 6:30 am
Forum: Challenges Solved
Topic: The Powers That Be
Replies: 27
Views: 2902

First thing I've written in 5 years, and first time ever using ruby. I could clean this up, but this is what I did to solve: y = ((17**39)**11) y = y.to_s z = 0 x = y[z].chr while x != nil do puts x z = z + 33 x = y[z].chr end Of course, it pops a new number out each line. I know how to clean it now...