Is there a ‘better/alternative/more readable’ solution to http://www.pythonchallenge.com/pc/def/linkedlist.php than the ruby code below?
I can understand it but it just doesn’t seem very clear to me…
#!/usr/bin/env ruby -w
# encoding: utf-8
require 'net/http'
Net::HTTP.start 'www.pythonchallenge.com' do |http|
nothing = 12345
nothing = case http.get("/pc/def/linkedlist.php?nothing=#{nothing}").body
when /(\d+)$/ then $1.to_i
when /by two/ then nothing / 2
when /\.html/ then puts $`
end while nothing
end
It was ok but let’s try to make it a little more readable: