Nov-27-2017, 06:36 PM
(This post was last modified: Nov-27-2017, 06:47 PM by harryvandervelden.)
I've got an assignment to do, can someone help me out? I don't have a clue what to do.
The bitcoin is a digital currency whose value can go up and down considerably.
From an acquaintance with predictive gifts you get the value of the bitcoin in euros for the next N days.
You can now try to make as much profit as possible in that period.
The following applies:
The aim is to make as much profit as possible at the end of the period.
Your program reads the number N from a standard input first. Then your program reads N lines, each with a number W, which indicates the value of the bitcoin on the relevant day.
Your program writes to standard output one line with the maximum profit you can
pick up in these N days. That could possibly be 0; you do not have to make a purchase.
Example
Input:
10
5
11
4
2
8
10
7
4
3
6
Output:
17
A time limit of 2 seconds applies to the program.
Preconditions: In eight out of ten test cases, 1 <N <100 applies. In one test case, N = 2000 and in one test case N = 100000 applies. For every number W 0 <W <100 applies.
this is what i have now:
The bitcoin is a digital currency whose value can go up and down considerably.
From an acquaintance with predictive gifts you get the value of the bitcoin in euros for the next N days.
You can now try to make as much profit as possible in that period.
The following applies:
- At the beginning you do not have a bitcoin. At the end of the period you do not have a bitcoin.
You may never have more than one bitcoin at a time.
Every day of the period you can buy a bitcoin if you do not own one, or sell the bitcoin that you own.
The aim is to make as much profit as possible at the end of the period.
Your program reads the number N from a standard input first. Then your program reads N lines, each with a number W, which indicates the value of the bitcoin on the relevant day.
Your program writes to standard output one line with the maximum profit you can
pick up in these N days. That could possibly be 0; you do not have to make a purchase.
Example
Input:
10
5
11
4
2
8
10
7
4
3
6
Output:
17
A time limit of 2 seconds applies to the program.
Preconditions: In eight out of ten test cases, 1 <N <100 applies. In one test case, N = 2000 and in one test case N = 100000 applies. For every number W 0 <W <100 applies.
this is what i have now:
length = int(raw_input()) list = [] for x in range(0, length): list.append(raw_input()) minm = [] maxm = [] i=0 while i < length-1: if i < length - 1: while i < length-1 and y[i+1] >= y[i]: i+=1 if i != 0 and i < length-1: maxm = np.append(maxm,i) i+=1 if i < length - 1: while i < length-1 and y[i+1] <= y[i]: i+=1 if i < length-1: minm = np.append(minm,i) i+=1 print minm print maxm print(lijst)