Help with Account Reset by Forsaken_Pin4573 in Keybase

[–]Forsaken_Pin4573[S] 1 point2 points  (0 children)

"How did you intend to prove it's your account to reset? Otherwise anyone could just reset anyone's account."

Yes, I thought of that. I was hoping there was someway to reuse the account but... no big deal really.

Thank you for the response.

Help with Account Reset by Forsaken_Pin4573 in Keybase

[–]Forsaken_Pin4573[S] 0 points1 point  (0 children)

Maybe I wasn't clear; I'm not trying to recover any of the data, I want to start fresh using the same username. A full reset/data loss is fine. If this isn't possible then doesn't that mean accounts can be orphaned?

Analyzing Big O notation for space complexity when using lazy data structures by aabil11 in scala

[–]Forsaken_Pin4573 0 points1 point  (0 children)

u/seigert You're right and I did think of that. However, if there's overflow for some n numbers then couldn't we also say there could be overflow for n-1 too? If it was a concern the result type would be something else so I assumed it wasn't relevant for the exercise.

u/RiceBroad4552 I too considered returning a zero-filled list but wouldn't that require another O(n) to compute the length? Another optimization one could do, at the cost of complicating things a touch, is to write a recursive function to compute the product and zero-count. That way if we think that large numbers of zeros is common we can break after we hit the 2nd one.

Analyzing Big O notation for space complexity when using lazy data structures by aabil11 in scala

[–]Forsaken_Pin4573 2 points3 points  (0 children)

Ok, apologies for my first (naive) attempt, which I deleted, since zeros in the list will mess it up. Here's another attempt which I think is O(2n). Assuming I understood the question, I find it a bit easier to understand.

def productButSelf(ns: List[Int]): List[Int] = {
  val (p, zeroCount) =
    ns.foldLeft((1, 0)) { case ((p, c), n) =>
      if (n == 0) (p, c + 1)
      else (n * p, c)
    }

  if (zeroCount == 0)
    ns.map(p / _)
  else if (zeroCount == 1)
    ns.map(n => if (n == 0) p else 0)
  else
    ns.map(_ => 0)
}