Skip to content

Commit fb62712

Browse files
committed
initial commit
0 parents  commit fb62712

File tree

5 files changed

+9956
-0
lines changed

5 files changed

+9956
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

Cargo.lock

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "bee"
3+
version = "0.1.0"
4+
edition = "2018"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]

src/main.rs

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
use std::error::Error;
2+
use std::fs::File;
3+
use std::io::BufReader;
4+
use std::io::prelude::*;
5+
use std::path::Path;
6+
use std::env;
7+
8+
type BitVector = u32;
9+
10+
11+
fn main() {
12+
let problem = ProblemStatement::new();
13+
println!("{}", problem.center);
14+
println!("{:?}", problem.others);
15+
}
16+
17+
struct ProblemStatement {
18+
pub center: u8,
19+
pub others: Vec<u8>,
20+
pub dictionary: Vec<String>
21+
}
22+
23+
impl ProblemStatement {
24+
pub fn new() -> ProblemStatement {
25+
let center = ProblemStatement::parse_center();
26+
let others = ProblemStatement::parse_others();
27+
let dictionary = ProblemStatement::parse_dictionary();
28+
ProblemStatement { center, others, dictionary }
29+
}
30+
31+
fn parse_center() -> u8 {
32+
let c = std::io::stdin().lock().lines().next().unwrap().unwrap();
33+
c.chars().next().unwrap() as u8
34+
}
35+
36+
fn parse_others() -> Vec<u8> {
37+
let o = std::io::stdin().lock().lines().next().unwrap().unwrap();
38+
o.chars().map(|c| c as u8).collect::<Vec<u8>>()
39+
}
40+
41+
fn parse_dictionary() -> Vec<String> {
42+
let file = File::open("words.txt").unwrap();
43+
let buffer = BufReader::new(file);
44+
buffer.lines().map(|l| l.unwrap()).collect::<Vec<String>>()
45+
}
46+
}

0 commit comments

Comments
 (0)