@@ -7,11 +7,14 @@ use std::io::Write;
77use icfpc:: models:: * ;
88use icfpc:: parse:: read_all_inputs;
99use icfpc:: solve:: solve_small_while;
10+ use icfpc:: solve:: determine_buy;
1011use std:: time:: Duration ;
1112
12- fn solve < W : Write > ( task : Task , f : & mut W , duration : Duration ) {
13- let cmds = solve_small_while ( task, duration) ;
13+ fn solve < W : Write > ( task : Task , f : & mut W , b : & mut W , duration : Duration ) {
14+ let buy = determine_buy ( & task) ;
15+ let cmds = solve_small_while ( task, & buy, duration) ;
1416 write ! ( f, "{}" , cmds) . unwrap ( ) ;
17+ write ! ( b, "{}" , buy) . unwrap ( ) ;
1518}
1619
1720fn main ( ) {
@@ -49,15 +52,17 @@ fn main() {
4952 let inputs = read_all_inputs ( & input_root) ;
5053 let progress_bar = ProgressBar :: new ( inputs. len ( ) as u64 ) ;
5154 inputs. into_par_iter ( ) . for_each ( |input| {
52- let mut output_file: Box < dyn Write > = match output_root {
55+ let ( mut output_file, mut buy_file ) : ( Box < dyn Write > , Box < dyn Write > ) = match output_root {
5356 Some ( output_root) => {
5457 let output_path = format ! ( "{}/{}" , output_root, input. output_file_name( ) ) ;
5558 let output_file = File :: create ( & output_path) . unwrap ( ) ;
56- Box :: new ( output_file)
59+ let buy_path = format ! ( "{}/{}" , output_root, input. buy_file_name( ) ) ;
60+ let buy_file = File :: create ( & buy_path) . unwrap ( ) ;
61+ ( Box :: new ( output_file) , Box :: new ( buy_file) )
5762 }
58- None => Box :: new ( std:: io:: stdout ( ) ) ,
63+ None => ( Box :: new ( std:: io:: stdout ( ) ) , Box :: new ( std :: io :: sink ( ) ) ) ,
5964 } ;
60- solve ( input. task , & mut output_file, duration) ;
65+ solve ( input. task , & mut output_file, & mut buy_file , duration) ;
6166 progress_bar. inc ( 1 ) ;
6267 } ) ;
6368 progress_bar. finish ( ) ;
0 commit comments