7 deleted 178 characters in body
source | link

Ruby, 1000 - 303 299 337 - 50 373 - 170 382382 - 170 - 140 379 - 170 - 140 chars = 697 701 713 797 928928 931

I'm sure there are many improvements to be made.

(This requires Nokogiri)

require'open-uri'
require'nokogiri'
x="/wiki/"+gets.chomp
r=[]
n=i=0r=[n=i=0]
until x=~/\/Philosophy/
d=Nokogiri.HTML open"http://en.wikipedia.org#{x}"
x=d.css('p a').select{|a|t=a.xpath('preceding::text()').map(&:text)*'';t.count('(')==t.count(')')&&a.attr('href')=~/^\/^.wiki[^:]+$/}[i].attr'href'
i=0
puts r.index(x)?->"#{$><<'i=';i=($*[0]||gets).to_i;''}[]": r.push(x)[-1][6..-1]
n+=1
end
p n

Example run:

c:\a\ruby>wikipedia_crawl_philosophy
Latin (note: this is my input)
Classical_antiquity
History
Umbrella_term
Terminology
Word
Linguistics
Science
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
18

Sample one where I had to go to a different link

c:\a\ruby>wikipedia_crawl_philosophy
Snow
Precipitation_(meteorology)
Meteorology
Atmospheric_physics
Synoptic_scale_meteorology
i=2 // I put the 0-indexed number of the link I wanted to go to (so, the third link)

Weather
Atmosphere
Gas
State_of_matter#The_four_fundamental_states
Physics
Natural_science
Sciences
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
25

Tricks I used:

  • I used the selector p a to only get non-italic links, because all links in the actual article that are not italics are always in paragraph elements in Wikipedia.

Ruby, 1000 - 303 299 337 - 50 373 - 170 382 - 170 - 140 chars = 697 701 713 797 928

I'm sure there are many improvements to be made.

(This requires Nokogiri)

require'open-uri'
require'nokogiri'
x="/wiki/"+gets.chomp
r=[]
n=i=0
until x=~/\/Philosophy/
d=Nokogiri.HTML open"http://en.wikipedia.org#{x}"
x=d.css('p a').select{|a|t=a.xpath('preceding::text()').map(&:text)*'';t.count('(')==t.count(')')&&a.attr('href')=~/^\/wiki[^:]+$/}[i].attr'href'
i=0
puts r.index(x)?->{$><<'i=';i=($*[0]||gets).to_i;''}[]: r.push(x)[-1][6..-1]
n+=1
end
p n

Example run:

c:\a\ruby>wikipedia_crawl_philosophy
Latin (note: this is my input)
Classical_antiquity
History
Umbrella_term
Terminology
Word
Linguistics
Science
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
18

Sample one where I had to go to a different link

c:\a\ruby>wikipedia_crawl_philosophy
Snow
Precipitation_(meteorology)
Meteorology
Atmospheric_physics
Synoptic_scale_meteorology
i=2 // I put the 0-indexed number of the link I wanted to go to (so, the third link)

Weather
Atmosphere
Gas
State_of_matter#The_four_fundamental_states
Physics
Natural_science
Sciences
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
25

Tricks I used:

  • I used the selector p a to only get non-italic links, because all links in the actual article that are not italics are always in paragraph elements in Wikipedia.

Ruby, 1000 - 303 299 337 - 50 373 - 170 382 - 170 - 140 379 - 170 - 140 chars = 697 701 713 797 928 931

I'm sure there are many improvements to be made.

(This requires Nokogiri)

require'open-uri'
require'nokogiri'
x="/wiki/"+gets.chomp
r=[n=i=0]
until x=~/\/Philosophy/
d=Nokogiri.HTML open"http://en.wikipedia.org#{x}"
x=d.css('p a').select{|a|t=a.xpath('preceding::text()').map(&:text)*'';t.count('(')==t.count(')')&&a.attr('href')=~/^.wiki[^:]+$/}[i].attr'href'
i=0
puts r.index(x)?"#{$><<'i=';i=($*[0]||gets).to_i;''}": r.push(x)[-1][6..-1]
n+=1
end
p n

Example run:

c:\a\ruby>wikipedia_crawl_philosophy
Latin (note: this is my input)
Classical_antiquity
History
Umbrella_term
Terminology
Word
Linguistics
Science
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
18

Sample one where I had to go to a different link

c:\a\ruby>wikipedia_crawl_philosophy
Snow
Precipitation_(meteorology)
Meteorology
Atmospheric_physics
Synoptic_scale_meteorology
i=2 // I put the 0-indexed number of the link I wanted to go to (so, the third link)

Weather
Atmosphere
Gas
State_of_matter#The_four_fundamental_states
Physics
Natural_science
Sciences
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
25

Tricks I used:

  • I used the selector p a to only get non-italic links, because all links in the actual article that are not italics are always in paragraph elements in Wikipedia.
6 deleted 178 characters in body
source | link

Ruby, 1000 - 303 299 337 - 50 373 - 170 382 - 170 - 140 chars = 697 701 713 797 928

I'm sure there are many improvements to be made.

(This requires Nokogiri)

* latest version is untested but should work, will test when I get back home today

require'open-uri'
require'nokogiri'
x="/wiki/"+gets.chomp
r=[]
n=i=0
until x=~/\/Philosophy/
d=Nokogiri.HTML open"http://en.wikipedia.org#{x}"
x=d.css('p a').select{|a|t=a.xpath('preceding::text()').map(&:text)*'';t.count('(')==t.count(')')&&a.attr('href')=~/^\/wiki[^:]+$/}[i].attr'href'
i=0
puts r.index(x)?->{$><<'i=';i=($*[0]||gets).to_i;''}[]: r.push(x)[-1][6..-1]
n+=1
end
p n

Example run:

c:\a\ruby>wikipedia_crawl_philosophy
Latin (note: this is my input)
Classical_antiquity
History
Umbrella_term
Terminology
Word
Linguistics
Science
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
18

Sample one where I had to go to seconda different link

c:\a\ruby>wikipedia_crawl_philosophy
Snow
Precipitation_(meteorology)
Meteorology
Atmospheric_physics
Synoptic_scale_meteorology
i=1i=2 // I put the 0-indexed number of the link I wanted to go to

i=1 // I think this is a bug :( no ideaso, howthe tothird fix

Depression_(meteorologylink)
Atmospheric_pressure
Atmosphere_of_EarthWeather
GasesAtmosphere
Gas
State_of_matter#The_four_fundamental_states
Physics
Natural_science
Sciences
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
25

Tricks I used:

  • I used the selector p a to only get non-italic links, because all links in the actual article that are not italics are always in paragraph elements in Wikipedia.

Ruby, 1000 - 303 299 337 - 50 373 - 170 382 - 170 - 140 chars = 697 701 713 797 928

I'm sure there are many improvements to be made.

(This requires Nokogiri)

* latest version is untested but should work, will test when I get back home today

require'open-uri'
require'nokogiri'
x="/wiki/"+gets.chomp
r=[]
n=i=0
until x=~/\/Philosophy/
d=Nokogiri.HTML open"http://en.wikipedia.org#{x}"
x=d.css('p a').select{|a|t=a.xpath('preceding::text()').map(&:text)*'';t.count('(')==t.count(')')&&a.attr('href')=~/^\/wiki[^:]+$/}[i].attr'href'
i=0
puts r.index(x)?->{$><<'i=';i=($*[0]||gets).to_i;''}[]: r.push(x)[-1][6..-1]
n+=1
end
p n

Example run:

c:\a\ruby>wikipedia_crawl_philosophy
Latin (note: this is my input)
Classical_antiquity
History
Umbrella_term
Terminology
Word
Linguistics
Science
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
18

Sample one where I had to go to second link

c:\a\ruby>wikipedia_crawl_philosophy
Snow
Precipitation_(meteorology)
Meteorology
Atmospheric_physics
Synoptic_scale_meteorology
i=1 // I put the 0-indexed number of the link I wanted to go to

i=1 // I think this is a bug :( no idea how to fix

Depression_(meteorology)
Atmospheric_pressure
Atmosphere_of_Earth
Gases
State_of_matter#The_four_fundamental_states
Physics
Natural_science
Sciences
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
25

Tricks I used:

  • I used the selector p a to only get non-italic links, because all links in the actual article that are not italics are always in paragraph elements in Wikipedia.

Ruby, 1000 - 303 299 337 - 50 373 - 170 382 - 170 - 140 chars = 697 701 713 797 928

I'm sure there are many improvements to be made.

(This requires Nokogiri)

require'open-uri'
require'nokogiri'
x="/wiki/"+gets.chomp
r=[]
n=i=0
until x=~/\/Philosophy/
d=Nokogiri.HTML open"http://en.wikipedia.org#{x}"
x=d.css('p a').select{|a|t=a.xpath('preceding::text()').map(&:text)*'';t.count('(')==t.count(')')&&a.attr('href')=~/^\/wiki[^:]+$/}[i].attr'href'
i=0
puts r.index(x)?->{$><<'i=';i=($*[0]||gets).to_i;''}[]: r.push(x)[-1][6..-1]
n+=1
end
p n

Example run:

c:\a\ruby>wikipedia_crawl_philosophy
Latin (note: this is my input)
Classical_antiquity
History
Umbrella_term
Terminology
Word
Linguistics
Science
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
18

Sample one where I had to go to a different link

c:\a\ruby>wikipedia_crawl_philosophy
Snow
Precipitation_(meteorology)
Meteorology
Atmospheric_physics
Synoptic_scale_meteorology
i=2 // I put the 0-indexed number of the link I wanted to go to (so, the third link)

Weather
Atmosphere
Gas
State_of_matter#The_four_fundamental_states
Physics
Natural_science
Sciences
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
25

Tricks I used:

  • I used the selector p a to only get non-italic links, because all links in the actual article that are not italics are always in paragraph elements in Wikipedia.
5 added 124 characters in body; added 3 characters in body
source | link

Ruby, 1000 - 303 299 337 - 50 373 373 - 170 382 - 170 - 140 chars = 697 701 713 797797 928

I'm sure there are many improvements to be made.

(This requires Nokogiri)

* latest version is untested but should work, will test when I get back home today

require'open-uri'
require'nokogiri'
x="/wiki/"+gets.chomp
r=[]
n=i=0
until x=~/\/Philosophy/
d=Nokogiri.HTML open"http://en.wikipedia.org#{x}"
x=d.css('p a').select{|a|t=a.xpath('preceding::text()').map(&:text)*'';t.count('(')==t.count(')')&&a.attr('href')=~/^\/wiki[^:]+$/}[i].attr'href'
i=0
puts r.index(x)?->{$><<'i=';i=gets$><<'i=';i=($*[0]||gets).to_i;''}[]: r.push(x)[-1][6..-1]
n+=1
end
p n

Example run:

c:\a\ruby>wikipedia_crawl_philosophy
Latin (note: this is my input)
Classical_antiquity
History
Umbrella_term
Terminology
Word
Linguistics
Science
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
18

Sample one where I had to go to second link

c:\a\ruby>wikipedia_crawl_philosophy
Snow
Precipitation_(meteorology)
Meteorology
Atmospheric_physics
Synoptic_scale_meteorology
i=1 // I put the 0-indexed number of the link I wanted to go to

i=1 // I think this is a bug :( no idea how to fix

Depression_(meteorology)
Atmospheric_pressure
Atmosphere_of_Earth
Gases
State_of_matter#The_four_fundamental_states
Physics
Natural_science
Sciences
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
25

Tricks I used:

  • I used the selector p a to only get non-italic links, because all links in the actual article that are not italics are always in paragraph elements in Wikipedia.

Ruby, 1000 - 303 299 337 - 50 373 - 170 chars = 697 701 713 797

I'm sure there are many improvements to be made.

(This requires Nokogiri)

require'open-uri'
require'nokogiri'
x="/wiki/"+gets.chomp
r=[]
n=i=0
until x=~/\/Philosophy/
d=Nokogiri.HTML open"http://en.wikipedia.org#{x}"
x=d.css('p a').select{|a|t=a.xpath('preceding::text()').map(&:text)*'';t.count('(')==t.count(')')&&a.attr('href')=~/^\/wiki[^:]+$/}[i].attr'href'
i=0
puts r.index(x)?->{$><<'i=';i=gets.to_i;''}[]: r.push(x)[-1][6..-1]
n+=1
end
p n

Example run:

c:\a\ruby>wikipedia_crawl_philosophy
Latin (note: this is my input)
Classical_antiquity
History
Umbrella_term
Terminology
Word
Linguistics
Science
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
18

Sample one where I had to go to second link

c:\a\ruby>wikipedia_crawl_philosophy
Snow
Precipitation_(meteorology)
Meteorology
Atmospheric_physics
Synoptic_scale_meteorology
i=1 // I put the 0-indexed number of the link I wanted to go to

i=1 // I think this is a bug :( no idea how to fix

Depression_(meteorology)
Atmospheric_pressure
Atmosphere_of_Earth
Gases
State_of_matter#The_four_fundamental_states
Physics
Natural_science
Sciences
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
25

Tricks I used:

  • I used the selector p a to only get non-italic links, because all links in the actual article that are not italics are always in paragraph elements in Wikipedia.

Ruby, 1000 - 303 299 337 - 50 373 - 170 382 - 170 - 140 chars = 697 701 713 797 928

I'm sure there are many improvements to be made.

(This requires Nokogiri)

* latest version is untested but should work, will test when I get back home today

require'open-uri'
require'nokogiri'
x="/wiki/"+gets.chomp
r=[]
n=i=0
until x=~/\/Philosophy/
d=Nokogiri.HTML open"http://en.wikipedia.org#{x}"
x=d.css('p a').select{|a|t=a.xpath('preceding::text()').map(&:text)*'';t.count('(')==t.count(')')&&a.attr('href')=~/^\/wiki[^:]+$/}[i].attr'href'
i=0
puts r.index(x)?->{$><<'i=';i=($*[0]||gets).to_i;''}[]: r.push(x)[-1][6..-1]
n+=1
end
p n

Example run:

c:\a\ruby>wikipedia_crawl_philosophy
Latin (note: this is my input)
Classical_antiquity
History
Umbrella_term
Terminology
Word
Linguistics
Science
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
18

Sample one where I had to go to second link

c:\a\ruby>wikipedia_crawl_philosophy
Snow
Precipitation_(meteorology)
Meteorology
Atmospheric_physics
Synoptic_scale_meteorology
i=1 // I put the 0-indexed number of the link I wanted to go to

i=1 // I think this is a bug :( no idea how to fix

Depression_(meteorology)
Atmospheric_pressure
Atmosphere_of_Earth
Gases
State_of_matter#The_four_fundamental_states
Physics
Natural_science
Sciences
Knowledge
Fact
Proof_(truth)
Argument
Logic
Reasoning
Consciousness
Quality_(philosophy)
Property_(philosophy)
Modern_philosophy
Philosophy
25

Tricks I used:

  • I used the selector p a to only get non-italic links, because all links in the actual article that are not italics are always in paragraph elements in Wikipedia.
4 added 806 characters in body
source | link
3 added 70 characters in body
source | link
2 added 18 characters in body
source | link
1
source | link