-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bigints and missing plausible link
- Loading branch information
1 parent
1bf9d75
commit 55f1073
Showing
10 changed files
with
61 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous"> | ||
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script> | ||
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous" onload="renderMathInElement(document.body,{delimiters:[{left: '$$', right: '$$', display: true},{left: '$', right: '$', display: false}]});"></script> | ||
<script async defer data-domain="pietroppeter.github.io/nblog" src="https://plausible.io/js/plausible.js"></script> | ||
</head> | ||
<body> | ||
<header> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,46 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-us"> | ||
<head> | ||
<title>bigints_examples.nim</title> | ||
<title>drafts\bigints_examples.nim</title> | ||
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2280%22>🐳</text></svg>"> | ||
<meta content="text/html; charset=utf-8" http-equiv="content-type"> | ||
<meta content="width=device-width, initial-scale=1" name="viewport"> | ||
<link rel='stylesheet' href='https://unpkg.com/normalize.css/'> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/kognise/water.css@latest/dist/light.min.css"> | ||
<link rel='stylesheet' href='https://cdn.jsdelivr.net/gh/pietroppeter/nimib/assets/atom-one-light.css'> | ||
<style> | ||
.nb-box { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
} | ||
.nb-small { | ||
font-size: 0.8rem; | ||
} | ||
button.nb-small { | ||
float: right; | ||
padding: 2px; | ||
padding-right: 5px; | ||
padding-left: 5px; | ||
} | ||
section#source { | ||
display:none | ||
} | ||
</style> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous"> | ||
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script> | ||
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous" onload="renderMathInElement(document.body,{delimiters:[{left: '$$', right: '$$', display: true},{left: '$', right: '$', display: false}]});"></script> | ||
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script> | ||
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous" onload="renderMathInElement(document.body,{delimiters:[{left: '$$', right: '$$', display: true},{left: '$', right: '$', display: false}]});"></script> | ||
<script async defer data-domain="pietroppeter.github.io/nblog" src="https://plausible.io/js/plausible.js"></script> | ||
</head> | ||
<body> | ||
<main> | ||
<header> | ||
<div class="nb-box"> | ||
<span><a href="..">🏡</a></span> | ||
<span><code>drafts\bigints_examples.nim</code></span> | ||
<span><a href="https://github.com/pietroppeter/nblog"><svg aria-hidden="true" width="1.2em" height="1.2em" style="vertical-align: middle;" preserveAspectRatio="xMidYMid meet" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59c.4.07.55-.17.55-.38c0-.19-.01-.82-.01-1.49c-2.01.37-2.53-.49-2.69-.94c-.09-.23-.48-.94-.82-1.13c-.28-.15-.68-.52-.01-.53c.63-.01 1.08.58 1.23.82c.72 1.21 1.87.87 2.33.66c.07-.52.28-.87.51-1.07c-1.78-.2-3.64-.89-3.64-3.95c0-.87.31-1.59.82-2.15c-.08-.2-.36-1.02.08-2.12c0 0 .67-.21 2.2.82c.64-.18 1.32-.27 2-.27c.68 0 1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82c.44 1.1.16 1.92.08 2.12c.51.56.82 1.27.82 2.15c0 3.07-1.87 3.75-3.65 3.95c.29.25.54.73.54 1.48c0 1.07-.01 1.93-.01 2.2c0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z" fill="#000"></path></svg></a></span> | ||
</div> | ||
<hr> | ||
</header><main> | ||
<h1>Bigints Examples</h1> | ||
<p>see <a href="https://github.com/def-/nim-bigints/tree/master/examples">https://github.com/def-/nim-bigints/tree/master/examples</a></p> | ||
<pre><code class="nim hljs"><span class="hljs-keyword">import</span> | ||
|
@@ -26,7 +53,8 @@ <h3><a href="http://rosettacode.org/wiki/Arbitrary-precision_integers_(included) | |
<span class="hljs-keyword">echo</span> s[<span class="hljs-number">0</span> .. <span class="hljs-number">19</span>] & <span class="hljs-string">"..."</span> & s[^<span class="hljs-number">20</span> .. ^<span class="hljs-number">1</span>] | ||
<span class="hljs-keyword">echo</span> s.len, <span class="hljs-string">" digits"</span></code></pre> | ||
<pre><samp>62060698786608744707...92256259918212890625 | ||
183231 digits</samp></pre> | ||
183231 digits | ||
</samp></pre> | ||
<h3>Combinations and permutations</h3> | ||
<p>Solution for <a href="http://rosettacode.org/wiki/Combinations_and_permutations">Combinations_and_permutations</a></p> | ||
<pre><code class="nim hljs"><span class="hljs-keyword">proc</span> perm(n, k: <span class="hljs-built_in">int32</span>): <span class="hljs-type">BigInt</span> = | ||
|
@@ -51,24 +79,30 @@ <h3>Combinations and permutations</h3> | |
dump | ||
<span class="hljs-keyword">let</span> permutations = perm(<span class="hljs-number">1000</span>, <span class="hljs-number">969</span>) | ||
permutations</code></pre> | ||
<pre><samp>let combinations = comb(1000, 969) | ||
<pre><samp> | ||
let combinations = comb(1000, 969) | ||
combinations = 76023224077694604844267036884498328958811481548795886956000 | ||
|
||
let permutations = perm(1000, 969) | ||
permutations = 48935322338186189966677615285264341307180008233417452886421014800950224875798629273926474557369035547211608939952425271857427907004912931382799980022535452823312144836508204188170562716219897527182757583012458103224469238431017264361357084179542551077339421218458525552210108412655253787858136317956338985503569604861639899701375118833411302155834718351270828287035400491383900493509499569168658161030348473708836044022937712580718634122326391120676298445158652944658449416153349920876602658760327928712841524541385291103617324363995364258875104593688468122090426867620668347962556488927982208536582639896200845855316536558023419168588932089763266007161186460812895165172222679328450735400027239293877695823413549738647246493410762890027858462874704445249505066856869158499901313801901794502504723615154109215428770227142898548411560306800701245360319610995782542728449804204425224900432803335713216610535443069526664397910819420296727391485660367677390609552098469805487995593855202735055224825799441869393117501033477508656170735343719235877766454673978280218812457637409594643934896448323038418194453204867489293698469149128577156374321013443310588967727652631387253936678004973103562714936132170761327107457911224297737840734888430796837809293767771189645281284263896331364944569254604339636706219595567045351283162761038686472674861442149619773743631737332109187120268922583036351767801107619263151558668321857486766620956921907456537417653856615083500356414390187097277419506999359315073694959823940713086453121285609743159030742719230270447287701392999208349056164483814630837742061990086746976557389586277861847668106772171150342474311451036661958197415704018677687188960376326732499270448198456552100604403852921697064424469405220701806194938420802201228657655411564226071892658400557397747212683882156188289009011021109998569430007126733885336598000799364737831050436837847478136562462851361574908821992088989991543967878103201480422357083732815018107934471809944740913159057087257139704509658342961719342049479649453934358082983195657763260664269985623046548957257032904564935980463560696215026021182421434772003716535651452340247847865573980699543205268737090407337836401364575647481349938920034362250943586347426438597011699691456364487594862697358331692914687612436827219584614400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</samp></pre> | ||
permutations = 48935322338186189966677615285264341307180008233417452886421014800950224875798629273926474557369035547211608939952425271857427907004912931382799980022535452823312144836508204188170562716219897527182757583012458103224469238431017264361357084179542551077339421218458525552210108412655253787858136317956338985503569604861639899701375118833411302155834718351270828287035400491383900493509499569168658161030348473708836044022937712580718634122326391120676298445158652944658449416153349920876602658760327928712841524541385291103617324363995364258875104593688468122090426867620668347962556488927982208536582639896200845855316536558023419168588932089763266007161186460812895165172222679328450735400027239293877695823413549738647246493410762890027858462874704445249505066856869158499901313801901794502504723615154109215428770227142898548411560306800701245360319610995782542728449804204425224900432803335713216610535443069526664397910819420296727391485660367677390609552098469805487995593855202735055224825799441869393117501033477508656170735343719235877766454673978280218812457637409594643934896448323038418194453204867489293698469149128577156374321013443310588967727652631387253936678004973103562714936132170761327107457911224297737840734888430796837809293767771189645281284263896331364944569254604339636706219595567045351283162761038686472674861442149619773743631737332109187120268922583036351767801107619263151558668321857486766620956921907456537417653856615083500356414390187097277419506999359315073694959823940713086453121285609743159030742719230270447287701392999208349056164483814630837742061990086746976557389586277861847668106772171150342474311451036661958197415704018677687188960376326732499270448198456552100604403852921697064424469405220701806194938420802201228657655411564226071892658400557397747212683882156188289009011021109998569430007126733885336598000799364737831050436837847478136562462851361574908821992088989991543967878103201480422357083732815018107934471809944740913159057087257139704509658342961719342049479649453934358082983195657763260664269985623046548957257032904564935980463560696215026021182421434772003716535651452340247847865573980699543205268737090407337836401364575647481349938920034362250943586347426438597011699691456364487594862697358331692914687612436827219584614400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | ||
</samp></pre> | ||
<p><code>combinations</code> has 59 digits<br /> | ||
<code>permutations</code> has 2534 digits</p> | ||
|
||
</main> | ||
<footer> | ||
<hr> | ||
<span id="made">made with <a href="https://github.com/pietroppeter/nimib">nimib 🐳</a></span> | ||
<button id="show" onclick="toggleSourceDisplay()">Show Source</button> | ||
<div class="nb-box"> | ||
<span><span class="nb-small">made with <a href="https://pietroppeter.github.io/nimib/">nimib 🐳</a></span></span> | ||
<span></span> | ||
<span><button class="nb-small" id="show" onclick="toggleSourceDisplay()">Show Source</button></span> | ||
</div> | ||
</footer> | ||
<section id="source"> | ||
<pre><code class="nim hljs"><span class="hljs-keyword">import</span> nimib, strformat | ||
<span class="hljs-comment"># add timings</span> | ||
nbInit | ||
nbUseLatex | ||
nbDoc.useLatex | ||
nbText <span class="hljs-string">""" | ||
# Bigints Examples | ||
see <https://github.com/def-/nim-bigints/tree/master/examples>"""</span> | ||
|
@@ -121,8 +155,7 @@ <h3>Combinations and permutations</h3> | |
|
||
nbSave | ||
</code></pre> | ||
</section> | ||
<script> | ||
</section><script> | ||
function toggleSourceDisplay() { | ||
var btn = document.getElementById("show") | ||
var source = document.getElementById("source"); | ||
|
@@ -134,25 +167,5 @@ <h3>Combinations and permutations</h3> | |
source.style.display = "none"; | ||
} | ||
} | ||
</script> | ||
<style> | ||
span#made { | ||
font-size: 0.8rem; | ||
} | ||
button#show { | ||
font-size: 0.8rem; | ||
} | ||
|
||
button#show { | ||
float: right; | ||
padding: 2px; | ||
padding-right: 5px; | ||
padding-left: 5px; | ||
} | ||
section#source { | ||
display:none | ||
} | ||
</style> | ||
</footer> | ||
</body> | ||
</script></body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.