pengantar
Dalam tantangan ini, matriks 2 × 2 diindeks seperti ini:
0 1
2 3
Kami mendefinisikan keluarga fraktal seperti pola F(L)
, di mana L
merupakan panjang- n
daftar indeks ini dan F(L)
memiliki ukuran .2n-1 × 2n-1
- Jika
L == []
, makaF(L)
adalah pola 1 × 1#
. Jika
L != []
, makaF(L)
dibangun sebagai berikut. MembiarkanP
menjadi pola yang diperoleh dariL
dengan elemen pertama dihapus. Ambil empat kisi ukuran diisi dengan titik , dan ganti kisi diindeks dengan pola . Kemudian, rekatkan kisi-kisi menggunakan satu lapisan hash di antara mereka. Berikut adalah diagram untuk empat kasus:2n-1-1 × 2n-1-1
.
L[0]
P
#
L[0]==0 L[0]==1 L[0]==2 L[0]==3 #... ...# ...#... ...#... [P]#... ...#[P] ...#... ...#... #... ...# ...#... ...#... ####### ####### ####### ####### ...#... ...#... #... ...# ...#... ...#... [P]#... ...#[P] ...#... ...#... #... ...#
Contoh
Pertimbangkan inputnya L = [2,0]
. Kita mulai dengan kisi 1 × 1 #
, dan melintasi L
dari kanan. Elemen paling kanan adalah 0
, jadi kami mengambil empat salinan dari grid 1 × 1 .
, ganti yang pertama dengan #
, dan rekatkan bersama-sama dengan hash. Ini menghasilkan kisi 3 × 3
##.
###
.#.
Elemen berikutnya adalah 2
, jadi kami mengambil empat salinan dari kisi 3 × 3 .
, dan mengganti yang ketiga dengan kisi di atas. Keempat kisi tersebut adalah
... ... ##. ...
... ... ### ...
... ... .#. ...
dan menempelkannya bersama dengan #
hasil di kisi 7 × 7
...#...
...#...
...#...
#######
##.#...
####...
.#.#...
Ini adalah hasil akhir kami.
Memasukkan
Input Anda adalah daftar L
indeks 0, 1, 2, 3
. Anda dapat menganggapnya sebagai daftar bilangan bulat, atau serangkaian angka. Perhatikan bahwa mungkin kosong, dan mungkin berisi duplikat. Panjangnya L
paling banyak 5.
Keluaran
Output Anda adalah pola F(L)
sebagai string yang dibatasi-baris baru.
Aturan dan penilaian
Anda dapat menulis program atau fungsi lengkap. jumlah byte terendah menang, dan celah standar tidak diizinkan.
Uji kasus
[]
#
[0]
##.
###
.#.
[3]
.#.
###
.##
[2,0]
...#...
...#...
...#...
#######
##.#...
####...
.#.#...
[1,1]
...#.##
...####
...#.#.
#######
...#...
...#...
...#...
[1,2,0]
.......#...#...
.......#...#...
.......#...#...
.......########
.......###.#...
.......#####...
.......#.#.#...
###############
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
[3,3,1]
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
###############
.......#...#...
.......#...#...
.......#...#...
.......########
.......#...#.##
.......#...####
.......#...#.#.
[0,1,2,3]
.......#...#...#...............
.......#...#...#...............
.......#...#...#...............
.......#########...............
.......#.#.#...#...............
.......#####...#...............
.......#.###...#...............
################...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
###############################
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
[0,0,1,2,3]
.......#...#...#...............#...............................
.......#...#...#...............#...............................
.......#...#...#...............#...............................
.......#########...............#...............................
.......#.#.#...#...............#...............................
.......#####...#...............#...............................
.......#.###...#...............#...............................
################...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
################################...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
###############################################################
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
L = [2,0]
, Anda memenggal kepala dan melihat pola F([0])
, lalu memenggal kepala [0]
dan melihat pola F([])
, yaitu kisi 1x1 #
. Kemudian Anda menggunakan indeks yang dipotong 0
untuk membangun pola 3x3, dan menggunakan indeks yang dipotong 2
untuk yang membangun pola 7x7. Untuk menjawab pertanyaan Anda: ya, Anda selalu mulai dengan kisi 1x1 karena itulah dasar dari rekursi.
#
?L !=[]
dalam contoh itu, karena memiliki 1 atau lebih elemen. Apakah ini berarti bahwa F (L) selalu a#
pada awalnya?