add chops

This commit is contained in:
Adam 2024-01-12 09:36:47 -05:00
parent b3e31318a3
commit 47e85233ac
7 changed files with 98 additions and 0 deletions

9
fibs/recursive_fibs.py Normal file
View 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)

View 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));

View 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]))

View 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
View 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
View 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
View 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);