├── .gitignore ├── LICENSE ├── README.md └── qualifier ├── local_test_suite.py ├── qualifier.py └── test_qualifier.py /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | .idea/ 3 | __pycache__/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Python Discord 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Summer Code Jam 2021: Qualifier 2 | 3 | To qualify for the upcoming Summer Code Jam, you'll have to complete a qualifier assignment. In this assignment you have 4 | been tasked to create a function that makes a table with columns and rows. 5 | 6 | Please read the instructions carefully and submit your solution before the deadline using the 7 | [sign-up form](https://form.jotform.com/211714357615050). 8 | 9 | # Table of Contents 10 | 11 | - [Qualifying for the Code Jam](#qualifying-for-the-code-jam) 12 | - [Rules and Guidelines](#rules-and-guidelines) 13 | - [Qualifier Assignment](#qualifier-assignment) 14 | - [Function Signature](#function-signature) 15 | - [Examples](#examples) 16 | - [Example 1](#example-1) 17 | - [Example 2](#example-2) 18 | - [Example 3](#example-3) 19 | 20 | # Qualifying for the Code Jam 21 | 22 | To qualify for the Code Jam you will be required to upload your submission to the [sign-up form](https://form.jotform.com/211714357615050). 23 | We set up our test suite so you don't have to worry about setting one up yourself. 24 | 25 | Your code will be tested with a multitude of tests to test all aspects of your code making sure it works. 26 | 27 | # Rules and Guidelines 28 | 29 | - Your submission will be tested using a Python 3.9.5 interpreter without any additional packages installed. You're allowed to use everything included in Python's standard library, but nothing else. Please make sure to include the relevant `import` statements in your submission. 30 | 31 | - Use [`qualifier.py`](qualifier/qualifier.py) as the base for your solution. It includes a stub for the function you need to write: `make_table`. 32 | 33 | - Do not change the **signature** of the function included in [`qualifier.py`](qualifier/qualifier.py). The test suite we will use to judge your submission relies on it. Everything else, including the docstring, may be changed. 34 | 35 | - Do not include "debug" code in your submission. You should remove all debug prints and other debug statements before you submit your solution. 36 | 37 | - This qualifier task is supposed to be **an individual challenge**. You should not discuss (parts of) your solution in public (including our server), or rely on others' solutions to the qualifier. Failure to meet this requirement may result in the **disqualification** of all parties involved. You are still allowed to do research and ask questions about Python as they relate to your qualifier solution, but try to use general examples if you post code along with your questions. 38 | 39 | 40 | # Qualifier Assignment 41 | 42 | For the qualifier, you are required to write a function that creates and returns an ascii table. 43 | Your table must use these characters for the border. `│ ─ ┌ ┬ ┐ ├ ┼ ┤ └ ┴ ┘` 44 | - Length of each row will always equal the length of labels (if labels are provided) for the input data 45 | - No item in any row will contain an escape character such as `\n` for the input data 46 | - If an item cannot be centered evenly, the extra space character can be placed on either side. 47 | - Each column should be made wide enough to fit the longest item, with one space on either side for padding 48 | 49 | ### Function Signature 50 | ```py 51 | def make_table(rows: List[List[Any]], labels: Optional[List[Any]] = None, centered: bool = False) -> str: 52 | """ 53 | :param rows: 2D list containing objects that have a single-line representation (via `str`). 54 | All rows must be of the same length. 55 | :param labels: List containing the column labels. If present, the length must equal to that of each row. 56 | :param centered: If the items should be aligned to the center, else they are left aligned. 57 | :return: A table representing the rows passed in. 58 | """ 59 | ... 60 | ``` 61 | ## Examples 62 | 63 | ### Example 1 64 | 65 | This example shows the function being used to create a single column table. Each column should be made wide enough 66 | to fit the longest item with one space either side. 67 | 68 | ```py 69 | table = make_table( 70 | rows=[ 71 | ["Lemon"], 72 | ["Sebastiaan"], 73 | ["KutieKatj9"], 74 | ["Jake"], 75 | ["Not Joe"] 76 | ] 77 | ) 78 | >>> print(table) 79 | ┌────────────┐ 80 | │ Lemon │ 81 | │ Sebastiaan │ 82 | │ KutieKatj9 │ 83 | │ Jake │ 84 | │ Not Joe │ 85 | └────────────┘ 86 | ``` 87 | 88 | ### Example 2 89 | 90 | This example shows a table with three columns, each column is wide enough to fit the largest item of column with a 91 | space either side. The labels are placed independently at the top of each column to give them a clearer meaning. 92 | 93 | ```py 94 | table = make_table( 95 | rows=[ 96 | ["Lemon", 18_3285, "Owner"], 97 | ["Sebastiaan", 18_3285.1, "Owner"], 98 | ["KutieKatj", 15_000, "Admin"], 99 | ["Jake", "MoreThanU", "Helper"], 100 | ["Joe", -12, "Idk Tbh"] 101 | ], 102 | labels=["User", "Messages", "Role"] 103 | ) 104 | >>> print(table) 105 | ┌────────────┬───────────┬─────────┐ 106 | │ User │ Messages │ Role │ 107 | ├────────────┼───────────┼─────────┤ 108 | │ Lemon │ 183285 │ Owner │ 109 | │ Sebastiaan │ 183285.1 │ Owner │ 110 | │ KutieKatj │ 15000 │ Admin │ 111 | │ Jake │ MoreThanU │ Helper │ 112 | │ Joe │ -12 │ Idk Tbh │ 113 | └────────────┴───────────┴─────────┘ 114 | ``` 115 | 116 | ### Example 3 117 | 118 | This example shows the usage of centered. Each item will be aligned within the center of the column. Remember that the 119 | labels are also aligned. 120 | 121 | ```py 122 | table = make_table( 123 | rows=[ 124 | ["Ducky Yellow", 3], 125 | ["Ducky Dave", 12], 126 | ["Ducky Tube", 7], 127 | ["Ducky Lemon", 1] 128 | ], 129 | labels=["Name", "Duckiness"], 130 | centered=True 131 | ) 132 | >>> print(table) 133 | ┌──────────────┬───────────┐ 134 | │ Name │ Duckiness │ 135 | ├──────────────┼───────────┤ 136 | │ Ducky Yellow │ 3 │ 137 | │ Ducky Dave │ 12 │ 138 | │ Ducky Tube │ 7 │ 139 | │ Ducky Lemon │ 1 │ 140 | └──────────────┴───────────┘ 141 | ``` 142 | 143 | ## Good Luck! 144 | 145 | ![Event Banner](https://github.com/python-discord/branding/blob/main/jams/summer_code_jam_2021/site_banner.png?raw=true) 146 | -------------------------------------------------------------------------------- /qualifier/local_test_suite.py: -------------------------------------------------------------------------------- 1 | """ 2 | DO NOT EDIT THIS FILE. 3 | Also do note there are additional test when submitting. 4 | Trying to just respond with these will not be considered a passing solution. 5 | 6 | Run using `python -m unittest local_test_suite.py`. 7 | You must have the qualifier in the same working directory. 8 | """ 9 | import copy 10 | from typing import Any, List 11 | import unittest 12 | from dataclasses import dataclass 13 | 14 | from qualifier import make_table 15 | 16 | 17 | @dataclass 18 | class TableParams: 19 | rows: List[List[Any]] 20 | labels: List[Any] = None 21 | centered: bool = False 22 | 23 | def __repr__(self): 24 | """Used for putting in a dict.""" 25 | return f"{self.rows=}{self.labels=}{self.centered=}" 26 | 27 | 28 | class MakeTableTests(unittest.TestCase): 29 | baked_solutions = { 30 | "self.rows=[['Apple', 5]]self.labels=Noneself.centered=False": 31 | '┌───────┬───┐\n' 32 | '│ Apple │ 5 │\n' 33 | '└───────┴───┘', 34 | "self.rows=[['Apple', 5], ['Banana', 3], ['Cherry', 7]]self.labels=Noneself.centered=False": 35 | '┌────────┬───┐\n' 36 | '│ Apple │ 5 │\n' 37 | '│ Banana │ 3 │\n' 38 | '│ Cherry │ 7 │\n' 39 | '└────────┴───┘', 40 | "self.rows=[['Apple', 5], ['Banana', 3], ['Cherry', 7], ['Kiwi', 4], ['Strawberry', 6]]self.labels=Noneself.centered=False": 41 | '┌────────────┬───┐\n' 42 | '│ Apple │ 5 │\n' 43 | '│ Banana │ 3 │\n' 44 | '│ Cherry │ 7 │\n' 45 | '│ Kiwi │ 4 │\n' 46 | '│ Strawberry │ 6 │\n' 47 | '└────────────┴───┘', 48 | "self.rows=[['Apple', 5, 70]]self.labels=Noneself.centered=False": 49 | '┌───────┬───┬────┐\n' 50 | '│ Apple │ 5 │ 70 │\n' 51 | '└───────┴───┴────┘', 52 | "self.rows=[['Apple', 5, 70, 'Red'], ['Banana', 3, 5, 'Yellow'], ['Cherry', 7, 31, 'Red']]self.labels=Noneself.centered=False": 53 | '┌────────┬───┬────┬────────┐\n' 54 | '│ Apple │ 5 │ 70 │ Red │\n' 55 | '│ Banana │ 3 │ 5 │ Yellow │\n' 56 | '│ Cherry │ 7 │ 31 │ Red │\n' 57 | '└────────┴───┴────┴────────┘', 58 | "self.rows=[['Apple', 5, 70, 'Red', 76], ['Banana', 3, 5, 'Yellow', 8], ['Cherry', 7, 31, 'Red', 92], ['Kiwi', 4, 102, 'Green', 1], ['Strawberry', 6, 134, 'Red', 28]]self.labels=Noneself.centered=False": 59 | '┌────────────┬───┬─────┬────────┬────┐\n' 60 | '│ Apple │ 5 │ 70 │ Red │ 76 │\n' 61 | '│ Banana │ 3 │ 5 │ Yellow │ 8 │\n' 62 | '│ Cherry │ 7 │ 31 │ Red │ 92 │\n' 63 | '│ Kiwi │ 4 │ 102 │ Green │ 1 │\n' 64 | '│ Strawberry │ 6 │ 134 │ Red │ 28 │\n' 65 | '└────────────┴───┴─────┴────────┴────┘', 66 | "self.rows=[['Apple', 5, 70]]self.labels=['Fruit', 'Tastiness', 'Sweetness']self.centered=False": 67 | '┌───────┬───────────┬───────────┐\n' 68 | '│ Fruit │ Tastiness │ Sweetness │\n' 69 | '├───────┼───────────┼───────────┤\n' 70 | '│ Apple │ 5 │ 70 │\n' 71 | '└───────┴───────────┴───────────┘', 72 | "self.rows=[['Apple', 5, 70, 'Red'], ['Banana', 3, 5, 'Yellow'], ['Cherry', 7, 31, 'Red']]self.labels=['Fruit', 'Tastiness', 'Sweetness', 'Colour']self.centered=False": 73 | '┌────────┬───────────┬───────────┬────────┐\n' 74 | '│ Fruit │ Tastiness │ Sweetness │ Colour │\n' 75 | '├────────┼───────────┼───────────┼────────┤\n' 76 | '│ Apple │ 5 │ 70 │ Red │\n' 77 | '│ Banana │ 3 │ 5 │ Yellow │\n' 78 | '│ Cherry │ 7 │ 31 │ Red │\n' 79 | '└────────┴───────────┴───────────┴────────┘', 80 | "self.rows=[['Apple', 5, 70, 'Red', 76], ['Banana', 3, 5, 'Yellow', 8], ['Cherry', 7, 31, 'Red', 92], ['Kiwi', 4, 102, 'Green', 1], ['Strawberry', 6, 134, 'Red', 28]]self.labels=['Fruit', 'Tastiness', 'Sweetness', 'Colour', 'Smell']self.centered=False": 81 | '┌────────────┬───────────┬───────────┬────────┬───────┐\n' 82 | '│ Fruit │ Tastiness │ Sweetness │ Colour │ Smell │\n' 83 | '├────────────┼───────────┼───────────┼────────┼───────┤\n' 84 | '│ Apple │ 5 │ 70 │ Red │ 76 │\n' 85 | '│ Banana │ 3 │ 5 │ Yellow │ 8 │\n' 86 | '│ Cherry │ 7 │ 31 │ Red │ 92 │\n' 87 | '│ Kiwi │ 4 │ 102 │ Green │ 1 │\n' 88 | '│ Strawberry │ 6 │ 134 │ Red │ 28 │\n' 89 | '└────────────┴───────────┴───────────┴────────┴───────┘', 90 | "self.rows=[['Apple', 5, 70]]self.labels=['Fruit', 'Tastiness', 'Sweetness']self.centered=True":( 91 | '┌───────┬───────────┬───────────┐\n' 92 | '│ Fruit │ Tastiness │ Sweetness │\n' 93 | '├───────┼───────────┼───────────┤\n' 94 | '│ Apple │ 5 │ 70 │\n' 95 | '└───────┴───────────┴───────────┘', 96 | '┌───────┬───────────┬───────────┐\n' 97 | '│ Fruit │ Tastiness │ Sweetness │\n' 98 | '├───────┼───────────┼───────────┤\n' 99 | '│ Apple │ 5 │ 70 │\n' 100 | '└───────┴───────────┴───────────┘', 101 | ), 102 | "self.rows=[['Apple', 5, 70, 'Red'], ['Banana', 3, 5, 'Yellow'], ['Cherry', 7, 31, 'Red']]self.labels=['Fruit', 'Tastiness', 'Sweetness', 'Colour']self.centered=True": ( 103 | '┌────────┬───────────┬───────────┬────────┐\n' 104 | '│ Fruit │ Tastiness │ Sweetness │ Colour │\n' 105 | '├────────┼───────────┼───────────┼────────┤\n' 106 | '│ Apple │ 5 │ 70 │ Red │\n' 107 | '│ Banana │ 3 │ 5 │ Yellow │\n' 108 | '│ Cherry │ 7 │ 31 │ Red │\n' 109 | '└────────┴───────────┴───────────┴────────┘', 110 | '┌────────┬───────────┬───────────┬────────┐\n' 111 | '│ Fruit │ Tastiness │ Sweetness │ Colour │\n' 112 | '├────────┼───────────┼───────────┼────────┤\n' 113 | '│ Apple │ 5 │ 70 │ Red │\n' 114 | '│ Banana │ 3 │ 5 │ Yellow │\n' 115 | '│ Cherry │ 7 │ 31 │ Red │\n' 116 | '└────────┴───────────┴───────────┴────────┘' 117 | 118 | ), 119 | "self.rows=[['Apple', 5, 70, 'Red', 76], ['Banana', 3, 5, 'Yellow', 8], ['Cherry', 7, 31, 'Red', 92], ['Kiwi', 4, 102, 'Green', 1], ['Strawberry', 6, 134, 'Red', 28]]self.labels=['Fruit', 'Tastiness', 'Sweetness', 'Colour', 'Smell']self.centered=True": ( 120 | '┌────────────┬───────────┬───────────┬────────┬───────┐\n' 121 | '│ Fruit │ Tastiness │ Sweetness │ Colour │ Smell │\n' 122 | '├────────────┼───────────┼───────────┼────────┼───────┤\n' 123 | '│ Apple │ 5 │ 70 │ Red │ 76 │\n' 124 | '│ Banana │ 3 │ 5 │ Yellow │ 8 │\n' 125 | '│ Cherry │ 7 │ 31 │ Red │ 92 │\n' 126 | '│ Kiwi │ 4 │ 102 │ Green │ 1 │\n' 127 | '│ Strawberry │ 6 │ 134 │ Red │ 28 │\n' 128 | '└────────────┴───────────┴───────────┴────────┴───────┘', 129 | '┌────────────┬───────────┬───────────┬────────┬───────┐\n' 130 | '│ Fruit │ Tastiness │ Sweetness │ Colour │ Smell │\n' 131 | '├────────────┼───────────┼───────────┼────────┼───────┤\n' 132 | '│ Apple │ 5 │ 70 │ Red │ 76 │\n' 133 | '│ Banana │ 3 │ 5 │ Yellow │ 8 │\n' 134 | '│ Cherry │ 7 │ 31 │ Red │ 92 │\n' 135 | '│ Kiwi │ 4 │ 102 │ Green │ 1 │\n' 136 | '│ Strawberry │ 6 │ 134 │ Red │ 28 │\n' 137 | '└────────────┴───────────┴───────────┴────────┴───────┘' 138 | 139 | ), 140 | "self.rows=[['Pneumonoultramicroscopicsilicovolcanoconiosis'], ['Hippopotomonstrosesquippedaliophobia'], ['Supercalifragilisticexpialidocious'], ['Pseudopseudohypoparathyroidism'], ['Floccinaucinihilipilification'], ['Antidisestablishmentarianism'], ['.']]self.labels=['My Favourite Long Words']self.centered=True": ( 141 | '┌───────────────────────────────────────────────┐\n' 142 | '│ My Favourite Long Words │\n' 143 | '├───────────────────────────────────────────────┤\n' 144 | '│ Pneumonoultramicroscopicsilicovolcanoconiosis │\n' 145 | '│ Hippopotomonstrosesquippedaliophobia │\n' 146 | '│ Supercalifragilisticexpialidocious │\n' 147 | '│ Pseudopseudohypoparathyroidism │\n' 148 | '│ Floccinaucinihilipilification │\n' 149 | '│ Antidisestablishmentarianism │\n' 150 | '│ . │\n' 151 | '└───────────────────────────────────────────────┘', 152 | '┌───────────────────────────────────────────────┐\n' 153 | '│ My Favourite Long Words │\n' 154 | '├───────────────────────────────────────────────┤\n' 155 | '│ Pneumonoultramicroscopicsilicovolcanoconiosis │\n' 156 | '│ Hippopotomonstrosesquippedaliophobia │\n' 157 | '│ Supercalifragilisticexpialidocious │\n' 158 | '│ Pseudopseudohypoparathyroidism │\n' 159 | '│ Floccinaucinihilipilification │\n' 160 | '│ Antidisestablishmentarianism │\n' 161 | '│ . │\n' 162 | '└───────────────────────────────────────────────┘' 163 | ), 164 | 165 | "self.rows=[['Pneumonoultramicroscopicsilicovolcanoconiosis'], ['Hippopotomonstrosesquippedaliophobia'], ['Supercalifragilisticexpialidocious'], ['Pseudopseudohypoparathyroidism'], ['Floccinaucinihilipilification'], ['Antidisestablishmentarianism'], ['.']]self.labels=['My Favourite Long Words']self.centered=False": 166 | '┌───────────────────────────────────────────────┐\n' 167 | '│ My Favourite Long Words │\n' 168 | '├───────────────────────────────────────────────┤\n' 169 | '│ Pneumonoultramicroscopicsilicovolcanoconiosis │\n' 170 | '│ Hippopotomonstrosesquippedaliophobia │\n' 171 | '│ Supercalifragilisticexpialidocious │\n' 172 | '│ Pseudopseudohypoparathyroidism │\n' 173 | '│ Floccinaucinihilipilification │\n' 174 | '│ Antidisestablishmentarianism │\n' 175 | '│ . │\n' 176 | '└───────────────────────────────────────────────┘', 177 | "self.rows=[['A'], ['B'], ['C'], ['D'], ['E'], ['F'], ['Pneumonoultramicroscopicsilicovolcanoconiosis']]self.labels=['Alphabet']self.centered=True":( 178 | '┌───────────────────────────────────────────────┐\n' 179 | '│ Alphabet │\n' 180 | '├───────────────────────────────────────────────┤\n' 181 | '│ A │\n' 182 | '│ B │\n' 183 | '│ C │\n' 184 | '│ D │\n' 185 | '│ E │\n' 186 | '│ F │\n' 187 | '│ Pneumonoultramicroscopicsilicovolcanoconiosis │\n' 188 | '└───────────────────────────────────────────────┘', 189 | '┌───────────────────────────────────────────────┐\n' 190 | '│ Alphabet │\n' 191 | '├───────────────────────────────────────────────┤\n' 192 | '│ A │\n' 193 | '│ B │\n' 194 | '│ C │\n' 195 | '│ D │\n' 196 | '│ E │\n' 197 | '│ F │\n' 198 | '│ Pneumonoultramicroscopicsilicovolcanoconiosis │\n' 199 | '└───────────────────────────────────────────────┘' 200 | ), 201 | "self.rows=[['A'], ['B'], ['C'], ['D'], ['E'], ['F'], ['Pneumonoultramicroscopicsilicovolcanoconiosis']]self.labels=['Alphabet']self.centered=False": 202 | '┌───────────────────────────────────────────────┐\n' 203 | '│ Alphabet │\n' 204 | '├───────────────────────────────────────────────┤\n' 205 | '│ A │\n' 206 | '│ B │\n' 207 | '│ C │\n' 208 | '│ D │\n' 209 | '│ E │\n' 210 | '│ F │\n' 211 | '│ Pneumonoultramicroscopicsilicovolcanoconiosis │\n' 212 | '└───────────────────────────────────────────────┘', 213 | "self.rows=[[None, 1, 2.5, None, 32j, '123']]self.labels=[3, None, 12, 'A', 12.6, 12j]self.centered=True": ( 214 | '┌──────┬──────┬─────┬──────┬──────┬─────┐\n' 215 | '│ 3 │ None │ 12 │ A │ 12.6 │ 12j │\n' 216 | '├──────┼──────┼─────┼──────┼──────┼─────┤\n' 217 | '│ None │ 1 │ 2.5 │ None │ 32j │ 123 │\n' 218 | '└──────┴──────┴─────┴──────┴──────┴─────┘', 219 | '┌──────┬──────┬─────┬──────┬──────┬─────┐\n' 220 | '│ 3 │ None │ 12 │ A │ 12.6 │ 12j │\n' 221 | '├──────┼──────┼─────┼──────┼──────┼─────┤\n' 222 | '│ None │ 1 │ 2.5 │ None │ 32j │ 123 │\n' 223 | '└──────┴──────┴─────┴──────┴──────┴─────┘' 224 | ), 225 | "self.rows=[[, 5, 70]]self.labels=['Fruit', 'Tastiness', 'Sweetness']self.centered=True": ( 226 | '┌───────┬───────────┬───────────┐\n' 227 | '│ Fruit │ Tastiness │ Sweetness │\n' 228 | '├───────┼───────────┼───────────┤\n' 229 | '│ Apple │ 5 │ 70 │\n' 230 | '└───────┴───────────┴───────────┘', 231 | '┌───────┬───────────┬───────────┐\n' 232 | '│ Fruit │ Tastiness │ Sweetness │\n' 233 | '├───────┼───────────┼───────────┤\n' 234 | '│ Apple │ 5 │ 70 │\n' 235 | '└───────┴───────────┴───────────┘' 236 | ), 237 | "self.rows=[[, 5, 70, 'Red'], [, 3, 5, 'Yellow'], [, 7, 31, 'Red']]self.labels=['Fruit', 'Tastiness', 'Sweetness', 'Colour']self.centered=True": ( 238 | '┌────────┬───────────┬───────────┬────────┐\n' 239 | '│ Fruit │ Tastiness │ Sweetness │ Colour │\n' 240 | '├────────┼───────────┼───────────┼────────┤\n' 241 | '│ Apple │ 5 │ 70 │ Red │\n' 242 | '│ Banana │ 3 │ 5 │ Yellow │\n' 243 | '│ Cherry │ 7 │ 31 │ Red │\n' 244 | '└────────┴───────────┴───────────┴────────┘', 245 | '┌────────┬───────────┬───────────┬────────┐\n' 246 | '│ Fruit │ Tastiness │ Sweetness │ Colour │\n' 247 | '├────────┼───────────┼───────────┼────────┤\n' 248 | '│ Apple │ 5 │ 70 │ Red │\n' 249 | '│ Banana │ 3 │ 5 │ Yellow │\n' 250 | '│ Cherry │ 7 │ 31 │ Red │\n' 251 | '└────────┴───────────┴───────────┴────────┘' 252 | ), 253 | "self.rows=[[, 5, 70, 'Red', 76], [, 3, 5, 'Yellow', 8], [, 7, 31, 'Red', 92], [, 4, 102, 'Green', 1], [, 6, 134, 'Red', 28]]self.labels=['Fruit', 'Tastiness', 'Sweetness', 'Colour', 'Smell']self.centered=True":( 254 | '┌────────────┬───────────┬───────────┬────────┬───────┐\n' 255 | '│ Fruit │ Tastiness │ Sweetness │ Colour │ Smell │\n' 256 | '├────────────┼───────────┼───────────┼────────┼───────┤\n' 257 | '│ Apple │ 5 │ 70 │ Red │ 76 │\n' 258 | '│ Banana │ 3 │ 5 │ Yellow │ 8 │\n' 259 | '│ Cherry │ 7 │ 31 │ Red │ 92 │\n' 260 | '│ Kiwi │ 4 │ 102 │ Green │ 1 │\n' 261 | '│ Strawberry │ 6 │ 134 │ Red │ 28 │\n' 262 | '└────────────┴───────────┴───────────┴────────┴───────┘', 263 | '┌────────────┬───────────┬───────────┬────────┬───────┐\n' 264 | '│ Fruit │ Tastiness │ Sweetness │ Colour │ Smell │\n' 265 | '├────────────┼───────────┼───────────┼────────┼───────┤\n' 266 | '│ Apple │ 5 │ 70 │ Red │ 76 │\n' 267 | '│ Banana │ 3 │ 5 │ Yellow │ 8 │\n' 268 | '│ Cherry │ 7 │ 31 │ Red │ 92 │\n' 269 | '│ Kiwi │ 4 │ 102 │ Green │ 1 │\n' 270 | '│ Strawberry │ 6 │ 134 │ Red │ 28 │\n' 271 | '└────────────┴───────────┴───────────┴────────┴───────┘' 272 | ), 273 | "self.rows=[['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row']]self.labels=Noneself.centered=False": 274 | '┌──────┬─────────┬─────┐\n' 275 | '│ Just │ Another │ Row │\n' 276 | '│ Just │ Another │ Row │\n' 277 | '│ Just │ Another │ Row │\n' 278 | '│ Just │ Another │ Row │\n' 279 | '│ Just │ Another │ Row │\n' 280 | '│ Just │ Another │ Row │\n' 281 | '│ Just │ Another │ Row │\n' 282 | '│ Just │ Another │ Row │\n' 283 | '│ Just │ Another │ Row │\n' 284 | '│ Just │ Another │ Row │\n' 285 | '│ Just │ Another │ Row │\n' 286 | '│ Just │ Another │ Row │\n' 287 | '│ Just │ Another │ Row │\n' 288 | '│ Just │ Another │ Row │\n' 289 | '│ Just │ Another │ Row │\n' 290 | '│ Just │ Another │ Row │\n' 291 | '│ Just │ Another │ Row │\n' 292 | '│ Just │ Another │ Row │\n' 293 | '│ Just │ Another │ Row │\n' 294 | '│ Just │ Another │ Row │\n' 295 | '│ Just │ Another │ Row │\n' 296 | '│ Just │ Another │ Row │\n' 297 | '│ Just │ Another │ Row │\n' 298 | '│ Just │ Another │ Row │\n' 299 | '│ Just │ Another │ Row │\n' 300 | '└──────┴─────────┴─────┘', 301 | "self.rows=[['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row'], ['Just', 'Another', 'Row']]self.labels=Noneself.centered=True": ( 302 | '┌──────┬─────────┬─────┐\n' 303 | '│ Just │ Another │ Row │\n' 304 | '│ Just │ Another │ Row │\n' 305 | '│ Just │ Another │ Row │\n' 306 | '│ Just │ Another │ Row │\n' 307 | '│ Just │ Another │ Row │\n' 308 | '│ Just │ Another │ Row │\n' 309 | '│ Just │ Another │ Row │\n' 310 | '│ Just │ Another │ Row │\n' 311 | '│ Just │ Another │ Row │\n' 312 | '│ Just │ Another │ Row │\n' 313 | '│ Just │ Another │ Row │\n' 314 | '│ Just │ Another │ Row │\n' 315 | '│ Just │ Another │ Row │\n' 316 | '│ Just │ Another │ Row │\n' 317 | '│ Just │ Another │ Row │\n' 318 | '│ Just │ Another │ Row │\n' 319 | '│ Just │ Another │ Row │\n' 320 | '│ Just │ Another │ Row │\n' 321 | '│ Just │ Another │ Row │\n' 322 | '│ Just │ Another │ Row │\n' 323 | '│ Just │ Another │ Row │\n' 324 | '│ Just │ Another │ Row │\n' 325 | '│ Just │ Another │ Row │\n' 326 | '│ Just │ Another │ Row │\n' 327 | '│ Just │ Another │ Row │\n' 328 | '└──────┴─────────┴─────┘', 329 | '┌──────┬─────────┬─────┐\n' 330 | '│ Just │ Another │ Row │\n' 331 | '│ Just │ Another │ Row │\n' 332 | '│ Just │ Another │ Row │\n' 333 | '│ Just │ Another │ Row │\n' 334 | '│ Just │ Another │ Row │\n' 335 | '│ Just │ Another │ Row │\n' 336 | '│ Just │ Another │ Row │\n' 337 | '│ Just │ Another │ Row │\n' 338 | '│ Just │ Another │ Row │\n' 339 | '│ Just │ Another │ Row │\n' 340 | '│ Just │ Another │ Row │\n' 341 | '│ Just │ Another │ Row │\n' 342 | '│ Just │ Another │ Row │\n' 343 | '│ Just │ Another │ Row │\n' 344 | '│ Just │ Another │ Row │\n' 345 | '│ Just │ Another │ Row │\n' 346 | '│ Just │ Another │ Row │\n' 347 | '│ Just │ Another │ Row │\n' 348 | '│ Just │ Another │ Row │\n' 349 | '│ Just │ Another │ Row │\n' 350 | '│ Just │ Another │ Row │\n' 351 | '│ Just │ Another │ Row │\n' 352 | '│ Just │ Another │ Row │\n' 353 | '│ Just │ Another │ Row │\n' 354 | '│ Just │ Another │ Row │\n' 355 | '└──────┴─────────┴─────┘', 356 | ), 357 | "self.rows=[['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column']]self.labels=Noneself.centered=False": 358 | '┌──────┬─────────┬────────┬──────┬─────────┬────────┬──────┬─────────┬────────┬──────┬─────────┬────────┐\n' 359 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 360 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 361 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 362 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 363 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 364 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 365 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 366 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 367 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 368 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 369 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 370 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 371 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 372 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 373 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 374 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 375 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 376 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 377 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 378 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 379 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 380 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 381 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 382 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 383 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 384 | '└──────┴─────────┴────────┴──────┴─────────┴────────┴──────┴─────────┴────────┴──────┴─────────┴────────┘', 385 | "self.rows=[['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column'], ['Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column', 'Just', 'Another', 'Column']]self.labels=Noneself.centered=True": ( 386 | '┌──────┬─────────┬────────┬──────┬─────────┬────────┬──────┬─────────┬────────┬──────┬─────────┬────────┐\n' 387 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 388 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 389 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 390 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 391 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 392 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 393 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 394 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 395 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 396 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 397 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 398 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 399 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 400 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 401 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 402 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 403 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 404 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 405 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 406 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 407 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 408 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 409 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 410 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 411 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 412 | '└──────┴─────────┴────────┴──────┴─────────┴────────┴──────┴─────────┴────────┴──────┴─────────┴────────┘', 413 | '┌──────┬─────────┬────────┬──────┬─────────┬────────┬──────┬─────────┬────────┬──────┬─────────┬────────┐\n' 414 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 415 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 416 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 417 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 418 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 419 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 420 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 421 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 422 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 423 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 424 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 425 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 426 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 427 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 428 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 429 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 430 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 431 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 432 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 433 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 434 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 435 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 436 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 437 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 438 | '│ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │ Just │ Another │ Column │\n' 439 | '└──────┴─────────┴────────┴──────┴─────────┴────────┴──────┴─────────┴────────┴──────┴─────────┴────────┘', 440 | ) 441 | } 442 | last_char = None # Done as class Var to ensure consistent across all test. (Unittest object recreates for each test) 443 | centering_strategy = None 444 | 445 | def run_against_solution(self, params: TableParams, fail_msg: str) -> None: 446 | """Run the user's result against the solution.""" 447 | expected = MakeTableTests.baked_solutions.get(repr(params)) 448 | temp_params = copy.deepcopy(params) # Save a temp copy to check for mutation of params 449 | result = make_table(**vars(params)) 450 | 451 | self.assertEqual(repr(temp_params), repr(params), msg="Seems like your method is mutating the arguments.") 452 | 453 | if expected is None: 454 | raise RuntimeError("Couldn't find the known good result for this test.") 455 | 456 | if MakeTableTests.last_char is None: # Allows for ending with newline return 457 | MakeTableTests.last_char = "\n" if result[-1] == "\n" else "" 458 | 459 | if params.centered: 460 | if MakeTableTests.centering_strategy is None: 461 | f_string, center = expected 462 | if f_string + MakeTableTests.last_char == result: 463 | MakeTableTests.centering_strategy = 0 464 | elif center + MakeTableTests.last_char == result: 465 | MakeTableTests.centering_strategy = 1 466 | else: 467 | raise AssertionError("Table does not meet our centering requirements.") 468 | expected = expected[MakeTableTests.centering_strategy] 469 | 470 | 471 | 472 | self.assertEqual(result, expected + MakeTableTests.last_char, msg=fail_msg) 473 | 474 | def test_001_parameters(self) -> None: 475 | make_table( 476 | rows=[ 477 | ["Apple", 5], 478 | ["Banana", 3], 479 | ["Cherry", 7], 480 | ], 481 | ), 482 | make_table( 483 | rows=[ 484 | ["Apple", 5], 485 | ["Banana", 3], 486 | ["Cherry", 7], 487 | ], 488 | labels=["Fruit", "Tastiness"], 489 | ), 490 | make_table( 491 | rows=[ 492 | ["Apple", 5], 493 | ["Banana", 3], 494 | ["Cherry", 7], 495 | ], 496 | labels=["Fruit", "Tastiness"], 497 | centered=True 498 | ) 499 | 500 | def test_002_return_type(self) -> None: 501 | table = make_table( 502 | rows=[ 503 | ["Apple", 5], 504 | ["Banana", 3], 505 | ["Cherry", 7], 506 | ], 507 | ) 508 | self.assertIsInstance(table, str, msg="The return type from your solution does not seem to be a string.") 509 | 510 | def test_003_creates_rows(self) -> None: 511 | cases = ( 512 | TableParams(rows=[ 513 | ["Apple", 5], 514 | ]), 515 | TableParams(rows=[ 516 | ["Apple", 5], 517 | ["Banana", 3], 518 | ["Cherry", 7], 519 | ]), 520 | TableParams(rows=[ 521 | ["Apple", 5], 522 | ["Banana", 3], 523 | ["Cherry", 7], 524 | ["Kiwi", 4], 525 | ["Strawberry", 6] 526 | ]) 527 | ) 528 | 529 | for case in cases: 530 | self.run_against_solution(case, fail_msg="Failed when creating multiple rows.") 531 | 532 | def test_004_creates_cols(self) -> None: 533 | cases = ( 534 | TableParams(rows=[ 535 | ["Apple", 5, 70], 536 | ]), 537 | TableParams(rows=[ 538 | ["Apple", 5, 70, "Red"], 539 | ["Banana", 3, 5, "Yellow"], 540 | ["Cherry", 7, 31, "Red"], 541 | ]), 542 | TableParams(rows=[ 543 | ["Apple", 5, 70, "Red", 76], 544 | ["Banana", 3, 5, "Yellow", 8], 545 | ["Cherry", 7, 31, "Red", 92], 546 | ["Kiwi", 4, 102, "Green", 1], 547 | ["Strawberry", 6, 134, "Red", 28] 548 | ]) 549 | ) 550 | 551 | for case in cases: 552 | self.run_against_solution(case, fail_msg="Failed when creating multiple columns.") 553 | 554 | def test_005_creates_label(self) -> None: 555 | cases = ( 556 | TableParams( 557 | rows=[ 558 | ["Apple", 5, 70] 559 | ], 560 | labels=["Fruit", "Tastiness", "Sweetness"] 561 | ), 562 | TableParams( 563 | rows=[ 564 | ["Apple", 5, 70, "Red"], 565 | ["Banana", 3, 5, "Yellow"], 566 | ["Cherry", 7, 31, "Red"], 567 | ], 568 | labels=["Fruit", "Tastiness", "Sweetness", "Colour"] 569 | ), 570 | TableParams( 571 | rows=[ 572 | ["Apple", 5, 70, "Red", 76], 573 | ["Banana", 3, 5, "Yellow", 8], 574 | ["Cherry", 7, 31, "Red", 92], 575 | ["Kiwi", 4, 102, "Green", 1], 576 | ["Strawberry", 6, 134, "Red", 28] 577 | ], 578 | labels=["Fruit", "Tastiness", "Sweetness", "Colour", "Smell"] 579 | ) 580 | ) 581 | 582 | for case in cases: 583 | self.run_against_solution(case, fail_msg="Failed when creating labels.") 584 | 585 | def test_006_align_center(self) -> None: 586 | cases = ( 587 | TableParams( 588 | rows=[ 589 | ["Apple", 5, 70] 590 | ], 591 | labels=["Fruit", "Tastiness", "Sweetness"], 592 | centered=True 593 | ), 594 | TableParams( 595 | rows=[ 596 | ["Apple", 5, 70, "Red"], 597 | ["Banana", 3, 5, "Yellow"], 598 | ["Cherry", 7, 31, "Red"], 599 | ], 600 | labels=["Fruit", "Tastiness", "Sweetness", "Colour"], 601 | centered=True 602 | ), 603 | TableParams( 604 | rows=[ 605 | ["Apple", 5, 70, "Red", 76], 606 | ["Banana", 3, 5, "Yellow", 8], 607 | ["Cherry", 7, 31, "Red", 92], 608 | ["Kiwi", 4, 102, "Green", 1], 609 | ["Strawberry", 6, 134, "Red", 28] 610 | ], 611 | labels=["Fruit", "Tastiness", "Sweetness", "Colour", "Smell"], 612 | centered=True 613 | ) 614 | ) 615 | 616 | for case in cases: 617 | self.run_against_solution(case, fail_msg="Failed when using align_center parameter.") 618 | 619 | def test_007_column_width_scaling(self) -> None: 620 | cases = ( 621 | TableParams( 622 | rows=[ 623 | ["Pneumonoultramicroscopicsilicovolcanoconiosis"], 624 | ["Hippopotomonstrosesquippedaliophobia"], 625 | ["Supercalifragilisticexpialidocious"], 626 | ["Pseudopseudohypoparathyroidism"], 627 | ["Floccinaucinihilipilification"], 628 | ["Antidisestablishmentarianism"], 629 | ["."] 630 | ], 631 | labels=["My Favourite Long Words"], 632 | centered=True 633 | ), 634 | TableParams( 635 | rows=[ 636 | ["Pneumonoultramicroscopicsilicovolcanoconiosis"], 637 | ["Hippopotomonstrosesquippedaliophobia"], 638 | ["Supercalifragilisticexpialidocious"], 639 | ["Pseudopseudohypoparathyroidism"], 640 | ["Floccinaucinihilipilification"], 641 | ["Antidisestablishmentarianism"], 642 | ["."] 643 | ], 644 | labels=["My Favourite Long Words"], 645 | centered=False 646 | ), 647 | TableParams( 648 | rows=[ 649 | ["A"], 650 | ["B"], 651 | ["C"], 652 | ["D"], 653 | ["E"], 654 | ["F"], 655 | ["Pneumonoultramicroscopicsilicovolcanoconiosis"] 656 | ], 657 | labels=["Alphabet"], 658 | centered=True 659 | ), 660 | TableParams( 661 | rows=[ 662 | ["A"], 663 | ["B"], 664 | ["C"], 665 | ["D"], 666 | ["E"], 667 | ["F"], 668 | ["Pneumonoultramicroscopicsilicovolcanoconiosis"] 669 | ], 670 | labels=["Alphabet"], 671 | centered=False 672 | ), 673 | ) 674 | 675 | for case in cases: 676 | self.run_against_solution(case, fail_msg="Columns did not seem to scale in size appropriately.") 677 | 678 | def test_008_other_item_types(self) -> None: 679 | cases = ( 680 | TableParams( 681 | rows=[ 682 | [None, 1, 2.5, None, 32j, '123'], 683 | ], 684 | labels=[3, None, 12, "A", 12.6, 12j], 685 | centered=True 686 | ), 687 | ) 688 | 689 | for case in cases: 690 | self.run_against_solution( 691 | case, 692 | fail_msg="Could not handle list of object that implement __str__() correctly." 693 | ) 694 | 695 | def test_009_custom_objects(self) -> None: 696 | class Fruit: 697 | def __init__(self, fruit: str): 698 | self.fruit = fruit 699 | 700 | def __str__(self) -> str: 701 | return self.fruit 702 | 703 | def __repr__(self) -> str: 704 | return f"" 705 | 706 | apple = Fruit("Apple") 707 | banana = Fruit("Banana") 708 | cherry = Fruit("Cherry") 709 | kiwi = Fruit("Kiwi") 710 | strawberry = Fruit("Strawberry") 711 | 712 | cases = ( 713 | TableParams( 714 | rows=[ 715 | [apple, 5, 70] 716 | ], 717 | labels=["Fruit", "Tastiness", "Sweetness"], 718 | centered=True 719 | ), 720 | TableParams( 721 | rows=[ 722 | [apple, 5, 70, "Red"], 723 | [banana, 3, 5, "Yellow"], 724 | [cherry, 7, 31, "Red"], 725 | ], 726 | labels=["Fruit", "Tastiness", "Sweetness", "Colour"], 727 | centered=True 728 | ), 729 | TableParams( 730 | rows=[ 731 | [apple, 5, 70, "Red", 76], 732 | [banana, 3, 5, "Yellow", 8], 733 | [cherry, 7, 31, "Red", 92], 734 | [kiwi, 4, 102, "Green", 1], 735 | [strawberry, 6, 134, "Red", 28] 736 | ], 737 | labels=["Fruit", "Tastiness", "Sweetness", "Colour", "Smell"], 738 | centered=True 739 | ) 740 | ) 741 | 742 | for case in cases: 743 | self.run_against_solution(case, fail_msg="Couldn't handle a class with a __str__ implementation.") 744 | 745 | def test_010_lots_of_rows(self) -> None: 746 | rows = [["Just", "Another", "Row"] for _ in range(25)] 747 | 748 | cases = ( 749 | TableParams(rows=rows), 750 | TableParams(rows=rows, centered=True) 751 | ) 752 | 753 | for case in cases: 754 | self.run_against_solution(case, fail_msg="Couldn't handle lots of rows.") 755 | 756 | def test_011_lots_of_columns(self) -> None: 757 | rows = [["Just", "Another", "Column"] * 4 for _ in range(25)] 758 | cases = ( 759 | TableParams(rows=rows), 760 | TableParams(rows=rows, centered=True) 761 | ) 762 | 763 | for case in cases: 764 | self.run_against_solution(case, fail_msg="Couldn't handle lots of cols.") 765 | -------------------------------------------------------------------------------- /qualifier/qualifier.py: -------------------------------------------------------------------------------- 1 | from typing import Any, List, Optional 2 | 3 | 4 | def make_table(rows: List[List[Any]], labels: Optional[List[Any]] = None, centered: bool = False) -> str: 5 | """ 6 | :param rows: 2D list containing objects that have a single-line representation (via `str`). 7 | All rows must be of the same length. 8 | :param labels: List containing the column labels. If present, the length must equal to that of each row. 9 | :param centered: If the items should be aligned to the center, else they are left aligned. 10 | :return: A table representing the rows passed in. 11 | """ 12 | ... 13 | -------------------------------------------------------------------------------- /qualifier/test_qualifier.py: -------------------------------------------------------------------------------- 1 | import random 2 | from typing import Any, List 3 | import unittest 4 | from dataclasses import dataclass 5 | 6 | from qualifier import make_table 7 | from solution import make_table as solution 8 | 9 | 10 | @dataclass 11 | class TableParams: 12 | rows: List[List[Any]] 13 | labels: List[Any] = None 14 | centered: bool = False 15 | 16 | 17 | class MakeTableTests(unittest.TestCase): 18 | """Basic Requirements.""" 19 | 20 | def test_001_parameters(self) -> None: 21 | make_table( 22 | rows=[ 23 | ["Apple", 5], 24 | ["Banana", 3], 25 | ["Cherry", 7], 26 | ], 27 | ), 28 | make_table( 29 | rows=[ 30 | ["Apple", 5], 31 | ["Banana", 3], 32 | ["Cherry", 7], 33 | ], 34 | labels=["Fruit", "Tastiness"], 35 | ), 36 | make_table( 37 | rows=[ 38 | ["Apple", 5], 39 | ["Banana", 3], 40 | ["Cherry", 7], 41 | ], 42 | labels=["Fruit", "Tastiness"], 43 | centered=True 44 | ) 45 | 46 | def test_002_return_type(self) -> None: 47 | table = make_table( 48 | rows=[ 49 | ["Apple", 5], 50 | ["Banana", 3], 51 | ["Cherry", 7], 52 | ], 53 | ) 54 | self.assertIsInstance(table, str) 55 | 56 | def test_003_creates_rows(self) -> None: 57 | cases = ( 58 | TableParams(rows=[ 59 | ["Apple", 5], 60 | ]), 61 | TableParams(rows=[ 62 | ["Apple", 5], 63 | ["Banana", 3], 64 | ["Cherry", 7], 65 | ]), 66 | TableParams(rows=[ 67 | ["Apple", 5], 68 | ["Banana", 3], 69 | ["Cherry", 7], 70 | ["Kiwi", 4], 71 | ["Strawberry", 6] 72 | ]) 73 | ) 74 | 75 | for case in cases: 76 | self.assertEqual(make_table(**vars(case)), solution(**vars(case))) 77 | 78 | def test_004_creates_cols(self) -> None: 79 | cases = ( 80 | TableParams(rows=[ 81 | ["Apple", 5, 70], 82 | ]), 83 | TableParams(rows=[ 84 | ["Apple", 5, 70, "Red"], 85 | ["Banana", 3, 5, "Yellow"], 86 | ["Cherry", 7, 31, "Red"], 87 | ]), 88 | TableParams(rows=[ 89 | ["Apple", 5, 70, "Red", 76], 90 | ["Banana", 3, 5, "Yellow", 8], 91 | ["Cherry", 7, 31, "Red", 92], 92 | ["Kiwi", 4, 102, "Green", 1], 93 | ["Strawberry", 6, 134, "Red", 28] 94 | ]) 95 | ) 96 | 97 | for case in cases: 98 | self.assertEqual(make_table(**vars(case)), solution(**vars(case))) 99 | 100 | def test_005_creates_label(self) -> None: 101 | cases = ( 102 | TableParams( 103 | rows=[ 104 | ["Apple", 5, 70] 105 | ], 106 | labels=["Fruit", "Tastiness", "Sweetness"] 107 | ), 108 | TableParams( 109 | rows=[ 110 | ["Apple", 5, 70, "Red"], 111 | ["Banana", 3, 5, "Yellow"], 112 | ["Cherry", 7, 31, "Red"], 113 | ], 114 | labels=["Fruit", "Tastiness", "Sweetness", "Colour"] 115 | ), 116 | TableParams( 117 | rows=[ 118 | ["Apple", 5, 70, "Red", 76], 119 | ["Banana", 3, 5, "Yellow", 8], 120 | ["Cherry", 7, 31, "Red", 92], 121 | ["Kiwi", 4, 102, "Green", 1], 122 | ["Strawberry", 6, 134, "Red", 28] 123 | ], 124 | labels=["Fruit", "Tastiness", "Sweetness", "Colour", "Smell"] 125 | ) 126 | ) 127 | 128 | for case in cases: 129 | self.assertEqual(make_table(**vars(case)), solution(**vars(case))) 130 | 131 | def test_006_align_center(self) -> None: 132 | cases = ( 133 | TableParams( 134 | rows=[ 135 | ["Apple", 5, 70] 136 | ], 137 | labels=["Fruit", "Tastiness", "Sweetness"], 138 | centered=True 139 | ), 140 | TableParams( 141 | rows=[ 142 | ["Apple", 5, 70, "Red"], 143 | ["Banana", 3, 5, "Yellow"], 144 | ["Cherry", 7, 31, "Red"], 145 | ], 146 | labels=["Fruit", "Tastiness", "Sweetness", "Colour"], 147 | centered=True 148 | ), 149 | TableParams( 150 | rows=[ 151 | ["Apple", 5, 70, "Red", 76], 152 | ["Banana", 3, 5, "Yellow", 8], 153 | ["Cherry", 7, 31, "Red", 92], 154 | ["Kiwi", 4, 102, "Green", 1], 155 | ["Strawberry", 6, 134, "Red", 28] 156 | ], 157 | labels=["Fruit", "Tastiness", "Sweetness", "Colour", "Smell"], 158 | centered=True 159 | ) 160 | ) 161 | 162 | for case in cases: 163 | self.assertEqual(make_table(**vars(case)), solution(**vars(case))) 164 | 165 | def test_007_column_width_scaling(self) -> None: 166 | cases = ( 167 | TableParams( 168 | rows=[ 169 | ["Pneumonoultramicroscopicsilicovolcanoconiosis"], 170 | ["Hippopotomonstrosesquippedaliophobia"], 171 | ["Supercalifragilisticexpialidocious"], 172 | ["Pseudopseudohypoparathyroidism"], 173 | ["Floccinaucinihilipilification"], 174 | ["Antidisestablishmentarianism"], 175 | ["."] 176 | ], 177 | labels=["My Favourite Long Words"], 178 | centered=True 179 | ), 180 | TableParams( 181 | rows=[ 182 | ["Pneumonoultramicroscopicsilicovolcanoconiosis"], 183 | ["Hippopotomonstrosesquippedaliophobia"], 184 | ["Supercalifragilisticexpialidocious"], 185 | ["Pseudopseudohypoparathyroidism"], 186 | ["Floccinaucinihilipilification"], 187 | ["Antidisestablishmentarianism"], 188 | ["."] 189 | ], 190 | labels=["My Favourite Long Words"], 191 | centered=False 192 | ), 193 | TableParams( 194 | rows=[ 195 | ["A"], 196 | ["B"], 197 | ["C"], 198 | ["D"], 199 | ["E"], 200 | ["F"], 201 | ["Pneumonoultramicroscopicsilicovolcanoconiosis"] 202 | ], 203 | labels=["Alphabet"], 204 | centered=True 205 | ), 206 | TableParams( 207 | rows=[ 208 | ["A"], 209 | ["B"], 210 | ["C"], 211 | ["D"], 212 | ["E"], 213 | ["F"], 214 | ["Pneumonoultramicroscopicsilicovolcanoconiosis"] 215 | ], 216 | labels=["Alphabet"], 217 | centered=False 218 | ), 219 | ) 220 | 221 | for case in cases: 222 | self.assertEqual(make_table(**vars(case)), solution(**vars(case))) 223 | 224 | def test_008_other_item_types(self) -> None: 225 | cases = ( 226 | TableParams( 227 | rows=[ 228 | [None, 1, 2.5, None, 32j, '123'], 229 | ], 230 | labels=[3, None, 12, "A", 12.6, 12j], 231 | centered=True 232 | ), 233 | ) 234 | 235 | for case in cases: 236 | self.assertEqual(make_table(**vars(case)), solution(**vars(case))) 237 | 238 | def test_009_custom_objects(self) -> None: 239 | class Fruit: 240 | def __init__(self, fruit: str): 241 | self.fruit = fruit 242 | 243 | def __str__(self) -> str: 244 | return self.fruit 245 | 246 | apple = Fruit("Apple") 247 | banana = Fruit("Banana") 248 | cherry = Fruit("Cherry") 249 | kiwi = Fruit("Kiwi") 250 | strawberry = Fruit("Strawberry") 251 | 252 | cases = ( 253 | TableParams( 254 | rows=[ 255 | [apple, 5, 70] 256 | ], 257 | labels=["Fruit", "Tastiness", "Sweetness"], 258 | centered=True 259 | ), 260 | TableParams( 261 | rows=[ 262 | [apple, 5, 70, "Red"], 263 | [banana, 3, 5, "Yellow"], 264 | [cherry, 7, 31, "Red"], 265 | ], 266 | labels=["Fruit", "Tastiness", "Sweetness", "Colour"], 267 | centered=True 268 | ), 269 | TableParams( 270 | rows=[ 271 | [apple, 5, 70, "Red", 76], 272 | [banana, 3, 5, "Yellow", 8], 273 | [cherry, 7, 31, "Red", 92], 274 | [kiwi, 4, 102, "Green", 1], 275 | [strawberry, 6, 134, "Red", 28] 276 | ], 277 | labels=["Fruit", "Tastiness", "Sweetness", "Colour", "Smell"], 278 | centered=True 279 | ) 280 | ) 281 | 282 | for case in cases: 283 | self.assertEqual(make_table(**vars(case)), solution(**vars(case))) 284 | 285 | def test_010_lots_of_rows(self) -> None: 286 | rows = [] 287 | for _ in range(25): 288 | temp = ["Just", "Another", "Row"] 289 | random.shuffle(temp) 290 | rows.append(temp) 291 | 292 | self.assertEqual(make_table(rows), solution(rows)) 293 | self.assertEqual(make_table(rows, centered=True), solution(rows, centered=True)) 294 | 295 | def test_011_lots_of_columns(self) -> None: 296 | rows = [] 297 | for _ in range(25): 298 | temp = ["Just", "Another", "Column"] * 4 299 | random.shuffle(temp) 300 | rows.append(temp) 301 | 302 | self.assertEqual(make_table(rows), solution(rows)) 303 | self.assertEqual(make_table(rows, centered=True), solution(rows, centered=True)) 304 | --------------------------------------------------------------------------------