mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
1.3 KiB
93 lines
1.3 KiB
5 years ago
|
## tetrisoptimizer
|
||
5 years ago
|
|
||
|
### Objectives
|
||
|
|
||
5 years ago
|
Develop a program that receives only one argument, a path to a text file which will contain a list of [tetrominoes](https://en.wikipedia.org/wiki/Tetromino) to assemble them in order to create the smallest square possible.
|
||
5 years ago
|
|
||
|
### Instructions
|
||
|
|
||
|
The program must :
|
||
|
|
||
5 years ago
|
- Be written in Go
|
||
|
- Compile successfully
|
||
|
- Assemble all of the tetrominoes in order to create the smallest square possible
|
||
5 years ago
|
- Identify each tetromino in the solution by printing them with uppercase latin letters (`A` for the first one, `B` for the second, etc)
|
||
|
- Expect at least one tetromino in the text file
|
||
5 years ago
|
- In case of bad format on the tetrominoes or bad file format it should print `ERROR`
|
||
5 years ago
|
|
||
|
#### Example of a text File
|
||
|
|
||
|
```console
|
||
|
#...
|
||
|
#...
|
||
|
#...
|
||
|
#...
|
||
|
|
||
|
....
|
||
|
....
|
||
|
..##
|
||
|
..##
|
||
|
```
|
||
|
|
||
5 years ago
|
- If it isn't possible to form a complete square, the program should leave spaces between the tetrominoes. For example:
|
||
5 years ago
|
|
||
|
```console
|
||
|
ABB.
|
||
|
ABB.
|
||
|
A...
|
||
|
A...
|
||
|
```
|
||
|
|
||
|
## Usage
|
||
|
|
||
|
```
|
||
5 years ago
|
student@ubuntu:~/tetrisoptimizer$ cat -e sample.txt
|
||
5 years ago
|
...#$
|
||
|
...#$
|
||
|
...#$
|
||
|
...#$
|
||
|
$
|
||
|
....$
|
||
|
....$
|
||
|
....$
|
||
|
####$
|
||
|
$
|
||
|
.###$
|
||
|
...#$
|
||
|
....$
|
||
|
....$
|
||
|
$
|
||
|
....$
|
||
|
..##$
|
||
|
.##.$
|
||
|
....$
|
||
|
$
|
||
|
....$
|
||
|
.##.$
|
||
|
.##.$
|
||
|
....$
|
||
|
$
|
||
|
....$
|
||
|
....$
|
||
|
##..$
|
||
|
.##.$
|
||
|
$
|
||
|
##..$
|
||
|
.#..$
|
||
|
.#..$
|
||
|
....$
|
||
|
$
|
||
|
....$
|
||
|
###.$
|
||
|
.#..$
|
||
|
....$
|
||
5 years ago
|
student@ubuntu:~/tetrisoptimizer$ ./tetrisoptimizer sample.txt | cat -e
|
||
5 years ago
|
ABBBB.$
|
||
|
ACCCEE$
|
||
|
AFFCEE$
|
||
|
A.FFGG$
|
||
|
HHHDDG$
|
||
|
.HDD.G$
|
||
5 years ago
|
student@ubuntu:~/tetrisoptimizer$
|
||
5 years ago
|
```
|