Skip to content

Added one Question #17

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

Closed
wants to merge 6 commits into from
Closed
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
22 changes: 22 additions & 0 deletions 100+ Python challenging programming exercises.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2373,4 +2373,26 @@ print solutions

#----------------------------------------#

Question:

The Doctor needs some stuff for his next adventure. He is currently on an alien planet and doesn't have any currency of that planet. But, he has a valuable gem that he found few days back on a planet when he was on his last adventure. The gem has some value N. He can get some coins with value 2 and some with 3 in exchange of the gem. Also, the sum of values of the coins will be equal to the value of the gem. Also, he wants to have maximum number of 3 valued coins as he'll have to carry less number of coins.Your task is to calculate the maximum number of 3 valued coins that he can get.

Hint:
use modulus of 3

Solution:

t=int(raw_input())
while(t):
n=int(raw_input())
r=n/3
y=n-r*3
if y==1:
r-=1
print r
t-=1

#----------------------------------------------------------------------------------------------------------------------------------------------#