fn parse_string_to_map(s: &str) -> HashMap<String, Vec<(i32, String)>> {
    let mut h = HashMap::new();
    let re = Regex::new(r"bags*\.*").unwrap();
    let re_count = Regex::new(r"(\d+) (.*)").unwrap();
    for line in s.split("\n") {
        let line_split: Vec<_> = line.split(" bags contain ").collect();
        let container = line_split[0];
        let v = h
            .entry(container.to_string())
            .or_insert(Vec::<(i32, String)>::new());
        for inner in line_split[1].split(", ") {
            let after = re.replace_all(inner, "");
            for cap in re_count.captures_iter(&after.trim()) {
                v.push((cap[1].parse::<i32>().unwrap(), cap[2].to_string()));
            }
        }
    }
    h
}
/// light red bags contain 1 bright white bag, 2 muted yellow bags.
/// dark orange bags contain 3 bright white bags, 4 muted yellow bags.
/// bright white bags contain 1 shiny gold bag.
/// muted yellow bags contain 2 shiny gold bags, 9 faded blue bags.
/// shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags.
/// dark olive bags contain 3 faded blue bags, 4 dotted black bags.
/// vibrant plum bags contain 5 faded blue bags, 6 dotted black bags.
/// faded blue bags contain no other bags.
/// dotted black bags contain no other bags.
///
/// {"light red": [("1", "bright white"), ("2", "muted yellow")],
///  "muted yellow": [("2", "shiny gold"), ("9", "faded blue")],
///  "bright white": [("1", "shiny gold")],
///  "dark olive": [("3", "faded blue"), ("4", "dotted black")],
///  "dotted black": [],
///  "vibrant plum": [("5", "faded blue"), ("6", "dotted black")],
///  "faded blue": [],
///  "dark orange": [("3", "bright white"), ("4", "muted yellow")],
///  "shiny gold": [("1", "dark olive"), ("2", "vibrant plum")]
/// }
light red bags contain 1 bright white bag, 2 muted yellow bags.
dark orange bags contain 3 bright white bags, 4 muted yellow bags.
bright white bags contain 1 shiny gold bag.
muted yellow bags contain 2 shiny gold bags, 9 faded blue bags.
shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags.
dark olive bags contain 3 faded blue bags, 4 dotted black bags.
vibrant plum bags contain 5 faded blue bags, 6 dotted black bags.
faded blue bags contain no other bags.
dotted black bags contain no other bags.


light red bags contain 1 bright white bag 2 muted yellow bags . dark orange bags contain 3 bright white bags 4 muted yellow bags . bright white bags contain 1 shiny gold bag . muted yellow bags contain 2 shiny gold bags 9 faded blue bags . shiny gold bags contain 1 dark olive bag 2 vibrant plum bags . dark olive bags contain 3 faded blue bags 4 dotted black bags . vibrant plum bags contain 5 faded blue bags 6 dotted black bags . faded blue bags contain no other bags . dotted black bags contain no other bags .
fn parse_string_to_map(s: &str) -> HashMap<String, Vec<(i32, String)>> {
    let mut h = HashMap::new();
    let re = Regex::new(r"bags*\.*").unwrap();
    let re_count = Regex::new(r"(\d+) (.*)").unwrap();
    for line in s.split("\n") {
        let line_split: Vec<_> = line.split(" bags contain ").collect();
        let container = line_split[0];
        let v = h
            .entry(container.to_string())
            .or_insert(Vec::<(i32, String)>::new());
        for inner in line_split[1].split(", ") {
            let after = re.replace_all(inner, "");
            for cap in re_count.captures_iter(&after.trim()) {
                v.push((cap[1].parse::<i32>().unwrap(), cap[2].to_string()));
            }
        }
    }
    h
}
fn parse_string_to_map ( s : & str ) -> HashMap < String , Vec < ( i32 , String ) > > { let mut h = HashMap :: new ( ) ; let re = Regex :: new ( r"bags*\.*" ) . unwrap ( ) ; let re_count = Regex :: new ( r"(\d+) (.*)" ) . unwrap ( ) ; for line in s . split ( " \n " ) { let line_split : Vec < _ > = line . split ( " " ) . collect ( ) ; let container = line_split [ 0 ] ; let v = h . entry ( container . to_string ( ) ) . or_insert ( Vec :: < ( i32 , String ) > :: new ( ) ) ; for inner in line_split [ 1 ] . split ( " " ) { let after = re . replace_all ( inner , " " ) ; for cap in re_count . captures_iter ( & after . trim ( ) ) { v . push ( ( cap [ 1 ] . parse :: < i32 > ( ) . unwrap ( ) , cap [ 2 ] . to_string ( ) ) ) ; } } } h }
light red bags contain 1 bright white bag, 2 muted yellow bags.
light red bags contain 1 bright white bag 2 muted yellow bags .
s
&str
s
&str