shoulda just said 'send it to India'. Or would that make you a PM?
- 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!
Reply to: Write Algorithm – interview question
Collapse
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
- You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
- You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
- If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
Logging in...
Previously on "Write Algorithm – interview question"
Collapse
-
Originally posted by PerlOfWisdomSo which part of the BT NHS project are you working??? on?
8) we need a team of testers
9) an IT support group
10) A budget for a couple of nights out to build team moral
11) A guy to keep the newspapers in the bogs freshly stocked - AtW, are you free ?
Leave a comment:
-
Originally posted by JabberwockyWell 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.
Leave a comment:
-
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.
Leave a 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).
tim
Leave a comment:
-
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 it
Leave a comment:
-
Its beyond me why anyone would write a recursive algorithm especially
when you can write this as a one liner.
Leave a comment:
-
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.
Leave a comment:
-
Anyone notice the question has an error?
... perhaps that was the real point of the exercise.
Just my banking experience showing through :-)
Leave a 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 ?
Leave a comment:
-
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.
Leave a comment:
-
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.
Leave a comment:
-
Can I provide a solution by dragging pretty coloured icons onto a designer surface and then have a cup of tea?
Leave a comment:
-
AtW, I agree your solution is more elegant than mine
But I wrote it in one single block on the grounds that the bank rejected a solution with an external function call
Leave a comment:
-
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);
--
There done - pretty simple.
A faster way however is to split all periods into minutes and calculate cumulative trading done up to any given minute - put it all into array, then in order to calculate trading done in any given time you just calculate number of minutes from 8:00am and just look up trading value in array - this is very fast as pre-computation is needed only once.
Can't see ANY need for recursion here.
Leave a 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
Contractor Services
CUK News
- Streamline Your Retirement with iSIPP: A Solution for Contractor Pensions Sep 1 09:13
- Making the most of pension lump sums: overview for contractors Sep 1 08:36
- Umbrella company tribunal cases are opening up; are your wages subject to unlawful deductions, too? Aug 31 08:38
- Contractors, relabelling 'labour' as 'services' to appear 'fully contracted out' won't dupe IR35 inspectors Aug 31 08:30
- How often does HMRC check tax returns? Aug 30 08:27
- Work-life balance as an IT contractor: 5 top tips from a tech recruiter Aug 30 08:20
- Autumn Statement 2023 tipped to prioritise mental health, in a boost for UK workplaces Aug 29 08:33
- Final reminder for contractors to respond to the umbrella consultation (closing today) Aug 29 08:09
- Top 5 most in demand cyber security contract roles Aug 25 08:38
- Changes to the right to request flexible working are incoming, but how will contractors be affected? Aug 24 08:25
Leave a comment: