Question 1 – Language independent
Objective
In this problem, you'll be filtering words based on the letters that they contain.
Specifically, you'll be given an input list of words (all lowercase), along with a set of lowercase letters, and asked to keep only the words that contain at least one letter in the given set.
Implementation
Implement the function filter_words(words, letters) which takes as input:
- a list of strings
words, with the words to filter. - a string
letters, used to filter the words.
For example:
words = ['the', 'dog', 'got', 'a', 'bone']letters = 'ae'
Your filter_words function should return a list of strings from words that contain at least one letter in letters. The returned list should maintain the same ordering as in the original list.
Question 2 – Language independent
Implement the function find_largest(numbers), so it returns the largest number from the list numbers.
Notes
numberscontains only integers.numbersalways contains at least one element, and never contains more than 10 elements.- The integers are ranged from
-2^31to2^31 - 1(they always fit in a 32-bit signed integer).
Question 3 – Language independent
Rules
Each puzzle is a grid, on which are placed wooden blocks of various shapes. These blocks must be taken out of the game, one after the other, without colliding. You have to determine the order in which they are taken out.
Each block is numbered with a value between 0 and 9. When you enter the number of a block, it will be moved to the right until it is off of the grid.
If several blocks can be exited at the same time, you can choose which one you would like to remove first.
Implementation
Implement the function solve(width, height, nb_blocks, grid).
This function is executed at each round of the game and should return the number of the next block to move.
Input data of the function
width: width of the puzzle, in number of cells.height: height of the puzzle, in number of cells.nb_blocks: number of blocks initially present in the puzzle.grid: a list ofheightelements, each of which is a string with a size equal towidth.
The parameters width, height and nb_blocks do not change during the whole game.
The grid parameter represents the current situation of the puzzle. Each of its characters can take one of the following values:
.(a dot): an empty square.X: a wall. They are placed on the first and last line, as well as on the first character of each line, to show that the only possible exit is to the right. You cannot move these walls.- an integer between
0andnb_blocks - 1: a square occupied by a block. The same number can be present several times in the grid, representing a single block that extends over several squares. All cells with the same block number are connected (they are never separated into several isolated groups).
Question 4 – Simple algorithm
Goal
Find the point closest to (0, 0).
You are given a list, each of its elements represents a point and contains two integers: x and y.
You must return the point closest to the origin.
If two points have the same distance, return the one that was given first in the list.
The list contains at most 100 elements. Coordinates range from -100000 to +100000.
The distance to use between two points is the Euclidean distance.
For two points A (coordinates Ax, Ay) and B (coordinates Bx, By), the distance is:
Question 5 – Simple algorithm
The string to return must contain newlines (character \n), so that it correctly represents the whole hourglass.
You must not add trailing whitespace, and you must not add a newline character at the end of the last line.
Detailed example
With starting_line = "-----", the corresponding hourglass is:
-----
---
-
---
-----
So, the string to return is:
"-----\n ---\n -\n ---\n-----"

Question 6 – Simple algorithm
You are given in parameters a list of integers: index_values. Start at the first element (index 0) and repeatedly move following this rule: the value of the current element is the index of the next element you should move to.
Will you ever return to the first element?
Detailed examples
With this parameter: index_values = [3, 4, 2, 1, 0]
- The first element of the list has the value 3.
- What is the element at index 3? That would be 1.
- What is the element at index 1? That would be 4.
- What is the element at index 4? That would be 0.
- We are back where we started.
But not every list of integers permits this. Say the list was [3, 4, 2, 1, 1]. Notice how, if you started at the first element, which is 3, you will never return there.
Question 7 – Simple algorithm
Goal
Implement add_spaces(text), which returns a string corresponding to the parameter text, with a space added between each pair of consecutive letters. Do not add a space between two characters that are not both letters (a-zA-Z).
Question 8 – Simple algorithm
Instructions
You must group the same characters of the ASCII string text given in parameters.
Create a string from each group, with the same character repeated as many times as it is found in text. Then, put these groups in a list, ordered by the ASCII value of the characters. Finally, return the list.
我们长期稳定承接各大科技公司如Capital One、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.

