Skip to content

Instantly share code, notes, and snippets.

Avatar
🎻
Code n play

Moisés Ñañez moisesnandres

🎻
Code n play
View GitHub Profile
View exercises.js
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);
}
});
View santa2.rb
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
View santa1.rb
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 == '<'
View promises.js
const mostrar = false
const myPromise = new Promise((resolve, reject) => {
setTimeout(() => {
if (mostrar) {
resolve('hello world!');
} else {
reject(Error('hello there!'));
}
}, 3000)
});
View app.js
const searchIcon = document.getElementById('search-icon');
const searchInput = document.getElementById('search-input');
searchIcon.addEventListener('click', () => {
searchInput.style.width = '200px';
searchInput.focus();
});
View styles.css
.wrapper {
width: 900px;
margin: auto;
}
ul {
padding: 0;
list-style: none;
}
View encap.py
>>> 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):
View asesoria.py
# -*- 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()]
View tortuga1.py
# -*- 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()]