Python Error - Google Foobar


Python Error - Google Foobar



To anyone who has done Google's Foobar challenge before, have you ever encountered an error like this?


Verifying solution...
{
"bytes" : "CAAaIgogQ291bGQgbm90IGZpbmQgJ2Fuc3dlcicgZnVuY3Rpb24"
}



I've tested my solution in Visual Studio, and it works fine, and it gives accurate output. I only have 36 hours remaining to submit my solution, and this is the final challenge, so I would really like to get credit for completing it. Here's the code I'm trying to verify:


from fractions import *
from math import factorial as fac

def cycle_index(n):
return [(coeff(term), term) for term in foo(n, n)]

def foo(n, lim):
soln_set =
if n > 0:
for x in range(lim, 0, -1):
if x == 1:
soln_set.append([(1, n)])
else:
for y in range(int(n / x), 0, -1):
recurse = foo(n - x * y, x - 1)
if len(recurse) == 0:
soln_set.append([(x, y)])
for soln in recurse:
soln_set.append([(x, y)] + soln)
return soln_set

def coeff(term):
val = 1
for x, y in term:
val *= fac(y) * x ** y
return Fraction(1, val)

def cross(cycle_a, cycle_b):
term =
for len_a, freq_a in cycle_a:
for len_b, freq_b in cycle_b:
lcm = len_a * len_b / gcd(len_a, len_b)
term.append((lcm, int(len_a * freq_a * len_b * freq_b / lcm)))
return term

def answer(w, h, s):
total = 0
cycidx_cols = cycle_index(w)
cycidx_rows = cycle_index(h)
for col_coeff, col_cycle in cycidx_cols:
for row_coeff, row_cycle in cycidx_rows:
coeff = col_coeff * row_coeff
cycle = cross(col_cycle, row_cycle)
value = 1
for _, power in cycle:
value *= s ** power
total += coeff * value
return total



I found someone else's solution last week and verified it through Foobar, but I wanted to write my own to get a deeper understanding. I've compared results side-by-side, and they are exact, so I know my code gives accurate results.



Out of curiosity, I just retried verifying the other person's solution again, and now I am getting the same error with a slightly different output even though it worked just fine when I tried last week:


Verifying solution...
{
"bytes" : "CAEQARABEAEQARABEAEQARABEAEQAQ"
}



I'm not sure where else to go. I was so excited that I had come up with my own solution to the challenge, but now I'm panicking that it won't matter. Any suggestions?



UPDATE - June 29, 2018, 6:00pm CST
The deadline passed for me last night, and I was unable to submit my code in time. I made sure to use the recruitme command before time ran out just in case I got booted out. However, I am still able to view my current status, and it let me request another Level 5 challenge. So, I will be checking periodically to see if the test cases start showing up again, and I will be sure to update this when they do. I would highly recommend that anyone on lower levels wait until I confirm that this issue is fixed before attempting to request another challenge.


recruitme



UPDATE - June 30, 2018, 5:00am CST
According to the pattern found by @RobertAnsei, I have completed the challenge. I confirmed this pattern by hardcoding the answer function to output solutions to the test cases given in the instructions. The resulting errors matched exactly with the predicted output. I also found an interesting thread on Google's Support Forum (linked here) where something similar happened to a bunch of Foobar challengers. It seems like their error was fixed by Google after about three days, but unfortunately, it also looks like a lot of people who timed out were not given another chance. Nevertheless, this will probably resolve itself within the next day or two. I will continue trying to verify and submit my solution until I am successful.


answer





I am having this exact same issue with the exact same { "bytes": "CAEQARABEAEQARABEAEQARABEAAQAA" } returned. Here's hoping this can be resolved.
– NoOrangeJuice
Jun 27 at 17:03


{ "bytes": "CAEQARABEAEQARABEAEQARABEAAQAA" }





It's seeming very likely this is something on their end then. Yeah, hopefully we can try again later today or tomorrow and everything will be fine.
– Kody Puebla
Jun 27 at 17:07





That's frustrating. Oddly enough, I timed out on one question on level 3 and was given another chance to continue, so maybe you will too if this isn't resolved.
– Kody Puebla
Jun 27 at 17:11





@HenryHsu, from what I can tell, it seems to be base64, with 1 leading 2-byte chunk, and each remaining 2-byte chunk representing a specific test-case. When the final bit of that chunk is a 1 => passing, a 0 => failing. Yours (and everyone else with the same string), if I'm right, indicates all passing tests. Mostly I gathered this just by futzing with different people's errors here (base64 -> binary, 2 byte chunks): cryptii.com/base64-to-binary Best of luck to you all!
– Robert Ansel
Jun 29 at 7:43





@RobertAnsel Thanks for the explanation and the link Robert! You're awesome :)
– Henry Hsu
Jun 29 at 7:55




2 Answers
2



This may not be the answer you're looking for, but that first "bytes" string is a base64 encoding of the following error message:



"Could not find 'answer' function".



I've done the Foobar challenge myself, and that should only happen if you are trying to verify a file that is missing a defined "answer" function, which obviously you are not. Are you certain that the spec they provide has 3 arguments vs an array with 3 items?



The second message (CAEQARABEAEQARABEAEQARABEAEQAQ), while valid base64, doesn't map to ASCII or UTF-8. After some closer analysis of some of the other strings others have posted, I've concluded that this is the base64 encoded version of the test output. It isn't very human readable, but I believe it is 11 2-byte chunks, the first of which is unhelpful, but the following 10 are the test result for each of the corresponding test cases. In the case of this message it converts to binary as:


0000100000000001 <- unknown pre-pended info
0001000000000001 <- passing test 1
0001000000000001 <- passing test 2
0001000000000001 <- passing test 3
0001000000000001 <- passing test 4
0001000000000001 <- passing test 5
0001000000000001 <- passing test 6
0001000000000001 <- passing test 7
0001000000000001 <- passing test 8
0001000000000001 <- passing test 9
0001000000000001 <- passing test 10



The '1's at the end of each of these lines indicates that all 10 tests are passing.



A failing test case is represented by the following string:


0001000000000000 <- failing test case



This should help you (and others) continue testing to achieve fully passing tests (you can complete your own analysis with tools like this one: https://cryptii.com/base64-to-binary), but unfortunately this will not help you move forward with your final submission until Google remediates the issue on their end.



UPDATE: July 2, 8PM PDT
After reaching out to a couple of Google recruiters about the issue they were able to confirm that the issue was identified and is believed to be resolved today.
If you re-save your code after making a change to it (whitespace should be fine), you should be able to test and submit correctly. Alternatively, you may now be able to request a new challenge anyway.





The instructions read "Write a function answer(w, h, s) that takes 3 integers and returns...", so I am certain there are three arguments. I could understand how I got that message the first time since I temporarily renamed that function. I might have forgotten to switch it back. But that is definitely not the case now, and I am only seeing the second error message now. It's too bad that one doesn't translate to anything useful.
– Kody Puebla
Jun 28 at 8:41





Thanks for the base64 tip! I was able to use it to extract all the hidden test cases to the first level 3 challenge. However, when I try to verify or submit my solution (of whose correctness I am now fairly certain), I get the same mysterious error, with apparently no effect.
– Sam Estep
Jun 29 at 3:52


verify


submit





Heh, turns out I did have another error after all...
– Sam Estep
Jun 29 at 4:34





So did it work after fixing the error?
– Kody Puebla
Jun 29 at 5:22





@SamEstep, I'm hoping to confirm a theory I have on the encoding scheme they are using. Was the error you mentioned having "after all" that you were failing test case #8? (per your CAEQARABEAEQARABEAEQARAAEAEQAQ output)
– Robert Ansel
Jun 29 at 7:13



There will be nothing for you to solve this issue, it is a issue on Google's site, as the Google Foobar API is responding with this message as I've found out.



Notherless your best bet will be to use the feedback command and give Google Foobar a feedback and mark it as a bug. This will be more likely to reach their attention and helping them to fix this issue!


feedback





How were you able to find out that these error messages are related to a fault with the Foobar API? I mean, I hope it is and not something I forgot to address in my algorithm. Were you able to decode the "CAEQARABEAEQARABEAEQARABEAEQAQ" string into an error message?
– Henry Hsu
Jun 29 at 6:19





I were not able to decode the message CAEQARABEAEQARABEAEQARABEAEQAQ. But I've looked at what the API responds and searched a bit through the source code. The response of the API always gives you a score which is always 0 in my case and this does not change whatever you send a working or a wrong solution. I have an friend who is in Google Foobar aswell and it should respond with test cases if all tests were passed and such but not this encoded message we get.
– Shawn Funke
Jun 29 at 8:20


CAEQARABEAEQARABEAEQARABEAEQAQ


0





Thanks for the clarification Shawn! Now I just wish they would fix it, lol.
– Henry Hsu
Jun 29 at 14:07





This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– poundifdef
12 hours ago




Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).


Would you like to answer one of these unanswered questions instead?

Popular posts from this blog

.

How to generate build files in next js

Delphi Android file open failure with API 26