<jupyter_start><jupyter_text>Fibonacci(JavaScript)[フィボナッチ数](https://ja.wikipedia.org/wiki/%E3%83%95%E3%82%A3%E3%83%9C%E3%83%8A%E3%83%83%E3%83%81%E6%95%B0)1. テストファースト1. アサートファースト1. 仮実装1. 三角測量1. 明白な実装1. リファクタリン  テストファースト<jupyter_code>%%html
<!DOCTYPE html>
<html lang="ja">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />

    <title>Programing Puzzles</title>
  </head>
  <body>

    <section id="app"></section>
    <section id="mocha"></section>
    <!-- Optional JavaScript -->
    <script
      src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
      integrity="<KEY>"
      crossorigin="anonymous"
    ></script>
    <script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>
    <script>
      mocha.setup("tdd");
    </script>
    <script>
      const assert = chai.assert;
      suite("FibonacciTest", () => {
        test("fail test", () => {
          assert.equal(1, 2);
        });
      });
    </script>
    <script>
      mocha.checkLeaks();
      mocha.globals(["jQuery"]);
      mocha.run();
    </script>
  </body>
</html><jupyter_output><empty_output><jupyter_text>アサートファースト<jupyter_code>%%html
<!DOCTYPE html>
<html lang="ja">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />

    <title>Programing Puzzles</title>
  </head>
  <body>

    <section id="app"></section>
    <section id="mocha"></section>
    <!-- Optional JavaScript -->
    <script
      src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
      integrity="<KEY>"
      crossorigin="anonymous"
    ></script>
    <script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>
    <script>
      mocha.setup("tdd");
    </script>
    <script>
      const assert = chai.assert;
      suite("FibonacciTest", () => {
        test("function", () => {
          assert.equal(fib(0), 0);
        });
      });
    </script>
    <script>
      mocha.checkLeaks();
      mocha.globals(["jQuery"]);
      mocha.run();
    </script>
  </body>
</html><jupyter_output><empty_output><jupyter_text>仮実装<jupyter_code>%%html
<!DOCTYPE html>
<html lang="ja">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />

    <title>Programing Puzzles</title>
  </head>
  <body>

    <section id="app"></section>
    <section id="mocha"></section>
    <!-- Optional JavaScript -->
    <script
      src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
      integrity="<KEY>"
      crossorigin="anonymous"
    ></script>
    <script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>
    <script>
      mocha.setup("tdd");
    </script>
    <script>
      const assert = chai.assert;
      suite("FibonacciTest", () => {
        test("function", () => {
          assert.equal(fib(0), 0);
        });
      });

      function fib(n) {
          return 0
      }
    </script>
    <script>
      mocha.checkLeaks();
      mocha.globals(["jQuery"]);
      mocha.run();
    </script>
  </body>
</html><jupyter_output><empty_output><jupyter_text>三角測量<jupyter_code>%%html
<!DOCTYPE html>
<html lang="ja">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />

    <title>Programing Puzzles</title>
  </head>
  <body>

    <section id="app"></section>
    <section id="mocha"></section>
    <!-- Optional JavaScript -->
    <script
      src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
      integrity="<KEY>"
      crossorigin="anonymous"
    ></script>
    <script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>
    <script>
      mocha.setup("tdd");
    </script>
    <script>
      const assert = chai.assert;
      suite("FibonacciTest", () => {
        test("function", () => {
          assert.equal(fib(0), 0);
          assert.equal(fib(1), 1);
        });
      });

      function fib(n) {
          return 0
      }
    </script>
    <script>
      mocha.checkLeaks();
      mocha.globals(["jQuery"]);
      mocha.run();
    </script>
  </body>
</html><jupyter_output><empty_output><jupyter_text>明白な実装<jupyter_code>%%html
<!DOCTYPE html>
<html lang="ja">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />

    <title>Programing Puzzles</title>
  </head>
  <body>

    <section id="app"></section>
    <section id="mocha"></section>
    <!-- Optional JavaScript -->
    <script
      src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
      integrity="<KEY>"
      crossorigin="anonymous"
    ></script>
    <script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>
    <script>
      mocha.setup("tdd");
    </script>
    <script>
      const assert = chai.assert;
      suite("FibonacciTest", () => {
        test("function", () => {
          assert.equal(fib(0), 0);
          assert.equal(fib(1), 1);
        });
      });

      function fib(n) {
        let result = n
        if (n === 0) {
            result = 0
        }
        return n
      }
    </script>
    <script>
      mocha.checkLeaks();
      mocha.globals(["jQuery"]);
      mocha.run();
    </script>
  </body>
</html>
%%html
<!DOCTYPE html>
<html lang="ja">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />

    <title>Programing Puzzles</title>
  </head>
  <body>

    <section id="app"></section>
    <section id="mocha"></section>
    <!-- Optional JavaScript -->
    <script
      src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
      integrity="<KEY>"
      crossorigin="anonymous"
    ></script>
    <script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>
    <script>
      mocha.setup("tdd");
    </script>
    <script>
      const assert = chai.assert;
      suite("FibonacciTest", () => {
        test("function", () => {
          assert.equal(fib(0), 0);
          assert.equal(fib(1), 1);
          assert.equal(fib(2), 1);
        });
      });

      function fib(n) {
        let result = n
        if (n === 0) {
            result = 0
        } else if (n === 1) {
            result = 1
        } else {
            result = (n - 2) + (n - 1)
        }
        return result
      }
    </script>
    <script>
      mocha.checkLeaks();
      mocha.globals(["jQuery"]);
      mocha.run();
    </script>
  </body>
</html>
%%html
<!DOCTYPE html>
<html lang="ja">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />

    <title>Programing Puzzles</title>
  </head>
  <body>

    <section id="app"></section>
    <section id="mocha"></section>
    <!-- Optional JavaScript -->
    <script
      src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
      integrity="<KEY>"
      crossorigin="anonymous"
    ></script>
    <script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>
    <script>
      mocha.setup("tdd");
    </script>
    <script>
      const assert = chai.assert;
      suite("FibonacciTest", () => {
        test("function", () => {
          assert.equal(fib(0), 0);
          assert.equal(fib(1), 1);
          assert.equal(fib(2), 1);
          assert.equal(fib(3), 2);
          assert.equal(fib(4), 3);
          assert.equal(fib(10), 55);
        });
      });

      function fib(n) {
        let result = n
        if (n === 0) {
            result = 0
        } else if (n === 1) {
            result = 1
        } else {
            result = fib(n - 2) + fib(n - 1)
        }
        return result
      }
    </script>
    <script>
      mocha.checkLeaks();
      mocha.globals(["jQuery"]);
      mocha.run();
    </script>
  </body>
</html><jupyter_output><empty_output><jupyter_text>リファクタリング<jupyter_code>%%html
<!DOCTYPE html>
<html lang="ja">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />

    <title>Programing Puzzles</title>
  </head>
  <body>

    <section id="app"></section>
    <section id="mocha"></section>
    <!-- Optional JavaScript -->
    <script
      src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
      integrity="<KEY>"
      crossorigin="anonymous"
    ></script>
    <script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>
    <script>
      mocha.setup("tdd");
    </script>
    <script>
      const assert = chai.assert;
      suite("FibonacciTest", () => {
        test("function", () => {
          assert.equal(fib(0), 0);
          assert.equal(fib(1), 1);
          assert.equal(fib(2), 1);
          assert.equal(fib(3), 2);
          assert.equal(fib(4), 3);
          assert.equal(fib(10), 55);
        });
      });

      function fib(n) {
        if (n === 0) return 0
        if (n === 1) return 1
        return fib(n - 2) + fib(n - 1)
      }
    </script>
    <script>
      mocha.checkLeaks();
      mocha.globals(["jQuery"]);
      mocha.run();
    </script>
  </body>
</html>
%%html
<!DOCTYPE html>
<html lang="ja">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />

    <title>Programing Puzzles</title>
  </head>
  <body>

    <section id="app"></section>
    <section id="mocha"></section>
    <!-- Optional JavaScript -->
    <script
      src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
      integrity="<KEY>"
      crossorigin="anonymous"
    ></script>
    <script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>
    <script>
      mocha.setup("tdd");
    </script>
    <script>
      const assert = chai.assert;
      suite("FibonacciTest", () => {
        test("function", () => {
          assert.equal(fib(0), 0);
          assert.equal(fib(1), 1);
          assert.equal(fib(2), 1);
          assert.equal(fib(3), 2);
          assert.equal(fib(4), 3);
          assert.equal(fib(10), 55);
        });
      });

      function fib(n) {
        const next = (n) => fib(n - 2) + fib(n - 1)
        
        if (n === 0) return 0
        if (n === 1) return 1
        return next(n)
      }
    </script>
    <script>
      mocha.checkLeaks();
      mocha.globals(["jQuery"]);
      mocha.run();
    </script>
  </body>
</html>
%%html
<!DOCTYPE html>
<html lang="ja">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />

    <title>Programing Puzzles</title>
  </head>
  <body>

    <section id="app"></section>
    <section id="mocha"></section>
    <!-- Optional JavaScript -->
    <script
      src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
      integrity="<KEY>TE1Pi6jizo"
      crossorigin="anonymous"
    ></script>
    <script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>
    <script>
      mocha.setup("tdd");
    </script>
    <script>
      const assert = chai.assert;
      suite("FibonacciTest", () => {
        test("function", () => {
          const data = {
              0:0,
              1:1,
              2:1,
              3:2,
              4:3,
              10:55
          }
          Object.keys(data).forEach(key => {
              console.log(`${key}:${data[key]}`)
              assert.equal(fib(parseInt(key)), parseInt(data[key]));
          })
        });
      });

      function fib(n) {
        const next = (n) => fib(n - 2) + fib(n - 1)
        
        if (n === 0) return 0
        if (n === 1) return 1
        return next(n)
      }
    </script>
    <script>
      mocha.checkLeaks();
      mocha.globals(["jQuery"]);
      mocha.run();
    </script>
  </body>
</html><jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20165784341042073, 'fraction_numerical': 0.020130955697966007, 'mean_word_length': 2.2241185717493823, 'pattern_counts': {'":': 0, '<': 345, '<?xml version=': 0, '>': 368, 'https://': 41, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '161353', 'license': 'MIT', 'n_tokens_mistral': 5534, 'n_tokens_neox': 5219, 'n_words': 738, 'path': 'docs/src/jupyter/sample/FibonacciJavaScript.ipynb', 'repo_name': 'k2works/pragmatic-programing-exercise', 'size': '15006'}