Задача разработчика Google Foobar - это один из процессов приема на работу в Google разработчиков, которые, по их мнению, могут хорошо подойти их организации.

Многие разработчики в Google были наняты благодаря этому вызову.

Как пройти отбор?

Судя по всему, Google отправляет вызов Foobar только определенным типам разработчиков. Я понятия не имею, почему меня выбрали, поэтому не могу дать никаких подсказок или советов.

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

Думаю, если вы разработчик, очевидно, что вы ищете множество проблем, связанных с программированием, в Google или Stack Overflow.

Что происходит, когда вас выбирают?

Итак, я просматривал Google, просто учился на выходных, когда этот действительно непонятный баннер появился в верхней части моего поиска!

Очевидно, я щелкнул по ней и приступил к задаче разработчика Google Foobar.

Это было очень удачное время, так как я недавно изучал Python (и понимание списка, как вы можете видеть, что я искал в Google в то время, что пригодилось, поскольку проблема заключалась именно в этом!)

Я начал ориентироваться в задаче 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.