4

To be honest, this is a bad way to solve the problem - recursion with strlen() is not a good idea. There was a recent discovery that Rockstar Games had their loading screens in GTA5 extended by several minutes due to their JSON parser calling strlen() on a string repeatedly. Instead, when handling strings in a recursive manner that requires knowledge of the ...


2

Your code is clearly organized and well presented, but it suffers from a number of problems, from the trivial to the profound. var i = 0 is never used and doesn't need to be there. safety: There's no check for bad input. pascal(2,1) will happily java.lang.StackOverflowError. Your code indicates a lack of familiarity with the Scala Standard Library. ...


2

Bug: short string Consider reverse("", 1). Code attempts s[-1] which leads to undefined behavior (UB). len = 0; s[(len - 1) - (1-1)] // UB Bug: long string Pedantic: Code fails for huge strings longer than INT_MAX. Use size_t, not int. Alternative // left points to left-most character // right points to right-most + 1 character static void rev(...


1

Assuming that you decide to retain _check_parameters(), here's an illustration of some alternative techniques for organizing a complex boolean check. (1) The isinstance() function will take a tuple of types, so you can do some consolidation. (2) If you need to check for None and check for types, you can do it all in one shot. (3) Some of your checks were ...


1

The big thing that jumped out to me was how you seem to be treating Haskell lists like Java... Arrays? (I haven’t used Java since... 2006?) If you’re repeatedly fiddling with the elements at the end of lists, you’re probably doing something wrong. I’m not sure what the complexity of this all is, but I think it might be something like \$\mathcal{O}(m^2n^2)\$ ...


Only top voted, non community-wiki answers of a minimum length are eligible