-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/MaximilianoHolsbach/retos-p…
- Loading branch information
Showing
3 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [Fácil]/python/restevean.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
Write a function that a list of numbers from 1 to 100, replacing: | ||
- Multiples of 3 by the word "fizz". | ||
- Multiples of 5 by the word "buzz". | ||
- Multiples of 3 and 5 by the word "fizzbuzz". | ||
""" | ||
|
||
|
||
def fizzbuzz_1(): | ||
numbers = [] | ||
for num in range(1, 101): | ||
if num % 3 == 0 and num % 5 == 0: | ||
numbers.append("fizzbuzz") | ||
elif num % 3 == 0: | ||
numbers.append("fizz") | ||
elif num % 5 == 0: | ||
numbers.append("buzz") | ||
else: | ||
numbers.append(num) | ||
|
||
return numbers | ||
|
||
|
||
def fizzbuzz_2(): | ||
for i in range(1, 101): | ||
if i % 3 == 0 and i % 5 == 0: | ||
print("fizzbuzz") | ||
elif i % 3 == 0: | ||
print("fizz") | ||
elif i % 5 == 0: | ||
print("buzz") | ||
else: | ||
print(i) | ||
|
||
|
||
if __name__ == "__main__": | ||
print(fizzbuzz_1()) | ||
fizzbuzz_2() |
42 changes: 42 additions & 0 deletions
42
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/python/restevean.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
Write a program that receives a text and transforms natural language to | ||
"hacker language" (known really as "leet" or "1337"). This language | ||
is characterized by replacing alphanumeric characters. | ||
- Use this table (https://www.gamehouse.com/blog/leet-speak-cheat-sheet/) | ||
with the alphabet and numbers in "leet". | ||
(Use the first option of each transformation. For example "4" for the "a") | ||
""" | ||
|
||
|
||
LEET_DICT = {'A': '4', 'B': 'I3', | ||
'C': '[', 'D': ')', 'E': '3', | ||
'F': '|=', 'G': '&', 'H': '#', | ||
'I': '1', 'J': ',_|', 'K': '>|', | ||
'L': '1', 'M': '/\/\/', 'N': '^/', | ||
'O': '0', 'P': '|*', 'Q': '(_,)', | ||
'R': 'I2', 'S': '5', 'T': '7', | ||
'U': '(_)', 'V': '\/', 'W': '\/\/', | ||
'X': '><', 'Y': 'j', 'Z': '2', | ||
'1': 'L', '2': 'R', '3': 'E', | ||
'4': 'A', '5': 'S', '6': 'b', | ||
'7': 'T', '8': 'B', '9': 'G', | ||
'0': 'o' | ||
} | ||
|
||
|
||
def leet(message): | ||
result = "" | ||
|
||
for character in message: | ||
if character == " ": | ||
result += " " | ||
else: | ||
result += LEET_DICT[character.upper()] + " " | ||
|
||
return result[:-1] | ||
|
||
|
||
if __name__ == "__main__": | ||
# Test the program | ||
text = "Hello World" | ||
print(leet(text)) |
27 changes: 27 additions & 0 deletions
27
Retos/Reto #8 - EL GENERADOR PSEUDOALEATORIO [Media]/swift/juanjoseen.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import UIKit | ||
|
||
class RandomGenerator { | ||
private let primes: [Int] = [2, 3, 5, 7, 11, 13, 17, 19, 23, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167] | ||
private var index: Int = 0 | ||
|
||
private init() {} | ||
|
||
static let shared: RandomGenerator = RandomGenerator() | ||
|
||
func random() -> Int { | ||
let time: Int = Int(Date().timeIntervalSince1970 * 1000) | ||
let part1: Int = Int(time / getPrime()) | ||
let part2: Int = Int(part1 * getPrime()) | ||
return part2 % 101 | ||
} | ||
|
||
private func getPrime() -> Int { | ||
let prime: Int = primes[index] | ||
index = (index + 1) % primes.count | ||
return prime | ||
} | ||
|
||
} | ||
|
||
let rg: RandomGenerator = RandomGenerator.shared | ||
print(rg.random()) |