Skip to content

Instantly share code, notes, and snippets.

Avatar

Pedro Escudero PedroEscudero

  • Zinio
  • Barcelona
View GitHub Profile
View Fibonacci.php
<?php
function fibonacci($n){
$start = microtime(true);
if ($n < 2){
$f = 1;
}else{
$f = fibonacci($n - 2) + fibonacci($n - 1);
}
return microtime(true) - $start;
}
View Fibonacci.py
import time
def Fibonacci(n):
if n<2:
return 1
else:
return Fibonacci(n-1)+Fibonacci(n-2)
start = time.time()
Fibonacci(22)
print(time.time() - start)
View Fibonacci.rb
def fibonacci(n)
return n if ( 0..1 ).include? n
(fibonacci(n - 1) + fibonacci( n - 2 ))
end
start = Time.now
fibonacci(22)
p Time.now - start
@PedroEscudero
PedroEscudero / mongo-author-inside.json
Last active Mar 16, 2020
mongo book data set with author inside (Medium article)
View mongo-author-inside.json
{
"title": "Zombi Kidergarten",
"isbn": "11121m21232323232",
"publish:_date": "23-07-2012",
"author": {
"name": "Pedro",
"surname": "Escudero",
"birth_year": "1976",
"nationality": "Spanish",
"alive": 1
@PedroEscudero
PedroEscudero / author.json
Last active Mar 16, 2020
Author in a different document set (Medium article)
View author.json
{
"id": "r?dskhuD9ewgvweosdJIe2s8u34br",
"name": "Pedro",
"surname": "Escudero",
"birth_year": "1976",
"nationality": "Spanish",
"alive": 1
}
@PedroEscudero
PedroEscudero / bubble.php
Last active Jan 5, 2021
Bubble script for testing speed of PHP-8
View bubble.php
<?php
function bubble_sort($array)
{
$start = microtime(true);
do
{
$sw = false;
for($i = 0, $size = count($array) - 1; $i < $size; $i++)
{
if( $array[$i] > $array[$i + 1] )