title: Google Foobar number_station_coded_messages
body: <p>I am trying to complete a google foo.bar level 2 challenge titled "number_station_coded_messages". Here is the problem:</p>
  
  <blockquote>
    <p>Given a non-empty list of positive integers l and a target positive integer t, write a function answer(l, t) which verifies if there is at least one consecutive sequence of positive integers within the list l (i.e. a contiguous sub-list) that can be summed up to the given target positive integer t (the key) and returns the lexicographically smallest list containing the smallest start and end indexes where this sequence can be found, or returns the array [-1, -1] in the case that there is no such sequence (to throw off Lambda's spies, not all number broadcasts will contain a coded message).</p>
    
    <p>For example, given the broadcast list l as [4, 3, 5, 7, 8] and the key t as 12, the function answer(l, t) would return the list [0, 2] because the list l contains the sub-list [4, 3, 5] starting at index 0 and ending at index 2, for which 4 + 3 + 5 = 12, even though there is a shorter sequence that happens later in the list (5 + 7). On the other hand, given the list l as [1, 2, 3, 4] and the key t as 15, the function answer(l, t) would return [-1, -1] because there is no sub-list of list l that can be summed up to the given target value t = 15.
    To help you identify the coded broadcasts, Bunny HQ has agreed to the following standards: </p>
    
    <ul>
    <li>Each list l will contain at least 1 element but never more than 100.</li>
    <li>Each element of l will be between 1 and 100.</li>
    <li>t will be a positive integer, not exceeding 250.</li>
    <li>The first element of the list l has index 0. </li>
    <li>For the list returned by answer(l, t), the start index must be equal or smaller than the end index. </li>
    </ul>
    
    <p>Remember, to throw off Lambda's spies, Bunny HQ might include more than one contiguous sublist of a number broadcast that can be summed up to the key. You know that the message will always be hidden in the first sublist that sums up to the key, so answer(l, t) should only return that sublist.</p>
  </blockquote>
  
  <p>Below is my current solution.</p>
  
  <pre><code>def answer(l, t):
      for index1, value1 in enumerate(l):
          for index2, value2 in enumerate(l):
              if sum(l[index1:index2]) == t:
                  return [index1, index2 -1]
  
      return [-1, -1]
  </code></pre>
  
  <p>I am able to pass 4/5 test cases but I fail on Test 5. I am not sure what it fails against? I am not necessarily looking for a solution so much as test cases that this does fail against! I was able to find a <a href="https://stackoverflow.com/questions/40695207/google-foobar-numbers-station">java solution</a> but sadly, I know nothing about java! Any help or tips are greatly appreciated!</p>