<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>ku-ma-me</author_name>
  <author_url>https://blog.hatena.ne.jp/ku-ma-me/</author_url>
  <blog_title>まめめも</blog_title>
  <blog_url>https://mametter.hatenablog.com/</blog_url>
  <categories>
    <anon>Ruby</anon>
  </categories>
  <description>二分探索は、感覚的なわかりやすさに反してバグが入りやすいことで有名なアルゴリズムです。20 の教科書のうち 15 でバグっていたという報告もあるそうです。実際、自分も書くたびにバグに苦しんできました。変な値を返すだけでなく、out of bounds アクセスや無限ループもよく起きます。一旦動いたと思っても、後になってバグが発症することも多く、たちが悪いです。そこで、きちんとテストした二分探索のサンプルコードを自分のコピペ用に作ってみました。 動作仕様 (境界探索版) ソートした配列 a に対して、「値が c 以上になる範囲のうちの一番左のインデックス」を返す関数 bsearch_min を書…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fmametter.hatenablog.com%2Fentry%2F20161117%2Fp1&quot; title=&quot; 二分探索サンプルコード集（コピペ用） - まめめも&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2016-11-17 00:00:00</published>
  <title> 二分探索サンプルコード集（コピペ用）</title>
  <type>rich</type>
  <url>https://mametter.hatenablog.com/entry/20161117/p1</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
