Skip to content

Instantly share code, notes, and snippets.

View drupol's full-sized avatar

Pol Dellaiera drupol

View GitHub Profile
@drupol
drupol / .block
Last active January 24, 2018 21:41
Lorenz attractors
license: gpl-3.0
@drupol
drupol / .block
Last active July 27, 2017 11:42
Hilbert curve
license: gpl-3.0

Keybase proof

I hereby claim:

  • I am drupol on github.
  • I am poldellaiera (https://keybase.io/poldellaiera) on keybase.
  • I have a public key ASB7pOkMHfoK_ZG9iDDpkbmAoD9N3G1lJqgJruj93a3Crgo

To claim this, I am signing this object:

@drupol
drupol / e.php
Last active August 15, 2017 11:19
Approximate numbers e and pi using combinatorics and Fibonacci.
<?php
/**
* Find the number e (2.7182818284590452354 => M_E constant in PHP).
*
* To find the number e using permutations:
* 1: Generate a set of size S of random values,
* 2: Find the number of permutations of that set, let it be #P0,
* 3: With all the permutations of this set, let #P1 the count of the permutations where
* any items are not at the same index as in the original input,
* 4: Divide #P0 by #P1, that's your approximation,
@drupol
drupol / .block
Last active January 5, 2018 22:43
Belgian railway stations
license: gpl-3.0
@drupol
drupol / .block
Last active January 9, 2018 10:15
London tube - stations and lines graph
license: gpl-3.0
@drupol
drupol / collatz.php
Created September 14, 2019 16:46
Collatz conjecture's sequence of numbers
<?php
declare(strict_types=1);
include 'vendor/autoload.php';
use drupol\collection\Collection;
// The Collatz conjecture (https://en.wikipedia.org/wiki/Collatz_conjecture)
$collatz = static function (int $initial = 1): int
@drupol
drupol / merkle.php
Last active December 16, 2019 16:38
PHPTree is now having a Merkle node type.
<?php
declare(strict_types=1);
use drupol\launcher\Launcher;
use drupol\phptree\Exporter\Image;
use drupol\phpmerkle\Hasher\DummyHasher;
use drupol\phptree\Node\MerkleNode;
include './vendor/autoload.php';
@drupol
drupol / composer.php
Last active December 16, 2019 11:52
Composer dependency tree with PHPTree
<?php
declare(strict_types=1);
use drupol\launcher\Launcher;
use drupol\phptree\Exporter\Image;
use drupol\phptree\Importer\SimpleArray;
include './vendor/autoload.php';
@drupol
drupol / pi_approximation.php
Last active September 4, 2024 14:59
Approximate PI using Monte Carlo method
<?php
declare(strict_types=1);
include 'vendor/autoload.php';
use loophp\collection\Collection;
$monteCarloMethod = static function ($in = 0, $total = 1) {
$randomNumber1 = mt_rand() / mt_getrandmax();