I had two job offers one time. One where the interviewer asked me how I solved real world problems and my experience and one where they wanted me to write a merge sort on the board.
Guess which job I took? I’m not going to be writing a merge sort in real life and I don’t waste my time learning algorithms and studying leet code. I solve real world problems using existing frameworks from the front end to cloud and on prem infrastructure.
Yes I have my geek credentials - started programming almost 35 years ago in 65C02 assembly, did bit twiddling in C for 12 years, etc. but I am way past wanting to reinvent the wheel.
One simple problem was given a list of users objects, create a list of the target object and generate a userid from the first initial, first four of the last name.
Then we had an algorithm for how to handle ID clashes. We had failing unit tests for all of the corner cases.
We were hiring contractors and paying them well so we made one of the requirements that you had to know LINQ and EF. Even though we weren’t using EF that often, Linq is Linq and linq queries work the same with in memory lists, EF, and the C# Mongo driver.
It was a requirement that they used Linq instead of foreach loops since Linq gets translated to Sql and MongoQuery instead of doing the processing in memory.
def groupByOddThenEvens(someList):
odds = []
evens = []
for x in someList:
print x
if x % 2 == 0:
# Even
evens.append(x)
else:
odds.append(x)
odds.extend(evens)
return odds list = getOddsToTheFront(list)
list = sortOdds(list)
list = sortEvens(list)
implementation of helper methods left as an exercise for the reader def order_list_by_predicate(l, &blk)
l.partition{|i| blk.call(i)}.flatten
end
part(1..6) do |i|
i % 2 == 1
end
And you can always sort the incoming list if that's a requirement. oddsBeforeEvens = uncurry (++) . Data.List.partition oddEven if you did something like implementing the square's size as an average of the underlying rectangle's width and height, which would apparently support both classes correctly, you will get in trouble with the semantics or with other, less "fakeable" properties of these objects.
That's not really true though. Definition is a quadrilateral w/ 4 right angles. Width and height can be dependent or not