₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,330,296 members, 8,444,840 topics. Date: Tuesday, 14 July 2026 at 07:04 AM

Toggle theme

Ektbear's Posts

Nairaland ForumEktbear's ProfileEktbear's Posts

1 2 3 4 5 6 7 8 ... 45 46 47 48 49 50 51 52 53 (of 485 pages)

PoliticsRe: In Event Of World War 3, Would Nigeria Be A Safe Country To Reside? by ektbear: 12:06am On Nov 17, 2012
Yes, it would.
Christianity EtcRe: Four-week-old Colombian Baby Can Walk & Breathe Fire by ektbear: 9:20am On Nov 16, 2012
cray
FoodFoods You Absolutely Cannot Stand by ektbear(op): 9:16am On Nov 16, 2012
For me, turkey and shrimp.
ProgrammingRe: Dynamic Programming Puzzle by ektbear(op): 9:12am On Nov 16, 2012
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]).
PoliticsRe: Ifeanyi Ubah's Assets Frozen Worldwide by ektbear: 8:42am On Nov 16, 2012
begwong: shebi Ubah said oga Maduka na pure water biz him dey do?
see pure water bizman get injunction to freeze billionaire's assets worldwide!
grin
RomanceRe: Do You Ever Plan On Being In A Permanent Relationship? by ektbear: 7:43am On Nov 16, 2012
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).
ComputersRe: John McAfee Wanted For Murder In Belize by ektbear: 7:19am On Nov 16, 2012
eledalo: These are the best jokes you can come up with? cry
grin cheesy
ProgrammingRe: Dynamic Programming Puzzle by ektbear(op): 6:59am On Nov 16, 2012
Yep, so yours is a DP algorithm, running forwards
RomanceRe: Do You Ever Plan On Being In A Permanent Relationship? by ektbear: 3:00pm On Nov 15, 2012
yes, within 4-5 years or so
TV/MoviesRe: Amazing Violin Rendition Of Davido's "Dami Duro" At Nigeria's Got Talent by ektbear: 2:48pm On Nov 15, 2012
pretty good

ventriloquist also good
ProgrammingRe: Dynamic Programming Puzzle by ektbear(op): 2:20am On Nov 15, 2012
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.
Foreign AffairsRe: Why Has China Built A Ghost Town In Africa? China Is Taking Over Africa...!!!? by ektbear: 11:11pm On Nov 14, 2012
The weak are food for the strong. This has always been the way of life on this planet.
PoliticsRe: Harvard-educated Nigerian Woman Flys To UK For 'emergency Caesarean' by ektbear: 10:27pm On Nov 14, 2012
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
grin
PoliticsRe: SW Leaders Led By Tinubu Do Not Want Regionalism, Shamelessly Prefer Status Quo by ektbear: 7:54pm On Nov 14, 2012
What is the universal definition of "regionalism?"

The OP is implicitly assuming that there is only one definition that everyone would agree on, no?
ProgrammingRe: Dynamic Programming Puzzle by ektbear(op): 7:48pm On Nov 14, 2012
[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"??
You should have implemented it using the standard modules that comes with python.... Numpy wasnt exactly necessary here.
This doesn't really matter. If you like, modify the example to only use the library random rather than np.random.
ProgrammingRe: Dynamic Programming Puzzle by ektbear(op): 6:08pm On Nov 14, 2012
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?
BusinessRe: Businesses You Can Start With Little Or No Money by ektbear: 9:21am On Nov 14, 2012
he would have earned more than $250/day with google, i believe.

na the largest website in nigeria
ProgrammingRe: Dynamic Programming Puzzle by ektbear(op): 9:20am On Nov 14, 2012
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)
------------
PoliticsRe: North Demands Death Penalty For Corruption by ektbear: 9:05am On Nov 14, 2012
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
ProgrammingRe: Dynamic Programming Puzzle by ektbear(op): 9:03am On Nov 14, 2012
Here is python code for the slow algorithm:
http://pastebin.com/6yyXJQXh
ProgrammingRe: Dynamic Programming Puzzle by ektbear(op): 3:30am On Nov 14, 2012
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.
PoliticsRe: Remembering Biafra-New York Times Review by ektbear: 2:13am On Nov 14, 2012
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
Foreign AffairsRe: Secession Bid Of Texas And Obama's War Options! by ektbear: 12:51am On Nov 14, 2012
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
PoliticsRe: Remembering Biafra-New York Times Review by ektbear: 12:48am On Nov 14, 2012
lmao grin

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"
Foreign AffairsRe: Secession Bid Of Texas And Obama's War Options! by ektbear: 12:34am On Nov 14, 2012
manny, isn't worth wasting your time discussing this with people who don't even live in yankee or understand how things work
ProgrammingRe: Dynamic Programming Puzzle by ektbear(op): 12:29am On Nov 14, 2012
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.
FamilyRe: What Will You Do When Your Daughter Starts To Date? by ektbear: 12:19am On Nov 14, 2012
this is why i hope i only have sons
ProgrammingDynamic Programming Puzzle by ektbear(op): 9:05pm On Nov 13, 2012
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)