Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if [ "$1" = -d ]
- then
- seconds=$2
- shift 2
- else
- seconds=
- fi
- problem=problem$1
- grep -F 'model name' /proc/cpuinfo | head -1 | cut -d: -f2
- if taskset -c 0 true 2>/dev/null
- then
- cmd='taskset -c 0 python2.7'
- else
- cmd=python2.7
- fi
- exec $cmd -O -c "
- import sys, eulerlib, $problem
- $problem.eulerlib= eulerlib
- try:
- test_argument, test_result= $problem.__test__
- except AttributeError:
- print 'No test data.'
- success= True
- else:
- test_run_result= $problem.main(test_argument)
- print 'Expected', test_result, 'got', test_run_result
- if test_run_result == test_result:
- print 'No test data.'
- success= True
- else:
- test_run_result= $problem.main(test_argument)
- print 'Expected', test_result, 'got', test_run_result
- if test_run_result == test_result:
- print 'Test succeeds, proceeding with run.'
- success= True
- else:
- print 'Test fails!'
- success= False
- if success:
- time0= eulerlib.cpu_used()
- result= Ellipsis
- eulerlib.only_one_minute($seconds)
- try:
- result= $problem.main()
- except SystemExit:
- pass
- except KeyboardInterrupt:
- print 'Interrupted'
- except MemoryError:
- print 'Memory error'
- else:
- print 'Answer to Project Euler problem $1:', result
- time1= eulerlib.cpu_used()
- print 'Time used:', time1 - time0, 'seconds'"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement