Ad
  • Custom User Avatar

    I'd like to chime in on this one. I was mislead in my initial solution assuming that x ran horizontal and y vertical, despite the picture showing the origin in the upper left. Sure I could of easily read this as a cartesian plane rotated 90 degrees, but then the navigational directions oriented with north up further lead me to think it was not rotated. Nothing in the description said otherwise. Making matters worse, the example and the first test case only use switches on points where x == y ([1,1], [4,4], etc) so there's nothing in there to tip the reader off.

    So I solved it for all the example cases only to have it blow up on the real cases. It took awhile for me to figure out why, and then to refactor for the rotated coordinates.

    I suggest you make it abundantly clear by labeling the coords in the picture. A second option would be to use a non=symmetrical example.

    All that said, I really enjoyed working this one and the colorful description!

  • Custom User Avatar

    edge cases needed:

    test.assert_equals(find_arithmetic_sequence([2,3,1,4]),[1,2,3])
    test.assert_equals(find_arithmetic_sequence([816, 428, 446, 459, 471, 486, 496, 511, 527, 537, 551, 564, 819, 594, 607, 616, 631, 646, 662, 674, 687, 698, 716, 724, 740, 755, 813, 778, 794, 808, 821, 837]),[446, 631, 816])
    
    test.assert_equals(find_arithmetic_sequence([265, 279, 295, 811, 321, 330, 346, 808, 371, 388, 398, 414, 425, 443, 814]), [808, 811, 814])
    test.assert_equals(find_arithmetic_sequence([893, 368, 382, 890, 408, 896, 434, 449], [890, 893, 896])
    

    note: I didn't "explore" the solution suggested by Johan, so you'll have to dig on this side too

  • Custom User Avatar

    Those examples are much clearer, thanks! I was about to say if it's so hard to explain, then maybe lose the requirement :-) But then that would make it somewhat easier to solve.

  • Custom User Avatar
  • Custom User Avatar

    what the hell did I do... x/

    Wait a sec

  • Custom User Avatar

    Where does that 27 come from ?!?

  • Custom User Avatar

    oh damn... let's make the "alignments" clearer (maybe...):

        (put some good worded specs here x) )
    
    
            For [99,11,4,7,1,200,9]:
        
              possible triplets:          [11,7,9] and [4,7,1]
              indexes:                    (1, 3,6)     (2,3,4)  
              returns the sorted triplet: [7,9,11], because lexicographically (1,3,6) < (2,3,4)
            
            
            For [17,20,21,9,13]:
        
              possible triplets:          [17,9,13] and [17,21,13]
              indexes:                    ( 0,3, 4)     ( 0, 2, 4)
              returns the sorted triplet: [13,17,21], because lexicographically (0,3,4) > (0,2,4)
    

    ?

  • Custom User Avatar

    Your code should find the first valid Arithmetic Sequence that can be constructed from any 3 integers in the group

    This is confusing, because that would imply sorting by the lowest highest index first. ( That's the first sequence you find completely. )

    "Your code should find the sequence whose indices are lexicographically lowest" ?

    It's jargony, but correct ( I think ), and the examples can clarify ( which is what they are for ).

  • Custom User Avatar

    [13,20,27] from [17,20,13,9,27] would give (1,2,4), not (0,2,3) ?

  • Custom User Avatar

    woops, that's because I changed the arrays allong the way. The </> thing is coming from python. Might not be general enough, yes. Any help about the first §? (because the spec is there, actually x) )

    edit: wait... How that it's not (0,2,3)???

  • Custom User Avatar

    except it isn't (0,2,3). and mixing < and > is confusing.

    Personally, I would rather focus on a correct spec than on improved examples.

  • Custom User Avatar

    mmmmh... I didn't even read that part... x) (formatting is somewhat horrible. Nobody will reach that part of the description, I guess, if you don't make it clear there is something important to grasp here).

    Sooo, that would be somehting like

        Return the first triplet (sorted by values) satisfying the conditions.
        If there are several possbilities choose the triplet so that its indexes
        in the original array would be minimal (like for a key function comparison):
    
            [99,11,4,7,1,200,9] returns [7,9,11] because:
        
              [11,7,9] is a possible triplet, but [4,7,1] too
              indexes: (1,3,6) < (2,3,4) because of the 1
              returns [7,9,11] (sorted)
            
            
            [17,20,13,9,27] returns [13,20,27] because:
        
              [17,13,9] is a possible triplet, but [17,20,13] too
              indexes: (0,2,3) > (0,1,2) because of the 1
              returns [13,20,27] (sorted)
    

    edit: I don't like that part: (like for a key function comparison). But didn't find something better...

  • Custom User Avatar

    Except in an ice hockey team then?

    It might help someone see that the first index need not be 0. I wasn't worried about that, but someone else might be. See the problem with examples?

  • Custom User Avatar

    99 is Wayne Gretzky's retired number. It's ALWAYS appropriate to include :)

    But really, I added it just to give a case where the first index isn't 0. Good feedback that it muddies more than helps though.

  • Custom User Avatar

    But you're right, I should've said it when I saw something was failing on a sample test, but passing random tests. I just went on hastily to another kata =/

  • Loading more items...