Ad
  • Custom User Avatar

    What do m and s even represent?

    past or present denominators, or defaults

    If the value before the most recent left choice was l/m and the value before the most recent right choice was r/s then the new value will be (l+r) / (m+s).

    That line, paraphrased / decoded / whatever:

    (l+r)/(m+s) is each new fraction (next iteration), before substitution and simplification. Let l/m represent whatever the fraction was, just before you most recently parsed an L choice. Let r/s represent whatever the fraction was, just before you most recently parsed an R choice.

    This is how values of l, r, m, s are obtained most often. But l = 1, r = 0, m = 0, s = 1 are defaults, used when there is no previously parsed L or R (or neither, as shown in the way that the initial 1/1, corresponding to the empty string, is formed entirely out of them).

    HTH

  • Custom User Avatar

    Same here, I took my notebook and wrote the numbers, the fractions, tried to find a pattern but nothing. I'm not quite following the explanation, this is a problem that most likely would be solved in lets say 10-15 lines maybe, but man I can't even find the logic. If someone can explain it I would appreciate it a lot.

  • Custom User Avatar
  • Default User Avatar

    This seems like it shouldn't be terribly difficult to implement, but, I can't make any sense of what is actually being asked. I'm trying to follow the "let's take a walk" examples as well, but to no avail.

    If there have been no left choices, l = 1. Why isn't it 0 since left has been chosen 0 times so far?

    If there have been no right choices, r = 0. Okay maybe that makes sense, as right has been chosen 0 times. But then why is s = 1 instead of 0? Or, why is m = 0 instead of 1? What do m and s even represent?

  • Default User Avatar

    Is the following test case erroneous?

    No the test is correct. You can notice that 5096 guys passed the Java kata.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Since they say that the word "and" may or may not come in between numbers, couldn't you just replace all the "and"s with before digging in?