Skip to content

Instantly share code, notes, and snippets.

@acalpixca
acalpixca / keybase.md
Created June 9, 2017 10:00
keybase.md

Keybase proof

I hereby claim:

  • I am acalpixca on github.
  • I am acalpixca (https://keybase.io/acalpixca) on keybase.
  • I have a public key ASBNc_mqgj32s5LAcnJfV_nIsw0XSgiaFAuzeePwdOg0kQo

To claim this, I am signing this object:

@acalpixca
acalpixca / chuletario sencillísimo git Y npm
Created June 14, 2017 08:47
chuletario sencillísimo git / npm
Para crear un repo en github y poblarlo con un proyecto ya existente (pero no en repo):
=======================================================================================
(versión larga: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/)
1. Crea el repo en Github y copia su url (sin README, licencia o gitignore).
2. Por linea de comandos accede a la carpeta/directorio donde esté el proyecto y...
3. Inicializa el repositorio
$ git init
@acalpixca
acalpixca / gist:6640853746c91920be384b913f48ffb4
Last active February 19, 2018 14:44
cassidoo challenge 18/02/2018
function minimumDiff(p) {
// old school solution
diff=0;
if (p.length>1) {
diff=Math.abs(p[1]-p[0]);
for (i=0;i<p.length;i++){
for (j=i+1;j<p.length;j++){
if (Math.abs(p[j]-p[i])<diff){
diff=Math.abs(p[j]-p[i]);
}
@acalpixca
acalpixca / gist:6d26f064f0d0c695dc6cdc1ef965fba2
Created March 3, 2018 15:14
cassidoo challenge 26/02/2018
/*
Now, onto this week!
Given two strings, return if they have a common substring.
Bonus: Return the common substring(s).
Bonus x2: Do the original question plus the first bonus in less than O(n^2) time!
*/
@acalpixca
acalpixca / cassidoo challenge 12-03-2018
Created March 14, 2018 17:02
cassidoo challenge 12-03-2018
/* Given two sets of rectangles (where each is represented by an array of four elements, where the first two elements are the coordinates of
the upper left corner, and the second pair is of the bottom right), determine the area of the space in which they overlap.
Example:
> overlapArea([0,0,4,4], [2,2,4,4])
> 4
*/
function area(r){
// base x altura
@acalpixca
acalpixca / cassidoo challenge 03-06-2018
Created June 4, 2018 11:06
cassidoo challenge 03-06-2018
//Given a queue, write a recursive function to reverse it.
function reverse(q) {
if (q.length === 1) {
return(q);
}
else {
var head=q.shift();
return(reverse(q).concat([head]));
@acalpixca
acalpixca / cassidoo challenge 15-05-2018
Created June 4, 2018 14:35
cassidoo challenge 15-05-2018
/*
Implement the charAt() and contains() functions using the best runtime possible.
Example:
> charAt(5)
> a
> "fish".contains("i")
> true
*/
@acalpixca
acalpixca / cassidoo challenge 29-05-2018
Created June 4, 2018 15:32
cassidoo challenge 29-05-2018
// Given n, write a function that returns the sum of 1*1! + 2*2! + ... + n*n!
function factorial(n) {
if (n===0) {
return(1);
}
else {
return(n * factorial(n-1));
}
}
@acalpixca
acalpixca / cassidoo challenge 25-06-2018
Last active June 27, 2018 08:38
cassidoo challenge 25-06-2018
/*
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
Example:
waterTrap([2,0,2])
> 2
Structure is like this:
| |
|_|
@acalpixca
acalpixca / cassidoo challenge 2018-07-24
Created July 25, 2018 13:57
cassidoo challenge 2018-07-24
/*
Given an int array, remove all leading zeros from the array.
removeLeading({0, 0, 0, 1, 0, 2, 3})
> 1 0 2 3
*/
function removeZeros(s) {
if (s.length<=0) {
return ([]);