Skip to content

Commit

Permalink
Made project more friendly to non-linux peeps
Browse files Browse the repository at this point in the history
  • Loading branch information
TedBrookings committed Feb 13, 2017
1 parent 33fbc76 commit 1a24b3c
Show file tree
Hide file tree
Showing 46 changed files with 15 additions and 17 deletions.
6 changes: 1 addition & 5 deletions ToDo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,5 @@ Do more problems

Make all euler functions return answer so that verified answers can be used in
unit tests
-Need to rename problem files to start with a letter, since python has
trouble importing files whose name starts with a number

Make all problem files use argparse to pass arguments

In the future, always unit tests first
Make all problem files use argparse to pass arguments
Empty file added __init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 14 additions & 12 deletions euler.py → run_euler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import os
import time
import euler
import pkgutil


_colors = {
Expand Down Expand Up @@ -40,18 +42,18 @@ def isEulerFile(f):


def runAllEuler(eulerDir, exeColor='boldYellow', scriptColor='white'):
dirList = os.listdir(eulerDir)
dirList.sort()
timeCmd = '/usr/bin/time -f "\tElapsedTime: %U"'
for f in dirList:
if isEulerFile(f):
# execute the script
print(_colors[exeColor] + 'executing %s' % f + _colors[scriptColor])
os.system(timeCmd + ' ' + os.path.join(eulerDir, f))
print(_colors['endColor'])


for importer, moduleName, ispackage in pkgutil.iter_modules(euler.__path__):
if not moduleName.startswith('euler'):
continue
print(_colors[exeColor] + 'executing %s' % moduleName + _colors[scriptColor])
funcName = 'euler' + str( int( moduleName[-3:]))
module = importer.find_module(moduleName).load_module(moduleName)
func = getattr( module, funcName )
startTime = time.time()
func()
endTime = time.time()
print( 'Completed in %.1f seconds' % (endTime - startTime) )
print(_colors['endColor'])


if __name__ == "__main__":
Expand Down

0 comments on commit 1a24b3c

Please sign in to comment.