Предизвикателството за разработчици на Google Foobar е един от процесите на Google за наемане на разработчици, които според тях могат да бъдат подходящи за тяхната организация.

Много разработчици в Google бяха наети чрез това предизвикателство за наемане.

Как да бъда избран?

Очевидно Google изпраща предизвикателството Foobar само на специални видове разработчици. Нямам представа защо ме избраха, така че не мога да дам никакви намеци или съвети.

От това, което прочетох, никой не знае точно критериите за допустимост на покана за Google Foobar, въпреки че е вероятно Google да изпрати поканата въз основа на вашата хронология на търсенията и вашите свързани с решаването на проблеми търсения с ключови думи

Предполагам, че ако сте разработчик, очевидно е, че търсите много проблеми, свързани с програмирането в Google или Stack Overflow.

Какво се случва, когато бъдете избрани?

И така, аз разглеждах Google, просто се учех през уикенда, когато този наистина неясен банер изскочи в горната част на търсенето ми!

Очевидно щракнах върху него и започнах с предизвикателството за разработчици на Google Foobar.

Времето беше доста добро, тъй като наскоро научих Python (и разбиране на списъка, както можете да видите какво търсих в гугъл по това време, което беше полезно, тъй като предизвикателството включваше точно това!)

Започнах да се ориентирам в предизвикателството на Foobar и да видя за какво става дума.

Mounting /home/craigpayne1985...
Welcome to foobar version 1-293-g571b8be-beta
Success! You've managed to infiltrate Commander Lambda's evil organization, and finally earned yourself an entry-level position as a Minion on her space station. From here, you just might be able to subvert her plans to use the LAMBCHOP doomsday device to destroy Bunny Planet. Problem is, Minions are the lowest of the low in the Lambda hierarchy. Better buck up and get working, or you'll never make it to the top...
foobar:~/ craigpayne1985$ ls
journal.txt
start_here.txt
foobar:~/ craigpayne1985$ cat journal.txt
Success! You've managed to infiltrate Commander Lambda's evil organization, and finally earned yourself an entry-level position as a Minion on her space station. From here, you just might be able to subvert her plans to use the LAMBCHOP doomsday device to destroy Bunny Planet. Problem is, Minions are the lowest of the low in the Lambda hierarchy. Better buck up and get working, or you'll never make it to the top...

Интересно, беше като интерактивна обвивка, само много ограничена. Имаше няколко файла, които реших, че трябва да прочета, за да видя какво става

foobar:~/ craigpayne1985$ cat start_here.txt
Type request to request a challenge. Type help for a list of commands.
foobar:~/ craigpayne1985$ request
You are about to begin a time-limited challenge which you will have 48 hours to complete.
Do you wish to proceed and start your first challenge?
[Y]es or [N]o: Y
Requesting challenge...
Commander Lambda sure is a task-master, isn't she? You're being worked to the bone!

Така че бях на път да започна предизвикателство за разработчици, с 48 часа за завършване, хубаво!

New challenge "Prison Labor Dodgers" added to your home folder.
Time to solve: 48 hours.
foobar:~/ craigpayne1985$ ls
prison-labor-dodgers
journal.txt
start_here.txt
foobar:~/ craigpayne1985$ cd prison-labor-dodgers/
foobar:~/prison-labor-dodgers craigpayne1985$ ls
Solution.java
constraints.txt
readme.txt
solution.py
foobar:~/prison-labor-dodgers craigpayne1985$ cat constraints.txt
Java
====
Your code will be compiled using standard Java 8. All tests will be run by calling the solution() method inside the Solution class

Execution time is limited.

Wildcard imports and some specific classes are restricted (e.g. java.lang.ClassLoader). You will receive an error when you verify your solution if you have used a blacklisted class.

Third-party libraries, input/output operations, spawning threads or processes and changes to the execution environment are not allowed.

Your solution must be under 32000 characters in length including new lines and and other non-printing characters.

Python
======
Your code will run inside a Python 2.7.13 sandbox. All tests will be run by calling the solution() function.

Standard libraries are supported except for bz2, crypt, fcntl, mmap, pwd, pyexpat, select, signal, termios, thread, time, unicodedata, zipimport, zlib.

Input/output operations are not allowed.

Your solution must be under 32000 characters in length including new lines and and other non-printing characters.

foobar:~/prison-labor-dodgers craigpayne1985$ cat readme.txt
Prison Labor Dodgers
====================

Commander Lambda is all about efficiency, including using her bunny prisoners for manual labor. But no one's been properly monitoring the labor shifts for a while, and they've gotten quite mixed up. You've been given the task of fixing them, but after you wrote up new shifts, you realized that some prisoners had been transferred to a different block and aren't available for their assigned shifts. And manually sorting through each shift list to compare against prisoner block lists will take forever - remember, Commander Lambda loves efficiency!

Given two almost identical lists of prisoner IDs x and y where one of the lists contains an additional ID, write a function solution(x, y) that compares the lists and returns the additional ID.

For example, given the lists x = [13, 5, 6, 2, 5] and y = [5, 2, 5, 13], the function solution(x, y) would return 6 because the list x contains the integer 6 and the list y doesn't. Given the lists x = [14, 27, 1, 4, 2, 50, 3, 1] and y = [2, 4, -4, 3, 1, 1, 14, 27, 50], the function solution(x, y) would return -4 because the list y contains the integer -4 and the list x doesn't.

In each test case, the lists x and y will always contain n non-unique integers where n is at least 1 but never more than 99, and one of the lists will contain an additional unique integer which should be returned by the function.  The same n non-unique integers will be present on both lists, but they might appear in a different order, like in the examples above. Commander Lambda likes to keep her numbers short, so every prisoner ID will be between -1000 and 1000.

Languages
=========

To provide a Python solution, edit solution.py
To provide a Java solution, edit Solution.java

Test cases
==========
Your code should pass the following test cases.
Note that it may also be run against hidden test cases not shown here.

-- Python cases --
Input:
solution.solution([13, 5, 6, 2, 5], [5, 2, 5, 13])
Output:
    6

Input:
solution.solution([14, 27, 1, 4, 2, 50, 3, 1], [2, 4, -4, 3, 1, 1, 14, 27, 50])
Output:
    -4

-- Java cases --
Input:
Solution.solution({13, 5, 6, 2, 5}, {5, 2, 5, 13})
Output:
    6

Input:
Solution.solution({14, 27, 1, 4, 2, 50, 3, 1}, {2, 4, -4, 3, 1, 1, 14, 27, 50})
Output:
    -4

Use verify [file] to test your solution and see how it does. When you are finished editing your code, use submit [file] to submit your answer. If your solution passes the test cases, it will be removed from your home folder.

Така че си помислих, че това не може да бъде твърде трудно, и опитах. Беше по-трудно, отколкото очаквах, вероятно лесно за някой, който е добре запознат с Python, но за мен с опит от няколко седмици се оказа по-сложно, но поне ми даде възможност да изпробвам разбирането на списъка.

След много неуспешни опити в конзолата на Foobar (преди да я изпробвам в Jupyter) успях да премина първия тест!

foobar:~/prison-labor-dodgers craigpayne1985$ verify solution.py
Verifying solution...
Test 1 failed 
Test 2 failed 
Test 3 failed  [Hidden]
Test 4 failed  [Hidden]
Test 5 failed  [Hidden]
Verifying solution...
All test cases passed. Use submit solution.py to submit your solution
foobar:~/prison-labor-dodgers craigpayne1985$ submit solution.py
Are you sure you want to submit your solution?
[Y]es or [N]o: Y
Submitting solution...

Кодът, който написах, беше следният:

def solution(x,y):  
  matrix = [x,y]  
  all_values = [y for x in matrix for y in x]  
  unique_values = list(set(all_values))  
  matched_values = [x for x in unique_values if all_values.count(x) % 2 == 0]  
  missing_values = [x for x in unique_values if x not in matched_values ]  
  return missing_values[0]

И имам страхотно зайче ascii, което подскача наоколо!!

You survived a week in Commander Lambda's organization, and you even managed to get yourself promoted. Hooray! Henchmen still don't have the kind of security access you'll need to take down Commander Lambda, though, so you'd better keep working. Chop chop!
Submission: SUCCESSFUL. Completed in: 2 hrs, 1 min, 56 secs.