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_142.md
Created October 30, 2020 01:14
Challenge 142 - Total Volume of All Boxes

Challenge 142 - Total Volume of All Boxes

Given a list of boxes, create a function that returns the total volume of all those boxes combined together. A box is represented by a list with three elements: length, width, and height.

For instance, total_volume([2, 3, 2], [6, 6, 7], [1, 2, 1]) should return 266 since (2 x 3 x 2) + (6 x 6 x 7) + (1 x 2 x 1) = 12 + 252 + 2 = 266.

Examples

total_volume((4, 2, 4), (3, 3, 3), (1, 1, 2), (2, 1, 1)) ➞ 63
@ZechCodes
ZechCodes / challenge_141.md
Created October 29, 2020 01:56
Challenge 141 - Apocalyptic Numbers

Challenge 141 - Apocalyptic Numbers

A number n is apocalyptic if 2^n contains a string of 3 consecutive 6s (666 being the presumptive "number of the beast").

Create a function that takes a number n as input. If the number is apocalyptic, find the index of 666 in 2^n, and return "Repent! X days until the Apocalypse!" (X being the index). If not, return "Crisis averted. Resume sinning.".

Examples

apocalyptic(109) ➞ "Crisis averted. Resume sinning."
@ZechCodes
ZechCodes / challenge_140.md
Created October 27, 2020 01:32
Challenge 140 - Older Than Me

Challenge 140 - Older Than Me

Create a Person class which which takes name and age parameters at initialization. Then create a method compare_age which takes a person as a parameter and returns a string with the following format:

{other_person} is {older than / younger than / the same age as} me.

Examples

p1 = Person("Samuel", 24)
@ZechCodes
ZechCodes / challenge_139.md
Last active October 26, 2020 01:56
Challenge 139 - Halloween Day

Challenge 139 - Halloween Day

Create a function that takes date in the format yyyy/mm/dd as an input and returns "Trick or Treat" if the date is October 31, else return "Trick".

Examples

halloween("2013/10/31") ➞ "Trick or Treat"

halloween("2012/07/31") ➞ "Trick"
@ZechCodes
ZechCodes / challenge_138.md
Last active October 25, 2020 02:48
Challenge 138 - Length of Worm

Challenge 138 - Length of Worm

Given a string worm create a function that takes the length of the worm and converts it into millimeters. Each - represents one centimeter.

Examples

worm_length("----------") ➞ "100 mm."

worm_length("") ➞ "invalid"
@ZechCodes
ZechCodes / challenge_137.md
Created October 23, 2020 01:57
Challenge 137 - Even or Odd Number of Factors

Challenge 137 - Even or Odd Number of Factors

Create a function that returns "even" if a number has an even number of factors and "odd" if a number has an odd number of factors.

Examples

factor_group(33) ➞ "even"

factor_group(36) ➞ "odd"
@ZechCodes
ZechCodes / challenge_136.md
Created October 21, 2020 01:47
Challenge 136 - Spin Around, Touch the Ground

Challenge 136 - Spin Around, Touch the Ground

Given a list of directions to spin, "left" or "right", return an integer of how many full 360° rotations were made. Note that each word in the list counts as a 90° rotation in that direction.

Worked Example

spin_around(['right', 'right', 'right', 'right', 'left', 'right', ]) ➞ 1
# You spun right 4 times (90 * 4 = 360)
# You spun left once (360 - 90 = 270)
# But you spun right once more to make a full rotation (270 + 90 = 360)
@ZechCodes
ZechCodes / challenge_135.md
Last active October 19, 2020 01:04
Challenge 135 - Temperature Conversion

Challenge 135 - Temperature Conversion

Write a program that takes a temperature input in celsius and converts it to Fahrenheit and Kelvin. Return the converted temperature values in a tuple.

The formula to calculate the temperature in Fahrenheit from Celsius is:

F = C*9/5 +32

The formula to calculate the temperature in Kelvin from Celsius is:

@ZechCodes
ZechCodes / challenge_134.md
Created October 18, 2020 01:31
Challenge 134 - Card Counting (BlackJack)

Challenge 134 - Card Counting (BlackJack)

In BlackJack, cards are counted with -1, 0, 1 values:

  • 2, 3, 4, 5, 6 are counted as +1
  • 7, 8, 9 are counted as 0
  • 10, J, Q, K, A are counted as -1

Create a function that counts the number and returns it from the list of cards provided.

@ZechCodes
ZechCodes / challenge_133.md
Created October 17, 2020 00:29
Challenge 133 - Double Letters

Challenge 133 - Double Letters

Create a function that takes a word and returns True if the word has two consecutive identical letters.

Examples

double_letters("loop") ➞ True

double_letters("yummy") ➞ True