-
Notifications
You must be signed in to change notification settings - Fork 2
Added question about Golden Treasure #8
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||
| # The Golden Treasure | ||||||
|
|
||||||
| ## Question | ||||||
|
|
||||||
| Welcome to **The Golden Treasure** | ||||||
|
|
||||||
| You are stranded on an island with one other person. To get back to land, you have to dig up a treasure. The only problem? The treasure is behind a very secure lock. The only way to break the lock is to ask The Second Monster to open it. The Second Monster demands you to solve a problem he has. Including 0, sum up all the elements at the indexes which divide evenly into 2 | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very fun that the Monster is named after their puzzle |
||||||
|
|
||||||
| ## Input | ||||||
|
|
||||||
| Given a sample input list like this | ||||||
| ```python | ||||||
| numbers = [5,18,2,35,19,20,9] | ||||||
| ``` | ||||||
| Turn it into an output like | ||||||
| ```python | ||||||
| sum = 5+2+19+9 | ||||||
| sum = 35 | ||||||
| ``` | ||||||
|
Comment on lines
+16
to
+19
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a great example 👍 |
||||||
| You take the elements starting from 0 and then take every 2nd element after that. So it'd be 5+2+19+9 | ||||||
|
|
||||||
| ## Sample Solution | ||||||
| ```python | ||||||
| list1 = [32,55,1,23,55,46,78] | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks great here. Only thing is maybe avoid variables like List1 in cases where you are using lots of variables |
||||||
| sum = 0 | ||||||
| for i in range(len(list1)): | ||||||
| if i % 2 == 0: | ||||||
| sum+=list1[i] | ||||||
| print(sum) | ||||||
| ``` | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice name!