This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def apply_operation(operation: Callable[[int], int], numbers: List[int]) -> List[int]: | |
| result = [] | |
| for num in numbers: | |
| result.append(operation(num)) | |
| return result | |
| def square(num: int) -> int: | |
| return num * num |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def count_calls(func): | |
| """ | |
| This function is a decorator that keeps track of the number of times a function is called. | |
| It takes a function as input and returns a new function that behaves exactly like the input function, | |
| but also increments a counter and prints the number of calls each time the function is called. | |
| :param func: The function to be decorated. | |
| :return: The decorated function that counts and prints the number of calls. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def display_board(board, size=3): | |
| """ | |
| Prints the Tic Tac Toe board to the terminal in a formatted way. | |
| """ | |
| for idx in range(0, size): | |
| print("".join(list(map(lambda i: f" {board[i + idx * size]}{' |' if i < size - 1 else ''}", range(0, size))))) | |
| if idx < size - 1: | |
| print(f"{'---|---|---'}") | |
| def is_valid_move(board, position): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { HttpResponse, JsonBodyType } from "msw"; | |
| export const errors = { | |
| resourceNotFound: ( | |
| body: JsonBodyType = { error: { message: "Resource not found" } } | |
| ) => HttpResponse.json(body, { status: 404 }), | |
| unauthorized: ( | |
| body: JsonBodyType = { | |
| error: { | |
| message: "Not authorized to access resource" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const localStorageMock: Storage = { | |
| getItem: jest.fn(), | |
| setItem: jest.fn(), | |
| removeItem: jest.fn(), | |
| clear: jest.fn(), | |
| length: 0, | |
| key: jest.fn() | |
| }; | |
| global.localStorage = localStorageMock; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { expect, test } from "@jest/globals"; | |
| function sum(...args: number[]): number { | |
| return args.reduce((acc, val) => acc + val, 0); | |
| } | |
| function isSumOddOrEven(...args: number[]): string { | |
| const total = sum(...args); | |
| if (total % 2 === 0) { |