Ad
  • Custom User Avatar

    @zLuki 2 substractions and 2 divisions? what if the sequence is consistent at the start but not in the middle? What if it the sequence breaks at the end of the sequence? They won't be a valid AP/GP anymore. Thus, you have to loop through the entire list to check. 2 check is not enough

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    [0, 1, 0, 1, 0] --> 0 # none

    Maybe -1?

  • Custom User Avatar

    Enforced 1 liner solutions will give this a 5, otherwise a 8 :)

  • Custom User Avatar

    Can you please make this a 6kyu one. Because I haven't seen any question as hard as this in 7kyu's.

  • Custom User Avatar

    I thought it was a 6kyu one. But the person approved it put it as 7kyu I guess. I cant do anything.

  • Custom User Avatar

    Too difficult to be a 7kyu.

  • Custom User Avatar

    No more issues, so we can approve?

    Looks good :)

  • Custom User Avatar

    Fixed

  • Custom User Avatar
    [189, 0, 0, 0, 0]
    -1 should equal 0
    
    [681, 0, 0, 0, 0]
    -1 should equal 0
    
    [511, 0, 0, 0, 0]
    -1 should equal 0
    
    [188, 0, 0, 0, 0]
    -1 should equal 0
    
    [27, 0, 0, 0, 0]
    -1 should equal 0
    

    The tests are wrong again.

    Are you just changing stuff at random hoping that this time it will be correct?

  • Custom User Avatar
  • Custom User Avatar

    It is correct. You can go and read any article on AP and GP.

    No it is not. The Wikipedia article on arithmeric progressions doesn't list any limitations for a_1 or d, and googling for "arithmetic progression zero difference" gives results stating that a_1 = d = 0 is valid.

    Also, it is amusing to hear this from a person who expected a list of zeros to be classified as a geometric progression when, according to Wikipedia (at least), it isn't actually one.

  • Custom User Avatar

    I am no math guy and the only source I used is Wikipedia, but from what I;ve read there:

    • in a definition of an arithmetic progression, difference d is not constrained in any way and can be 0.
    • in a definition of a geometric progression, ratio r is defined to be different than 0.

    If these rules are correct, it would mean that:

    • [42, 0] is a valid arithmetic progression with d=-42. It's not a valid geometric progression, because r would be 0
    • [42, 0, 0] is not a valid arithmetic progression, and it's not a valid geometric progression because r would be 0
    • [0, 0, 0] is a valid arithmetic progression with d=0. I am not sure if it's a valid geometric progression or not, because r can be anything, be it 0 or not. I think it's not a GP, I am not sure though.
    • [42, 42, 42] is a valid arithmetic progression with d=0. It's also a valid geometric progression with a ratio of 1
    • [-42, 42, -42, 42] would not be an arithmetic progression, but a valid geometric progression with r=-1

    So basically cases with [x, 0, ...more zeros...] are nasty edge cases, because:

    • when x is 0, it's AP but not a GP (examples: [0, 0], [0, 0, 0]). It's also different than [x ,x, x] because for x != 0 it's both AP and GP (example: [42, 42, 42])
    • when x is not 0, things depend on its length
      • when length is 2, it's AP but not GP (example: [42, 0])
      • when length is more than 2, it's neither AP nor GP (example: [42, 0, 0])

    Things depend on defintion, and maybe there are other definitions than ones I found on Wikipedia. But cases with trailing zeros are really tricky because answer depends on what's the first term, and what's the length of the progression.

  • Loading more items...