diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..055a55f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,35 @@ +language: python +python: + - "3.5" +install: + - sudo apt-get update + - sudo apt-get -y install libblas-dev liblapack-dev libatlas-base-dev gfortran + # We do this conditionally because it saves us some downloading if the + # version is the same. + - if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then + wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh; + else + wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; + fi + - bash miniconda.sh -b -p $HOME/miniconda + - export PATH="$HOME/miniconda/bin:$PATH" + - hash -r + - conda config --set always_yes yes --set changeps1 no + - conda update -q conda + # Useful for debugging any issues with conda + - conda info -a + + - conda create -q -n test-dmwp python=$TRAVIS_PYTHON_VERSION sympy matplotlib + - source activate test-dmwp + - conda install -c https://conda.anaconda.org/amitsaha matplotlib-venn + +# whitelist +branches: + only: + - automated_run +before_script: + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" + - sleep 3 # give xvfb some time to start +script: + - ./run.bash diff --git a/README.md b/README.md index d56d970..8f55cc7 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/doingmathwithpython/code.svg?branch=automated_run)](https://travis-ci.org/doingmathwithpython/code) + # Chapter programs and solutions Chapter programs/snippets and Solutions to Challenges for "Doing Math with Python". diff --git a/chapter1/solutions/inputs/enhanced_mult_table.input b/chapter1/solutions/inputs/enhanced_mult_table.input new file mode 100644 index 0000000..c47213d --- /dev/null +++ b/chapter1/solutions/inputs/enhanced_mult_table.input @@ -0,0 +1,3 @@ +1 +2 + diff --git a/chapter1/solutions/inputs/enhanced_unit_converter.input b/chapter1/solutions/inputs/enhanced_unit_converter.input new file mode 100644 index 0000000..ecf479b --- /dev/null +++ b/chapter1/solutions/inputs/enhanced_unit_converter.input @@ -0,0 +1,2 @@ +2 +1.6 diff --git a/chapter1/solutions/inputs/enhanced_unit_converter_exit_power.input b/chapter1/solutions/inputs/enhanced_unit_converter_exit_power.input new file mode 100644 index 0000000..313da04 --- /dev/null +++ b/chapter1/solutions/inputs/enhanced_unit_converter_exit_power.input @@ -0,0 +1,7 @@ +1 +2 +n +2 +2 +y + diff --git a/chapter1/solutions/inputs/even_odd_vending.input b/chapter1/solutions/inputs/even_odd_vending.input new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/chapter1/solutions/inputs/even_odd_vending.input @@ -0,0 +1 @@ +3 diff --git a/chapter1/solutions/inputs/fractions_operations.input b/chapter1/solutions/inputs/fractions_operations.input new file mode 100644 index 0000000..9dede25 --- /dev/null +++ b/chapter1/solutions/inputs/fractions_operations.input @@ -0,0 +1,3 @@ +1/2 +3/4 +Add diff --git a/chapter1/solutions/inputs/fractions_operations_exit_power.input b/chapter1/solutions/inputs/fractions_operations_exit_power.input new file mode 100644 index 0000000..2dfa9eb --- /dev/null +++ b/chapter1/solutions/inputs/fractions_operations_exit_power.input @@ -0,0 +1,8 @@ +1/2 +3/4 +Add +n +2/3 +1/2 +Multiply +y diff --git a/chapter1/solutions/inputs/mult_table_exit_power.input b/chapter1/solutions/inputs/mult_table_exit_power.input new file mode 100644 index 0000000..09b8f20 --- /dev/null +++ b/chapter1/solutions/inputs/mult_table_exit_power.input @@ -0,0 +1,4 @@ +3 +n +4.5 +y diff --git a/chapter1/solutions/run.bash b/chapter1/solutions/run.bash new file mode 100755 index 0000000..9e22733 --- /dev/null +++ b/chapter1/solutions/run.bash @@ -0,0 +1,12 @@ +#!/bin/bash + +for file in `ls *.py`; do + filename=$(basename $file) + filename="${filename%.*}" + python3 $filename.py < inputs/$filename.input + + if [[ $? != 0 ]]; then + echo "Something failed" + exit 1 + fi +done diff --git a/chapter2/solutions/expenditures_barchar.png b/chapter2/solutions/expenditures_barchar.png new file mode 100644 index 0000000..1c33b52 Binary files /dev/null and b/chapter2/solutions/expenditures_barchar.png differ diff --git a/chapter2/solutions/expenditures_barchart.py b/chapter2/solutions/expenditures_barchart.py index 54a8817..9b84420 100644 --- a/chapter2/solutions/expenditures_barchart.py +++ b/chapter2/solutions/expenditures_barchart.py @@ -20,7 +20,8 @@ def create_bar_chart(data, labels): plt.title('Weekly expenditures') # Turns on the grid which may assist in visual estimation plt.grid() - plt.show() + #plt.show() + plt.savefig('expenditures_barchar.png') if __name__ == '__main__': n = int(input('Enter the number of categories: ')) diff --git a/chapter2/solutions/fibonacci_goldenratio.png b/chapter2/solutions/fibonacci_goldenratio.png new file mode 100644 index 0000000..c4556b2 Binary files /dev/null and b/chapter2/solutions/fibonacci_goldenratio.png differ diff --git a/chapter2/solutions/fibonacci_goldenratio.py b/chapter2/solutions/fibonacci_goldenratio.py index e3aab04..994056b 100644 --- a/chapter2/solutions/fibonacci_goldenratio.py +++ b/chapter2/solutions/fibonacci_goldenratio.py @@ -32,7 +32,8 @@ def plot_ratio(series): plt.title('Ratio between Fibonacci numbers & Golden ratio') plt.ylabel('Ratio') plt.xlabel('No.') - plt.show() + #plt.show() + plt.savefig('fibonacci_goldenratio.png') if __name__ == '__main__': # Number of fibonacci numbers diff --git a/chapter2/solutions/inputs/expenditures_barchart.input b/chapter2/solutions/inputs/expenditures_barchart.input new file mode 100644 index 0000000..3e787f0 --- /dev/null +++ b/chapter2/solutions/inputs/expenditures_barchart.input @@ -0,0 +1,7 @@ +3 +Phone +20 +Food +50 +Travel +30 diff --git a/chapter2/solutions/inputs/fibonacci_goldenratio.input b/chapter2/solutions/inputs/fibonacci_goldenratio.input new file mode 100644 index 0000000..e69de29 diff --git a/chapter2/solutions/inputs/nyc_forecast_basic.input b/chapter2/solutions/inputs/nyc_forecast_basic.input new file mode 100644 index 0000000..e69de29 diff --git a/chapter2/solutions/inputs/projectile_comparison_gen.input b/chapter2/solutions/inputs/projectile_comparison_gen.input new file mode 100644 index 0000000..20ba979 --- /dev/null +++ b/chapter2/solutions/inputs/projectile_comparison_gen.input @@ -0,0 +1,7 @@ +3 +25 +60 +30 +60 +70 +40 diff --git a/chapter2/solutions/inputs/quad_function_plot.input b/chapter2/solutions/inputs/quad_function_plot.input new file mode 100644 index 0000000..e69de29 diff --git a/chapter2/solutions/nyc_forecase_basic.png b/chapter2/solutions/nyc_forecase_basic.png new file mode 100644 index 0000000..f8daca3 Binary files /dev/null and b/chapter2/solutions/nyc_forecase_basic.png differ diff --git a/chapter2/solutions/nyc_forecast_basic.py b/chapter2/solutions/nyc_forecast_basic.py index d773f04..a92f5cc 100644 --- a/chapter2/solutions/nyc_forecast_basic.py +++ b/chapter2/solutions/nyc_forecast_basic.py @@ -13,7 +13,8 @@ def plot_forecast(): plt.plot(time_interval, forecast_temp, 'o-') plt.xticks(time_interval, time_of_day) - plt.show() + #plt.show() + plt.savefig('nyc_forecase_basic.png') if __name__ == '__main__': plot_forecast() diff --git a/chapter2/solutions/nyc_forecast_owm.py b/chapter2/solutions/nyc_forecast_owm.py.later similarity index 100% rename from chapter2/solutions/nyc_forecast_owm.py rename to chapter2/solutions/nyc_forecast_owm.py.later diff --git a/chapter2/solutions/projectile_comparison_gen.png b/chapter2/solutions/projectile_comparison_gen.png new file mode 100644 index 0000000..b909e39 Binary files /dev/null and b/chapter2/solutions/projectile_comparison_gen.png differ diff --git a/chapter2/solutions/projectile_comparison_gen.py b/chapter2/solutions/projectile_comparison_gen.py index 2205d67..23fedda 100644 --- a/chapter2/solutions/projectile_comparison_gen.py +++ b/chapter2/solutions/projectile_comparison_gen.py @@ -66,4 +66,5 @@ def draw_trajectory(u, theta, t_flight): for i in range(0, num_trajectories): legends.append('{0} - {1}'.format(velocities[i], math.degrees(angles[i]))) plt.legend(legends) - plt.show() + #plt.show() + plt.savefig('projectile_comparison_gen.png') diff --git a/chapter2/solutions/quad_function_plot.png b/chapter2/solutions/quad_function_plot.png new file mode 100644 index 0000000..765d721 Binary files /dev/null and b/chapter2/solutions/quad_function_plot.png differ diff --git a/chapter2/solutions/quad_function_plot.py b/chapter2/solutions/quad_function_plot.py index 18b191e..a17ce46 100644 --- a/chapter2/solutions/quad_function_plot.py +++ b/chapter2/solutions/quad_function_plot.py @@ -8,8 +8,9 @@ def draw_graph(x, y): plt.plot(x, y) - plt.show() - + #plt.show() + plt.savefig('quad_function_plot.png') + if __name__ == '__main__': # assume values of x x_values = range(-100, 100, 20) diff --git a/chapter2/solutions/run.bash b/chapter2/solutions/run.bash new file mode 100755 index 0000000..9e22733 --- /dev/null +++ b/chapter2/solutions/run.bash @@ -0,0 +1,12 @@ +#!/bin/bash + +for file in `ls *.py`; do + filename=$(basename $file) + filename="${filename%.*}" + python3 $filename.py < inputs/$filename.input + + if [[ $? != 0 ]]; then + echo "Something failed" + exit 1 + fi +done diff --git a/chapter3/solutions/inputs/grouped_frequency.input b/chapter3/solutions/inputs/grouped_frequency.input new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/chapter3/solutions/inputs/grouped_frequency.input @@ -0,0 +1 @@ +5 diff --git a/chapter3/solutions/inputs/linear_correlation_enhanced.input b/chapter3/solutions/inputs/linear_correlation_enhanced.input new file mode 100644 index 0000000..e69de29 diff --git a/chapter3/solutions/inputs/percentile_score.input b/chapter3/solutions/inputs/percentile_score.input new file mode 100644 index 0000000..6529ff8 --- /dev/null +++ b/chapter3/solutions/inputs/percentile_score.input @@ -0,0 +1 @@ +98 diff --git a/chapter3/solutions/inputs/percentile_score_microsoft_excel.input b/chapter3/solutions/inputs/percentile_score_microsoft_excel.input new file mode 100644 index 0000000..3ad5abd --- /dev/null +++ b/chapter3/solutions/inputs/percentile_score_microsoft_excel.input @@ -0,0 +1 @@ +99 diff --git a/chapter3/solutions/inputs/statistics_calculator.input b/chapter3/solutions/inputs/statistics_calculator.input new file mode 100644 index 0000000..e69de29 diff --git a/chapter3/solutions/inputs/stats.input b/chapter3/solutions/inputs/stats.input new file mode 100644 index 0000000..e69de29 diff --git a/chapter3/solutions/inputs/us_population_stats.input b/chapter3/solutions/inputs/us_population_stats.input new file mode 100644 index 0000000..e69de29 diff --git a/chapter3/solutions/run.bash b/chapter3/solutions/run.bash new file mode 100755 index 0000000..9e22733 --- /dev/null +++ b/chapter3/solutions/run.bash @@ -0,0 +1,12 @@ +#!/bin/bash + +for file in `ls *.py`; do + filename=$(basename $file) + filename="${filename%.*}" + python3 $filename.py < inputs/$filename.input + + if [[ $? != 0 ]]; then + echo "Something failed" + exit 1 + fi +done diff --git a/chapter3/solutions/us_population_stats.png b/chapter3/solutions/us_population_stats.png new file mode 100644 index 0000000..e0af2a4 Binary files /dev/null and b/chapter3/solutions/us_population_stats.png differ diff --git a/chapter3/solutions/us_population_stats.py b/chapter3/solutions/us_population_stats.py index bd50abf..e2a1682 100644 --- a/chapter3/solutions/us_population_stats.py +++ b/chapter3/solutions/us_population_stats.py @@ -73,4 +73,5 @@ def plot_population_diff(growth, years): plot_population(population, years) growth = calculate_stats(population) plot_population_diff(growth, years) - plt.show() + #plt.show() + plt.savefig('us_population_stats.png') diff --git a/chapter4/solutions/graphic_eq_solve.py b/chapter4/solutions/graphic_eq_solve.py index fd7709c..b7f5c53 100644 --- a/chapter4/solutions/graphic_eq_solve.py +++ b/chapter4/solutions/graphic_eq_solve.py @@ -18,7 +18,7 @@ def solve_plot_equations(eq1, eq2, x, y): # Plot eq1_y = solve(eq1,'y')[0] eq2_y = solve(eq2, 'y')[0] - plot(eq1_y, eq2_y, legend=True) + plot(eq1_y, eq2_y, legend=True, show=False) @@ -38,7 +38,7 @@ def solve_plot_equations(eq1, eq2, x, y): # check if the expressions consist of only two variables eq1_symbols = eq1.atoms(Symbol) eq2_symbols = eq2.atoms(Symbol) - + if len(eq1_symbols)> 2 or len(eq2_symbols) > 2: print('The equations must have only two variables - x and y') elif x not in eq1_symbols or y not in eq1_symbols: diff --git a/chapter4/solutions/inputs/factorizer.input b/chapter4/solutions/inputs/factorizer.input new file mode 100644 index 0000000..4414d9e --- /dev/null +++ b/chapter4/solutions/inputs/factorizer.input @@ -0,0 +1 @@ +x**2 + 4*x + 2 diff --git a/chapter4/solutions/inputs/graphic_eq_solve.input b/chapter4/solutions/inputs/graphic_eq_solve.input new file mode 100644 index 0000000..ab7c046 --- /dev/null +++ b/chapter4/solutions/inputs/graphic_eq_solve.input @@ -0,0 +1,2 @@ +2*x**2 + 3*y + 1 +3*x + 2*y + 1 diff --git a/chapter4/solutions/inputs/isolve.input b/chapter4/solutions/inputs/isolve.input new file mode 100644 index 0000000..f6be16b --- /dev/null +++ b/chapter4/solutions/inputs/isolve.input @@ -0,0 +1 @@ +2*x + 3 > 4 diff --git a/chapter4/solutions/inputs/series_summation.input b/chapter4/solutions/inputs/series_summation.input new file mode 100644 index 0000000..5bc1303 --- /dev/null +++ b/chapter4/solutions/inputs/series_summation.input @@ -0,0 +1,2 @@ +a+(n-1)*d +10 diff --git a/chapter4/solutions/run.bash b/chapter4/solutions/run.bash new file mode 100755 index 0000000..9e22733 --- /dev/null +++ b/chapter4/solutions/run.bash @@ -0,0 +1,12 @@ +#!/bin/bash + +for file in `ls *.py`; do + filename=$(basename $file) + filename="${filename%.*}" + python3 $filename.py < inputs/$filename.input + + if [[ $? != 0 ]]; then + echo "Something failed" + exit 1 + fi +done diff --git a/chapter5/solutions/inputs/estimate_circle_area.input b/chapter5/solutions/inputs/estimate_circle_area.input new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/chapter5/solutions/inputs/estimate_circle_area.input @@ -0,0 +1 @@ +2 diff --git a/chapter5/solutions/inputs/estimate_pi.input b/chapter5/solutions/inputs/estimate_pi.input new file mode 100644 index 0000000..e69de29 diff --git a/chapter5/solutions/inputs/game_tosses.input b/chapter5/solutions/inputs/game_tosses.input new file mode 100644 index 0000000..29d6383 --- /dev/null +++ b/chapter5/solutions/inputs/game_tosses.input @@ -0,0 +1 @@ +100 diff --git a/chapter5/solutions/inputs/law_ln.input b/chapter5/solutions/inputs/law_ln.input new file mode 100644 index 0000000..e69de29 diff --git a/chapter5/solutions/inputs/shuffle_enhanced.input b/chapter5/solutions/inputs/shuffle_enhanced.input new file mode 100644 index 0000000..e69de29 diff --git a/chapter5/solutions/inputs/venn_sports.input b/chapter5/solutions/inputs/venn_sports.input new file mode 100644 index 0000000..e69de29 diff --git a/chapter5/solutions/run.bash b/chapter5/solutions/run.bash new file mode 100755 index 0000000..9e22733 --- /dev/null +++ b/chapter5/solutions/run.bash @@ -0,0 +1,12 @@ +#!/bin/bash + +for file in `ls *.py`; do + filename=$(basename $file) + filename="${filename%.*}" + python3 $filename.py < inputs/$filename.input + + if [[ $? != 0 ]]; then + echo "Something failed" + exit 1 + fi +done diff --git a/chapter5/solutions/venn_sports.png b/chapter5/solutions/venn_sports.png new file mode 100644 index 0000000..0573988 Binary files /dev/null and b/chapter5/solutions/venn_sports.png differ diff --git a/chapter5/solutions/venn_sports.py b/chapter5/solutions/venn_sports.py index d2af87f..3b1416f 100644 --- a/chapter5/solutions/venn_sports.py +++ b/chapter5/solutions/venn_sports.py @@ -28,7 +28,8 @@ def read_csv(filename): def draw_venn(f, o): venn2(subsets=(f, o), set_labels=('Football', 'Others')) - plt.show() + #plt.show() + plt.savefig('venn_sports.png') if __name__ == '__main__': football, others = read_csv('sports.csv') diff --git a/chapter6/solutions/circle_in_square.png b/chapter6/solutions/circle_in_square.png new file mode 100644 index 0000000..5d04e92 Binary files /dev/null and b/chapter6/solutions/circle_in_square.png differ diff --git a/chapter6/solutions/circle_in_square.py b/chapter6/solutions/circle_in_square.py index 24d52e9..45b7275 100644 --- a/chapter6/solutions/circle_in_square.py +++ b/chapter6/solutions/circle_in_square.py @@ -30,4 +30,5 @@ def draw_circle(x, y): y += 1.0 plt.axis('scaled') - plt.show() + #plt.show() + plt.savefig('circle_in_square.png') diff --git a/chapter6/solutions/henon.png b/chapter6/solutions/henon.png new file mode 100644 index 0000000..fa66a2d Binary files /dev/null and b/chapter6/solutions/henon.png differ diff --git a/chapter6/solutions/henon.py b/chapter6/solutions/henon.py index 7e44a08..bb858d3 100644 --- a/chapter6/solutions/henon.py +++ b/chapter6/solutions/henon.py @@ -22,4 +22,5 @@ def transform(p): x.append(p[0]) y.append(p[1]) plt.plot(x, y, 'o') - plt.show() + #plt.show() + plt.savefig('henon.png') diff --git a/chapter6/solutions/henon_animation.py b/chapter6/solutions/henon_animation.py index 179c8b4..4a782cc 100644 --- a/chapter6/solutions/henon_animation.py +++ b/chapter6/solutions/henon_animation.py @@ -37,4 +37,4 @@ def update_points(i, x, y, plot): frames = len(x), interval = 25) plt.title('Henon Function Animation') - plt.show() + #plt.show() diff --git a/chapter6/solutions/inputs/circle_in_square.input b/chapter6/solutions/inputs/circle_in_square.input new file mode 100644 index 0000000..e69de29 diff --git a/chapter6/solutions/inputs/henon.input b/chapter6/solutions/inputs/henon.input new file mode 100644 index 0000000..e69de29 diff --git a/chapter6/solutions/inputs/henon_animation.input b/chapter6/solutions/inputs/henon_animation.input new file mode 100644 index 0000000..e69de29 diff --git a/chapter6/solutions/inputs/mandelbrot.input b/chapter6/solutions/inputs/mandelbrot.input new file mode 100644 index 0000000..e69de29 diff --git a/chapter6/solutions/inputs/sierpinski.input b/chapter6/solutions/inputs/sierpinski.input new file mode 100644 index 0000000..5caff40 --- /dev/null +++ b/chapter6/solutions/inputs/sierpinski.input @@ -0,0 +1 @@ +10000 diff --git a/chapter6/solutions/mandelbrot.py b/chapter6/solutions/mandelbrot.py index 4f7c890..8ffa5a9 100644 --- a/chapter6/solutions/mandelbrot.py +++ b/chapter6/solutions/mandelbrot.py @@ -56,4 +56,6 @@ def mandelbrot_set(): image = mandelbrot_set() plt.imshow(image, origin='lower', extent=(x0, x1, y0,y1), cmap=cm.Greys_r, interpolation='nearest') - plt.show() + #plt.show() + plt.savefig('mandelbrot.png') + diff --git a/chapter6/solutions/run.bash b/chapter6/solutions/run.bash new file mode 100755 index 0000000..9e22733 --- /dev/null +++ b/chapter6/solutions/run.bash @@ -0,0 +1,12 @@ +#!/bin/bash + +for file in `ls *.py`; do + filename=$(basename $file) + filename="${filename%.*}" + python3 $filename.py < inputs/$filename.input + + if [[ $? != 0 ]]; then + echo "Something failed" + exit 1 + fi +done diff --git a/chapter6/solutions/sierpinski.png b/chapter6/solutions/sierpinski.png new file mode 100644 index 0000000..6e9196f Binary files /dev/null and b/chapter6/solutions/sierpinski.png differ diff --git a/chapter6/solutions/sierpinski.py b/chapter6/solutions/sierpinski.py index f524f96..243de8d 100644 --- a/chapter6/solutions/sierpinski.py +++ b/chapter6/solutions/sierpinski.py @@ -68,4 +68,4 @@ def draw_sierpinski(n): # Plot the points plt.plot(x, y, 'o') plt.title('Sierpinski with {0} points'.format(n)) - plt.show() + plt.savefig('sierpinski.png') diff --git a/chapter7/solutions/grad_descent.png b/chapter7/solutions/grad_descent.png index fea87fb..1b0cda3 100644 Binary files a/chapter7/solutions/grad_descent.png and b/chapter7/solutions/grad_descent.png differ diff --git a/chapter7/solutions/grad_descent.py b/chapter7/solutions/grad_descent.py index 406da53..c70e29d 100644 --- a/chapter7/solutions/grad_descent.py +++ b/chapter7/solutions/grad_descent.py @@ -48,7 +48,8 @@ def create_plot(X_traversed, f, var): f_traversed = [f.subs({var:x}) for x in X_traversed] plt.plot(X_traversed, f_traversed, 'r.') plt.legend(['Function', 'Intermediate points'], loc='best') - plt.show() + #plt.show() + plt.savefig('grad_descent.png') if __name__ == '__main__': diff --git a/chapter7/solutions/inputs/area_curves.input b/chapter7/solutions/inputs/area_curves.input new file mode 100644 index 0000000..081f0ae --- /dev/null +++ b/chapter7/solutions/inputs/area_curves.input @@ -0,0 +1,5 @@ +2*x+1 +3*x**2 +x +0 +2 diff --git a/chapter7/solutions/inputs/grad_descent.input b/chapter7/solutions/inputs/grad_descent.input new file mode 100644 index 0000000..152bffe --- /dev/null +++ b/chapter7/solutions/inputs/grad_descent.input @@ -0,0 +1,3 @@ +3*x**2 + x*2 +x +0.1 diff --git a/chapter7/solutions/inputs/length_curve.input b/chapter7/solutions/inputs/length_curve.input new file mode 100644 index 0000000..9c01120 --- /dev/null +++ b/chapter7/solutions/inputs/length_curve.input @@ -0,0 +1,4 @@ +2*x*2 +x +0 +2 diff --git a/chapter7/solutions/inputs/verify_continuity.input b/chapter7/solutions/inputs/verify_continuity.input new file mode 100644 index 0000000..bfde720 --- /dev/null +++ b/chapter7/solutions/inputs/verify_continuity.input @@ -0,0 +1,4 @@ +1/x +x +0 + diff --git a/chapter7/solutions/run.bash b/chapter7/solutions/run.bash new file mode 100755 index 0000000..9e22733 --- /dev/null +++ b/chapter7/solutions/run.bash @@ -0,0 +1,12 @@ +#!/bin/bash + +for file in `ls *.py`; do + filename=$(basename $file) + filename="${filename%.*}" + python3 $filename.py < inputs/$filename.input + + if [[ $? != 0 ]]; then + echo "Something failed" + exit 1 + fi +done diff --git a/run.bash b/run.bash new file mode 100755 index 0000000..a703046 --- /dev/null +++ b/run.bash @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +echo "Python: " +python3 -c "import sys;print(sys.version)" +echo "Sympy: " +python3 -c "import sympy;print(sympy.__version__)" +echo "Matplotlib: " +python3 -c "import matplotlib; print(matplotlib.__version__)" + +for dir in 'chapter1' 'chapter2' 'chapter3' 'chapter4' 'chapter5' 'chapter6' 'chapter7'; do + pushd $dir/solutions + ./run.bash + popd +done