Saya tidak suka mengetik, jadi saya menggambar labirin dalam format yang sangat sederhana:
# #####
# #
# ### #
# # # #
# # #
##### #
Bukankah ini membingungkan ? Tentu saja, saya pikir semua labirin harus terlihat 3d, serupa tetapi tidak sama dengan tantangan ini , untuk labirin maksimum, jadi saya (enggan) secara manual memperbarui labirin agar terlihat seperti ini:
+-----+ +-----------------------------+
|\ \ |\ \
+ \ \ + \ \
\ \ \ \ +-----------------------+ \
\ \ \ \| |\ \
\ \ \ +-----------------------+ \ \
\ \ \ +-----------------+ \ \ \
\ \ \ |\ \ \ \ \
\ \ \ + \ \ \ \ \
\ \ \ \ \ +-----+ \ \ \ \
\ \ \ \ \ \ |\ \ \ \ \
\ \ \ \ \ \---+ \ \ \ \ \
\ \ \ \ +-----+ \ \ \ \ \ \
\ \ \ \| | \ \ \ \ \ \
\ \ \ +-----+ \ \ \ \ \ \
\ \ +-----------------+ \ \ \ \
\ \ \ \ \ \
\ \ \ \ \ \
\ +-----------------------------+ \ +-----+
\| | \| |
+-----------------------------+ +-----+
Sayangnya, sulit untuk bekerja dengan labirin dalam format itu, dan setelah semua itu mengetik manual, saya tidak ingin hanya mengetik ulang yang asli, jadi saya ingin Anda menulis sebuah program untuk melakukan pembalikan untuk saya.
Aturan
- Masukan akan menjadi string atau karakter matriks multiline hanya terdiri dari
" "
,"|"
,"\"
,"+"
,"-"
, dan baris baru. - Output terdiri dari
" "
dan"#"
, dalam pola yang dijelaskan oleh labirin. - Karena keterampilan merancang labirin yang luar biasa, Anda tidak dapat menganggap apa pun tentang struktur labirin, selain itu memiliki dekonstruksi yang valid.
- Dalam 3d-ification, (proses yang sekarang harus Anda batalkan,) masing
#
- masing dikonversi ke blok karakter 3x4x7 ini:+-----+ |\ \ + \ \ \ +-----+ \| | +-----+
- Blok yang berdekatan digabungkan bersama, seperti ini:
tetapi tanpa bergabung dengan garis, jadi itu benar-benar terlihat seperti ini:+-----+-----+ |\ \ \ + \ \ \ \ +-----+-----+ \|\ \ \ + \ \ \ \ +-----+-----+ \| | | +-----+-----+
+-----------+ |\ \ + \ \ \ \ \ \ \ \ \ \ \ \ +-----------+ \| | +-----------+
- Ruang cekung terkadang menghalangi bagian dinding lainnya.
+-----------+ |\ \ + \ \ \ \ +-----+ \ \ \ | \ \ \---+ \ +-----+ \| | +-----+
- Membuntuti spasi putih di input atau output dapat diterima. (Anda harus menentukan apakah jawaban Anda memerlukan spasi kosong di input.)
- Spasi terkemuka harus sesuai dengan spasi kosong di input.
- Saya masih tidak suka mengetik, jadi kode terpendek menang
Kasus uji:
Input:
+-----+ +-----------------------------+
|\ \ |\ \
+ \ \ + \ \
\ \ \ \ +-----------------------+ \
\ \ \ \| |\ \
\ \ \ +-----------------------+ \ \
\ \ \ +-----------------+ \ \ \
\ \ \ |\ \ \ \ \
\ \ \ + \ \ \ \ \
\ \ \ \ \ +-----+ \ \ \ \
\ \ \ \ \ \ |\ \ \ \ \
\ \ \ \ \ \---+ \ \ \ \ \
\ \ \ \ +-----+ \ \ \ \ \ \
\ \ \ \| | \ \ \ \ \ \
\ \ \ +-----+ \ \ \ \ \ \
\ \ +-----------------+ \ \ \ \
\ \ \ \ \ \
\ \ \ \ \ \
\ +-----------------------------+ \ +-----+
\| | \| |
+-----------------------------+ +-----+
Output:
# #####
# #
# ### #
# # # #
# # #
##### #
Input:
+-----+
|\ \
+ \ \
\ +-----+
\| |
+-----+
Output:
#
Input:
+-----------------+
|\ \
+ \ \
+-----+ +-----+ +-----+
|\ \ |\ \
+ \ \---+ \ \
\ \ +-----+ \ +-----+ \
\ \ \ | \| |\ \
\ \ \---+ +-----+ \ \
\ \ +-----+ +-----+ \
\ \ \ |\ \
\ \ \ + \ \
\ +-----+ +-----+ +-----+
\| |\ \ |
+-----+ \ \---+
\ +-----------------+
\| |
+-----------------+
Output:
###
## ##
# #
## ##
###
Input:
+-----------------------------------------------------------------------------------------------------+
|\ \
+ \ \
\ +-----------------------------------------------+ +-----------------------------------------+ \
\| |\ \ |\ \
+-----------------------------------------------+ \ \---------------------------------------+ \ \
+-----+ +-----------------------------+ \ \ \ +-----------------------------+ \ \ \
|\ \ |\ \ \ \ \ |\ \ \ \ \
+ \ \ + \ \ \ \ \ + \ \ \ \ \
\ \ \ \ +-----------+ +-----+ \ \ \ \ \ +-----------------------+ \ \ \ \
\ \ \ \| |\ \ |\ \ \ \ \ \| |\ \ \ \ \
\ \ \ +-----------+ \ \---+ \ \ \ \ \ +-----------------------+ \ \ \ \ \
\ \ \ +-----+ \ \ \ \ \ \ \ \ +-----------------------+ \ \ \ \ \ \
\ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ \ \ + \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ \ \ \ +-----+ \ \ \ \ \ \ \ +-----------------------------+ \ \ \ \ \ \
\ \ \ \| | \ \ \ \ \ \ \| | \ \ \ \ \ \
\ \ \ +-----+ \ \ \ \ \ \ +-----------------------------+ \ \ \ \ \ \
\ \ +-----------+ \ \ \ \ \ +-----------------------------------+ \ \ \ \ \ \
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ \ +-----------+ \ \ \ \ \ +-----------------------+ +-----+ \ \ \ \ \ \
\ \ \ | \ \ \ \ \ \ |\ \ | \ \ \ \ \ \
\ \ \---------+ \ \ \ \ \ \---------------------+ \ \---+ \ \ \ \ \ \
\ \ \ +-----------+ \ \ \ \ +-----------+ \ \ \ +-----+ \ \ +-----+
\ \ \ |\ \ \ \ \ |\ \ \ \ \ |\ \ \| |
\ \ \ + \ \ \ \ \ + \ \ \ \ \ + \ \ +-----+
\ \ \ \ +-----------------+ \ \ \ \ \ \ \ +-----+ \ +-----+ \
\ \ \ \| | \ \ \ \ \ \ \| | \| |\ \
\ \ \ +-----------------+ \ \ \ \ \ \ +-----+ +-----+ \ \
\ \ +-----------------------------+ +-----+ +-----------------------+ +-----------+
\ \ \
\ \ \
\ +-----------------------------------------------------------------------------------------------------+
\| |
+-----------------------------------------------------------------------------------------------------+
Output:
#################
# #
# ##### # ##### #
# # # # # #
# # # # ##### # #
# # # # #
### # ####### # #
# # # # # #
# ### # ## # ##
# # ## #
#################
Input:
+-----------------+
|\ \
+ \ \
\ \ \
\ \ \
\ \ \
\ \ \
\ \ \
\ \ \
\ +-----------------+
\| |
+-----------------+
Output:
###
###
###
Input: (Note leading whitespace)
+-----+ +-----+
|\ \ |\ \
+ \ \ + \ \
+-----+-----+-----+-----+
|\ \ |\ \ |
+ \ \---+ \ \---+
\ +-----+-----+-----+-----+
\| |\ \ |\ \
+-----+ \ \---+ \ \
+-----+-----+-----+-----+
|\ \ |\ \ |
+ \ \---+ \ \---+
\ +-----+ \ +-----+
\| | \| |
+-----+ +-----+
Output:
# #
# #
# #
# #