in reply to Re: Faster (but uglier) PWC 350-2 solutions
in thread Faster (but uglier) PWC 350-2 solutions

I think if in e.g. "Example 2" the $to was e.g. 8500, then your solution would find all 3 pairs again and report false positives. I.e. stronger accounting is required. I'm not sure I'm happy with my own accounting, on the 2nd thought.

If $count in "Example 3" was not "5" but "1", then how many items would be added to the result for "1428570"? 1 or 5? The "at least" in the wording of the challenge seems to imply that "1". Or such is my interpretation (PWC ambiguous as usual). But then it follows, that you can't break out early with "next I;". Because there will be false positives later if $to was higher (see?). I had a similar "next OUTER;" in initial drafts, but then decided against it.

Replies are listed 'Best First'.
Re^3: Faster (but uglier) PWC 350-2 solutions
by ysth (Canon) on Dec 09, 2025 at 23:42 UTC
    I don't know what you mean by false positives? The test is how many numbers in the range are part of at least count pairs. Having both ends of a pair in the range just means both numbers count. And each number only counts once. Can you explain what you think is ambiguous? (Agreed that PWC often is; usually the examples clarify, but not always.)
      The test is how many numbers in the range are part of at least count pairs.

      Didn't they ask for "different pairs"? 1782 and 7128 belong to the same pair. OTOH, "1428570 belongs to 5 different shuffle pairs" -- yeah, how else, what's the alternative? What does that even mean to "belong to several pairs which are not different"? Replicate any as much as I please? Perhaps your interpretation is correct, if only by Occam's razor, just remove one meaningless word globally in the task. Sorry, never mind.