I really like your videos and it really got me into haskell, now I am able to solve some problems in haskell too. Thank you for that. But I have a question: Why did not you add the (-1) to the list after the filter and then apply the maximum function?
That's a neat idea. I was think mapping values over the threshold to -1 and then apply maximum. However, I like the solution in the video more as it makes it clear by using Maybe whether we found a solution or not and then apply the default value at a later stage. The only part I wish was done differently is not using the sort. However, the constraint is quite low, so that kind of optimization might have been overkill.
༼ つ ◕_◕ ༽つ simply beautiful. My favorite part as always is how you break down large problems into small problems. This gives me the confidence to solve problems in Haskell
Superb video and thank you for demonstrating not just an elegant solution but also monadic nature of the simple list in Haskell. I really wished that you could have chosen a different problem for that demonstration, though. This particular problem involved a cross of two lists, implying O(N^2) time complexity. It can be solved in asymptotically faster time by sorting and traversal, even with Haskell though it won't look as pretty. The input size of just 1000 for this problem made this pass.
this may not be of concern, but isn't sorting the whole list (n log n) less efficient than just taking the minimum (n)? (after filtering out empty lists e.g. by pattern matching)
I don't know what algorithm Haskell uses for sorting, but since it's lazy it won't necessarily sort the whole list, as long as it gets the first element correct.
Hello! I really like this series. Thanks for making them. I got stumped by the "Array Manipulation" problem. I'm confident my code works, but it times out on several tests. I don't know if you're interested in scaling up the difficulty of the problems in the series. If you are, I'm just going to leave this one as a suggestion.
7:03 Can't you also solve the -1 problem by adding "(-1) : " right before filter? That way the list is never empty, and since all of the other values are positive the maximum function will never select -1 unless there are no other values in the list.
Introducing too many complicated things for a simple problem. Prices and budgets are never negative so just throw a -1 in the list and you are basically done. Plus you can use a list comprehension rather than liftM, which I find more readable and less obscure even though they are the same thing under the hood. solve b keyboards drives = maximum $ -1 : [z | x