File tree Expand file tree Collapse file tree 1 file changed +6
-14
lines changed Expand file tree Collapse file tree 1 file changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -163,20 +163,12 @@ fn generate_random_id(except_ids: &[u32]) -> u32 {
163163}
164164
165165fn get_solved_ids ( ) -> Vec < u32 > {
166- let paths = fs:: read_dir ( "./src/problem" ) . unwrap ( ) ;
167- let mut solved_ids = Vec :: new ( ) ;
168-
169- for path in paths {
170- let path = path. unwrap ( ) . path ( ) ;
171- let s = path. to_str ( ) . unwrap ( ) ;
172- if !s. starts_with ( 'n' ) {
173- continue ;
174- }
175- let id = & s[ 7 ..11 ] ;
176- let id = id. parse :: < u32 > ( ) . unwrap ( ) ;
177- solved_ids. push ( id) ;
178- }
179- solved_ids
166+ let content = fs:: read_to_string ( "./src/problem/mod.rs" ) . unwrap ( ) ;
167+ let id_pattern = Regex :: new ( r"p(\d{4})_" ) . unwrap ( ) ;
168+ id_pattern
169+ . captures_iter ( & content)
170+ . map ( |x| x. get ( 1 ) . unwrap ( ) . as_str ( ) . parse ( ) . unwrap ( ) )
171+ . collect ( )
180172}
181173
182174fn parse_extra_use ( code : & str ) -> String {
You can’t perform that action at this time.
0 commit comments