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, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 
 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0]

ini pertama kalinya saya memposting puzzle kode. jika Anda memiliki peningkatan gaya. biarkan aku tahu.
john mangual

7
Hai John, dan selamat datang di PPCG! Tantangan di sini perlu memiliki kondisi kemenangan yang objektif (biasanya golf kode). Kami juga merekomendasikan menjalankan semua tantangan melalui kotak pasir sebelum memposting.

3
Karena tujuan dari masalah ini tampaknya adalah menemukan urutannya, saya sarankan meminta kode terpendek yang akan menghasilkan 1.000 elemen pertama ini dengan benar.

@Mnemonic yang kedengarannya benar. Kode saya sudah cukup pendek, dan saya bertanya apakah ada kode yang lebih pendek. Silakan mengedit :-) atau saya bisa pindah ke kotak pasir
john mangual

Saya lupa siapa yang melakukan tantangan ini sebelumnya. Tetapi diterima dengan sangat baik untuk "menemukan polanya". Samar-samar saya ingat seseorang memecahkannya dalam 50 menit; tetapi orang-orang terus menjawab bahkan setelah itu.
Magic Gurita Guci

Jawaban:


17

Jelly , 11 10 byte

Disimpan 1 byte berkat @Dennis

ȷḶ×⁽q£:ȷ5Ḃ

Cobalah online!

Bagaimana?

Saya pertama kali memperhatikan bahwa pola berganti-ganti antara panjang 4 dan panjang 3, lewati langkah-4 setiap beberapa kali berjalan. Hal ini membuat saya mencari angka yang dapat dibagi ke dalam indeks saat ini, kemudian mengambil mod 2 dan lantai - yaitu mengambil bit paling tidak signifikan - untuk memberikan bit pada indeks itu dalam seri. Setelah banyak trial and error, saya menemukan yang 3.41845melakukan hal itu, tetapi mengalikannya dengan perkiraan timbal baliknya ( .29253) lebih pendek satu byte.

ȷḶ×⁽q£:ȷ5Ḃ    Main link. Arguments: none
ȷ             Yield 1e3, i.e. 1000.
 Ḷ            Lowered range; yield [0, 1, 2, ..., 999].
  ×⁽q£        Multiply each item by 29253.
      :ȷ5     Floor-divide each item by 1e5, i.e. 100000.
         Ḃ    Take each item mod 2.

ah Anda menemukannya
Jonathan Allan

[0 ... 999] kali masing-masing sebesar 0,2925, mod 2 dan lantai (saya akan naik lantas mod 2 tetapi setara)
Jonathan Allan

6
Nah itu agak antiklimaks, memang mengharapkan sesuatu yang lebih rumit.
Nit

@ Jonathan Allan Saya awalnya mencoba hanya tetapi ternyata itu hanya mod 2 daripada bit terendah, jadi saya menambahkan untuk memperbaikinya. Ditukar sekarang
ETHproduksi

1
ȷḶ×⁽q£:ȷ5Ḃbekerja, selama 10 byte.
Dennis

3

Dyalog APL , 99 83 82 byte

a←{⍵/0 1}¨(↓3 24 3 3)
{a⊢←↓⍉↑a{⍺∘{⍵/⊂⍺}¨⍵}¨↓3 3⍴⍵}¨(9/5)∘⊤¨1386531 496098
1000⍴∊a

Cobalah online!

Jelas bukan solusi yang dimaksudkan karena ini masih memiliki banyak data hardcode, tapi ini awal.


3

Ruby , 34 29 26 22 byte

$.+=184while p$./629%2

Cobalah online!

Penjelasan cepat: ini bekerja karena angka ajaib 629. Saya perhatikan bahwa urutan mulai berulang setelah elemen ke-629, dan saya mencoba untuk "meningkatkan" beberapa jawaban yang ada, hanya menggunakan bilangan bulat matematika. Saya menemukan bahwa "angka ajaib" lainnya (0,29253) sebenarnya 184/629.


2

Jelly , 31 byte

Mengingat polanya mungkin ada cara yang lebih pendek ...

ĖŒṙḂ
“ṁ⁽⁺ḄæI’BḤ+3żḂ$ẎÇo2Ç+3Çḣȷ¬

Cobalah online!

Bagaimana?

Mengeksploitasi struktur panjang run berulang yang terlihat hingga kedalaman tiga.

ĖŒṙḂ - Link 1, make runs of bits: list of lengths    e.g. [5,3,5,3,3]
Ė    - enumerate                      [[1,5],[2,3],[3,5],[4,3],[5,3]]
 Œṙ  - run-length decode      [1,1,1,1,1,2,2,2,3,3,3,3,3,4,4,4,5,5,5]
   Ḃ - bit (modulo by 2)      [1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1]

“ṁ⁽⁺ḄæI’BḤ+3żḂ$ẎÇo2Ç+3Çḣȷ¬ - Main link: no arguments
“ṁ⁽⁺ḄæI’                   - literal 234931870193324
        B                  - to binary = [1,1,0,1,0,1,0,1,1,0,1,0,1,0,1,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,1,0,1,0,1,0,1,1,0,0]
         Ḥ                 - double    = [2,2,0,2,0,2,0,2,2,0,2,0,2,0,2,2,0,2,0,2,0,2,2,0,2,0,2,0,2,0,2,2,0,2,0,2,0,2,2,0,2,0,2,0,2,2,0,0]
          +3               - add three = [5,5,3,5,3,5,3,5,5,3,5,3,5,3,5,5,3,5,3,5,3,5,5,3,5,3,5,3,5,3,5,5,3,5,3,5,3,5,5,3,5,3,5,3,5,5,3,3]
              $            - last two links as a monad:
             Ḃ             -   bit     = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
            ż              -   zip     = [[5,1],[5,1],[3,1],[5,1],[3,1],[5,1],[3,1],[5,1],[5,1],[3,1],[5,1],[3,1],[5,1],[3,1],[5,1],[5,1],[3,1],[5,1],[3,1],[5,1],[3,1],[5,1],[5,1],[3,1],[5,1],[3,1],[5,1],[3,1],[5,1],[3,1],[5,1],[5,1],[3,1],[5,1],[3,1],[5,1],[3,1],[5,1],[5,1],[3,1],[5,1],[3,1],[5,1],[3,1],[5,1],[5,1],[3,1],[3,1]]
               Ẏ           - tighten   = [5,1,5,1,3,1,5,1,3,1,5,1,3,1,5,1,5,1,3,1,5,1,3,1,5,1,3,1,5,1,5,1,3,1,5,1,3,1,5,1,3,1,5,1,5,1,3,1,5,1,3,1,5,1,3,1,5,1,3,1,5,1,5,1,3,1,5,1,3,1,5,1,3,1,5,1,5,1,3,1,5,1,3,1,5,1,3,1,5,1,5,1,3,1,3,1]
                Ç          - call the last Link (1) as a monad
                           -           = [1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,0,1,1,1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,1,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,1,0]          

Saya belum pernah melihat Jelly sebelumnya!
john mangual

Selamat datang di PPCG :) - ini adalah bahasa golf yang ditulis oleh salah satu moderator kami, Dennis. Klik di tajuk untuk halaman git-hub di mana ada wiki.
Jonathan Allan

Saya berjanji untuk menjadi lebih baik dalam mengajukan pertanyaan. saya melihat ada kotak pasir dan beberapa format standar.
john mangual

Ini adalah pendekatan saya ketika saya mulai.
Buah Esolanging

@EsolangingFruit saya pikir ketika saya melakukan itu bisa jadi fraksi melakukan pengulangan ... 117/400 sepertinya!
Jonathan Allan

2

Java 8, 75 64 62 byte

v->{for(int i=0;i<1e3;)System.out.print((int)(i++*.29253)%2);}

Mencetak seluruh urutan tanpa pembatas untuk menyimpan byte, karena mereka hanya akan 0dan 1tetap.

Ports jawaban Jelly @ ETHproductions , karena saya ragu saya menemukan sesuatu yang lebih pendek ..

Cobalah online.

Penjelasan:

v->{                     // Method with empty unused parameter and no return-type
  for(int i=0;i<1e3;)    //  Loop `i` in range [0,1000)
    System.out.print(    //   Print:
      (int)(i++*.29253)  //    `i` multiplied with 0.29253,
                         //    and then truncated of their decimal values by casting to int
      %2);}              //    Modulo-2 to result in either 0 or 1

Jawaban lama mengembalikan array yang dihasilkan ( 75 byte ):

v->{int i=1000,r[]=new int[i];for(;i-->0;)r[i]=(int)(i*.29253)%2;return r;}

Cobalah online.

Penjelasan:

v->{                   // Method with empty unused parameter and integer-array return-type
  int i=1000,          //  Index `i`, starting at 1000
      r[]=new int[i];  //  Result-array of size 1000
  for(;i-->0;)         //  Loop `i` in range (1000,0]
    r[i]=              //   Set the item in the array at index `i` to:
      (int)(i*.29253)  //    `i` multiplied with 0.29253,
                       //    and then truncated of their decimal values by casting to int
      %2;              //    Modulo-2 to result in either 0 or 1
  return r;}           //  Return the resulting integer-array



1

Bahasa Wolfram (Mathematica) , 96 byte

Saya mencari otomat seluler yang melihat 4 tetangga di sebelah kiri dan menghasilkan pola berjalan kiri yang terlihat dalam data saat Anda Memisahkan data menjadi panjang 7 dan menjaga setiap baris ketiga.

Automaton seluler ini akan berjalan selama 29 generasi yang masing-masing rangkap tiga, mencocokkan urutan sempurna untuk karakter 1 hingga 629. Namun urutan mulai berulang pada karakter 630 daripada melanjutkan pola yang diamati, sehingga kode tambahan diperlukan untuk menangani pengulangan pola terpotong. Saya menghasilkan pola utama dua kali untuk mendapatkan 1258 karakter.

Most@Flatten[{#,#,#}&/@CellularAutomaton[{271,2,-{{4},{3},{2},{1}}},{0,0,0,0,1,1,1},29]]~Table~2

Tanpa kesalahan itu kita bisa melakukannya dalam 74 byte yang lebih pendek. Angka 47 adalah jumlah generasi yang diperlukan untuk mencapai 1000 karakter (ini sebenarnya berarti 1008 = 48 * 7 * 3)

{#,#,#}&/@CellularAutomaton[{271,2,-{{4},{3},{2},{1}}},{0,0,0,0,1,1,1},47]

Cobalah online!


1

Z80Golf , 27 byte

00000000: 018d 2b7b 1f1f e601 f630 ff09 3001 1313  ..+{.....0..0...
00000010: 7bfe 9220 ee7a fe04 20e9 76              {.. .z.. .v

Cobalah online!

Diterjemahkan dari kode C ini:

for (n = 0; n >> 16 != 1170; n += 11149 + 65536)
    putchar('0'|n>>18&1);

Membongkar:

  ld bc, 11149
loop:
  ld a, e
  rra
  rra
  and 1
  or '0'
  rst $38           ; putchar
  add hl, bc        ; Add 11149 to n = DEHL.
  jr nc, just_one   ; Add 65536 to n, possibly with carry from low 16 bits.
  inc de
just_one:
  inc de
  ld a, e
  cp 1170 & 255
  jr nz, loop
  ld a, d
  cp 1170 >> 8
  jr nz, loop
  halt

Ini pada dasarnya adalah pendekatan aritmatika titik tetap: (11149 + 65536) / 2 18 ≈ 0,29253, konstanta yang digunakan oleh jawaban lain.




0

Arang , 13 byte

Eφ§01×·²⁹²⁵³ι

Cobalah online! Tautan adalah untuk mengucapkan versi kode. Penjelasan:

 φ              Predefined variable 1000
E               Map over implicit range
            ι   Current value
      ·²⁹²⁵³    Literal constant `0.29253`
     ×          Multiply
   01           Literal string `01`
  §             Cyclically index
                Implicitly print each result on its own line

Berkat @ ASCII-only untuk memungkinkan pengindeksan untuk menerima float yang dilemparkan ke integer (dan kemudian secara otomatis mengurangi modulo 2 dalam kasus ini).


0

C, 55 53 52 byte

f(i,j){for(i=0;j=.29253*i,i++-1e3;)putchar(j%2+48);}

Port of Java Kevin Cruijssen menjawab . Cobalah online di sini .

Berkat vazt untuk bermain golf 2 byte dan untuk Jonathan Frech untuk bermain golf satu lagi.

Versi tidak disatukan:

f(i, j) { // function taking two dummy arguments (implicitly int) and implicitly returning an unused int
    for(i = 0; j = .29253*i, i++ - 1e3; ) //  loop 1000 times, multiply i with 0.29253, truncating to an integer
        putchar(j % 2 + 48);  // modulo the truncated integer by 2, yielding 0 or 1, then convert to ASCII (48 is ASCII code for '0') and print
}

idiinisialisasi ke 0 karena bersifat global, sehingga Anda dapat menghapus i=0dari penginisialisasi for-loop untuk menghemat 3 byte. Juga jika Anda memperkenalkan variabel kedua (sebagai parameter f()) dan menetapkannya i++*.29253, Anda dapat menghindari para pemain dan menyimpan 2 byte lainnya: i;f(j){for(;i<1e3;)printf("%d",(j=i++*.29253)%2);} Cobalah secara online!
vazt

@vazt Ya, idiinisialisasi ke 0 di awal, tetapi jika kita ingin memanggil fungsi ini lebih dari sekali, itu tidak cukup baik. Menggunakan juntuk menghindari para pemain adalah golf yang hebat, terima kasih.
OOBalance


Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.