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
# CodigoFacilito Challenge 2: Registro de usuarios | |
num_users = int(input('¿Cuántos nuevos usuarios se pretenden registrar? ')) | |
# Itera sobre el número de usuarios a registrar | |
for i in range(0, num_users): | |
print("Registro del usuario:", i+1) | |
# Solicita y valida el nombre | |
while True: |
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
# Request data from the user and store it in variables | |
first_name = input('Enter your First Name: ') | |
last_name = input('Enter your Last Name: ') | |
telephone = int(input('Enter your Telephone Number: ')) | |
email = input('Enter your e-mail: ') | |
# Print the requested results. | |
print('Hola' + ' ' + first_name + ' ' + last_name + ', en breve recibirás un correo a ' + email + '.') |
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
# -*- coding: utf-8 -*- | |
# | |
# @lc app=leetcode id=127 lang=ruby | |
# | |
# [127] Word Ladder | |
# | |
# https://leetcode.com/problems/word-ladder/description/ | |
# | |
# Given two words (beginWord and endWord), and a dictionary's word | |
# list, find the length of shortest transformation sequence from |
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
require_relative '../lib/models/decorator' | |
require_relative '../lib/models/persons' | |
describe 'Tests For Decorator class:' do | |
# we need to provide data for the parameters | |
person = Person.new('harry Potter', 20, parent_permission: true) | |
# created instance of decorator class | |
decorator = Decorator.new(person) |
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
require_relative '../lib/models/decorator' | |
require_relative '../lib/models/persons' | |
describe 'Tests For Decorator class:' do | |
# we need to provide data for the parameters | |
person = Person.new('harry Potter', 20, parent_permission: true) | |
# created instance of decorator class | |
decorator = Decorator.new(person) |
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
""" | |
Adds two strings representing non-negative integers. | |
Args: | |
num1: A string representing a non-negative integer. | |
num2: A string representing a non-negative integer. | |
Returns: | |
A string representing the sum of num1 and num2. | |
""" |
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
# Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative. | |
# Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case | |
def count_bits(n) | |
count = 0 | |
while n > 0 | |
count += n & 1 | |
n >>= 1 | |
end |
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 Node | |
attr_reader :data | |
attr_accessor :left, :right | |
def initialize data | |
@data = data | |
end | |
end | |
def array_to_tree(array, index = 0) | |
# use your function from the previous challenge |
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
function bubbleSort(arr) { | |
const n = arr.length; | |
let swapped; | |
do { | |
swapped = false; | |
for (let i = 0; i < n - 1; i++) { | |
if (arr[i] > arr[i + 1]) { | |
// Swap the elements if they are in the correct order | |
const temp = arr[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
function leftmostNodesSum(array) { | |
let sum = 0; | |
let index = 0; | |
while (index < array.length && array[index] !== 0) { | |
sum += array[index]; | |
index = 2 * index + 1; | |
} | |
return sum; |