Skip to content

juanbiassini/core-code-from-scratch-readme

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 

Repository files navigation

core-code-from-scratch-readme

Week 1: Algorithms

Week Challenges
(Wednesday)

1. Let's make pizza 🍕

Description
Design an algorithm to prepare a pizza from scratch. Define the ingredients, what will be the flavor and the preparation.

Solution:

Flavor: Pepperoni pizza.

Ingredients:
  • Pizza dough.
  • Pizza sauce:
    • Tomato sauce.
    • Kosher salt.
    • Ground black pepper.
    • Granulated garlic.
    • Granulated onion.
    • Red bell pepper flakes.
    • Olive oil.
  • Pepperoni.
  • Shredded mozzarella cheese.
  • Fresh oregano (optional).
  • Flour.

Preparation:
  1. Procurement of ingredients.
  2. Preheat the oven.
  3. Prepare the sauce.
  4. Roll out the dough.
  5. Add the ingredients.
  6. Cooking pizza.
  7. Cut and serve (optional: add oregano).

2. Hot N Cold 🤒 🧊 🔥

Description
Define an algorithm that is able to convert temperatures from Celsius to Fahrenheit and vice versa.

Solution:

  1. Obtain the temperature value to be converted.
  2. If the temperature value is in degrees Fahrenheit, then use Formula A.
  3. Else (if in degrees Celcius) use Formula B.

A. Formula to convert from degrees Fahrenheit to degrees Celsius:
  1. I calculate C=(F-32)*5/9 where F is the temperature in degrees Fahrenheit.
  2. The final result C is the temperature in degrees Celcius.

B. Formula to convert from degrees Celsius to degrees Fahrenheit:
  1. I calculate F=(C*9/5)+32 where C is the temperature in degrees Celcius.
  2. The final result F is the temperature in degrees Fahrenheit.

3. Some geometry 📐

Description
Design an algorithm to calculate the volume of a pyramid, a cube and a sphere.

Solution:

  1. Knowing the body for which to calculate the volume
  2. If the body is a pyramid, then use Formula A.
  3. Else (if it is a cube) use Formula B.
  4. Else (if it is a sphere) use Formula C.

A. Formula to calculate the volume of a pyramid:
  1. I calculate V=1/3*b*a*h where b is the length of the base, a is the width of the base, and h is the height of the pyramid.
  2. The final result V is the volume of the pyramid.

B. Formula to calculate the volume of a cube:
  1. I calculate V=l^3 where l is the length of an edge of the base of the cube.
  2. The final result V is the volume of the cube.

C. Formula to calculate the volume of a sphere:
  1. I calculate V=4/3*π*r^3 where r is the radius of the sphere and π is the number pi.
  2. The final result V is the volume of the sphere.

Week Challenges
(Thursday)

4. Numbers 📈

Description
Design an algorithm to check if a number is even or odd. If it is even, write that it is even, otherwise write that it is odd. Represent the algorithm in a flowchart.

Solution:

Week 1 - Exercice 4

5. How old are you 👴

Description
Write pseudocode for an algorithm that calculates the age of a person based on date of birth.

Solution:

  1. PROGRAM How old are you;
  2. BEGIN
  3. OUTPUT("What's your date of birth?");
  4. INPUT(date of birth);
  5. SAVE date of birth -> date_of_birth;
  6. DEFINE current year -> rigth_now;
  7. DEFINE age -> age;
  8. RESULT age=rigth_now-date_of_birth;
  9. OUTPUT("is" + age + "years old");
  10. END.

6. Find the treasure 👑

Description
We are in a room with three chests. We know that at least one has a treasure in it. Each chest has a message, but all the messages are lies.

Left chest: The middle chest has a treasure
Middle chest: All these chests have treasures in them
Right chest: Only one of these chests has treasures.

Which chests have treasures?

202836372-19159ef8-14d5-4ecf-b08c-819b05e79f81

Solution:

  1. Since all messages are lies, let's change them to truth:
    • Left chest: The middle chest has no treasure.
    • Middle chest: No all chests have treasures on them.
    • Right chest: It's not possible for Only one of the chests to have a treasure.
  2. With the above analysis we have two options:
      A. None of the chests has a treasure.
      B. The chests on the left and right have treasure.
  3. We know that at least one chest has a treasure, so the only congruent option is that the left and right chests have a treasure.
  4. Answer: Chests A and C have treasures.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors