<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>obelisk2</author_name>
  <author_url>https://blog.hatena.ne.jp/obelisk2/</author_url>
  <blog_title>Camera Obscura</blog_title>
  <blog_url>https://obelisk.hatenablog.com/</blog_url>
  <categories>
    <anon>Ruby</anon>
  </categories>
  <description>Ruby を使っているとビット操作はあまり必要なのだが、競技プログラミングをやっていたりすると時にはビット操作したくなることもある。で、Ruby をあらためて見てみると（当り前だが）ビット操作も一通り揃っているわけだ。競プロで便利だなと思うのは例えば「ビットの立っている」ものを数える、つまり整数を二進数表現に直して &quot;1&quot; の数を数えるというもので、Ruby では to_s(2).chars.count { _1 == &quot;1&quot; } #追記 以下でよい to_s(2).count(&quot;1&quot;) と簡潔に書ける。 また、いわゆる「ビット全探索」は、Ruby ではビットを使わなくても簡単に書ける。例えば…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fobelisk.hatenablog.com%2Fentry%2F2021%2F01%2F13%2F132030&quot; title=&quot;ビット操作メソッド三題（Ruby） - Camera Obscura&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>2021-01-13 13:20:30</published>
  <title>ビット操作メソッド三題（Ruby）</title>
  <type>rich</type>
  <url>https://obelisk.hatenablog.com/entry/2021/01/13/132030</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
