ruby challenge 4

follow the chain

This challenge has a link that goes to ;

and it tells you that ‘the next nothing is 92512’. So the challenge is to enter the each nothing in order to return the next nothing. Easy enough, till they throw you a couple of challenges a few dozen nothings in. After adjusting the script a couple of times I ended up with;

nothing = 12345
url = ""
require 'open-uri'
while nothing > 0
  nNothing = open(url + nothing.to_s).read
  puts nNothing
  if nNothing.split(" ")[1] == "Divide"
    nothing /= 2
  nothing = nNothing.split("nothing is ")[1].to_i

I started out using regex to grab the numbers, but they quickly nix that method.

Next challenge 5; Peak Hell


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s