Originally posted by Trimbo
- 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: Programming Puzzle
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 "Programming Puzzle"
Collapse
-
I obviously didn't make it clear, you are rearranging the array, not sorting it. To put it another way, you are not allowed to look at the contents of the array items to help you. So any kind of sort function is right out. Anyway who cares its old news now..! (somebody pasted a good solution on the digg page).
Originally posted by AtWtoo late... use assembly's command: xchg
Just sort the array (in place using QuickSort, supported by any good library) but use reversed key values, thus: it will sort as:
1a, 1b, 2a, 2b etc - of course reverse order only to be used for key comparison purposes, it won't be changed in the array: there job done in less than few minutes.
Of course in reality the solution should be more effective - you don't really need to swap them and trash processor cache - you need to think what you will do with the data later, say if its saving in such a state on disk then you can just do it in simple loop with counter plus fixed offset thus merging two sorted streams on the fly.
And if you need array with changed places for some later processing then you can do similar merging on the fly.
All in all stupid task that is only excusable by separating pros (who will solve it in 1 minute using existing tools) from amateurs who will actually be stupid enough to follow artificial rules instead of just bending the spoon.
If they don't like it then I'd walk out.
Leave a comment:
-
too late... use assembly's command: xchgOriginally posted by scotspinedon't let a certain russian see that temp var for goodness sake!
Just sort the array (in place using QuickSort, supported by any good library) but use reversed key values, thus: it will sort as:
1a, 1b, 2a, 2b etc - of course reverse order only to be used for key comparison purposes, it won't be changed in the array: there job done in less than few minutes.
Of course in reality the solution should be more effective - you don't really need to swap them and trash processor cache - you need to think what you will do with the data later, say if its saving in such a state on disk then you can just do it in simple loop with counter plus fixed offset thus merging two sorted streams on the fly.
And if you need array with changed places for some later processing then you can do similar merging on the fly.
All in all stupid task that is only excusable by separating pros (who will solve it in 1 minute using existing tools) from amateurs who will actually be stupid enough to follow artificial rules instead of just bending the spoon.
If they don't like it then I'd walk out.Last edited by AtW; 4 September 2006, 01:01.
Leave a comment:
-
As a professional business man, I'd offer the following solution.
1. Stick the algorithm requirement on RentACoder.
2. Pay the $10 required for the solution
3. Bill the client £500
HTH
Leave a comment:
-
I agree - totally useless. It was many years ago (I was still a student!) and they offered me £50 a week!Originally posted by Cowboy BobCompletely useless waste of time to set that in an interview. If I needed to do something like that and didn't know immediately off the top of my head how to do it, I'd just Google it. Simple algorithmics are no indicator of a decent developer.
To be honest, I'd have probably just got up and walked out. I'm a professional contractor and the only kind of tests that may be acceptable are ones directly related to the project being discussed - and even then I see them as a kind of insult.
Leave a comment:
-
Completely useless waste of time to set that in an interview. If I needed to do something like that and didn't know immediately off the top of my head how to do it, I'd just Google it. Simple algorithmics are no indicator of a decent developer.
To be honest, I'd have probably just got up and walked out. I'm a professional contractor and the only kind of tests that may be acceptable are ones directly related to the project being discussed - and even then I see them as a kind of insult.
Leave a comment:
-
Programming Puzzle
Got this many years ago in an interview:
http://digg.com/programming/Array_Re...ramming_Puzzle
Not too hard, but hard to do in < 30 minutes under pressure.Tags: None
- 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

Leave a comment: