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
"use latest"; | |
var Promise = require("[email protected]"); | |
var request = Promise.promisifyAll(require("[email protected]")); | |
var validator = require('[email protected]'); | |
const SLACK_WEBHOOK_URL = "https://hooks.slack.com/services/T00000000/B00000000/X00000000000000000"; | |
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
import timeit | |
INNER_ITERATIONS = 10000 | |
TIMEIT_ITERATIONS = 5000 | |
def func(): | |
return [x for x in range(INNER_ITERATIONS)] | |
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
# -*- coding: utf-8 -*- | |
""" | |
A pretty lame test from: | |
http://hackealo.co/ | |
El instituto geográfico nacional se encarga de, periódicamente, | |
tomar fotografías aéreas para detectar cambios en el relieve terrestre. | |
Para agilizar esta tarea desean tener una herramienta que, dada una imagen tomada, |
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
# Assertions can be removed by command flags, | |
# this can not | |
class ConstraintError(AssertionError): | |
"""""" | |
def constraint(condition, message=''): | |
""" | |
Usage:: |
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
/* | |
sqrt(8) | |
(0 + 8) / 2 = 4 | |
4 * 4 = 16 | |
(0 + 4) / 2 = 2 | |
2 * 2 = 4 | |
(2 + 4) / 2 = 3 | |
3 * 3 = 9 |
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
// Space complexity: O(n) | |
// Time complexity: O(n) where n includes nested elements | |
function flatten(arr) { | |
return arr.reduce((acc, elem) => { | |
if (Array.isArray(elem)) | |
acc.push(...flatten(elem)); | |
else | |
acc.push(elem); | |
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
/* | |
We have an array of objects A and an array of indexes B. Reorder objects in array A with given indexes in array B. Do not change array A's length. | |
example: | |
var A = [C, D, E, F, G]; | |
var B = [3, 0, 4, 1, 2]; | |
sort(A, B); |
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
/* | |
If you were building a search tool and wanted search results to pop up as you | |
typed but the server call was taxing, write a function that gets called on every | |
key down but calls the server when the user stops typing for 400ms. | |
*/ | |
// <input type="text" class="js-search"> | |
// Why a IIFE? coz I don't feel like polluting the global scope with crap [happy face] | |
(() => { |
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 is just a BFS. It only works if the node to find is unique (ie: has an ID) | |
*/ | |
function findNode(curr, node) { | |
if (curr == null) | |
return; | |
if (curr.isEqualNode(node)) |
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
/* | |
Translate roman numbers to decimals. If a roman letter/number is lesser than the next one substract, otherwise add. | |
*/ | |
// Time-Complexity = O(n) | |
// Space-Complexity = O(1) | |
const Romans = { | |
I: 1, | |
V: 5, |