From 47e85233acec62aa1ad71fdfffba6e01e0ad155d Mon Sep 17 00:00:00 2001 From: Adam <24621027+adoyle0@users.noreply.github.com> Date: Fri, 12 Jan 2024 09:36:47 -0500 Subject: [PATCH] add chops --- fibs/recursive_fibs.py | 9 +++++++++ find_odd_int/find_odd_int.js | 20 ++++++++++++++++++++ find_odd_int/find_odd_int.py | 7 +++++++ find_odd_int/find_odd_int.ts | 11 +++++++++++ fizzbuzz/fizzbuzz.js | 19 +++++++++++++++++++ fizzbuzz/fizzbuzz.py | 12 ++++++++++++ fizzbuzz/fizzbuzz.ts | 20 ++++++++++++++++++++ 7 files changed, 98 insertions(+) create mode 100644 fibs/recursive_fibs.py create mode 100644 find_odd_int/find_odd_int.js create mode 100644 find_odd_int/find_odd_int.py create mode 100644 find_odd_int/find_odd_int.ts create mode 100644 fizzbuzz/fizzbuzz.js create mode 100644 fizzbuzz/fizzbuzz.py create mode 100644 fizzbuzz/fizzbuzz.ts diff --git a/fibs/recursive_fibs.py b/fibs/recursive_fibs.py new file mode 100644 index 0000000..4a10cc7 --- /dev/null +++ b/fibs/recursive_fibs.py @@ -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) diff --git a/find_odd_int/find_odd_int.js b/find_odd_int/find_odd_int.js new file mode 100644 index 0000000..9ed7870 --- /dev/null +++ b/find_odd_int/find_odd_int.js @@ -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)); diff --git a/find_odd_int/find_odd_int.py b/find_odd_int/find_odd_int.py new file mode 100644 index 0000000..1dcf6e8 --- /dev/null +++ b/find_odd_int/find_odd_int.py @@ -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])) diff --git a/find_odd_int/find_odd_int.ts b/find_odd_int/find_odd_int.ts new file mode 100644 index 0000000..40cde13 --- /dev/null +++ b/find_odd_int/find_odd_int.ts @@ -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)) diff --git a/fizzbuzz/fizzbuzz.js b/fizzbuzz/fizzbuzz.js new file mode 100644 index 0000000..4af064d --- /dev/null +++ b/fizzbuzz/fizzbuzz.js @@ -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); diff --git a/fizzbuzz/fizzbuzz.py b/fizzbuzz/fizzbuzz.py new file mode 100644 index 0000000..995af5b --- /dev/null +++ b/fizzbuzz/fizzbuzz.py @@ -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 diff --git a/fizzbuzz/fizzbuzz.ts b/fizzbuzz/fizzbuzz.ts new file mode 100644 index 0000000..0041890 --- /dev/null +++ b/fizzbuzz/fizzbuzz.ts @@ -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);