{"id":177,"date":"2019-01-30T14:44:18","date_gmt":"2019-01-30T19:44:18","guid":{"rendered":"https:\/\/resrvoir.com\/?page_id=177"},"modified":"2019-03-17T13:49:13","modified_gmt":"2019-03-17T17:49:13","slug":"reflected-binary","status":"publish","type":"page","link":"https:\/\/resrvoir.com\/?page_id=177","title":{"rendered":"Reflected Binary"},"content":{"rendered":"\n<p>Given a number, implement the conversion from binary to reflected binary.<br><br>Reflected binary is an alternate binary representation where numbers in sequence only change a single bit at a time. For example, the numbers 0 through 4 are represented in binary and reflected binary below. This is also known as Gray code.<\/p>\n\n\n\n<div class=\"wp-block-columns has-3-columns is-layout-flex wp-container-4 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>Number<br>0<br>1<br>2<br>3<br>4<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>Binary<br>0000<br>0001 <br>0010<br>0011<br>0100<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>Reflected<br>0000<br>0001<br>0011<br>0010<br>0110<\/p>\n<\/div>\n<\/div>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">uint toReflected(uint x) {\n  return x ^ (x >> 1)\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Given a number, implement the conversion from binary to reflected binary. Reflected binary is an alternate binary representation where numbers in sequence only change a single bit at a time. For example, the numbers 0 through 4 are represented in binary and reflected binary below. This is also known as Gray code. Number01234 Binary00000001 001000110100 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2,"menu_order":9,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/resrvoir.com\/index.php?rest_route=\/wp\/v2\/pages\/177"}],"collection":[{"href":"https:\/\/resrvoir.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/resrvoir.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/resrvoir.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/resrvoir.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=177"}],"version-history":[{"count":9,"href":"https:\/\/resrvoir.com\/index.php?rest_route=\/wp\/v2\/pages\/177\/revisions"}],"predecessor-version":[{"id":718,"href":"https:\/\/resrvoir.com\/index.php?rest_route=\/wp\/v2\/pages\/177\/revisions\/718"}],"up":[{"embeddable":true,"href":"https:\/\/resrvoir.com\/index.php?rest_route=\/wp\/v2\/pages\/2"}],"wp:attachment":[{"href":"https:\/\/resrvoir.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}