Skip to content

Commit

Permalink
Cleans up Rust 022
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankKair committed Oct 24, 2018
1 parent b7ad8f1 commit 92f7d39
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/022/p022.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ use std::fs::File;
use std::io::Read;

fn solve() -> i32 {
let filename = "p022_names.txt";
let mut file = File::open(filename).expect("File not found.");
let mut contents = String::new();
file.read_to_string(&mut contents).expect("Error reading file.");
File::open("p022_names.txt")
.expect("File not found")
.read_to_string(&mut contents)
.expect("Error reading");

let filtered_name_list = contents.replace("\"", " ").replace(" ", "");
let mut names = filtered_name_list.split(',').collect::<Vec<&str>>();
let filtered = contents.replace("\"", " ").replace(" ", "");
let mut names = filtered.split(',').collect::<Vec<&str>>();
names.sort();

names
Expand Down

0 comments on commit 92f7d39

Please sign in to comment.