88import typing as t
99from collections import defaultdict
1010from copy import deepcopy
11- from datetime import timedelta
11+ from datetime import timedelta , datetime
1212from operator import itemgetter
1313from pathlib import Path
1414from zlib import crc32
4141INTERPRETERS = {
4242 "Python" : {
4343 "Python" : "python3" ,
44- "PyPy" : ".pypy3.10/bin/python" ,
45- "Py3.10" : ".py3.10/bin/python" ,
46- "Py3.11" : ".py3.11/bin/python" ,
47- "Py3.12" : ".py3.12/bin/python" ,
48- "Py3.13" : ".py3.13/bin/python" ,
44+ "PyPy" : ".venv/ pypy3.10/bin/python" ,
45+ "Py3.10" : ".venv/ py3.10/bin/python" ,
46+ "Py3.11" : ".venv/ py3.11/bin/python" ,
47+ "Py3.12" : ".venv/ py3.12/bin/python" ,
48+ "Py3.13" : ".venv/ py3.13/bin/python" ,
4949 }
5050}
5151
@@ -154,12 +154,12 @@ def run(
154154 start = time .time_ns ()
155155 out = subprocess .run (cmd + [file .absolute ()], stdout = subprocess .PIPE )
156156 elapsed = time .time_ns () - start
157- answers = out .stdout .decode ().strip ()
157+ answers = " " . join ( out .stdout .decode ().strip (). split ( " \n " ) )
158158
159159 status = "unknown"
160160 if solution :
161- solution = solution .read_text ()
162- if answers == solution . strip () :
161+ solution = " " . join ( solution .read_text (). strip (). split ( " \n " ) )
162+ if answers == solution :
163163 status = "ok"
164164 else :
165165 status = "error"
@@ -169,7 +169,13 @@ def run(
169169 else :
170170 status = "unknown"
171171
172- return {"elapsed" : elapsed , "status" : status , "answers" : answers }
172+ result = {"elapsed" : elapsed , "status" : status , "answers" : answers }
173+
174+ with Path ("run.log" ).open ("at" ) as f :
175+ line = f"{ datetime .now ()} { lang } { cmd } { file .absolute ()} { elapsed } { status } '{ solution or '' } ' '{ answers } '"
176+ print (line , file = f )
177+
178+ return result
173179
174180
175181def make (year : Path , source : Path , dest : Path , cmd : str ):
@@ -314,7 +320,7 @@ def run_day(
314320
315321 status_color = {"missing" : MAGENTA , "unknown" : GRAY , "error" : RED , "ok" : GREEN }[e ["status" ]]
316322
317- answers = e ["answers" ]. split ( " \n " )
323+ answers = e ["answers" ]
318324
319325 line = (
320326 f"{ CR } { RESET } { CLEAR_EOL } "
@@ -334,7 +340,7 @@ def run_day(
334340 if not in_cache and e ["elapsed" ] / 1e9 > 5 :
335341 save_cache ()
336342
337- results .add (" " . join ( answers ) )
343+ results .add (answers )
338344
339345 elapsed [lang ].append (e ["elapsed" ] / 1e9 )
340346
@@ -389,7 +395,7 @@ def install_venv(interpreter: Path):
389395
390396 slug = subprocess .check_output ([interpreter , "-c" , slug ]).decode ().strip ()
391397
392- venv = "." + slug .lower ()
398+ venv = f".venv/ { slug .lower ()} "
393399
394400 # subprocess.check_call([interpreter, "-mensurepip"])
395401 subprocess .check_output ([interpreter , "-mvenv" , venv ])
0 commit comments