This file contains hidden or 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
from jinja2 import Template | |
with open('template.tpl') as file: | |
text = file.read() | |
template = Template(text) | |
new = template.render(slide={'num': 1, 'name': 'a'}) | |
with open('out', 'w') as output: |
This file contains hidden or 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
#include <cstdio> | |
using namespace std; | |
typedef long long ll; | |
/** | |
* O(n) | |
*/ | |
bool esPrimoLineal(ll n, ll &contador) { | |
contador = 0LL; |
This file contains hidden or 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
typedef vector<int> vi; | |
/** | |
* LONGEST INCREASING SUBSEQUENCE | |
* COMPLEXITY O(N^2) | |
*/ | |
int lci(vi &A) { | |
vi DP (A.size(), 1); | |
for(int i=1; i<(int)A.size(); i++) { | |
for(int j=0; j<i; j++) { |
This file contains hidden or 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
# Tree representation | |
class Node: | |
def __init__(self, val): | |
self.data = val | |
self.right = None | |
self.left = None | |
def recursive_inorder(node): | |
if not node: | |
return |
This file contains hidden or 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
class Heap: | |
def __init__(self, arr): | |
self.cont = arr | |
self.size = len(self.cont) - 1 | |
self.buildheap() | |
def left(self, i): | |
return (i << 1) + 1 | |
def right(self, i): |
This file contains hidden or 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
var merge_sort = function(array, b, e){ | |
if(b < e) { | |
var m = Math.floor((b + e) / 2); | |
//Recursive stuff | |
merge_sort(array, b, m); | |
merge_sort(array, m+1, e); | |
//Merge stuff | |
var lower = [], | |
higher = []; |
This file contains hidden or 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
var selectionSort = function(array) { | |
var temp; | |
for(var i=0; i<array.length; i++){ | |
var mi = i; | |
for(var j = i + 1; j<array.length; j++) { | |
if(array[j] < array[mi]) | |
mi = j; | |
} |
This file contains hidden or 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
var binarySearch = function(array, value) { | |
var guess, | |
min = 0, | |
max = array.length - 1; | |
while(min <= max){ | |
guess = Math.floor((min + max) /2); | |
if(array[guess] === value) | |
return guess; | |
else if(array[guess] < value) |
This file contains hidden or 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
#!/bin/bash | |
re='^-?[0-9]+([.][0-9]+)?$' | |
if ! [[ $2 =~ $re ]] ; then | |
echo "El parámetro inicial NO es un número." | |
exit | |
fi | |
if ! [[ $3 =~ $re ]] ; then | |
echo "El parámetro final NO es un número." | |
exit |
NewerOlder