Can I provide a solution by dragging pretty coloured icons onto a designer surface and then have a cup of tea?
- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Write Algorithm – interview question
Collapse
X
-
-
I actually would not be suprised if they accepted your solution rather than mine...Originally posted by Rebecca LoosAtW, I agree your solution is more elegant than mine
IMO there is too big emphasis onto how this simple problem is to be solved - they should be giving some real hard problems where solving the problem is important, not whether you use external function or not.
Perhaps the real answer they were looking for was that you will just outsource coding to people on Rent-A-Coder.Last edited by AtW; 2 December 2005, 18:14.Comment
-
I wouldn't hire you mr atw - pass your parameters in using the correct type - percentages are floats, times should be typed too - what if the caller assumes a 24 hour clock - also I don't like iTradingDone as an int - what about rounding errors on each call - gosh the things I have to teach you people on here.Originally posted by AtWChrist, is it what they pay stupid money for working in Banks?
-------------------------------------------------------
8:01 - 9:00 20% [i.e each minute is 1/3 %]
9:01 - 10:00 40% [i.e each minute is 2/3 %]
10:01 - 11:00 30% [i.e each minute is 1/2 %]
11:01 - 12:00 10% [i.e each minute is 1/6 %]
-------------------------------------------------------
1) you need simple function - CalcTradingRatio that accepts the following arguements:
a) %-tage of trading in given period
b) period start time, ie 8:01
c) period end time, ie 9:00
d) current time: this can be
d1) INSIDE period - in this case you calculation and return fraction of parameter a)
d2) BEFORE period starts (ie smaller then b) - return 0
d3) AFTER period ends - return full value a)
2) macro function that calls 1) for all periods:
string sCurTime="8:55";
int iTradingDone=0;
iTradingDone+=CalcTradingRatio("20","8:01","9:00", sCurTime);
iTradingDone+=CalcTradingRatio("40","9:01","10:00" ,sCurTime);
iTradingDone+=CalcTradingRatio("30","10:01","11:00 ",sCurTime);
iTradingDone+=CalcTradingRatio("10","11:01","12:00 ",sCurTime);
JabberNerdLast edited by Jabberwocky; 4 December 2005, 01:12.Comment
-
also there was no mention of needing current time in the parameters only a start and end time.
or am I wrong .... should I wear the dunces cap ?Comment
-
Anyone notice the question has an error?
... perhaps that was the real point of the exercise.
Just my banking experience showing through :-)Behold the warranty -- the bold print giveth and the fine print taketh away.Comment
-
Shut up.Originally posted by RSolesOne golden rule of recursion:-
"Never use recursion"
Computers' resources are finite, recursion's appetite for resources isn't.
P.S. I'm not promoting recursion for the algorithm in discussion.
P.P.S. Developers who write off techniques in one sweeping comment are generally crap.Comment
-
Its beyond me why anyone would write a recursive algorithm especially
when you can write this as a one liner.
I'm alright JackComment
-
Also it depends what programming language we are talking about
In Oracle PL/SQL you can use the decode function and write it in a one liner with itChico, what time is it?Comment
-
I got caught by an interview question like this once.
I thought that he wanted to see how neat an algorithm I could come up with.
He didn't, he was more interested in seeing whether I bothered to validate the parameters etc before using them, which of course I had taken as read in an interview question but would have done in the real world.
I was annoyed with being caught out (not that I actually wanted the job).
timComment
-
Well here is the JabberContractor solution:
0) get the hardware, we need plenty of servers to cope with demand, two for the db, one for the application server, two for web servers (redundancy), a further db server for the data analysts to enter the times. Then we need two further boxes for development work.
1) We need a database to store the times, so buy and install Oracle
2) We shall use Java, so install the Java run time on all boxes.
3) Obviously there will be a fourth generation user interface, so install Apache and a content management system to store user pages + graphics.
4) Tomcat provides the servlet server to handle dynamic interaction.
5) Now we will use distributed objects to distribute the load, so install an application server with an EJB container.
6) Next we hire a team of Java contractors, a PM to manage them and a team of data analysts to enter the data.
7) We download the code off the internet, sit back and read a user manual for three months.Comment
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers

Comment