|
|
|
|
|
by dekhn
1169 days ago
|
|
presumably regarding the string reversing: they probably wanted a reverse in place (then making sure you handle the even/odd edge condition). however, Python strings are immutable, so you'd have to use a bytearray, but if you have a huge string, converting it to a bytearray, reversing the array, and converting back to a string would likely take longer than having python's string reverse function allocate a new string and write the reverse into it (I would have written both implementations, a timer, and test with increasingly long strings, assuming coderpad). For the 'e' question: I mean, we learned functions to approximate e in high school. There's a summing series you can do to approximate it- were they expecting you to remember that off the top of your head (if so, you probably dodged a bullet). Otherwise, e*x is its own differential, so i wonder if you could write some terrible routine iterating from a random value to the right one by computing finite differences of various values. |
|