Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View moisesnandres's full-sized avatar
🎻
Code n play

Moisés Ñañez moisesnandres

🎻
Code n play
View GitHub Profile
@moisesnandres
moisesnandres / exercises.js
Created September 3, 2019 19:28
JS exercises
function solution(input, markers) {
const lines = input.split('\n');
const strippedLines = lines.map((line) => {
let strippedLine = line;
markers.forEach((marker) => {
if (line.includes(marker)) {
const index = line.indexOf(marker);
strippedLine = line.slice(0, index);
}
});
def decode_message(input)
words = input.split("\n")
letters = [{}, {}, {}, {}, {}, {}]
words.each do |word|
word.each_char.with_index do |char, index|
if letters[index].key?(char)
letters[index][char] = letters[index][char] + 1
else
letters[index][char] = 1
end
def deliver_presents(moves)
total_visits = 1
start_location = [0, 0]
total_houses = [start_location]
new_location = start_location
moves.each_char do |move|
x, y = new_location
if move == '>'
new_location = [x + 1, y]
elsif move == '<'
const mostrar = false
const myPromise = new Promise((resolve, reject) => {
setTimeout(() => {
if (mostrar) {
resolve('hello world!');
} else {
reject(Error('hello there!'));
}
}, 3000)
});
@moisesnandres
moisesnandres / app.js
Created July 17, 2017 03:25
medium navbar
const searchIcon = document.getElementById('search-icon');
const searchInput = document.getElementById('search-input');
searchIcon.addEventListener('click', () => {
searchInput.style.width = '200px';
searchInput.focus();
});
@moisesnandres
moisesnandres / styles.css
Last active July 17, 2017 01:25
github navbar
.wrapper {
width: 900px;
margin: auto;
}
ul {
padding: 0;
list-style: none;
}
@moisesnandres
moisesnandres / encap.py
Created February 26, 2015 16:42
Encapsulamiento
>>> class Televisor(object):
... def __init__(self,marca):
... self.__marca = marca
... self.encendido = False
... def encenderT(self):
... if self.encendido == False:
... self.encendido = True
... else:
... print "El televisor ya estaba encendido"
... def apagarT(self):
# -*- coding: utf-8 -*-
import random
def lanzar_dado():
return 1 + random.randrange(6)
def num_dados(n):
lista = []
for i in range(n):
lista += [lanzar_dado()]
@moisesnandres
moisesnandres / tortuga1.py
Last active August 29, 2015 14:15
tortuga
# -*- coding: utf-8 -*-
import random
def lanzar_dado():
return 1 + random.randrange(6)
def num_dados(n):
lista = []
for i in range(n):
lista += [lanzar_dado()]