Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iswaryachallengeone #274

Open
wants to merge 4 commits into
base: solution
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ We have created starter projects in Java, Scala, and Python that you can use to
- [Scala Project](scala/README.md)
- [Python Project](python/README.md)

Note: We will be coding in Scala for the Hours with Experts course but for this challenge you can choose any language you like.
Note: We will be coding in Python for the Hours with Experts course and strongly recommend you submit your code in python, but you are welcome to choose any language you would like and we'll take that into account.

#### Important
When you are ready to start working on your solution, create a new branch called - yournameChallengeThree - ex) nickraffertyChallengeThree
Expand Down
1 change: 1 addition & 0 deletions github/funfacts/Spring2022/Iswarya/funfacts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Iswarya Rajasekaran - I love to cook and play with children.
13 changes: 13 additions & 0 deletions python/decoded_recipe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
1 cup of butter
1 cup of dark brown sugar, packed
1 cup of granulated sugar
2 of eggs
1 teaspoon of vanilla
2 1/2 cups of oatmeal
2 cups of flour
1/2 teaspoon of salt
1 teaspoon of baking soda
1 teaspoon of baking powder
12 ounces of chocolate chips
1 of 4-ounce milk chocolate bar
1 1/2 cups of chopped nuts
18 changes: 16 additions & 2 deletions python/secret_recipe_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,32 @@ def __init__(self, amount, description) -> None:
def decode_string(str):
"""Given a string named str, use the Caesar encoding above to return the decoded string."""
# TODO: implement me
return '1 cup'
decoded_string = ''.join(ENCODING.get(char, char) for char in str)
return decoded_string


def decode_ingredient(line):
"""Given an ingredient, decode the amount and description, and return a new Ingredient"""
# TODO: implement me
return Ingredient("1 cup", "butter")
amount_encoded, description_encoded = line.split('#', 1)
amount_decoded = decode_string(amount_encoded.strip())
description_decoded = decode_string(description_encoded.strip())
return Ingredient(amount_decoded, description_decoded)


def main():
"""A program that decodes a secret recipe"""
# TODO: implement me
input_file = 'secret_recipe.txt'
output_file = 'decoded_recipe.txt'

with open(input_file, 'r') as file:
lines = file.readlines()

with open(output_file, 'w') as file:
for line in lines:
ingredient = decode_ingredient(line.strip())
file.write(f"{ingredient.amount} of {ingredient.description}\n")

if __name__ == "__main__":
main()