[Shopify] OA 2025 start – 11 Apr (ecom engineer prep)

Rules

You are an engineer in a datacenter, and one of your servers is being hacked.

You don't know which one, but you can probe any server in the datacenter to know if it's the one.

The game is played on a grid of width servers wide and height servers high. The server on the top left corner is (0, 0). x defines the column and y defines the row.

Each turn, you are given your current position x, y and the direction to the compromised server:

Direction Definitions

  • U (Up): the target server is above you
  • UR (Up Right): the target server is above you and on your right
  • R (Right): the target server is on your right
  • DR (Down Right): the target server is below you and on your right
  • D (Down): the target server is below you
  • DL (Down Left): the target server is below you and on your left
  • L (Left): the target server is on your left
  • UL (Up Left): the target server is above you and on your left

You have to return the location of the server you want to probe as a list of 2 integers x, y, until you find the compromised server.

To succeed your mission, you must find the server as fast as possible, before the hacker infiltrates your network, which is represented by a maximum number of tries.

Your initial coordinates are not always (0, 0) and the initial direction is not always "DR".

Function Signature

solve(direction, x, y, width, height)

Parameters

  • direction: a string amongst the 8 possible directions
  • x: your current x
  • y: your current y
  • width: the grid width
  • height: the grid height

Returns

Should return the position [x, y] where you want to go next, as a list of 2 integers.

Victory Conditions

You found the compromised server before the hacker infiltrated your network.

Lose Conditions

  • Your function returns an incorrect position.
  • You haven't found the compromised server within the tries limit.

Constraints

1 ≤ width, height ≤ 10000

我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。

We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

Leave a Reply

Your email address will not be published. Required fields are marked *