Beta

The Intervals

Description
Loading description...
Algorithms
Mathematics
  • Please sign in or sign up to leave a comment.
  • Mafir Avatar

    According to the testcases duplicates in numbers should be treated as if they were different numbers. This should be explained in the kata's description or there should be no duplicate numbers allowed. Logically it makes no sense to analyse and write down intervals for same numbers more than once.

  • Just4FunCoder Avatar

    Some typo / minor grammar fixes in the description (ordered by appearance):

    • This story will be about intervals.
    • ...and returns a string using the expectd expected formatting ...
    • ...Both boundaries of an intervak interval are exclusive...
    • ...identify all the inervals interval it belongs to...
    • ...2 belong belongs to the interval (1,4)...
    • ...With the intervals: (1,3), (3,5) and (2,9), 4 belong belongs to the two last only, so the output iwould would be: "4 ∈ (3;5) ∩ (2;9)"...
    • ...The intervals are handle handled in the order of the list of intervals argument...
    • ...Strings are concatenated together, separated with by and...

    It might also be better to mention that the number(s) that don't belong to any intervals are omitted from the output.

  • uttumuttu Avatar

    To be mathematically precise, intersection symbol should be used everywhere instead of union, as that's the correct logical choice here. By definition, if a number belongs to sets A and B, then it belongs to the intersection of A and B.

    Conversely, if a number belongs to A, then it belongs to the union of A and any other set.

  • Blind4Basics Avatar

    Don't close issues until you handled them, thx. They are not here just for decorum, they have a meaning about the overall process your kata is involved in.

    • the description hasn't been changed (afaik...)
    • about the input mutation, you just have to:
      • either call the reference solution before the user's solution (in a separate statement/expression)
      • or just send a copy of the array to the user's function.

    Cheers

    • Blind4Basics Avatar

      btw:

      how to edit tests from outside

      what do you mean exactly?

    • user902000 Avatar

      oh i thought you were talking about the ability to somehow change the content of the tests and pass the kata with this, thanks i will keep that in mind when creating the kata

    • Blind4Basics Avatar

      no, it's not that problematic... ;)

    • user902000 Avatar

      now 'from solution import the_intervals' is on the 39th line,and i hope this is the way you suggested

    • user902000 Avatar

      I'm still waiting for your answer so as not to close the problems until I figured them out

    • Blind4Basics Avatar

      I didn't see your previous message, sorry. No, still not good. Use the following:

              for i in range(100):
                  s=im(random.randrange(1,15))
                  e=eq(random.randrange(1,15))
                  exp = ti(s,e)
                  test.assert_equals(the_intervals(s,e),exp)
      

      What about the description?

    • user902000 Avatar

      oh yeah thanks

      I worked on the description and I think that there are no problems with it

    • Blind4Basics Avatar

      The interval is indicated by brackets parentheses [...] and a semi colon in the middle


      The overlapping of intervals is denoted by the symbol '⋃'

      (1;4) ⋃ (2;5) = 3

      I didn't realize before, but that part isn't logical. You're mixing union and intersection, there. The symbol is union. What you're talking about is intersection. => ? (you could talk about union everywhere => avoids the need to change the code, but then (1;4) ⋃ (2;5) = (1;5). The actual problem is that the task has nothing to do with either union or instersection. You use the symbol just to express an "and" relation, actually. That's confusing / EDIT: btw, even f you replace with intersection, that mathematic relation isn't correct: intersection gives you another interval => that would be (1;4) inter (2;5) = (2;4)).


      So, in this kata your task is to write a program which determines, for each number in the array, appropriate intervals from array

      What array? And the example below aren't written in a way so that what you're talking about is obvious, while the user has absolutely no clue of what you're talking about. So instead (or something close to that):

      So, in this kata your task is to write a program which, given a list of intervals and a list of numbers, determines for each number the appropriate intervals it belongs to.

      intervals: [(1,3),(3,5),(2,9)]
      numbers: [4]
      result: "4 ∈ (3;5) ⋃ (2;9)"
      
      intervals: [(1,4),(2,5)]
      numbers: [3,4]
      result: "3 ∈ (1;4) ⋃ (2;5) and 4 ∈ (2;5)"
      

      input/ouput titles:

      • use markdown to make them stand out : ### at the beginning of the line
      • don't show the python types, because they won't be matching any other language if the kata gets translated. the sentences in the § below are enough anyway

      End of input and ouput sections: there is a sentence after each code block starting with a * -> it looks like a foot note => remove the *. For the output section, remove the parentheses as well (it's not a note, it's an actual spec!)

    • user902000 Avatar

      Damn language barrier, k I used the Wikipedia link instead of any explanation and otherwise followed your advice

    • Blind4Basics Avatar

      I updated the kata. Some notes for later use:

      • the test framework wasn't imported (I forgot to update the sample tests => you'll have to do it)
      • it's better if the ref solution and the random utilities are defined after the fixed tests
      • fixed tests should never rely on the ref solution (see "not so simple fixed tests")
      • the titles for the describe/it blocks are strings. So you should write actual messages there, not stuff with underscores everywhere.

      I rewrote the description. Hopefully it will be enough.

      Issue marked resolved by Blind4Basics 2 years ago
    • user902000 Avatar

      Holy thanks otherwise it could take more longer time, I will remember all this

  • Blind4Basics Avatar

    Hi,

    • the description really needs a complete rewrite. It's currently very hard to understand what the actual task is, because most of the information is given in wrong order (...that rings a bell... Was it you?), and contains superfluous details:
      • only (a;b) is used, so there is no point to talk about (...] or any other variation
      • there is no point to develop about fractional numbers since they are not handled. Stating that the boundaries are exclusive and that we will search for some specific values that are given as inputs is enough.
    • since there is only one type of interval, there is no point in giving the input as strings => tuples of ints will do a better job
    • no test with points outisde o all intervals
    • it's not specified in the description in what order the strings should be built (order of the intervals) and ordered (in the overal output). Ok, it is... But why isn't that in the output section? (=> "wrong order" ;) )
    • you have and extra print statement in the random tests
    • the random tests are vulnearble to input mutation.

    Cheers

    • user902000 Avatar

      Yeah thanks i just dont completely understand how to edit tests from outside, and even more so how to deal with it, but in my opinion this kata still is not so hard to edit random tests instead solve them. I will think about this problem later

      Issue marked resolved by user902000 2 years ago
  • Fbasham Avatar

    ['(20;100)', '(10;110)', '(0:90)']

    This test appears in 'fixed_not_so_simple_tests' tests. Notice the semicolons and 1 colon.

  • Fbasham Avatar

    ['(8;149)', '(2;56)', '(3;100)', '(12;69)', '(2;85)', '(85;134)', '(28;118)', '(11;119)', '(11;105)', '(89;126)', '(7;40)', '(15;126)'] [94, 133, 42, 103, 65, 92, 118, 149, 6, 124]

    '103 ∈ (62;106) ⋃ (58;127) and 40 ∈ (0;48) ⋃ (7;99) and 36 ∈ (0;48) ⋃ (7;99) and 125 ∈ (58;127)' should equal '103 ⋃ (62;106) ⋃ (58;127) and 40 ∈ (0;48) ⋃ (7;99) and 36 ∈ (0;48) ⋃ (7;99) and 136 and 125 ⋃ (58;127) and 133 '

    I'm pretty sure the description says the formatting should be n ∈ {interval}, but the exepcted result in this test (and many more) has the formatting n ⋃ {interval}

  • Fbasham Avatar

    ['(45;90)', '(69;100)', '(12;70)'] [67, 255]

    '67 ∈ (45;90) ⋃ (12;70)' should equal '67 ∈ (45;90) ⋃ (12;70) and 255 '

    Also happens in random tests. Maybe I'm not understanding the kata.