1

Currently I'm doing the Google Foobar challenges, and I've run into a very odd issue that I'm having difficulty troubleshooting, due to the lack of detailed error reporting in Google's Foobar interface. Don't worry, nothing is given away from the problem here. Also, I have almost never used python before. The last couple days have been my first experience with it. I have had experience in Swift (not app development but general use) and Java.

And the end of a function I've written, I need to convert a concatenated list, lets call it combined_ints, of integers into a final single integer for returning. Every single time I do the final step of converting the string made from combined_ints, it gives me a TypeError. Due to it being Google Foobar, that's all it says. I cannot recreate this problem myself in any version of python, including 2.7.6 exactly. Example of the problem:

#list 1 2 3 arbitrarily appended ints prior

combined_ints = list1 + list2 + list3
final_str = ''.join(map(str, combined_ints))
return int(final_str) #TypeError here

Now what's super odd, is if I don't use a concatenated list here, but instead a list that was initialized and never changed, I don't get a TypeError. I have tried advice given in this thread about list of ints -> 1 number, this thread about converting strings to ints, and a couple more that I've since closed. Because I cannot manage to recreate my problem anywhere, even by just copying any pasting the exact same code from google foobar into a python 2.7.6 interpreter, I am at a complete loss. I need to return an int. I hope this isn't a stupid error on my end, or Google's end.

Community
  • 1
  • 1
  • How about `print repr(final_str)` just before the conversion and post the entire stack frame. – tdelaney Apr 23 '17 at 02:48
  • you should check what's in final_str to see if it's what you expected. – Shiping Apr 23 '17 at 02:53
  • Are you guaranteed that all the `int`s are positive. – AChampion Apr 23 '17 at 03:10
  • final_str is a regular string and I am guaranteed all ints are between 1 and 9. To tdelaney -- I have a very minimal idea about how I would go about doing that, but I have an extremely minimal interface on Google's little game. Print statements do nothing as there is no real console. Because of such, there would probably be no way to get the stack frame either. –  Apr 23 '17 at 04:13

0 Answers0