just confirming it’s working now, thx
Failure
Found: Nothing
Expected: Nothing
… what it writes in test 3
N.S
I do not understand this part “Random is defined as using the JBM level-0 twister: “for the ith choice, pick the ith clause (modulo the number of clauses)”.”. When it is the 4th choice and there are only 2 choices what word I have to pick? And for the 3th choice with only 2 choices?
When it’s the 4th choice and there are only 2 clauses, you pick clause index 4 mod 2 = 0 (that’s the 0-indexed first one)
When it’s the 3rd choice and there are only 2 clauses, you pick clause index 3 mod 2 = 1 (that’s the 0-indexed second one)
Gah, shouldn’t answer before coffee, see below for proper answer.
Thanks for your fast reply.
For the 3th test case the 4th line (and 4th choice to make) is “Does it (wrap|unwrap)?” and “wrap” must be used but I get:
Found: Does it wrap?
Expected: Does it unwrap?
That’s because I’m explaining it bad, and stupid human convention to index at 1 for ordinals makes it worse.
The general idea is: you take the choices in order, not skipping any (i.e., starting with the “first”), looping when you move past the end.
Expressed mathematically involves actually using 0-based indices, so:
- When it’s the [human] 4th choice and there are only 2 clauses, you pick clause [sane] 3 mod 2 = 1. Which translates to “second” in human terms.
- When it’s the [human] 3rd choice and there are only 2 clauses, you pick clause [sane] 2 mod 2 = 0. Which translates to “first” in human terms.
But I think understanding the general idea is more important than reading the math.
So indeed “Does it (wrap|unwrap)” should unwrap.
Thanks for explaining, I fixed it but I still get some other results… Will skip this puzzle, I get the idea and believe my solution is correct. Thanks for your effort.
Sorry, but personally I found the description of this puzzle completely confusing. First, this thing with “random” choices, but it’s okay, finally I got it without any help. But I don’t understand the main idea of the puzzle - should I print all possible templates (I mean like Cartesian product) or should I print only one template replacing placeholders with one global increasing index for all choices? It’s not clear and it’s not fun
Seems puzzling to me you could get it without understanding the main idea.
But if that suited you, great!
Why can’t I split the input with .splilines()
in Python3? It returns a number of lists instead of one for each line.
I don’t know Python, so I won’t answer that part of your question, but keep in mind this puzzle is not line-based.
See for example the last choice of test 3 “Edge Cases”, that spans three lines.
in test 3 the lies after unwrap gives 2 identical choices linesInput[4] = “(Multi”;
linesInput[5] = “line|Multi”;
linesInput[6] = “line)”;
unwraped Multiline|Multiline
and the solution must be Multi ??? what am I missing
Based on the input you provided, the solution would appear to be:
Multi
line
thanks
Hi. I passed all tests but got only 80%. I think I covered all possible cases. I use java. May I ask for any advice?
Which validator do you fail at ?
Last one, #5 More Edge Cases
Have you considered this case:
(|)
?
Nope, you got me! I applied this one and got 100%. Thanks a lot!
Really nice riddle… and I take it as a nice exercise for regex.
Still struggling why my nice regex in Python fails in the multiline case. (Works find for single lines and results ins nicely compact code.j)
pattern = re.compile(r’(([^)]*))’,re.MULTILINE)
It still fails for testcase03
(Multi
line|Multi
line)
Tinkering…