use crate::Solution;
problem!(Problem0099, 99, "Largest Exponential");
impl Solution for Problem0099 {
fn solve(&self) -> String {
const INPUT: &str = include_str!("0099_base_exp.txt");
let base_exp_pairs = INPUT
.trim()
.lines()
.map(|line| {
let mut line_iter = line
.trim()
.split(',')
.map(|num_str| num_str.parse::<u32>().unwrap());
(line_iter.next().unwrap(), line_iter.next().unwrap())
})
.collect::<Vec<(u32, u32)>>();
let mut max_log = f64::NEG_INFINITY;
let mut max_ind = 0;
for (i, (base, exp)) in base_exp_pairs.into_iter().enumerate() {
let logarithm = (exp as f64) * (base as f64).log2();
if logarithm > max_log {
max_log = logarithm;
max_ind = i + 1;
}
}
max_ind.to_string()
}
}