Square Conference Table
You must combine several long desks to make a square conference table of the specified size.
- The input values are the widths of the long desks (tuples of integer) and the side length of the table (integer). The long desks have any width and their depth is always 1.
- The answer is the combinations of long desks that make the four sides of the table. It must be a list of 4 tuples, each tuple being one or more integers. The adjacent tuples in the resulting list to actually represent adjacent sides of the table.
NOTE:
- Since there can be more than one correct answer, using a checker.
- All tests have correct answers.
- You don't always have to use up all the long desks.
Input: The long desks (a tuple of integers) and the side length of the table (a integer).
Output: The combinations of the long desks (a list of 4 tuples of integers).
square_conference_table((1, 2, 2, 3, 4, 4), 4) : | |
ex_1: | ex_2: |
[(4,), (3,), (2,1), (2,)] | [(4,), (2,), (4,), (2,)] |
Precondition:
- len(long_desks) <= 20
- side_length <= 60
Examples:
from itertools import chain from collections import Counter from typing import Callable def checker(fn: Callable, ds: tuple[int, ...], s: int) -> bool: result = fn(ds, s) if Counter(chain(*result)) <= Counter(ds): difs = [s - sum(r) for r in result] return difs in ([1, 1, 1, 1], [2, 0, 2, 0], [0, 2, 0, 2]) or sorted(difs) == [0, 1, 1, 2] return False assert checker(square_conference_table, (1, 2, 2, 3, 4), 4) is True assert checker(square_conference_table, (3, 3, 3, 3), 4) is True assert checker(square_conference_table, (1, 2, 2, 3, 3, 4, 5), 5) is True assert checker(square_conference_table, (1, 2, 3, 4, 5, 6), 6) is True
CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.
In order to install CheckiO client you'll need installed Python (version at least 3.8)
Install CheckiO Client first:
pip3 install checkio_client
Configure your tool
checkio --domain=py config --key=
Sync solutions into your local folder
checkio sync
(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)
checkio serv -d
Alternatevly, you can install Chrome extension or FF addon
checkio install-plugin
checkio install-plugin --ff
checkio install-plugin --chromium
Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.
Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!
You are trying to join a pair programming session that has not started yet.
Please wait for the session creator to join.
It looks like the creator of the pair programming session closed the editor window.
It might happen accidentally, so that you can wait for reconnection.