Skip to content

Instantly share code, notes, and snippets.

View ZechCodes's full-sized avatar
🏄‍♂️
Surfing on a space-time bubble

Zech Zimmerman ZechCodes

🏄‍♂️
Surfing on a space-time bubble
View GitHub Profile
@ZechCodes
ZechCodes / challenge_172.md
Created January 28, 2021 01:22
Challenge 172 - Growth of a Population

Challenge 172 - Growth of a Population

In a small town the population is p0 = 1000 at the beginning of a year. The population regularly increases by 2 percent per year and moreover 50 new inhabitants per year come to live in the town. How many years does the town need to see its population greater or equal to p = 1200 inhabitants?

At the end of the first year there will be: 1000 + 1000 * 0.02 + 50 => 1070 inhabitants

At the end of the 2nd year there will be: 1070 + 1070 * 0.02 + 50 => 1141 inhabitants (number of inhabitants is an integer)

@ZechCodes
ZechCodes / challenge_171.md
Last active January 27, 2021 00:30
Challenge 171 - Sum of Missing Numbers

Challenge 171 - Sum of Missing Numbers

Create a function that returns the sum of missing numbers from the given list.

Examples

sum_missing_numbers([4, 3, 8, 1, 2]) ➞ 18
# 5 + 6 + 7 = 18

sum_missing_numbers([17, 16, 15, 10, 11, 12]) ➞ 27
@ZechCodes
ZechCodes / challenge_170.md
Last active January 26, 2021 00:56
Challenge 170 - Fruit Salad 🍇🍓🍎

Challenge 170 - Fruit Salad 🍇🍓🍎

Fruit salads are served best when the fruits are sliced and diced into small chunks!

For this challenge, slice each fruit in half and sort the chunks alphabetically. This recipe tastes best when the chunks are joined together to make a string.

Example

fruit_salad(['apple', 'pear', 'grapes']) ➞ 'apargrapepesple'
@ZechCodes
ZechCodes / challenge_169.md
Created January 23, 2021 02:03
Challenge 169 - Card Flipping Game

Challenge 169 - Card Flipping Game

This challenge is about a simple card flipping solitaire game. You're presented with a sequence of cards, some face up, some face down. You can remove any face up card, but you must then flip the adjacent cards (if any). The goal is to successfully remove every card. Making the wrong move can get you stuck.

In this challenge, a 1 signifies a face up card and a 0 signifies a face down card. We will also use zero-based indexing, starting from the left, to indicate specific cards. So, to illustrate a game, consider this starting card set.

0100110

I can choose to remove card 1, 4, or 5 since these are face up. If I remove card 1, the game looks like this (using . to signify an empty spot):

@ZechCodes
ZechCodes / challenge_168.md
Created January 20, 2021 02:08
Challenge 168 - Count Palindrome Numbers

Challenge 168 - Count Palindrome Numbers

Create a function that returns the number of palindrome numbers in a specified range (inclusive).

For example, between 8 and 34, there are 5 palindromes: 8, 9, 11, 22, and 33. Between 1550 and 1552 there is exactly one palindrome: 1551.

Examples

count_palindromes(1, 10) ➞ 9
@ZechCodes
ZechCodes / challenge_167.md
Created January 19, 2021 01:33
Challenge 167 - Determine If Two Numbers Add up to a Target Value

Challenge 167 - Determine If Two Numbers Add up to a Target Value

Given two unique integer lists and an integer target value, create a function to determine whether there is a pair of numbers that add up to the target value, where one number comes from one list and the other comes from the second list.

Return True if there is a pair that adds up to the target value and False otherwise.

Examples

sum_of_two([1, 2], [4, 5, 6], 5) ➞ True
@ZechCodes
ZechCodes / challenge_166.md
Created January 16, 2021 01:35
Challenge 166 - Scottish Screaming

Challenge 166 - Scottish Screaming

A strong Scottish accent makes every vowel similar to an "e", so you should replace every vowel with an "e". Additionally, it is being screamed, so it should be in block capitals.

Create a function that takes a string and returns a string.

Examples

to_scottish_screaming("hello world") ➞ "HELLE WERLD"
@ZechCodes
ZechCodes / challenge_165.md
Created January 14, 2021 02:37
Challenge 165 - Double Factorial

Challenge 165 - Double Factorial

Create a function that takes a number num and returns its double factorial. Mathematically, the formulas for double factorial are as follows.

num !! = num ( num - 2)( num - 4)( num - 6) ... (4)(2)

If num == 0 or num == -1, then num !! == 1 by convention.

Examples

@ZechCodes
ZechCodes / challenge_164.md
Created January 13, 2021 02:15
Challenge 164 - Unusual Subtraction

Challenge 164 - Unusual Subtraction

Create a function that subtracts 1 from n (unless it ends in 0) k number of times. If n ends in 0, remove the 0.

To illustrate

n = 22
k = 3

This means our number is 22 and we have to repeat the algorithm three times. 22 does not end in 0 so we continue subtracting 1.

@ZechCodes
ZechCodes / challenge_163.md
Created January 12, 2021 03:29
Challenge 163 - Calculate the Missing Value with Ohm's Law

Challenge 163 - Calculate the Missing Value with Ohm's Law

Create a function that calculates the missing value of 3 inputs using Ohm's law. The inputs are v, r or i (aka: voltage, resistance and current).

Ohm's law:

V = R * I

Return the missing value rounded to two decimal places.