|
589 | 589 | shuffle(<list>)
|
590 | 590 | </code></pre></div>
|
591 | 591 |
|
592 |
| -<div><h3 id="binhex">Bin, Hex</h3><pre><code class="python language-python hljs"><int> = <span class="hljs-number">0</span>b<bin> <span class="hljs-comment"># Or: 0x<hex></span> |
593 |
| -<int> = int(<span class="hljs-string">'<bin>'</span>, <span class="hljs-number">2</span>) <span class="hljs-comment"># Or: int('<hex>', 16)</span> |
594 |
| -<int> = int(<span class="hljs-string">'0b<bin>'</span>, <span class="hljs-number">0</span>) <span class="hljs-comment"># Or: int('0x<hex>', 0)</span> |
595 |
| -<span class="hljs-string">'0b<bin>'</span> = bin(<int>) <span class="hljs-comment"># Or: '0x<hex>' = hex(<int>)</span> |
596 |
| -</code></pre></div> |
597 |
| - |
598 |
| -<div><h3 id="bitwiseoperators">Bitwise Operators</h3><pre><code class="python language-python hljs"><int> = <int> & <int> <span class="hljs-comment"># And</span> |
599 |
| -<int> = <int> | <int> <span class="hljs-comment"># Or</span> |
600 |
| -<int> = <int> ^ <int> <span class="hljs-comment"># Xor (0 if both bits equal)</span> |
601 |
| -<int> = <int> << n_bits <span class="hljs-comment"># Shift left</span> |
602 |
| -<int> = <int> >> n_bits <span class="hljs-comment"># Shift right</span> |
603 |
| -<int> = ~<int> <span class="hljs-comment"># Compliment (flips bits)</span> |
| 592 | +<div><h3 id="binhex">Bin, Hex</h3><pre><code class="python language-python hljs"><int> = <span class="hljs-number">0</span>b<bin> <span class="hljs-comment"># Or: 0x<hex></span> |
| 593 | +<int> = int(<span class="hljs-string">'<bin>'</span>, <span class="hljs-number">2</span>) <span class="hljs-comment"># Or: int('<hex>', 16)</span> |
| 594 | +<int> = int(<span class="hljs-string">'0b<bin>'</span>, <span class="hljs-number">0</span>) <span class="hljs-comment"># Or: int('0x<hex>', 0)</span> |
| 595 | +<span class="hljs-string">'0b<bin>'</span> = bin(<int>) <span class="hljs-comment"># Or: '0x<hex>' = hex(<int>)</span> |
| 596 | +</code></pre></div> |
| 597 | + |
| 598 | +<div><h3 id="bitwiseoperators">Bitwise Operators</h3><pre><code class="python language-python hljs"><int> = <int> & <int> <span class="hljs-comment"># And</span> |
| 599 | +<int> = <int> | <int> <span class="hljs-comment"># Or</span> |
| 600 | +<int> = <int> ^ <int> <span class="hljs-comment"># Xor (0 if both bits equal)</span> |
| 601 | +<int> = <int> << n_bits <span class="hljs-comment"># Shift left</span> |
| 602 | +<int> = <int> >> n_bits <span class="hljs-comment"># Shift right</span> |
| 603 | +<int> = ~<int> <span class="hljs-comment"># Compliment (flips bits)</span> |
604 | 604 | </code></pre></div>
|
605 | 605 |
|
606 | 606 | <div><h2 id="combinatorics"><a href="#combinatorics" name="combinatorics">#</a>Combinatorics</h2><ul>
|
|
0 commit comments