This commit is contained in:
2026-05-15 21:22:51 -04:00
parent 48dddc616b
commit af9208ef00
2 changed files with 32 additions and 17 deletions
+3 -3
View File
@@ -1,8 +1,8 @@
usage:
```
> solve 41/63 50/60 55/55 43/64 60/66 51/55 48/59 41/63
10: [Wood, Grains, String, String, Oil, Meat, Meat, Gem, Gem, Gem]
solve 41/63 50/60 55/55 43/64 60/66 51/55 48/59 41/63
> Wood:1, Grains:1, String:2, Oil:1, Meat:2, Gem:3 (10 total)
```
solves for the least number of materials needed given a priority
@@ -12,7 +12,7 @@ input is just the stats in order shown in wynncraft (limit/max)
dot `.` means it's maxed out already
```
> priority wood paper grains string oil meat
priority wood paper grains string oil meat
```
sets the material priority for solving (what to use and what to try first)
+29 -14
View File
@@ -1,6 +1,5 @@
mod data;
mod solve;
use std::io::Write;
pub use data::*;
pub use solve::*;
@@ -18,8 +17,6 @@ fn main() {
];
usage();
print_priority(&priority);
print!("> ");
let _ = std::io::stdout().flush();
let input = std::io::stdin();
for line in input.lines() {
let Ok(line) = line else {
@@ -38,8 +35,6 @@ fn main() {
usage();
}
}
print!("> ");
let _ = std::io::stdout().flush();
}
}
@@ -88,9 +83,8 @@ fn run_solve(args: &str, priority: &Priority) {
boost: attrs[6],
training: attrs[7],
};
println!("requirements: {mount:?}");
let res = solve(mount, priority);
println!("{}: {res:?}", res.len());
let mats = solve(mount, priority);
print_mats(&mats);
}
fn run_priority(args: &str, priority: &mut Priority) {
@@ -129,9 +123,11 @@ fn run_priority(args: &str, priority: &mut Priority) {
fn print_priority(priority: &Priority) {
println!("current priority:");
for (i, mat) in priority.iter().enumerate() {
println!(" {}: {mat:?}", i + 1);
print!(" ");
for mat in &priority[..priority.len() - 1] {
print!("{mat:?} -> ");
}
println!("{:?}", priority.last().unwrap());
}
fn validate_priority(priority: &Priority) -> bool {
@@ -145,12 +141,31 @@ fn validate_priority(priority: &Priority) -> bool {
}
fn usage() {
println!("usage:");
println!(" > solve 41/63 50/60 . 43/64 60/66 51/55 48/59 41/63");
println!("examples:");
println!(" solve 41/63 50/60 . 43/64 60/66 51/55 48/59 41/63");
println!(" > Wood:1, Grains:1, String:2, Oil:1, Meat:2, Gem:3 (10 total)");
println!(" solves for the least number of materials needed given a priority, eg:");
println!(" 10: [Wood, Grains, String, String, Oil, Meat, Meat, Gem, Gem, Gem]");
println!(" input is just the stats in order shown in wynncraft (limit/max)");
println!(" dot '.' means it's maxed out already");
println!(" > priority wood paper grains string oil meat");
println!(" priority wood paper grains string oil meat");
println!(" sets the material priority for solving (what to use and what to try first)");
}
fn print_mats(mats: &[Mat]) {
if mats.is_empty() {
return;
}
let mut count = 0;
let mut prev = mats[0];
for &mat in mats {
if mat == prev {
count += 1;
continue;
} else {
print!("{prev:?}:{count}, ");
count = 1;
}
prev = mat;
}
println!("{prev:?}:{count} ({} total)", mats.len());
}