add chops
This commit is contained in:
parent
b3e31318a3
commit
47e85233ac
7 changed files with 98 additions and 0 deletions
9
fibs/recursive_fibs.py
Normal file
9
fibs/recursive_fibs.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
def fib(n):
|
||||
if n <= 1:
|
||||
return n
|
||||
else:
|
||||
return fib(n-1) + fib(n-2)
|
||||
|
||||
out = [fib(i) for i in range(1,54)]
|
||||
for line in out:
|
||||
print(line)
|
20
find_odd_int/find_odd_int.js
Normal file
20
find_odd_int/find_odd_int.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.findOdd = void 0;
|
||||
var findOdd = function (numbers) {
|
||||
var _loop_1 = function (number) {
|
||||
if (numbers.filter(function (x) { return x === number; }).length % 2 !== 0) {
|
||||
return { value: number };
|
||||
}
|
||||
};
|
||||
for (var _i = 0, numbers_1 = numbers; _i < numbers_1.length; _i++) {
|
||||
var number = numbers_1[_i];
|
||||
var state_1 = _loop_1(number);
|
||||
if (typeof state_1 === "object")
|
||||
return state_1.value;
|
||||
}
|
||||
return 69;
|
||||
};
|
||||
exports.findOdd = findOdd;
|
||||
var test = [1, 1, 2, 3, 2];
|
||||
console.log((0, exports.findOdd)(test));
|
7
find_odd_int/find_odd_int.py
Normal file
7
find_odd_int/find_odd_int.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
def findOdd(numbers: list[int]) -> int:
|
||||
for number in numbers:
|
||||
if numbers.count(number) % 2 != 0:
|
||||
return number
|
||||
return 69
|
||||
|
||||
print(findOdd([1,1,2,3,2]))
|
11
find_odd_int/find_odd_int.ts
Normal file
11
find_odd_int/find_odd_int.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
export const findOdd = (numbers: number[]): number => {
|
||||
for (const number of numbers) {
|
||||
if (numbers.filter(x => x===number).length % 2 !== 0){
|
||||
return number;
|
||||
}
|
||||
}
|
||||
return 69;
|
||||
}
|
||||
|
||||
const test: number[] = [1,1,2,3,2]
|
||||
console.log(findOdd(test))
|
19
fizzbuzz/fizzbuzz.js
Normal file
19
fizzbuzz/fizzbuzz.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
function fizzBuzz(stopNumber) {
|
||||
var i = 1;
|
||||
while (i < stopNumber + 1) {
|
||||
if (i % 5 === 0 && i % 3 === 0) {
|
||||
console.log('FizzBuzz');
|
||||
}
|
||||
else if (i % 3 === 0) {
|
||||
console.log('Fizz');
|
||||
}
|
||||
else if (i % 5 === 0) {
|
||||
console.log('Buzz');
|
||||
}
|
||||
else {
|
||||
console.log(i);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
fizzBuzz(30);
|
12
fizzbuzz/fizzbuzz.py
Normal file
12
fizzbuzz/fizzbuzz.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
i = 1
|
||||
|
||||
while i <= 30:
|
||||
if i % 5 == 0 and i % 3 == 0:
|
||||
print('fizzbuzz')
|
||||
elif i % 3 == 0:
|
||||
print('fizz')
|
||||
elif i % 5 == 0:
|
||||
print('buzz')
|
||||
else:
|
||||
print(i)
|
||||
i +=1
|
20
fizzbuzz/fizzbuzz.ts
Normal file
20
fizzbuzz/fizzbuzz.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
function fizzBuzz(stopNumber: number) {
|
||||
let i = 1;
|
||||
while (i < stopNumber + 1) {
|
||||
if (i % 5 === 0 && i % 3 === 0) {
|
||||
console.log('FizzBuzz');
|
||||
}
|
||||
else if (i % 3 === 0) {
|
||||
console.log('Fizz')
|
||||
}
|
||||
else if (i % 5 === 0) {
|
||||
console.log('Buzz')
|
||||
}
|
||||
else {
|
||||
console.log(i)
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
fizzBuzz(30);
|
Loading…
Add table
Reference in a new issue