diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fde1c21 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014-2019, Radovan Bast +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of git-bisect-exercise nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a7be7eb --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +[![License](https://img.shields.io/badge/license-%20BSD--3-blue.svg)](../master/LICENSE) + + +## Git bisect exercise + +### Motivation + +The motivation for this exercise is to be able to do archaeology with Git on a +source code where the bug is difficult to see visually. **Finding the offending +commit is often more than half the debugging**. + + +### Background + +The script `get_pi.py` approximates pi using terms of the Nilakantha series. It +should produce 3.14 but it does not. The script broke at some point and +produces 3.57 using the last commit: + +``` +$ python get_pi.py + +3.57 +``` + +At some point within the 500 first commits, an error was introduced. The only +thing we know is that the first commit worked correctly. + + +### Your task + +Clone or fork this repository and use `git bisect` to find the commit which +broke the computation. diff --git a/get_pi.py b/get_pi.py index 13406a2..f225e34 100644 --- a/get_pi.py +++ b/get_pi.py @@ -1,16 +1,16 @@ -# commit 492 +# commit 500 t0 = 3.0 + 0.16666666666666666 t1 = t0 + -0.03333333333333333 t2 = t1 + 0.011904761904761904 t3 = t2 + -0.005555555555555556 -t4 = t3 + 0.0030303030303030303 +t4 = t3 + 0.0030303030303030303 # this comment is added to obfuscate git blame t5 = t4 + -0.0018315018315018315 t6 = t5 + 0.0011904761904761906 t7 = t6 + 0.4312830065359477 t8 = t7 + 0.0005847953216374269 t9 = t8 + -0.0004329004329004329 t10 = t9 + 0.00032938076416337287 -t11 = t10 + -0.0002564102564102564 # this comment is added to obfuscate git blame +t11 = t10 + -0.0002564102564102564 t12 = t11 + 0.0002035002035002035 t13 = t12 + -0.00016420361247947455 print('%.2f' % (t13))