[Community Puzzle] Fun with Set theory


Send your feedback or ask for help here!

Created by @Eldoir,validated by @bbb000bbbyyy,@Deltaspace and @Jamproject.
If you have any issues, feel free to ping them.

Congratulations for this puzzle ! Very interesting, and not so easy !
Proud to done it :slight_smile:

1 Like

Great puzzle, a harder version could be made with tests that contain very large numbers.
You would not be able to simply generate the numbers that way.

Is there a possibility to get the test cases “Nested parenthesis” and “Everything”? They are different then the test cases in the editor, which I do pass

I’m failing test cases 12, 14, and 15 when I go to submit, but there are definitely no “hard-coded solutions” in my code.

Error: The following validators differ from the puzzle test cases to prevent hard coded solutions. This is why you can have some fails here even if all of the tests provided in the IDE have been successfully passed.

This message is here to explain why validators differs from test cases, but seeing it not necessarily mean that you have hard-coded anything. Your code probably don’t handle some cases and/or is not optimized enough for big datasets.

1 Like

Though this explanation statement does not mean to blame the coder of hard-coding, the reality is that from time to time there are new members feeling this way. To reduce misunderstanding, CG could rephrase the statement. No need to explain the reason of the difference. Just tell the coder his submitted code failed to pass one or more validators, with a reminder like “… the validators look similar but different from their corresponding test cases”.


test case 12 is not the best one: ] -4;2 [ I [ 0;3 [, even if you make an error in first set e.g. by including -4 it could produce correct result at the end, because it is intersection between two sets and you would not be aware of the mistake. But if the validator change a single letter and instead of I they set U, the error would show. Try to log your process and check it out - it helped me. As far as test cases 14 and 15 are concerned, I’m still trying to figure out what went wrong with my code. Best regards

I did it lazily with eval and a bunch of replace.
As a first step, I went easy and imagined all numbers were 1-digit integers (positive or negative).
It could pass all testcases except the last one that contains 2-digits numbers.
I still submitted to see how many validators it would pass and suprisedly, it passed 100% of them.

I tried the same trick, with same results.
I was “lucky” I still submitted it, since I wanted to test a different approach only later.

The reason (at least for my code) was not due to the number of digits, but to the precedence.
Python does & before | while it seems that it is not expected in by this exercise. And luckily it is not properly tested in the result evaluation.

Details for last visible test 15:Everything!

Right part [4;20]-[-5;5] turns into 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Left part [20;30[U]40;50]I{25;-35;0;42;47}U{-3;-1}U]-10;10[

  • without precedence one gets -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 25 42 47which ends up being 6 7 8 9 after intersection with the right part.
  • while with precedence one gets -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 20 21 22 23 24 25 26 27 28 29 42 47 that why the result (after intersection with right part) gives 6 7 8 9 20

Struggling with this one.

Editor tests pass 100%
Hidden tests pass everything except "Everything"

I make sure to process parentheses completely before dissolving them & process unions, differences and interactions left to right. Any idea what I might be missing?

Nevermind, rewrote the logic from ground up and passed 100%
Still not sure what I was doing wrong…