2 changed files with 37 additions and 0 deletions
@ -0,0 +1,36 @@
|
||||
use std::collections::HashSet; |
||||
|
||||
|
||||
const REQUEST_URL: &str = "http://www.pythonchallenge.com/pc/def/linkedlist.php"; |
||||
|
||||
|
||||
fn get_next_nothing(current_nothing: String) -> Result<String, reqwest::Error> |
||||
{ |
||||
let client = reqwest::blocking::Client::new(); |
||||
let resp = client.get(REQUEST_URL) |
||||
.query(&[("nothing", current_nothing)]) |
||||
.send()?; |
||||
|
||||
let body = resp.text()?; |
||||
let nothing = body.split_ascii_whitespace().last().unwrap(); |
||||
Ok(nothing.to_string()) |
||||
|
||||
} |
||||
|
||||
fn main() -> Result<(), reqwest::Error> { |
||||
|
||||
let mut nothings= HashSet::new(); |
||||
let mut current_nothing = String::from("12345"); |
||||
|
||||
|
||||
while !nothings.contains(¤t_nothing) |
||||
{ |
||||
nothings.insert(current_nothing.clone()); |
||||
current_nothing = get_next_nothing(current_nothing)?; |
||||
println!("Next nothing is: {}",current_nothing); |
||||
|
||||
} |
||||
|
||||
println!("{:?}", nothings); |
||||
Ok(()) |
||||
} |
||||
Loading…
Reference in new issue