วิวัฒนาการของ 'x'


15

รับเป็นบอร์ดขนาดตัวแปรที่มีขนาดสูงสุด 5 ครั้ง 5 สาขา ทุกสาขาจะเต็มไปด้วย 'x' ถ้ามันไม่ได้เต็มไปด้วย 'x' มันก็จะเต็มไปด้วย 'o'

สถานะเริ่มต้นของทุกบอร์ดจะได้รับ (ดูด้านล่าง) แต่ละกระดานจะต้องเล่น 10 รอบ (อย่างมาก, ตามเงื่อนไข: ดูด้านล่าง) และต้องดูวิวัฒนาการของ x

หนึ่งรอบทำงานด้วยวิธีต่อไปนี้:

  1. 'x' ทุกตัวจะแพร่กระจายไปยังเขตข้อมูลที่มีขอบตั้งฉาก แต่จะหายไปเอง
  2. แต่ละครั้งที่ 'x' สองตัวอยู่ในเขตข้อมูลเดียว

วิวัฒนาการของ 'x' ในแต่ละรอบจะต้องเกิดขึ้นพร้อมกัน ตัวอย่าง:

    o o o            o x o
    o x o     ->     x o x
    o o o            o x o

ด้วยวิวัฒนาการแต่ละรอบคุณต้องดูว่ากระดานว่างเปล่า 'x' หรือไม่ ไม่ว่างเปล่าอาจมีรูปแบบการทำซ้ำ หากไม่เป็นเช่นนั้นเราจะยกเลิกการวิเคราะห์วิวัฒนาการ นอกจากนี้คุณต้องพิมพ์เปอร์เซ็นต์สูงสุดของฟิลด์ x สำหรับบอร์ดเริ่มต้นทุกอัน (ปัดเศษลงเป็นจำนวนเต็ม)

การป้อนข้อมูล:

สามารถดูข้อมูลอินพุตได้ที่นี่ (Pastebin) ข้อมูลนี้มีสถานะเริ่มต้น 100 สถานะ ตามที่ได้กล่าวไปแล้วบอร์ดมีขนาดแตกต่างกัน จำนวนแถวถูกระบุด้วยหมายเลข n จาก 1 ถึง 5 ตามด้วย n แถวที่มีเฉพาะ 'x' และ 'o' แทนรูปแบบเริ่มต้น บอร์ดทุกแถวมี 1 ถึง 5 ฟิลด์

เอาท์พุท:

ผลลัพธ์ที่สมบูรณ์จะต้องพิมพ์ออกมาหนึ่งแถวที่พิมพ์ออกมาสำหรับแต่ละบอร์ดเริ่มต้นในรูปแบบต่อไปนี้:

    Round {0-10}: {repetition/empty/giveup}, {0-100} percent maximum-fill

ตัวอย่าง:

ตัวอย่างที่ 1:

    Input: 2       Starting state: x o x
           xox                     x x
           xx

                          Round 1: x x o
                                   o x

                          Round 2: x o x
                                   o x

                          Round 3: o x o
                                   o o

                          Round 4: x o x   -> The pattern repeats:
                                   o x        It is the same as in round 2,
                                              therefore we stop. Maximum fill was
                                              in the starting state with four times 'x'
                                              of 5 fields altogether,
                                              so we have 4/5 = 80 %.

    Output: Round 4: repetition, 80 percent maximum-fill

ตัวอย่างที่ 2:

    Input: 1       Starting state: x x
           xx                      

                          Round 1: x x    ->  We already have a repetition, because
                                              the pattern is the same as in the starting
                                              state. The board is always filled 100 %.

    Output: Round 1: repetition, 100 percent maximum-fill

หลังจากแปดวันฉันจะทำเครื่องหมายคำตอบการทำงานด้วยตัวละครน้อยที่สุดในฐานะผู้ชนะ นอกจากนี้ฉันจะโพสต์เอาต์พุตที่ถูกต้องสำหรับ 100 บอร์ดเริ่มต้น (อินพุต)

คุณสามารถใช้ภาษาที่ต้องการ (การเขียนโปรแกรม / สคริปต์ / อะไรก็ได้)

มีความสุข!

PS: ถ้าคุณมีคำถามอย่าลังเลที่จะถาม

PPS: ในส่วนของผู้สร้างเดิม: สำหรับคนที่ความสามารถในการพูดภาษาเยอรมันคำถามที่ถูกนำมาจากไม่คลิกถ้าคุณไม่ต้องการ SPOILERS ที่นี่ ตั้งแต่เวลาอย่างเป็นทางการในการทำสิ่งที่ท้าทายได้สิ้นสุดลงฉันต้องการดูว่ามีใครบางคนสามารถคิดหาคำตอบสั้น ๆ และสง่างามได้หรือไม่

2014/04/22:

ท้าทายเสร็จแล้ว! ผู้ชนะที่ทำเครื่องหมายว่ายอมรับแล้ว เอาท์พุทที่ถูกต้อง:

    Round 10: giveup, 50 percent maximum-fill
    Round 5: empty, 66 percent maximum-fill
    Round 1: repetition, 100 percent maximum-fill
    Round 1: empty, 100 percent maximum-fill
    Round 4: repetition, 100 percent maximum-fill
    Round 4: repetition, 70 percent maximum-fill
    Round 2: repetition, 60 percent maximum-fill
    Round 4: empty, 88 percent maximum-fill
    Round 10: giveup, 50 percent maximum-fill
    Round 5: repetition, 80 percent maximum-fill
    Round 10: repetition, 80 percent maximum-fill
    Round 1: empty, 80 percent maximum-fill
    Round 3: repetition, 60 percent maximum-fill
    Round 4: repetition, 48 percent maximum-fill
    Round 9: empty, 41 percent maximum-fill
    Round 10: giveup, 92 percent maximum-fill
    Round 10: giveup, 53 percent maximum-fill
    Round 10: giveup, 66 percent maximum-fill
    Round 6: repetition, 50 percent maximum-fill
    Round 10: giveup, 88 percent maximum-fill
    Round 10: giveup, 76 percent maximum-fill
    Round 10: giveup, 68 percent maximum-fill
    Round 10: giveup, 40 percent maximum-fill
    Round 10: giveup, 100 percent maximum-fill
    Round 10: giveup, 71 percent maximum-fill
    Round 2: empty, 81 percent maximum-fill
    Round 6: repetition, 36 percent maximum-fill
    Round 10: giveup, 61 percent maximum-fill
    Round 10: giveup, 60 percent maximum-fill
    Round 4: repetition, 66 percent maximum-fill
    Round 10: giveup, 72 percent maximum-fill
    Round 3: empty, 80 percent maximum-fill
    Round 10: giveup, 50 percent maximum-fill
    Round 10: giveup, 83 percent maximum-fill
    Round 7: repetition, 37 percent maximum-fill
    Round 9: repetition, 85 percent maximum-fill
    Round 5: repetition, 40 percent maximum-fill
    Round 5: repetition, 60 percent maximum-fill
    Round 4: empty, 80 percent maximum-fill
    Round 10: giveup, 60 percent maximum-fill
    Round 4: repetition, 46 percent maximum-fill
    Round 6: repetition, 42 percent maximum-fill
    Round 10: giveup, 72 percent maximum-fill
    Round 4: repetition, 70 percent maximum-fill
    Round 4: repetition, 80 percent maximum-fill
    Round 6: repetition, 50 percent maximum-fill
    Round 4: repetition, 56 percent maximum-fill
    Round 10: giveup, 60 percent maximum-fill
    Round 10: giveup, 54 percent maximum-fill
    Round 10: giveup, 66 percent maximum-fill
    Round 2: repetition, 40 percent maximum-fill
    Round 2: repetition, 40 percent maximum-fill
    Round 6: repetition, 75 percent maximum-fill
    Round 7: empty, 85 percent maximum-fill
    Round 10: giveup, 50 percent maximum-fill
    Round 6: repetition, 70 percent maximum-fill
    Round 2: empty, 66 percent maximum-fill
    Round 1: empty, 66 percent maximum-fill
    Round 3: empty, 100 percent maximum-fill
    Round 3: empty, 66 percent maximum-fill
    Round 8: repetition, 42 percent maximum-fill
    Round 1: empty, 60 percent maximum-fill
    Round 2: repetition, 100 percent maximum-fill
    Round 2: repetition, 83 percent maximum-fill
    Round 4: repetition, 66 percent maximum-fill
    Round 6: repetition, 75 percent maximum-fill
    Round 4: empty, 66 percent maximum-fill
    Round 10: giveup, 61 percent maximum-fill
    Round 10: giveup, 56 percent maximum-fill
    Round 4: empty, 66 percent maximum-fill
    Round 6: repetition, 33 percent maximum-fill
    Round 3: empty, 57 percent maximum-fill
    Round 3: repetition, 100 percent maximum-fill
    Round 6: repetition, 73 percent maximum-fill
    Round 10: giveup, 50 percent maximum-fill
    Round 6: repetition, 50 percent maximum-fill
    Round 10: giveup, 73 percent maximum-fill
    Round 5: empty, 80 percent maximum-fill
    Round 10: giveup, 61 percent maximum-fill
    Round 3: repetition, 53 percent maximum-fill
    Round 10: giveup, 33 percent maximum-fill
    Round 10: giveup, 80 percent maximum-fill
    Round 10: giveup, 63 percent maximum-fill
    Round 10: giveup, 70 percent maximum-fill
    Round 10: giveup, 84 percent maximum-fill
    Round 7: repetition, 70 percent maximum-fill
    Round 10: repetition, 57 percent maximum-fill
    Round 10: giveup, 55 percent maximum-fill
    Round 6: repetition, 36 percent maximum-fill
    Round 4: repetition, 75 percent maximum-fill
    Round 10: giveup, 72 percent maximum-fill
    Round 10: giveup, 64 percent maximum-fill
    Round 10: giveup, 84 percent maximum-fill
    Round 10: giveup, 58 percent maximum-fill
    Round 10: giveup, 60 percent maximum-fill
    Round 10: giveup, 53 percent maximum-fill
    Round 4: repetition, 40 percent maximum-fill
    Round 4: empty, 40 percent maximum-fill
    Round 10: giveup, 50 percent maximum-fill
    Round 10: giveup, 68 percent maximum-fill

โปรดติดแท็กเป็น code-golf หรือ code-challenge แต่ไม่ใช่ทั้งสองอย่าง (ควรเป็น code-golf ในกรณีนี้)
user80551

1
บางคนควรเปลี่ยนให้เป็นออโตเมติกเซลลูลาร์ที่กำหนดไว้อย่างดี :-)
Justin

คำตอบ:


4

Perl, 308, 304, 305, 293, 264 , 262

แก้ไข:ข้อผิดพลาดพุ่งเข้ามาหลังจากหนึ่งในการแก้ไขล่าสุดทำให้เอาต์พุตไม่ถูกต้องสำหรับบอร์ดว่างเปล่า (เอาต์พุตชุดทดสอบคือ OK) ตั้งแต่Round 0ในรูปแบบเอาต์พุตที่กำหนดอาจหมายความว่ามีบอร์ดว่างในอินพุตเท่านั้น (แม้ว่าจะไม่มีในชุดทดสอบ) จึงต้องแก้ไขบั๊ก การแก้ไขด่วนหมายถึงการเพิ่มจำนวนไบต์ (จริง ๆ 1) - ไม่ใช่ตัวเลือกแน่นอน ดังนั้นฉันต้องตีกอล์ฟเพิ่มอีกนิด

เรียกใช้ด้วย-p(เพิ่ม +1 เพื่อนับ) อ่านจาก STDIN ต้องการ 5.014 เนื่องจากrตัวดัดแปลงการแทนที่

(@a,%h,$m)=('',map<>=~y/ox\n/\0!/rd,1..$_);for$n(0..10){$_="Round $n: ".($h{$_="@a"}++?repetition:(($.=100*y/!///y/ //c)<$m?$.:$m=$.)?giveup:empty).", $m percent maximum-fill\n";@a=/g/?map{$_=$a[$i=$_];y//!/cr&(s/.//r.P^P.s/.$//r^$a[$i+1]^$a[$i-1])}0..$#a:last}

กล่าวคือ

# '-p' switch wraps code into the 'while(<>){....}continue{print}' loop, 
# which reads a line from STDIN into $_, executes '....' and prints contents 
# of $_. We use it to read board height and print current board's result.

# First line reads board's state into @a array, a line per element, at the same 
# time replacing 'o' with 'x00', 'x' with '!' and chomping trailing newlines. 
# '!' was chosen because it's just like 'x01' except 5th bit (which is not important)
# but saves several characters in source code.

# Note: array is prepended with an empty line, which automatically remains in this 
# state during evolution, but saves us trouble of checking if actual (any non-empty)
# line has neighboring line below.

# %h hash and $m hold seen states and maximum fill percentage for current board,
# they are initialized to undef i.e empty and 0.

(@a,%h,$m)=('',map<>=~y/ox\n/\0!/rd,1..$_);

# /
# Then do required number of evolutions:

for$n(0..10){

# Stringify board state, i.e. concatenate lines with spaces ($") as separators.
# Calculate fill percentage - divide number of '!' by number of non-spaces. 
# Note: using $. magick variable automatically takes care of rounding.
# Construct output string. It's not used if loop gets to next iteration. 
# Check if current state was already seen (at the same time add it to %h) 
# and if fill percentage is 0.

$_="Round $n: "
    .($h{$_="@a"}++?repetition:(($.=100*y/!///y/ //c)<$m?$.:$m=$.)?giveup:empty)
    .", $m percent maximum-fill\n";

# /
# Next is funny: if output string contains 'g' (of 'giveup' word), then evolve 
# further, otherwise break-out of the loop.

    @a=/g/
        ?map{

# Do evolution round. Act of evolution for a given line is none other than 
# XOR-ing 4 strings: itself shifted right, itself shifted left, line above, line 
# below. Result of this operation is truncated to original length using bitwise '&'. 
# Note, when shifting string right or left we prepend (append) not an ascii-0, 
# but 'P' character. It's shorter, and 4th and 6th bits will be annihilated anyway.

            $_=$a[$i=$_];
            y//!/cr
            &(s/.//r.P
            ^P.s/.$//r
            ^$a[$i+1]
            ^$a[$i-1])
        }0..$#a
        :last
}

ว้าววิธีแก้ปัญหาอย่างรวดเร็ว ฉันประหลาดใจ เนื่องจากฉันไม่คุ้นเคยกับ PERL (ฉันได้ติดตั้งไว้แล้ว) ฉันจะเริ่มต้นสคริปต์ของคุณด้วยข้อมูลที่ป้อนเข้าของฉันได้อย่างไร
plocks

2
@DevanLoper เช่นperl -p x.pl < input.txtหากข้อมูลอยู่ในไฟล์หรือperl -p x.plและฟีดต่อบรรทัดเพื่อทดสอบรายการเดียว (ยุติด้วยctrl-D( ctrl-Z)) อย่าลืมตรวจสอบ Perl ของคุณว่าเป็น5.014หรือใหม่กว่า
2846289

ขอบคุณ VadimR ตอนนี้มันทำงาน แต่ฉันมีผลลัพธ์ที่แตกต่างกันในสองบรรทัดที่เกี่ยวข้องกับเปอร์เซ็นต์การเติมที่พิมพ์ แต่นั่นอาจเป็นการปัดเศษข้อผิดพลาด
plocks

1
@DevanLoper ขออภัยเป็นข้อผิดพลาดของฉันเปอร์เซ็นต์ถูกนำมาจากการวนซ้ำก่อนหน้านี้ ฉันจะแก้ไขเร็ว ๆ นี้
2846289

1
แก้ไขข้อผิดพลาด + บางส่วนถูกโยนทิ้งไป ผลการทดสอบตรงกับที่มาจากไซต์ที่ลิงก์ ในทางเทคนิคแล้ว 11 รอบวิ่ง แต่ไม่มีการตรวจสอบหรือใช้รอบสุดท้าย มันคือทั้งหมดที่กระชับ ฉันวางห่วงที่จะหมดสภาพในการเริ่มต้นที่จะจับ1 \n oการป้อนข้อมูล
2846289

3

C # - 1164 ตัวอักษร

นี่คือการเข้าร่วมครั้งแรกของฉันในการเขียนโค้ดกอล์ฟดังนั้นโปรดทำตาม ;-)

ฉันรู้ว่าฉันอยู่ไกลจากผลลัพธ์ที่ดีที่สุด - น่าทึ่งจริงๆ!

แต่ฉันคิดว่าฉันจะแบ่งปันวิธีแก้ปัญหาของฉันใน C # ต่อไป

using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Net;class Program{static void Main(string[] args){new WebClient().DownloadFile("http://mc.capgemini.de/challenge/in.txt",@"D:\in.txt");var a=File.ReadAllLines(@"D:\in.txt");int l=0;while(l<a.Length){int n=Int32.Parse(a[l]);var b=a.Skip(l+1).Take(n).ToArray();var f=new List<string[]>{b};var d=0;string g=null;while(d<10){var s=f.Last();if(s.All(e=>e.All(c=>c=='o'))){g="empty";break;}var h=new string[n];for(int r=0;r<n;r++){var k="";for(int c=0;c<b[r].Length;c++){int x=0;try{if(s[r][c-1]=='x')x++;}catch{}try{if(s[r][c+1]=='x')x++;}catch{}try{if(s[r-1][c]=='x')x++;}catch{}try{if(s[r+1][c]=='x')x++;}catch{}k+=((x%2)==1)?'x':'o';}h[r]=k;}d++;f.Add(h);var w=false;for(int i=0;i<f.Count-1;i++){var m=f[i];if (!h.Where((t,y)=>t!=m[y]).Any())w=true;}if(w){g="repetition";break;}}if(d==10&&g==null)g="giveup";File.AppendAllLines(@"D:\out.txt",new[]{string.Format("Round {0}: {1}, {2} percent maximum-fill",d,g,f.Select(z=>{int t=0;int x=0;foreach(var c in z.SelectMany(s=>s)){t++;if(c=='x')x++;}return(int)Math.Floor((double)x/t*100);}).Concat(new[]{0}).Max())});l=l+n+1;}}}

คำสั่งที่ใช้แล้วนับ 97 ตัวอักษรอยู่แล้ว - ดังนั้นฉันคิดว่ามันคงเป็นเรื่องยากที่จะบรรลุส่วนที่เหลือภายในตัวละครน้อยกว่า 200 ตัว

มันเป็นวิธีการทำซ้ำอย่างเป็นธรรมใช้ประโยชน์จาก LINQ ในหลายสถานที่ ฉันยังรวมการดาวน์โหลดไฟล์อินพุตและการเขียนไฟล์เอาต์พุตลงในโค้ด

นี่คือหนึ่งในรุ่นที่อ่านได้น้อยมาก:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;

class Program
{
    static void Main(string[] args)
    {
        // Download the file
        new WebClient().DownloadFile("http://mc.capgemini.de/challenge/in.txt", @"D:\in.txt");
        // Read of lines of downloaded file
        var a = File.ReadAllLines(@"D:\in.txt");
        // Line index in input file
        int l = 0;
        while (l < a.Length)
        {
            // Parse number of rows to take
            int n = Int32.Parse(a[l]);

            // Take the n rows
            var b = a.Skip(l + 1).Take(n).ToArray();
            var f = new List<string[]> { b };
            var d = 0;
            string g = null;
            while (d < 10)
            {
                // Last state consists only of o's? -> 
                var s = f.Last();
                if (s.All(e => e.All(c => c == 'o')))
                {
                    g = "empty";
                    break;
                }
                // In h we will build up the new state
                var h = new string[n];
                // Loop through all rows of initial state
                for (int r = 0; r < n; r++)
                {
                    // This is our new row we will build up for the current state
                    var k = "";
                    // Count number of orthogonal adjacent x's
                    // And catch potential OutOfRangeExceptions
                    for (int c = 0; c < b[r].Length; c++)
                    {
                        int x = 0;
                        try { if (s[r][c - 1] == 'x') x++; }
                        catch { }
                        try { if (s[r][c + 1] == 'x') x++; }
                        catch { }
                        try { if (s[r - 1][c] == 'x') x++; }
                        catch { }
                        try { if (s[r + 1][c] == 'x') x++; }
                        catch { }
                        // Is number of adjacent x's odd? -> character will be 'x'
                        // otherwise -> 'o'
                        k += ((x % 2) == 1) ? 'x' : 'o';
                    }
                    // Add the new row to the current state
                    h[r] = k;
                }
                // Increase round count
                d++;
                // Add the new state to our state collection
                f.Add(h);
                // Now check, whether it is a repetition by comparing the last state (h) with all other states
                bool w = false;
                for (int i = 0; i < f.Count - 1; i++)
                {
                    var m = f[i];
                    if (!h.Where((t, y) => t != m[y]).Any())
                        w = true;
                }
                if (w)
                {
                    g = "repetition";
                    break;
                }
            }
            // Check whether we reached maximum AND the last round wasn't a repetition
            if (d == 10 && g == null)
                g = "giveup";
            // Now we append the final output row to our text file
            File.AppendAllLines(@"D:\out.txt",
                new[]
                    {
                        string.Format("Round {0}: {1}, {2} percent maximum-fill",
                        d,
                        g,
                        // Here we select all rates of x's per state
                        // and then grab the maximum of those rates
                        f.Select(z =>
                            {
                                int t=0;
                                int x=0;
                                foreach (char c in z.SelectMany(s => s))
                                {
                                    t++;
                                    if(c=='x')
                                        x++;
                                }
                                return (int) Math.Floor((double) x / t *100);
                            }).Concat(new[] {0}).Max())
                    });
            // finally we shift our index to the next (expected) number n in the input file
            l = l + n + 1;
        }
    }
}

1
สั้น, สั้น, โซลูชันของ Ben คุณได้สร้างเช่นไมโครของการคิดการแก้ปัญหาใน C # แง่ a ...
พอล Facklam

2

J - 275 ตัวอักษร

โอ้ข้อกำหนดของ I / O ทั้งหมดเหล่านี้! คะแนนขนาดใหญ่ที่น่าละอายสำหรับเจในที่สุด รับอินพุตบน STDIN ด้วยการขึ้นบรรทัดใหม่และสมมติว่าไม่มี carriage return ( \r) ในอินพุต นี่คือผลลัพธ์ของการนำไปใช้กับไฟล์อินพุตตัวอย่างในคำถาม

stdout;,&LF&.>}:(".@{~&0(('Round ',":@(#->/@t),': ',(empty`repetition`giveup{::~2<.#.@t=.11&=@#,0={:),', ',' percent maximum-fill',~0":>./)@(100*1&=%&(+/"1)_&~:)@,.@(a=:(a@,`[@.(e.~+.10<#@[)(_*_&=)+[:~:/((,-)(,:|.)0 1)|.!.0=&1){:)@,:@('ox'&i.^_:)@{.;$: ::]@}.)}.)];._2[1!:1]3

Ungolfed: (ฉันอาจเพิ่มคำอธิบายที่ละเอียดกว่าและเป็นมิตรกับ J-newbie ในภายหลัง)

input   =: ];._2 [ 1!:1]3
convert =: 'ox'&i. ^ _:               NB. 'x'=>1  'o'=>0  else=>infinity
spread  =: ((,-)(,:|.)0 1) |.!.0 =&1  NB. x spreading outwards
cover   =: (_*_&=) + [: ~:/ spread    NB. collecting x`s and removing tiles not on board
iterate =: (iterate@, ` [ @. (e.~ +. 10<#@[) cover) {:
percent =: 100 * 1&= %&(+/"1) _&~:    NB. percentage of x at each step
max     =: 0 ": >./
stat    =: 11&=@# , 0={:              NB. information about the simulation
ending  =: empty`repetition`giveup {::~ 2 <. #.@stat   NB. how simulation ended
round   =: ": @ (# - >/@stat)         NB. round number
format  =: 'Round ', round, ': ', ending, ', ', ' percent maximum-fill',~ max
evolvex =: format @ percent@,. @ iterate@,: @ convert
joinln  =: ,&LF &.>
nlines  =: ". @ {~&0
remain  =: }.
stdout ; joinln }: (nlines (evolvex@{. ; $: ::]@}.) remain) input

$:ส่วนหนึ่งที่ทำให้ recurse ตัวหลักมากกว่าการป้อนข้อมูล (รูปแบบที่สะดวกชะมัดสำหรับ J เพื่อแยก) ใช้@ห่วงโซ่เดซี่มากกว่าแต่ละส่วนnlinesค้นหาจำนวนบรรทัดสำหรับบอร์ดถัดไป

การกระทำในแต่ละกระดาน ( evolvex) นั้นเรียบร้อย: iterate(เรียกว่าaในกอล์ฟ) สร้างรายการของการจำลองซ้ำแต่ละครั้งจนกว่าเราจะตีอะไรบางอย่างที่เห็นมาก่อนหรือหลายก้าวเกินไป จากนั้นpercent@,.คำนวณเปอร์เซ็นต์ของสี่เหลี่ยมที่เติมในแต่ละผลลัพธ์แล้วformatเรียกใช้สถิติบางอย่าง ( statเรียกว่าtในสนามกอล์ฟ) เพื่อหาว่าการจำลองสิ้นสุดลงอย่างไร

ในที่สุด}:ดูแลขยะบางส่วนก่อนที่จะ; joinlnรวมบอร์ดทั้งหมดออกเป็นสายอักขระที่คั่นด้วยหนึ่งบรรทัดใหม่


สวัสดี algorithmshark คุณช่วยกรุณาให้คำแนะนำเกี่ยวกับวิธีการเริ่มสคริปต์ของคุณจากบรรทัดคำสั่งด้วยไฟล์. txt เป็นพารามิเตอร์ป้อนเข้าหรือไม่ ขอบคุณ!
plocks

1
@DevanLoper ที่เตือนฉันฉันลืมที่จะส่งออกไปยัง stdout; เพิ่มการแก้ไขนั้น jconsole golf.ijs < input.txtมันควรจะทำงานวิธีมาตรฐานในขณะนี้:
algorithmshark

ขอบคุณสำหรับข้อมูล แต่ก็ยังไม่ได้พิมพ์ผลลัพธ์ใด ๆ สำหรับฉันแม้ว่ารหัสของคุณจะเปลี่ยนไป
plocks

@DevanLoper ปัญหาดูเหมือนจะใช้vเป็นชื่อของฉันด้วยเหตุผลใดก็ตามที่ไม่ได้รับอนุญาตในสคริปต์ (ฉันเรียกใช้ข้อมูลโค้ดใน REPL) การเปลี่ยนให้aดูเหมือนว่าใช้งานได้
algorithmshark

@algoshark มันอาจเป็นฉันก็ได้ แต่ฉันก็ยังไม่สามารถพิมพ์อะไรออกมาได้เลย
plocks
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.