Ektbear's Posts
Nairaland Forum › Ektbear's Profile › Ektbear's Posts
1 2 3 4 5 6 7 8 ... 45 46 47 48 49 50 51 52 53 (of 485 pages)
Yes, it would. |
cray |
For me, turkey and shrimp. |
Ah, interesting. Yeah, max subarray is equivalent to this problem (max subarray of the list L is the min subarray of the list M with M[i]=-L[i]). |
begwong: shebi Ubah said oga Maduka na pure water biz him dey do? ![]() |
Today, I made progress towards this goal. A certain individual who I have very strong feelings for but am incompatible with, we've agreed to just be friends (rather than the previous emotionally damaging fwb but not quite in a relationship situation). |
eledalo: These are the best jokes you can come up with? ![]() |
Yep, so yours is a DP algorithm, running forwards |
yes, within 4-5 years or so |
pretty good ventriloquist also good |
Here is my own solution: http://pastebin.com/6yyXJQXh Mine basically computes the worst list starting at each value i=1,2,...,N, then takes the minimum over those N different possible choices. I do this by first computing a solution for i=N, then i=N-1, etc. I think Prince's solution is similar to mine, except: a) computes answers from the front to the beginning (i.e., from i=1, then i=2, etc) b) and then rather than taking the minimum at the very end, just computes a running version of it. (b) in particular means he uses less memory than I do. |
The weak are food for the strong. This has always been the way of life on this planet. |
seanet01: Hmm, u are wicked. Okay be like say the guy dey talk about the princeton school one day if i could recollect very. Fake Doctors abound worldwide. Lol ![]() |
What is the universal definition of "regionalism?" The OP is implicitly assuming that there is only one definition that everyone would agree on, no? |
[quote author=₱®ÌИСΞ]Yea it works....I tried it on ur samples....it recieves all d values in a single line (each seperated by a space) and prints out d GMP(greatest minimum profit)[/quote]OK, it looks like your approach works on the examples I tried. Good job. It wasn't what I had in mind, but that is fine. Can you modify your code to return the correct indices too, corresponding to the least profitable interval? WhiZTiM: Why did you use "numpy"??This doesn't really matter. If you like, modify the example to only use the library random rather than np.random. |
How does your code work on sample inputs? Did you try it on the same sample inputs I posted? If so, does it correctly identify the least profit interval? |
he would have earned more than $250/day with google, i believe. na the largest website in nigeria |
And here is the result of running the above code on some examples: ------------------------------------- [ -7 -2 7 -8 0 6 7 -9 -2 3 -7 4 -10 2 -4] Our worst profit is: -23 Starting/ending indices of worst profit is: (7, 14) [-9 -9 -7 6 -8 6 -7 -5 2 -6 0 -2 5 4 -5] Our worst profit is: -39 Starting/ending indices of worst profit is: (0, 11) [-9 -2 4 -3 9 -6 -1 -2 -3 6 -3 -8 6 -9 -9] Our worst profit is: -30 Starting/ending indices of worst profit is: (0, 14) [ 3 7 -7 -3 -1 -8 -2 -6 6 -7 1 -6 -5 1 3] Our worst profit is: -38 Starting/ending indices of worst profit is: (2, 12) [ 6 -1 -3 -4 1 -2 9 0 9 3 4 7 8 -8 -3] Our worst profit is: -11 Starting/ending indices of worst profit is: (13, 14) ------------ |
At the federal level, sure. But at the state level, this should be left to the people of each state to decide. Btw, since almost everyone in nigerian politics is corrupt...if not done properly this can be used selectively to have enemies executed |
Here is python code for the slow algorithm: http://pastebin.com/6yyXJQXh |
Here is the crappy solution that doesn't use DP. Essentially, assuming we have a list of N numbers, we need to 1) examine all possible pairs of indices a,b for which a<b 2) Compute the profit/loss over the interval a through b 3) return the smallest profit over all of the (a,b) pairs we found in step (1). So, for step 1, how many pairs are there? Just T=(N^2-N)/2 (it is easiest to see this by drawing a picture). For each interval, we can compute its profit/loss in at most time N. Taking the maximum over the T intervals takes at most another O(T) time. So overall, we have a O(N^3) algorithm. Would be pretty straightforward to code up. |
Prof Corruption: Adam Nossiter is West Africa bureau chief for The Times and the author of books on France and Mississippi.Nossiter sounds like an Gwari name to me. Typical Biafra hater |
A key part of my sentence was "understand how things work." Some people have lived in America all their lives. Maybe their ancestors came to the country in the 1600s even. This does not mean that they understand how things work |
lmao ![]() Well, when you write from a clearly biased point of view not in touch with reality, don't be disappointed when people call you out on it. I see that nobody is attempting to counter the author's points about Achebe's book. All we hear is "NY Times doesn't like group XYZ" |
manny, isn't worth wasting your time discussing this with people who don't even live in yankee or understand how things work |
I got this problem this morning...companies seem to like asking DP problems for some reason. Here it goes: You are a stock broker. You have a list of gains/losses for N days for some stock. For example, if N=7 and corresponds to one week (Monday through Sunday), the gain/losses might look like the following: -1 10 5 -3 7 0 0 So the stock went down by 1 dollar on Monday, up by 10 on Tuesday,, up by 5 on Weds, etc. You are interested in computing the smallest profit over any consecutive sequence of days. For example, if N=365, there might have been a really bad sequence of say 3 consecutive days when the stock fell really hard. For this to be the worst consecutive sequence, the amount of money accrued on that day obviously has to be worse than that of any other sequence. So in particular, I lose more money on this particular 3 day sequence than I lost on any other: 1 day sequence 2 day sequence 3 day sequence 4 day sequence.. etc. Eyeballing the above 7 day sequence, the worst profit seems to -3. Your job is to write an algorithm that computes this smallest profit. Note that you don't need to necessarily identify the starting and end days associated with the smallest profit, just the number itself. Hints: 1) There exists a DP-based algorithm that runs in O(N) time. 2) First think perhaps of a brute-force solution, the one someone might do if they've never heard of dynamic programming before in their lives. I came up with a brute force solution that is O(N^3). Then think if you can use DP to come up with a better solution. |
this is why i hope i only have sons |
This space reserved...will post in a bit |
1 2 3 4 5 6 7 8 ... 45 46 47 48 49 50 51 52 53 (of 485 pages)

