Skip to content
Open
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
30 changes: 30 additions & 0 deletions questions/Golden-Treasure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# The Golden Treasure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice name!


## 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
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 even-numbered indices

Copy link
Collaborator

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The 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]
Copy link
Collaborator

Choose a reason for hiding this comment

The 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)
```