mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2024-12-08 00:45:29 +01:00
feat(challenges): add ascii-art
This commit is contained in:
parent
173c32d6f2
commit
19d3d407ca
@ -14,6 +14,6 @@ insert_final_newline = true
|
|||||||
indent_size = 4
|
indent_size = 4
|
||||||
|
|
||||||
[*.txt]
|
[*.txt]
|
||||||
indent_size = 1
|
indent_size = unset
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = unset
|
||||||
insert_final_newline = false
|
insert_final_newline = unset
|
||||||
|
56
challenges/ascii-art/README.md
Normal file
56
challenges/ascii-art/README.md
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
# ascii-art
|
||||||
|
|
||||||
|
Created by [@Divlo](https://github.com/Divlo) on 1 May 2022.
|
||||||
|
|
||||||
|
## Instructions
|
||||||
|
|
||||||
|
### Goal
|
||||||
|
|
||||||
|
In stations and airports you often see this type of screen:
|
||||||
|
|
||||||
|
![Led Display](./led_display.jpg)
|
||||||
|
|
||||||
|
Have you ever asked yourself how it might be possible to simulate this display on a good old terminal? We have: with ASCII art!
|
||||||
|
|
||||||
|
### Rules
|
||||||
|
|
||||||
|
ASCII art allows you to represent forms by using characters. To be precise, in our case, these forms are words. For example, the word "MANHATTAN" could be displayed as follows in ASCII art:
|
||||||
|
|
||||||
|
```txt
|
||||||
|
# # # ### # # # ### ### # ###
|
||||||
|
### # # # # # # # # # # # # # #
|
||||||
|
### ### # # ### ### # # ### # #
|
||||||
|
# # # # # # # # # # # # # # # #
|
||||||
|
# # # # # # # # # # # # # # # #
|
||||||
|
```
|
||||||
|
|
||||||
|
Your mission is to write a program that can display a line of text in ASCII art in a style you are given as input.
|
||||||
|
|
||||||
|
### Input
|
||||||
|
|
||||||
|
- **Line 1:** The width `W` of a letter represented in ASCII art. All letters are the same width.
|
||||||
|
- **Line 2:** The height `H` of a letter represented in ASCII art. All letters are the same height.
|
||||||
|
- **Line 3:** The line of text `T`, composed of `N` ASCII characters.
|
||||||
|
- **Following lines:** the string of characters `ABCDEFGHIJKLMNOPQRSTUVWXYZ?` Represented in ASCII art.
|
||||||
|
|
||||||
|
### Output
|
||||||
|
|
||||||
|
The text `T` in ASCII art.
|
||||||
|
|
||||||
|
The characters a to z are shown in ASCII art by their equivalent in upper case.
|
||||||
|
|
||||||
|
The characters that are not in the intervals `[a-z]` or `[A-Z]` will be shown as a question mark in ASCII art.
|
||||||
|
|
||||||
|
### Constraints
|
||||||
|
|
||||||
|
- 0 < W < 30
|
||||||
|
- 0 < H < 30
|
||||||
|
- 0 < N < 200
|
||||||
|
|
||||||
|
## Source
|
||||||
|
|
||||||
|
- [CodinGame](https://www.codingame.com/training/easy/ascii-art)
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
See the `test` folder for examples of input/output.
|
BIN
challenges/ascii-art/led_display.jpg
Normal file
BIN
challenges/ascii-art/led_display.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
0
challenges/ascii-art/solutions/.gitkeep
Normal file
0
challenges/ascii-art/solutions/.gitkeep
Normal file
8
challenges/ascii-art/test/1/input.txt
Normal file
8
challenges/ascii-art/test/1/input.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
4
|
||||||
|
5
|
||||||
|
E
|
||||||
|
# ## ## ## ### ### ## # # ### ## # # # # # ### # ## # ## ## ### # # # # # # # # # # ### ###
|
||||||
|
# # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
### ## # # # ## ## # # ### # # ## # ### # # # # ## # # ## # # # # # # ### # # # ##
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ### # # # #
|
||||||
|
# # ## ## ## ### # ## # # ### # # # ### # # # # # # # # # ## # ### # # # # # # ### #
|
5
challenges/ascii-art/test/1/output.txt
Normal file
5
challenges/ascii-art/test/1/output.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
###
|
||||||
|
#
|
||||||
|
##
|
||||||
|
#
|
||||||
|
###
|
8
challenges/ascii-art/test/2/input.txt
Normal file
8
challenges/ascii-art/test/2/input.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
4
|
||||||
|
5
|
||||||
|
MANHATTAN
|
||||||
|
# ## ## ## ### ### ## # # ### ## # # # # # ### # ## # ## ## ### # # # # # # # # # # ### ###
|
||||||
|
# # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
### ## # # # ## ## # # ### # # ## # ### # # # # ## # # ## # # # # # # ### # # # ##
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ### # # # #
|
||||||
|
# # ## ## ## ### # ## # # ### # # # ### # # # # # # # # # ## # ### # # # # # # ### #
|
5
challenges/ascii-art/test/2/output.txt
Normal file
5
challenges/ascii-art/test/2/output.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# # # ### # # # ### ### # ###
|
||||||
|
### # # # # # # # # # # # # # #
|
||||||
|
### ### # # ### ### # # ### # #
|
||||||
|
# # # # # # # # # # # # # # # #
|
||||||
|
# # # # # # # # # # # # # # # #
|
8
challenges/ascii-art/test/3/input.txt
Normal file
8
challenges/ascii-art/test/3/input.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
4
|
||||||
|
5
|
||||||
|
ManhAtTan
|
||||||
|
# ## ## ## ### ### ## # # ### ## # # # # # ### # ## # ## ## ### # # # # # # # # # # ### ###
|
||||||
|
# # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
### ## # # # ## ## # # ### # # ## # ### # # # # ## # # ## # # # # # # ### # # # ##
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ### # # # #
|
||||||
|
# # ## ## ## ### # ## # # ### # # # ### # # # # # # # # # ## # ### # # # # # # ### #
|
5
challenges/ascii-art/test/3/output.txt
Normal file
5
challenges/ascii-art/test/3/output.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# # # ### # # # ### ### # ###
|
||||||
|
### # # # # # # # # # # # # # #
|
||||||
|
### ### # # ### ### # # ### # #
|
||||||
|
# # # # # # # # # # # # # # # #
|
||||||
|
# # # # # # # # # # # # # # # #
|
8
challenges/ascii-art/test/4/input.txt
Normal file
8
challenges/ascii-art/test/4/input.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
4
|
||||||
|
5
|
||||||
|
M@NH@TT@N
|
||||||
|
# ## ## ## ### ### ## # # ### ## # # # # # ### # ## # ## ## ### # # # # # # # # # # ### ###
|
||||||
|
# # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
### ## # # # ## ## # # ### # # ## # ### # # # # ## # # ## # # # # # # ### # # # ##
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ### # # # #
|
||||||
|
# # ## ## ## ### # ## # # ### # # # ### # # # # # # # # # ## # ### # # # # # # ### #
|
5
challenges/ascii-art/test/4/output.txt
Normal file
5
challenges/ascii-art/test/4/output.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# # ### ### # # ### ### ### ### ###
|
||||||
|
### # # # # # # # # # # #
|
||||||
|
### ## # # ### ## # # ## # #
|
||||||
|
# # # # # # # # # #
|
||||||
|
# # # # # # # # # # # # #
|
14
challenges/ascii-art/test/5/input.txt
Normal file
14
challenges/ascii-art/test/5/input.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
21
|
||||||
|
11
|
||||||
|
MANHATTAN
|
||||||
|
.----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .-----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------.
|
||||||
|
| .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. |
|
||||||
|
| | __ | | | | ______ | | | | ______ | | | | ________ | | | | _________ | | | | _________ | | | | ______ | | | | ____ ____ | | | | _____ | | | | _____ | | | | ___ ____ | | | | _____ | | | | ____ ____ | | | | ____ _____ | | | | ____ | | | | ______ | | | | ___ | | | | _______ | | | | _______ | | | | _________ | | | | _____ _____ | | | | ____ ____ | | | | _____ _____ | | | | ____ ____ | | | | ____ ____ | | | | ________ | | | | ______ | |
|
||||||
|
| | / \ | | | | |_ _ \ | | | | .' ___ | | | | | |_ ___ `. | | | | |_ ___ | | | | | |_ ___ | | | | | .' ___ | | | | | |_ || _| | | | | |_ _| | | | | |_ _| | | | | |_ ||_ _| | | | | |_ _| | | | ||_ \ / _|| | | ||_ \|_ _| | | | | .' `. | | | | |_ __ \ | | | | .' '. | | | | |_ __ \ | | | | / ___ | | | | | | _ _ | | | | ||_ _||_ _|| | | ||_ _| |_ _| | | | ||_ _||_ _|| | | | |_ _||_ _| | | | | |_ _||_ _| | | | | | __ _| | | | | / _ __ `. | |
|
||||||
|
| | / /\ \ | | | | | |_) | | | | | / .' \_| | | | | | | `. \ | | | | | |_ \_| | | | | | |_ \_| | | | | / .' \_| | | | | | |__| | | | | | | | | | | | | | | | | | | |_/ / | | | | | | | | | | | \/ | | | | | | \ | | | | | | / .--. \ | | | | | |__) | | | | | / .-. \ | | | | | |__) | | | | | | (__ \_| | | | | |_/ | | \_| | | | | | | | | | | | | \ \ / / | | | | | | /\ | | | | | | \ \ / / | | | | \ \ / / | | | | |_/ / / | | | | |_/____) | | |
|
||||||
|
| | / ____ \ | | | | | __'. | | | | | | | | | | | | | | | | | | | _| _ | | | | | _| | | | | | | ____ | | | | | __ | | | | | | | | | | | _ | | | | | | | __'. | | | | | | _ | | | | | |\ /| | | | | | | |\ \| | | | | | | | | | | | | | | ___/ | | | | | | | | | | | | | __ / | | | | '.___`-. | | | | | | | | | | | ' ' | | | | | \ \ / / | | | | | |/ \| | | | | | > `' < | | | | \ \/ / | | | | .'.' _ | | | | / ___.' | |
|
||||||
|
| | _/ / \ \_ | | | | _| |__) | | | | | \ `.___.'\ | | | | _| |___.' / | | | | _| |___/ | | | | | _| |_ | | | | \ `.___] _| | | | | _| | | |_ | | | | _| |_ | | | | | |_' | | | | | _| | \ \_ | | | | _| |__/ | | | | | _| |_\/_| |_ | | | | _| |_\ |_ | | | | \ `--' / | | | | _| |_ | | | | \ `-' \_ | | | | _| | \ \_ | | | | |`\____) | | | | | _| |_ | | | | \ `--' / | | | | \ ' / | | | | | /\ | | | | | _/ /'`\ \_ | | | | _| |_ | | | | _/ /__/ | | | | | |_| | |
|
||||||
|
| ||____| |____|| | | | |_______/ | | | | `._____.' | | | | |________.' | | | | |_________| | | | | |_____| | | | | `._____.' | | | | |____||____| | | | | |_____| | | | | `.___.' | | | | |____||____| | | | | |________| | | | ||_____||_____|| | | ||_____|\____| | | | | `.____.' | | | | |_____| | | | | `.___.\__| | | | | |____| |___| | | | | |_______.' | | | | |_____| | | | | `.__.' | | | | \_/ | | | | |__/ \__| | | | | |____||____| | | | | |______| | | | | |________| | | | | (_) | |
|
||||||
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||||
|
| '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' |
|
||||||
|
'----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------'
|
11
challenges/ascii-art/test/5/output.txt
Normal file
11
challenges/ascii-art/test/5/output.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
.----------------. .----------------. .-----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .-----------------.
|
||||||
|
| .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. | | .--------------. |
|
||||||
|
| | ____ ____ | | | | __ | | | | ____ _____ | | | | ____ ____ | | | | __ | | | | _________ | | | | _________ | | | | __ | | | | ____ _____ | |
|
||||||
|
| ||_ \ / _|| | | | / \ | | | ||_ \|_ _| | | | | |_ || _| | | | | / \ | | | | | _ _ | | | | | | _ _ | | | | | / \ | | | ||_ \|_ _| | |
|
||||||
|
| | | \/ | | | | | / /\ \ | | | | | \ | | | | | | | |__| | | | | | / /\ \ | | | | |_/ | | \_| | | | | |_/ | | \_| | | | | / /\ \ | | | | | \ | | | |
|
||||||
|
| | | |\ /| | | | | | / ____ \ | | | | | |\ \| | | | | | | __ | | | | | / ____ \ | | | | | | | | | | | | | | | | / ____ \ | | | | | |\ \| | | |
|
||||||
|
| | _| |_\/_| |_ | | | | _/ / \ \_ | | | | _| |_\ |_ | | | | _| | | |_ | | | | _/ / \ \_ | | | | _| |_ | | | | _| |_ | | | | _/ / \ \_ | | | | _| |_\ |_ | |
|
||||||
|
| ||_____||_____|| | | ||____| |____|| | | ||_____|\____| | | | | |____||____| | | | ||____| |____|| | | | |_____| | | | | |_____| | | | ||____| |____|| | | ||_____|\____| | |
|
||||||
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||||
|
| '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' | | '--------------' |
|
||||||
|
'----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------'
|
8
challenges/ascii-art/test/6/input.txt
Normal file
8
challenges/ascii-art/test/6/input.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
4
|
||||||
|
5
|
||||||
|
MAN HAT TAN
|
||||||
|
# ## ## ## ### ### ## # # ### ## # # # # # ### # ## # ## ## ### # # # # # # # # # # ### ###
|
||||||
|
# # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
### ## # # # ## ## # # ### # # ## # ### # # # # ## # # ## # # # # # # ### # # # ##
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ### # # # #
|
||||||
|
# # ## ## ## ### # ## # # ### # # # ### # # # # # # # # # ## # ### # # # # # # ### #
|
5
challenges/ascii-art/test/6/output.txt
Normal file
5
challenges/ascii-art/test/6/output.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# # # ### ### # # # ### ### ### # ###
|
||||||
|
### # # # # # # # # # # # # # # # #
|
||||||
|
### ### # # ## ### ### # ## # ### # #
|
||||||
|
# # # # # # # # # # # # # # # #
|
||||||
|
# # # # # # # # # # # # # # # # # #
|
@ -52,7 +52,7 @@ The name of the defibrillator located the closest to the user’s position.
|
|||||||
|
|
||||||
## Source
|
## Source
|
||||||
|
|
||||||
- [CodinGame](https://www.codingame.com/ide/puzzle/defibrillators)
|
- [CodinGame](https://www.codingame.com/training/easy/defibrillators)
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user