Bir Balıksırtı Deseni Çiz


22

Genişlik ve yükseklik olarak iki pozitif tam sayı alan ve bu 25 x 26 metin ızgarasını temel hücre olarak kullanan bir ASCII sanat balıksırtı ızgara deseni çizen bir program veya işlev yazın :

.......#.....#####.......
.......##.....#####......
.......###.....#####.....
.......####.....####.....
.......#####.....###.....
.......######.....##.....
.......#######.....#.....
.......########..........
####################.....
.####################....
..####################...
...####################..
....####################.
.....####################
#.....##############.####
##.....#############..###
###....#############...##
####...#############....#
#####..#############.....
.#####.#############.....
..##################.....
........#####............
.........#####...........
..........#####..........
...........#####.........
............#####........

Yani girdi 2,1olsaydı çıktı şöyle olurdu:

.......#.....#####..............#.....#####.......
.......##.....#####.............##.....#####......
.......###.....#####............###.....#####.....
.......####.....####............####.....####.....
.......#####.....###............#####.....###.....
.......######.....##............######.....##.....
.......#######.....#............#######.....#.....
.......########.................########..........
####################.....####################.....
.####################.....####################....
..####################.....####################...
...####################.....####################..
....####################.....####################.
.....####################.....####################
#.....##############.#####.....##############.####
##.....#############..#####.....#############..###
###....#############...#####....#############...##
####...#############....#####...#############....#
#####..#############.....#####..#############.....
.#####.#############......#####.#############.....
..##################.......##################.....
........#####....................#####............
.........#####....................#####...........
..........#####....................#####..........
...........#####....................#####.........
............#####....................#####........

Girdi 5,4olsaydı çıktı şöyle olurdu:

.......#.....#####..............#.....#####..............#.....#####..............#.....#####..............#.....#####.......
.......##.....#####.............##.....#####.............##.....#####.............##.....#####.............##.....#####......
.......###.....#####............###.....#####............###.....#####............###.....#####............###.....#####.....
.......####.....####............####.....####............####.....####............####.....####............####.....####.....
.......#####.....###............#####.....###............#####.....###............#####.....###............#####.....###.....
.......######.....##............######.....##............######.....##............######.....##............######.....##.....
.......#######.....#............#######.....#............#######.....#............#######.....#............#######.....#.....
.......########.................########.................########.................########.................########..........
####################.....####################.....####################.....####################.....####################.....
.####################.....####################.....####################.....####################.....####################....
..####################.....####################.....####################.....####################.....####################...
...####################.....####################.....####################.....####################.....####################..
....####################.....####################.....####################.....####################.....####################.
.....####################.....####################.....####################.....####################.....####################
#.....##############.#####.....##############.#####.....##############.#####.....##############.#####.....##############.####
##.....#############..#####.....#############..#####.....#############..#####.....#############..#####.....#############..###
###....#############...#####....#############...#####....#############...#####....#############...#####....#############...##
####...#############....#####...#############....#####...#############....#####...#############....#####...#############....#
#####..#############.....#####..#############.....#####..#############.....#####..#############.....#####..#############.....
.#####.#############......#####.#############......#####.#############......#####.#############......#####.#############.....
..##################.......##################.......##################.......##################.......##################.....
........#####....................#####....................#####....................#####....................#####............
.........#####....................#####....................#####....................#####....................#####...........
..........#####....................#####....................#####....................#####....................#####..........
...........#####....................#####....................#####....................#####....................#####.........
............#####....................#####....................#####....................#####....................#####........
.......#.....#####..............#.....#####..............#.....#####..............#.....#####..............#.....#####.......
.......##.....#####.............##.....#####.............##.....#####.............##.....#####.............##.....#####......
.......###.....#####............###.....#####............###.....#####............###.....#####............###.....#####.....
.......####.....####............####.....####............####.....####............####.....####............####.....####.....
.......#####.....###............#####.....###............#####.....###............#####.....###............#####.....###.....
.......######.....##............######.....##............######.....##............######.....##............######.....##.....
.......#######.....#............#######.....#............#######.....#............#######.....#............#######.....#.....
.......########.................########.................########.................########.................########..........
####################.....####################.....####################.....####################.....####################.....
.####################.....####################.....####################.....####################.....####################....
..####################.....####################.....####################.....####################.....####################...
...####################.....####################.....####################.....####################.....####################..
....####################.....####################.....####################.....####################.....####################.
.....####################.....####################.....####################.....####################.....####################
#.....##############.#####.....##############.#####.....##############.#####.....##############.#####.....##############.####
##.....#############..#####.....#############..#####.....#############..#####.....#############..#####.....#############..###
###....#############...#####....#############...#####....#############...#####....#############...#####....#############...##
####...#############....#####...#############....#####...#############....#####...#############....#####...#############....#
#####..#############.....#####..#############.....#####..#############.....#####..#############.....#####..#############.....
.#####.#############......#####.#############......#####.#############......#####.#############......#####.#############.....
..##################.......##################.......##################.......##################.......##################.....
........#####....................#####....................#####....................#####....................#####............
.........#####....................#####....................#####....................#####....................#####...........
..........#####....................#####....................#####....................#####....................#####..........
...........#####....................#####....................#####....................#####....................#####.........
............#####....................#####....................#####....................#####....................#####........
.......#.....#####..............#.....#####..............#.....#####..............#.....#####..............#.....#####.......
.......##.....#####.............##.....#####.............##.....#####.............##.....#####.............##.....#####......
.......###.....#####............###.....#####............###.....#####............###.....#####............###.....#####.....
.......####.....####............####.....####............####.....####............####.....####............####.....####.....
.......#####.....###............#####.....###............#####.....###............#####.....###............#####.....###.....
.......######.....##............######.....##............######.....##............######.....##............######.....##.....
.......#######.....#............#######.....#............#######.....#............#######.....#............#######.....#.....
.......########.................########.................########.................########.................########..........
####################.....####################.....####################.....####################.....####################.....
.####################.....####################.....####################.....####################.....####################....
..####################.....####################.....####################.....####################.....####################...
...####################.....####################.....####################.....####################.....####################..
....####################.....####################.....####################.....####################.....####################.
.....####################.....####################.....####################.....####################.....####################
#.....##############.#####.....##############.#####.....##############.#####.....##############.#####.....##############.####
##.....#############..#####.....#############..#####.....#############..#####.....#############..#####.....#############..###
###....#############...#####....#############...#####....#############...#####....#############...#####....#############...##
####...#############....#####...#############....#####...#############....#####...#############....#####...#############....#
#####..#############.....#####..#############.....#####..#############.....#####..#############.....#####..#############.....
.#####.#############......#####.#############......#####.#############......#####.#############......#####.#############.....
..##################.......##################.......##################.......##################.......##################.....
........#####....................#####....................#####....................#####....................#####............
.........#####....................#####....................#####....................#####....................#####...........
..........#####....................#####....................#####....................#####....................#####..........
...........#####....................#####....................#####....................#####....................#####.........
............#####....................#####....................#####....................#####....................#####........
.......#.....#####..............#.....#####..............#.....#####..............#.....#####..............#.....#####.......
.......##.....#####.............##.....#####.............##.....#####.............##.....#####.............##.....#####......
.......###.....#####............###.....#####............###.....#####............###.....#####............###.....#####.....
.......####.....####............####.....####............####.....####............####.....####............####.....####.....
.......#####.....###............#####.....###............#####.....###............#####.....###............#####.....###.....
.......######.....##............######.....##............######.....##............######.....##............######.....##.....
.......#######.....#............#######.....#............#######.....#............#######.....#............#######.....#.....
.......########.................########.................########.................########.................########..........
####################.....####################.....####################.....####################.....####################.....
.####################.....####################.....####################.....####################.....####################....
..####################.....####################.....####################.....####################.....####################...
...####################.....####################.....####################.....####################.....####################..
....####################.....####################.....####################.....####################.....####################.
.....####################.....####################.....####################.....####################.....####################
#.....##############.#####.....##############.#####.....##############.#####.....##############.#####.....##############.####
##.....#############..#####.....#############..#####.....#############..#####.....#############..#####.....#############..###
###....#############...#####....#############...#####....#############...#####....#############...#####....#############...##
####...#############....#####...#############....#####...#############....#####...#############....#####...#############....#
#####..#############.....#####..#############.....#####..#############.....#####..#############.....#####..#############.....
.#####.#############......#####.#############......#####.#############......#####.#############......#####.#############.....
..##################.......##################.......##################.......##################.......##################.....
........#####....................#####....................#####....................#####....................#####............
.........#####....................#####....................#####....................#####....................#####...........
..........#####....................#####....................#####....................#####....................#####..........
...........#####....................#####....................#####....................#####....................#####.........
............#####....................#####....................#####....................#####....................#####........
  • Önce genişlik argümanı gelmelidir. Herhangi makul giriş biçimi (örneğin w,h, w h, (w, h)) gayet iyi.
  • İsteğe bağlı izleyen bir yeni satırla sonucu yazdırın veya iade edin.
  • Herhangi iki farklı kullanabilir yazdırılabilir ASCII yerine karakterleri .ve #.
  • Baz hücreyi, periyodik sınır koşullarına sahipmiş gibi dikey veya yatay olarak çevirebilirsiniz . Dolayısıyla çıktının sol üst köşesi mutlaka 7 x 8'lik bir dikdörtgen olmayacaktır .. ( Yeni kural! )

Bayt cinsinden en kısa kod kazanır.

Bonus olarak, her .biri bir rengin pikseli ve her birinin #başka bir rengin piksel olduğu bir resim oluşturun .


Ne tür bir bonus? Kurabiye..? ;-)
Zach Gates,

4
"En kısa kodunu kazan" kodunu boşver, ben bunu Befunge' ediyorum!
El'endia Starman,

7
@ZachGates Belki bir köpek bisküvi.
Calvin'in Hobileri

Buna gelgit!
Greg Bacon

Yanıtlar:


17

Pyth, 61 60 55 49 bayt

j*vwmjk*Qd++Rm012Jmms}k++Rhd5U-d4T=T13+Lm1T_mP_dJ

Çevrimiçi deneyin: Gösteri

düzenleme 1: Grubu ve üçgeni oluşturan iki ifadeyi birleştirin (aşağıya bakınız)

düzenleme 2: Herhangi bir sembol kullanabileceğimizi görmedim. 5 bayt düzenledi

düzenleme 3: @ Calvin'sHobbies temel resmi çevirmeye izin verdi. Yaklaşımım bu fikre dayandığından, bu oldukça yardımcı oldu. -6 bayt

Ve için Çerez ikramiye :

.w*vw*RQ++Rm012Jmm*K255}k++Rhd5U-d4T=T13+LmKT_mP_dJ

Bu yalnızca 2 bayt daha uzun (51 bayt) ve dosyayı oluşturur o.png. Giriş 5\n4için aşağıdaki resmi oluşturur:

Balıksırtı Deseni

Açıklama:

Balıksırtı Deseni oldukça düzensiz görünüyor. Fakat sol 7 sütunu sağa ve üst 5 sırayı bottona getirirsek çok daha güzel bir desen elde ederiz:

.#####...................
..#####..................
...#####.................
....#####................
.....#####...............
#.....#####..............
##.....#####.............
###.....#####............
####.....####............
#####.....###............
######.....##............
#######.....#............
########.................
#############.....#######
##############.....######
###############.....#####
################.....####
#################.....###
##################.....##
#############.#####.....#
#############..#####.....
#############...#####....
#############....#####...
#############.....#####..
#############......#####.
#############.......#####

İlk önce sol üst 13x13 bloğunu üretiyorum:

.#####.......
..#####......
...#####.....
....#####....
.....#####...
#.....#####..
##.....#####.
###.....#####
####.....####
#####.....###
######.....##
#######.....#
########.....

İki alanı tanımlayan 2 basit eşitsizlik var #. Bant ile tarif edilebilir y + 1 <= x <= y + 5ve üçgen tarafından tarif edilebilir x <= y - 5. Bu iki koşulu birleştirdim:

Jmms}k++Rhd5U-d4T=T13
                 =T13   T = 13
 m               T      map each d of [0, 1, ..., 12] to: 
                           the list produced by
  m             T          map each k of [0, 1, ..., 12] to:
       +Rhd5                  the list [d+1, d+2, ..., d+5]
      +                       extended by 
            U-d4              the list [0, 1, ..., d - 5]
    }k                        test if k is in the list
   s                          and convert the boolean result to 1 or 0
J                       assign this 13x13 block to J

Daha sonra +Rm012üstteki 25x13 bloğunu elde etmek için her satırın sonuna 12 sıfır ekler.

Alt 25x13 bloğu şimdi gerçekten basittir:

+Lm1T_mP_dJ
      m   J    map each row d of J to:
       P_d        reverse the row and pop the last element
     _         reverse the order the rows
+Lm1T          add T ones at the beginning of each row. 

Geriye kalan tek şey, deseni tekrarlamak ve yazdırmaktır.

j*vwmjk*Qd+upperlower   implicit: Q = first input number
          +upperlower   combine the two blocks to a 25x26 block
    m                   map each row d to:
       *Qd                 repeat d Q times
     jk                    and join to a string
 *vw                    read another number from input and repeat
j                       join by newlines and print

İçin fark Çerez ikramiye kodu:

  • 255 yerine 1
  • dize istemiyorum çünkü mjk*Qdkullanmak yerine*RQ
  • .w bu 2D diziyi dosyaya kaydeder (dolaylı olarak png biçimine dönüştürür)

5
Harika bir açıklama!
trichoplax 22:15

Açıkça "En üste 5 sıra" demek istiyorsun, bu sadece bir yazım hatası. Yorumumun neden işlem yapılmadan silindiğini anlamıyorum. Sonuç olarak, şimdi yayınınızı kendim düzenlemek ve düzenlemekten utanıyorum. Sonuç olarak, çok iyi bir cevap ve mükemmel bir açıklama. Daha önce çok oy aldım
Level River St

@ steveverrill Ah, özür dilerim. İngilizcemi, dönüşümü anlattığım pasajda düzeltmek istediğinizi düşündüm. Şimdi düzeltildi. Teşekkürler.
Jakube

11

CJam, 106 73 71 bayt

0000000: 71 7e 22 04 94 51 af 40 6e 73 b2 68 3a e1 7e 13 f2 a1  q~"..Q.@ns.h:.~...
0000012: 3e 1d de f5 64 9c 6b 0f 27 4c 36 d7 81 3d 30 35 56 f8  >...d.k.'L6..=05V.
0000024: cd e8 cd 7c dc 90 31 59 40 8b 8c 22 32 35 36 62 32 32  ...|..1Y@.."256b22
0000036: 62 41 73 33 39 2a 2e 2a 73 32 35 2f 2a 66 2a 4e 2a     bAs39*.*s25/*f*N*

Baskılar 1ve 0yerine .ve #. CJam tercümanında çevrimiçi olarak deneyin .

Nasıl çalışır

q~      e# Read and evaluate all input. This pushes W and H.
"…"     e# Push an encoding of run lengths of the characters in the output.
256b22b e# Convert from base 256 to base 22.
As39*   e# Push "10" and repeat it 39 times.
.*      e# Vectorized character repetition; multiply each base 22 digit (run
        e# length) by the corresponding character of "10…10".
s25/    e# Flatten and split into chunks of length 25.
*       e# Repeat the resulting array of rows H times.
f*      e# Repeat each row W times.
N*      e# Join the rows, separating by linefeeds.

Çerez bonusu

0000000: 27 50 6f 31 70 71 7e 5d 5f 5b 32 35 5f 29 5d 2e 2a 5c  'Po1pq~]_[25_)].*\
0000012: 7e 22 04 94 51 af 40 6e 73 b2 68 3a e1 7e 13 f2 a1 3e  ~"..Q.@ns.h:.~...>
0000024: 1d de f5 64 9c 6b 0f 27 4c 36 d7 81 3d 30 35 56 f8 cd  ...d.k.'L6..=05V..
0000036: e8 cd 7c dc 90 31 59 40 8b 8c 22 32 35 36 62 32 32 62  ..|..1Y@.."256b22b
0000048: 41 73 33 39 2a 2e 2a 73 32 35 2f 2a 66 2a 73 2b 4e 2a  As39*.*s25/*f*s+N*

ASCII resmi yerine bir Taşınabilir BitMap yazdırır.

24 13PNG'ye dönüştürülen giriş için çıktı aşağıdadır :

çıktı


7

Befunge-93 , 2120 1967 bayt

İşte hata ayıklama için özel durum işleme, bazı yüksek kaliteli befunge!

&&00p10pv
v       <
    >94+2*20p        v
>00g|   >                v
    @                >10g>0020gv-1:<
                               >:0`|
                     ,       v    $<
                     +        >v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v
 v_$1-:#^_$20g1-20p55^       >|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>"!DAB"....@
 ,:
 >^".......#.....#####......."                                                    <
  ^".......##.....#####......"                                                  <
  ^".......###.....#####....."                                                <
  ^".......####.....####....."                                              <
  ^".......#####.....###....."                                            <
  ^".......######.....##....."                                          <
  ^".......#######.....#....."                                        <
  ^".......########.........."                                      <
  ^"####################....."                                    <
  ^".####################...."                                  <
  ^"..####################..."                                <
  ^"...####################.."                              <
  ^"....####################."                            <
  ^".....####################"                          <
  ^"#.....##############.####"                        <
  ^"##.....#############..###"                      <
  ^"###....#############...##"                    <
  ^"####...#############....#"                  <
  ^"#####..#############....."                <
  ^".#####.#############....."              <
  ^"..##################....."            <
  ^"........#####............"          <
  ^".........#####..........."        <
  ^"..........#####.........."      <
  ^"...........#####........."    <
  ^"............#####........"  <
^                     p00-1g00<

(Açıkçası, bu hala çok golf oynuyor. Sadece şimdilik bir cevap almak istedim.)

Yani, bu farklı bölümlerden oluşur.

&&00p10p

Bu sadece başlatıcı, değerleri alır ve depolar

    >94+2*20p
>00g|      > 
    @  

Bu bölüm satır sayısını sıfırlar, böylece diğer (geniş) fotoğrafları yan yana basabiliriz. 94+2*26, satır sayısını hesaplıyor. Ayrıca, yükseklik sıfırsa, program sonlandırılır.

>10g

Bu, yığın üzerinde genişlik elde edeceğinden, kaç tane yazdırılacağını biliyoruz.

0020gv-1:<
     >:0`|
         $

Bu, bir işlemi ne zaman bitirdiğimizi ve hangi satırda (n) olduğumuzu söylemek için yığına iki boş değer ekler. Bu daha sonra n değerlerini yığına ekler.

>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v
|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>"!DAB"....@

                                                    <
                                                  <
                                                <
                                              <
                                            <
                                          <
                                        <
                                      <
                                    <
                                  <
                                <
                              <
                            <
                          <
                        <
                      <
                    <
                  <
                <
              <
            <
          <
        <
      <
    <
  <
<

Bu, (26-n) sırasına gidecek bir kontrol bölümüdür. Nasıl yapılacağını çözmenin en kolay yolu bu.

".......#.....#####......."
".......##.....#####......"
".......###.....#####....."
".......####.....####....."
".......#####.....###....."
".......######.....##....."
".......#######.....#....."
".......########.........."
"####################....."
".####################...."
"..####################..."
"...####################.."
"....####################."
".....####################"
"#.....##############.####"
"##.....#############..###"
"###....#############...##"
"####...#############....#"
"#####..#############....."
".#####.#############....."
"..##################....."
"........#####............"
".........#####..........."
"..........#####.........."
"...........#####........."
"............#####........"

Bu açık bir şekilde okunur ve yığında geriye doğru okunan satır ne olursa olsun açılır. Bu, onu çıkardığımızda, düzgün şekilde basılacağı anlamına gelir.

v_
,:
>^

Bu, yığın daha önce bıraktığımız 0 değerine ulaşana kadar yazacaktır.

1-:#^_

Bu, yazdırılacak belirli satır sayısının 1'ini alır, sıfır olup olmadığını kontrol eder. Sıfır değilse, dördüncü kod bloğuna geri döneriz.

          ,
          +
20g1-20p55^

Bu, 1 satırından (n) çıkarır, yeni bir satır basar ve 3. bloğa geri döner.

p00-1g00

Tüm satırların basılmasından sonra, bu, bir tane başlangıç ​​yüksekliğinden çıkarır ve blok 2'ye geri döner.

Kodun geri kalanı kontrol akışı veya yığın yönetimidir. Bu mas'ı düşündüğümden daha fazla yazmak, ancak göründüğünden memnun kaldım. Çok daha fazla golf tutulabilir ve bu muhtemelen başka bir gün için bir proje olarak kalacaktır.

2120 -> 1967 : çok fazla boşa harcanan alanlardan bazılarını topladı


1
Ben golf oynadım. Cevabınız tam olarak değil, ama Befunge'de bir çözüm buldum!
El'endia Starman

6

Perl, 243

( -nAnahtarın stdin'den girdi getirmesi için bir bayt eklendi .)

($w,$h)=split;for(1..$h){print((sprintf("%025b",hex)x$w).$/)foreach qw(20f80 307c0 383e0 3c1e0 3e0e0 3f060 3f820 3fc00 1ffffe0 fffff0 7ffff8 3ffffc 1ffffe fffff 107ffef 183ffe7 1c3ffe3 1e3ffe1 1f3ffe0 fbffe0 7fffe0 1f000 f800 7c00 3e00 1f00)}

Bu oldukça basittir - yaptığı tek şey 26 hex sayılarından oluşan bir diziyi ikiliye dönüştürmek ve gereken sayıda yazdırmaktır.

Örnek:

Giriş:

3 2

Çıktı:

000000010000011111000000000000001000001111100000000000000100000111110000000
000000011000001111100000000000001100000111110000000000000110000011111000000
000000011100000111110000000000001110000011111000000000000111000001111100000
000000011110000011110000000000001111000001111000000000000111100000111100000
000000011111000001110000000000001111100000111000000000000111110000011100000
000000011111100000110000000000001111110000011000000000000111111000001100000
000000011111110000010000000000001111111000001000000000000111111100000100000
000000011111111000000000000000001111111100000000000000000111111110000000000
111111111111111111110000011111111111111111111000001111111111111111111100000
011111111111111111111000001111111111111111111100000111111111111111111110000
001111111111111111111100000111111111111111111110000011111111111111111111000
000111111111111111111110000011111111111111111111000001111111111111111111100
000011111111111111111111000001111111111111111111100000111111111111111111110
000001111111111111111111100000111111111111111111110000011111111111111111111
100000111111111111110111110000011111111111111011111000001111111111111101111
110000011111111111110011111000001111111111111001111100000111111111111100111
111000011111111111110001111100001111111111111000111110000111111111111100011
111100011111111111110000111110001111111111111000011111000111111111111100001
111110011111111111110000011111001111111111111000001111100111111111111100000
011111011111111111110000001111101111111111111000000111110111111111111100000
001111111111111111110000000111111111111111111000000011111111111111111100000
000000001111100000000000000000000111110000000000000000000011111000000000000
000000000111110000000000000000000011111000000000000000000001111100000000000
000000000011111000000000000000000001111100000000000000000000111110000000000
000000000001111100000000000000000000111110000000000000000000011111000000000
000000000000111110000000000000000000011111000000000000000000001111100000000
000000010000011111000000000000001000001111100000000000000100000111110000000
000000011000001111100000000000001100000111110000000000000110000011111000000
000000011100000111110000000000001110000011111000000000000111000001111100000
000000011110000011110000000000001111000001111000000000000111100000111100000
000000011111000001110000000000001111100000111000000000000111110000011100000
000000011111100000110000000000001111110000011000000000000111111000001100000
000000011111110000010000000000001111111000001000000000000111111100000100000
000000011111111000000000000000001111111100000000000000000111111110000000000
111111111111111111110000011111111111111111111000001111111111111111111100000
011111111111111111111000001111111111111111111100000111111111111111111110000
001111111111111111111100000111111111111111111110000011111111111111111111000
000111111111111111111110000011111111111111111111000001111111111111111111100
000011111111111111111111000001111111111111111111100000111111111111111111110
000001111111111111111111100000111111111111111111110000011111111111111111111
100000111111111111110111110000011111111111111011111000001111111111111101111
110000011111111111110011111000001111111111111001111100000111111111111100111
111000011111111111110001111100001111111111111000111110000111111111111100011
111100011111111111110000111110001111111111111000011111000111111111111100001
111110011111111111110000011111001111111111111000001111100111111111111100000
011111011111111111110000001111101111111111111000000111110111111111111100000
001111111111111111110000000111111111111111111000000011111111111111111100000
000000001111100000000000000000000111110000000000000000000011111000000000000
000000000111110000000000000000000011111000000000000000000001111100000000000
000000000011111000000000000000000001111100000000000000000000111110000000000
000000000001111100000000000000000000111110000000000000000000011111000000000
000000000000111110000000000000000000011111000000000000000000001111100000000

3

Rev 1, C, 118 115 bayt

i,x,y;f(w,h){for(i=26*h*(w*=25);i--;i%w||puts(""))x=i%25,y=i/w%26,putchar(((y>x^y>x+5^x>y+4)&y/13==x/13^y/13)+34);}

Hücrenin çevrilmesine izin veren yeni kural nedeniyle 9 bayt kaydedildi. 3 bayt kullanılarak kaydedildi w*=25. Gönderinin geri kalanı değişmeden kalır.

Rev 0, C, 127 bayt

i,x,y;f(w,h){for(i=650*w*h;i--;i%(25*w)||puts(""))x=(i+20)%25,y=(i/25/w+8)%26,putchar(((y>x^y>x+5^x>y+4)&y/13==x/13^y/13)+34);}

Bu, karakterleri gözden geçirerek tek tek yazdırır. i%(25*w)||puts("")her satırın sonuna yeni satır ekler.

Tasarıma bakma yöntemim Jakube'e benziyor, ancak aşağıdaki görünümü elde etmek için üstteki 8 sırayı alta, 5 sağdaki sola getirdim. Bu adım programında tarafından "tersine" +20ve +8x ve y için ifadelerde.

"""""####################
#"""""###################
##"""""##################
###"""""#################
####"""""################
#####"""""###############
"#####"""""##############
""#####"""""#############
"""#####""""#############
""""#####"""#############
"""""#####""#############
""""""#####"#############
"""""""##################
"""""""""""""#####"""""""
""""""""""""""#####""""""
"""""""""""""""#####"""""
""""""""""""""""#####""""
"""""""""""""""""#####"""
""""""""""""#"""""#####""
""""""""""""##"""""#####"
""""""""""""###"""""#####
""""""""""""####"""""####
""""""""""""#####"""""###
""""""""""""######"""""##
""""""""""""#######"""""#
""""""""""""########"""""

"Renklerin ters çevrilmesi" dışında, birbirine çok benzeyebilir, ancak önemli bir fark var: diyagonal çizgiler eşleşiyor. (Orijinal tasarımın, 25x26'yı ölçtüğü gibi köşegen simetrisine sahip olmadığını unutmayın.)

Bu ifade ((y>x^y>x+5^x>y+4)^y/13)+34, çeşitli karşılaştırma işleçlerinin çizgileri ^y/13ürettiği, "renk çevirmeyi" yarı yolda ürettiği +34ve elde edilen sayıyı 0,1alıp ASCII aralığına yükselttiği aşağıdakileri üretir 34,35.

"""""####################
#"""""###################
##"""""##################
###"""""#################
####"""""################
#####"""""###############
"#####"""""##############
""#####"""""#############
"""#####"""""############
""""#####"""""###########
"""""#####"""""##########
""""""#####"""""#########
"""""""#####"""""########
########"""""#####"""""""
#########"""""#####""""""
##########"""""#####"""""
###########"""""#####""""
############"""""#####"""
#############"""""#####""
##############"""""#####"
###############"""""#####
################"""""####
#################"""""###
##################"""""##
###################"""""#
####################"""""

Terim &y/13==x/13, yukarıda gösterildiği gibi, desenin kare kısmını üreten, sağ üst ve sol alt çeyreklerde false = 0 olarak değerlendirilir. Program aşağı saydığı için, x = y = 0 kaynağının sağ altta olduğuna dikkat edin. #Kare ", sadece 12 karakter genişliğinde , kare ise 13 karakter genişliğinde kullanışlıdır .


2

Befunge -93, 968 bayt

Evet bu doğru! Rekabetçi bir Befunge cevabı!

&:&\00p10p:520pv:g00p02<v  <
    #   p1*45-1_v#:" "  <  v
    |`-1*65:g02$<      ,
    >:" "\39*\p:" "\47 *v
+:"<"\39*\p:"v"\47*\p25^>\p 1
".......#.....#####......."<v
".......##.....#####......"
".......###.....#####....."
".......####.....####....."
".......#####.....###....."
".......######.....##....."
".......#######.....#....."
".......########.........."
"####################....."
".####################...."
"..####################..."
"...####################.."
"....####################."
".....####################"
"#.....##############.####"
"##.....#############..###"
"###....#############...##"
"####...#############....#"
"#####..#############....."
".#####.#############....."
"..##################....."
"........#####............"
".........#####..........."
"..........#####.........."
"...........#####........."
"............#####........"
,,,,,,,,,,,,,,,,,,,,,,,,,  v>
    > 10g1-:10p #v_@
 " " \47*\p5:"<"v>:" "\39*\ p
\*74 \"v":p\*93\<      v,*5 2p

Yarın açıklama, şimdi yat. Bununla birlikte, birkaç yönlendirme okunu hareket ettirerek akıllıca şeyler yaptığımı ve sarma özelliğini de biraz kullandığımı söyleyeceğim. Bu çevrimiçi tercümanda test edin .

Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.