Better HN
topnewbestaskshowjobs
Log inSign up

quarktasche

13 karma · joined Apr 15, 2015 (11y ago) · 7 submissions

Submissions

comment 10y ago · link · parent

Which part?

Figuring out how to efficiently calculate a moving average seems like a good question for basic maths skills to me.

About complexity theory, there is already a lot of discussion about it's relevancy in the comments. My point was meant more along the line that, if you value a basic understanding of complexity theory, the question asked of the GP seems reasonable.

comment 10y ago · link · parent

Wouldn't the question about the moving average be a good one though? It should be quite obvious that you can calculate a moving average without remembering more than the current average and the window size. Given that, time and space complexity should be obvious. I think it would be a fine question to see if the interviewee has any idea what complexity means.

Or was it a more complicated moving average case (exponential etc) where the algorithm was given and you were asked to determine the complexity?

comment 10y ago · link · parent

I don't think the std::chrono example is fair at all.

In the C++ case, you specify which clock you want. What kind of clock is DateTime.UtcNow()? Is it monotonic? What's the resolution? It's maybe in the documentation, but if the author refuses to remember simple syntax, surely he won't want to remember such details either.

The author also chose an example where he abuses the default behavior in the C# case. The last line in the C++ example just vanishes if you use the default behavior in both cases.

comment 11y ago · link · parent

  mv mirrorlist mirrorlist.bak
  rankmirrors -n 10 mirrorlist.bak > mirrorlist

comment 11y ago · link · parent

If you like this kind of thing go read this write-up of predicting hands in online poker due to bad implementations of shuffling and PRNG algorithms! Its quite a fun read.

https://www.cigital.com/papers/download/developer_gambling.p...

comment 11y ago · link · parent

Wolfram Alpha does!

http://www.wolframalpha.com/input/?i=energy+to+heat+1l+of+wa...

comment 11y ago · link · parent

Might not work in some special cases though. Try:

  def foo():
      a = 4
      def bar():
          print("a = {a}".format(**locals()))
      bar()
        
  foo()
which will raise a KeyError, while it will work fine if you add a

  print(a)
to the end of bar().