ตรวจจับข้อความสี่เหลี่ยมด้วยรหัสสี่เหลี่ยม


19

กำหนดสตริงของข้อความ ASCII ที่พิมพ์ได้ (รวมถึงการขึ้นบรรทัดใหม่และช่องว่าง) ที่มีอักขระอย่างน้อยหนึ่งตัวที่ไม่ใช่การขึ้นบรรทัดใหม่หรือเว้นวรรคให้ส่งออกค่าความจริงหากสตริงเป็นรูปสี่เหลี่ยมผืนผ้าและค่าเท็จ นอกจากนี้รหัสแหล่งที่มาสำหรับการแก้ปัญหาของคุณจะต้องเป็นรูปสี่เหลี่ยมผืนผ้า

สตริงเป็นรูปสี่เหลี่ยมหากตรงตามเงื่อนไขต่อไปนี้ทั้งหมด:

  1. บรรทัดแรกและบรรทัดสุดท้ายไม่มีช่องว่าง
  2. อักขระตัวแรกและตัวสุดท้ายของแต่ละบรรทัดไม่ใช่ช่องว่าง
  3. ทุกบรรทัดมีจำนวนอักขระเท่ากัน

ตัวอย่างเช่นข้อความต่อไปนี้เป็นรูปสี่เหลี่ยมผืนผ้า:

abcd
e fg
hijk

อย่างไรก็ตามข้อความนี้ไม่ใช่รูปสี่เหลี่ยมผืนผ้า (ต้องการ # 3):

1234
567
8900

กรณีทดสอบ

Truthy:

sdghajksfg
asdf
jkl;
qwerty
u i op
zxcvbn
1234
5  6
7890
abcd
e fg
hijk

Falsey:

a b c
123
456
7 9
12
345
qwerty
 uiop
zxcvnm
1234
567
8900

นี่คือดังนั้นทางออกที่สั้นที่สุดในหน่วยไบต์ชนะ



2
ที่เกี่ยวข้อง
AdmBorkBork

9
ดังนั้นสายการบินที่ไม่มีช่องว่างใด ๆ เป็นการส่งที่ถูกต้องใช่ไหม
Arnauld


1
เราสามารถรับอินพุตเป็นอาร์เรย์ของสตริงหนึ่งรายการสำหรับแต่ละบรรทัดได้หรือไม่? หรือเราจะต้องป้อนสตริงยาวเดี่ยวที่มีตัวแบ่งบรรทัด?
BradC

คำตอบ:


12

C (gcc) , 127 125 124 118 ไบต์

  • ที่บันทึกไว้ไบต์ที่สองโดยการเล่นกอล์ฟไปr*=!e&(!t|t==c); (กอล์ฟนี้เป็นแรงบันดาลใจสำหรับเคล็ดลับ C ล่าสุดของฉันที่ตอบกลับการตั้งค่าสถานะ Inverse )r>>=e||t&&t-c;
  • บันทึกไบต์โดยการเล่นกอล์ฟไป*(_-2)_[~1]
  • ที่บันทึกไว้หกไบต์โดยการเล่นกอล์ฟ*_++-10||(...)ที่จะ*_++<11?...:0ต้องใช้ตัวยึดเป็นศูนย์...:0(ซึ่งไม่ได้ถูกใช้อย่างสร้างสรรค์) เพื่อกอล์ฟc++ที่เพิ่มขึ้น กอล์ฟเหล่านั้นอนุญาตให้ทำการวนซ้ำอีกครั้ง
  • เมื่อสามารถใช้ค่าเท็จหลายค่าอาจเป็นไปได้ที่114 ไบต์
r,e,c,t;_(char*_){for(r=1,t=c=0;*_;*_++<11?r*=(t||(t=c,!e))&*_>32&_[~1]>32&t==c,c=e=0:c++)*_-32||(e=1);r>>=e||t&&t-c;}

ลองออนไลน์!

เลย์เอาต์แหล่งที่มาเพื่อให้ได้สี่เหลี่ยมผืนผ้าที่สูงขึ้น

คำอธิบาย

ข้อมูลต่อไปนี้อธิบายถึงเวอร์ชั่นยาว 124 ไบต์

r,e,c,t;_(char*_){     // `r` is the boolean result flag, `e` a boolean flag if the current line contains
                       //  a space, `t` the first line's width, `c` the current line's current width
 for(r=1,t=c=0;*_;c++) // initialize, loop through entire string
  *_-32||              // if the current char is a space,
   (e=1),              //  the current line contains a space
  *_++-10||            // if the current char is a newline (char pointer `_` now incremented)
   (r*=(t||(t=c,!e))   // if t is not yet set, the current line is the first line; set it
                       //  to this line's length, check that no spaces where found
    &*_>32             // the next line's first char should not be a space
    &_[~1]>32          // this line's last char should not have been a space
    &t==c,c=~0,e=0);   // the line lengths should match, reset `c` and `e` to zero
                       //  (`~0 == -1`, countering the loop's increment of `c`)
 r>>=e||t&&t-c;}       // return boolean flag, check that the last line does not contain spaces,
                       //  there was either no newline or line lengths match
                       //  (here) equivalent to `r*=!e&(!t|t==c)`

ลองออนไลน์!


10
+1 สำหรับr,e,c,t
Magic Octopus Urn

4

Java 10, 214 176 169 152 144 139 ไบต์

s->{String[]a=s.split("\n")
;int r=1,i=0,R=a.length;for
(;i<R;i++)if(i<1|i>R-2?a[i]
.contains(" "):a[i].trim( )
!=a[i])r=0;return-r<0;}////

-5 ไบต์ขอบคุณที่@Neil

ใช้String[]aแทนvar a; return-r<0;แทนreturn r>0;; และเพิ่มความคิดเห็น//ที่ส่วนท้ายสุดดังนั้นจึงไม่มีช่องว่างในแถวแรกและแถวสุดท้าย

โปรดทราบว่าสี่เหลี่ยมนี้สั้นกว่าอินพุตบรรทัดเดียวเพราะint r=1,...;ควรแทนที่ด้วยint[]v{1,...};และการใช้จำนวนเต็มทั้งหมดจะกลายเป็นv[n](โดยที่nคือดัชนีของตัวแปรในอาร์เรย์v)

ลองออนไลน์

คำอธิบาย:

s->{                        // Method with String parameter and boolean return-type
  String[]a=s.split("\n");  //  Input split by new-lines
  int r=1,                  //  Result-integer, starting at 1
      i=0,                  //  Index `i`, starting at 0
      R=a.length;           //  Amount of rows `R`
  for(;i<R;i++)             //  Loop `i` over the rows
    if(i<1                  //   If it's the first row,
       |i>R-2?              //   or the last row:
        a[i].contains(" ")  //   And the current row contains a space
       :a[i].trim()!=a[i])  //   Or either column of the current row contains a space
      r=0;                  //    Set the result `r` to 0
   return-r<0;}             //  Return whether `r` is still 1
////                        // Comment to comply to the rules of the challenge

นี่คือโปรแกรมพื้นฐานเดียวกันกับช่องว่าง ( 128 126 ไบต์ ):

s->{var a=s.split("\n");int r=1,i=0,R=a.length;for(;i<R;i++)if(i<1|i>R-2?a[i].contains(" "):a[i].trim()!=a[i])r=0;return r>0;}

-2 ไบต์ขอบคุณที่@Neil

ลองออนไลน์



3

T-SQL, 237 207 ไบต์

SELECT(SELECT(IIF(max(len(v))=min(len(v)),1,0)*IIF(SUM(len(v+'x')-len
(trim(v))-1)=0,1,0))FROM t)*(SELECT(IIF(SUM(charindex(' ',v))=0,1,0))
FROM[t]WHERE[i]IN(SELECT(min(i))FROM[t]UNION(SELECT(max(i))FROM[t])))

เอาท์พุท 1 สำหรับรูปสี่เหลี่ยมมิฉะนั้น 0 ฉันต้องใช้อุปกรณ์เสริมและวงเล็บจำนวนมากเพื่อกำจัดช่องว่างฉันแน่ใจว่ามีพื้นที่กว้างขวางสำหรับการปรับปรุง

คำอธิบาย :

ต่อตัวเลือก I / O ของเราได้รับอนุญาตและชี้แจงในความคิดเห็นคำถามที่ใส่จะมาเป็นแถวแยกต่างหากในตารางที่มีอยู่ก่อนที เนื่องจากไม่มีการเรียงลำดับข้อมูลใน SQL โดยเนื้อแท้ตารางนั้นจึงมีฟิลด์ข้อมูลเฉพาะตัว "หมายเลขแถว" i :

CREATE TABLE t (i INT IDENTITY(1,1), v VARCHAR(999))

โดยทั่วไป SQL ของฉันจะทำการค้นหา 3 ชุดย่อยซึ่งแต่ละชุดจะส่งคืน0หรือ1ยึดตามเกณฑ์ 3 ข้อของรหัส "สี่เหลี่ยม" 3 ค่าเหล่านั้นจะถูกคูณเข้าด้วยกันเพียงส่งคืน1รหัสที่ตรงกับทั้ง 3

แก้ไข : รวมเกณฑ์ที่ 2 และ 3 ไว้ใน SELECT เดียวกันเพื่อประหยัดพื้นที่

SELECT(
SELECT(IIF(max(len(v))=min(len(v)),1,0)                  --All rows same length
      *IIF(SUM(len(v+'x')-len(trim(v))-1)=0,1,0))FROM t) --no leading or trailing spaces
*(SELECT(IIF(SUM(charindex(' ',v))=0,1,0))               --No spaces at all in
FROM[t]WHERE[i]IN(SELECT(min(i))FROM[t]                  --   first row or
            UNION(SELECT(max(i))FROM[t])))               --   last row

TRIM(v)ฟังก์ชั่นได้รับการสนับสนุนโดย SQL 2017 ขึ้นไปเท่านั้น รุ่นก่อนหน้านี้จะต้องใช้LTRIM(RTRIM(v))ซึ่งจะต้องมีการปรับสมดุลแถว

หนึ่งทราบสุ่มคือLEN()ฟังก์ชั่นใน SQL LEN('foo ') = 3ละเว้นช่องว่างต่อท้ายดังนั้น เพื่อให้ได้ความยาวที่ "จริง" คุณจะต้องใช้อักขระต่อท้ายจนต้องลบออกหนึ่งตัว: P


3

C ++, 199 183 181 175 ไบต์

ฟังก์ชันเทมเพลตนี้รับสายเป็นชุดของสตริง (ซึ่งอาจเป็นสตริงที่กว้าง) ส่งผ่านเป็นตัววนซ้ำคู่หนึ่ง

#include<algorithm>//
template<class I>bool
f(I a,I b){return!~+(
*a+b[-1]).find(' ')&&
std::all_of(a,b,[&a](
auto&s){return' '+-s.
back()&&s[0]-' '&&a->
size()==s.size();});}

ขอขอบคุณผู้ใช้งานผิดพลาดเพราะเตือนฉันถึงback()สมาชิกstd::stringและชี้ให้เห็นว่าnpos+1เป็นศูนย์

เทียบเท่าที่ไม่ดี

การเล่นกอล์ฟที่แท้จริงเพียงอย่างเดียวคือการต่อแถวแรกและบรรทัดสุดท้ายเข้าด้วยกันดังนั้นเราจึงสามารถแสดงเดี่ยวfindสำหรับช่องว่างในนั้น

#include <algorithm>
template<class It>
bool f(It a, It b)
{
    return (*a+b[-1]).find(' ') == a->npos
        && std::all_of(a, b,
                       [=](auto s) {
                           return s.back() != ' '
                               && s.front() != ' '
                               && s.size() == a->size(); });
}

โปรแกรมทดสอบ

#include <iostream>
#include <string>
#include <vector>
int expect(const std::vector<std::string>& v, bool expected)
{
    bool actual = f(v.begin(), v.end());
    if (actual == expected) return 0;
    std::cerr << "FAILED " << (expected ? "truthy" : "falsey") << " test\n";
    for (auto const& e: v)
        std::cerr << "  |" << e << "|\n";
    return 1;
}
int expect_true(const std::vector<std::string>& v) { return expect(v, true); }
int expect_false(const std::vector<std::string>& v) { return expect(v, false); }
int main()
{
    return
        // tests from the question
        + expect_true({"sdghajksfg"})
        + expect_true({"asdf", "jkl;",})
        + expect_true({"qwerty", "u i op", "zxcvbn",})
        + expect_true({"1234", "5  6", "7890",})
        + expect_true({"abcd", "e fg", "hijk",})
        + expect_false({"a b c",})
        + expect_false({"123", "456", "7 9",})
        + expect_false({"12", "345",})
        + expect_false({"qwerty", " uiop", "zxcvnm",})
        + expect_false({"1234", "567", "8900",})
        // extra tests for leading and trailing space
        + expect_false({"123", " 56", "789"})
        + expect_false({"123", "45 ", "789"})
        // the function source
        + expect_true({"#include<algorithm>//",
                       "template<class I>bool",
                       "f(I a,I b){return!~+(",
                       "*a+b[-1]).find(' ')&&",
                       "std::all_of(a,b,[&a](",
                       "auto&s){return' '+-s.",
                       "back()&&s[0]-' '&&a->",
                       "size()==s.size();});}",})
        ;
}

นี้สามารถแข็งแรงเล่นกอล์ฟต่อไปถึง 183 ไบต์ที่มีความกว้างสาย 22 ใช้.find(' ')+1==0และแทนs.back() *s.rbegin()
ผิดพลาด




2

Haskell , 79 ไบต์

g(x:r)=all((==(0<$x)).(0<$))r&&all(>='!')(x++last(x:r)++(head<$>r)++(last<$>r))

ลองออนไลน์! รับอินพุตเป็นรายการของบรรทัด

รูปแบบg(x:r)= ...ผูกบรรทัดแรกไปxและ (อาจจะเป็นที่ว่างเปล่า) rรายการของเส้นที่เหลือให้ จากนั้นall((==(0<$x)).(0<$))rตรวจสอบว่าทุกบรรทัดrมีความยาวเท่ากันx(ใช้เคล็ดลับนี้ )

ถ้าไม่เช่นนั้นจะเกิด&&การลัดวงจรและการFalseรวมกันมิฉะนั้นทางด้านขวามือจะถูกประเมิน มีสตริงที่สร้างซึ่งประกอบด้วยxสำหรับบรรทัดแรกlast(x:r)สำหรับบรรทัดสุดท้ายของr(หรือบรรทัดแรกอีกครั้งในกรณีที่rว่างเปล่า) และ(head<$>r)สำหรับแรกและ(last<$>r)สำหรับอักขระตัวสุดท้ายของแต่ละบรรทัด สำหรับสตริงนี้ให้all(>='!')ตรวจสอบว่าไม่มีช่องว่างใด ๆ (เราไม่สามารถใช้(>' ')เนื่องจากข้อ จำกัด ของรหัสที่มา)


ข้อผิดพลาดที่ "\ n \ n"
Angs

@Angs จับดี โชคดีที่ OP ชี้แจงว่าอินพุตcontains at least one character that is neither a newline nor a spaceซึ่งอนุญาตให้ดร็อปรายการเคสว่างได้
Laikoni

โอ้ดีไม่ได้สังเกตว่ามีการเพิ่ม
Angs

2

MATL , 13 ไบต์

ctgF6Lt&()32>

{'abc' 'de'}การป้อนข้อมูลเป็นอาร์เรย์ของสตริงในรูปแบบ

เอาท์พุทเป็นอาร์เรย์ที่มีคนเดียวซึ่งเป็นtruthyหรืออาร์เรย์ที่มีอย่างน้อยเป็นศูนย์ซึ่งเป็นfalsey

ลองออนไลน์! หรือตรวจสอบกรณีทดสอบทั้งหมดรวมถึงการทดสอบความจริง / ความเท็จ

คำอธิบาย

c       % Implicit input. Convert to char. This concatenates the
        % strings of the input cell array as rows of a rectangular
        % char array, right-padding with spaces as needed
tg      % Duplicate, convert to logical. Gives a logical array with
        % the same size containing true in all its entries
F       % Push false
6L      % Push the array [2, j-1], where j is the imaginary unit.
        % When used as an index, this is interpreted as 2:end-1
t       % Duplicate
&(      % Assignment indexing with 4 inputs: original array, new
        % value, two indexing arrays. This writes false at the inner
        % rectangle (2:end-1)×(2:end-1) of the logical array that
        % initially only contained true. This will be used as a
        % logical index (mask) into the rectangular char array
)       % Reference indexing. This selects the border of the char
        % array. The result is a column vector of chars
32>     % Is each entry greater than 32? (ASCII code for space)
        % Implicit display

11 ไบต์: cO6Lt&(32=~ ลองออนไลน์! เพียงลบส่วนที่ไม่ใช่ขอบออกแล้วตรวจสอบว่ามีช่องว่างหรือไม่
sundar - Reinstate Monica

@sundar ความคิดที่ดี! มันต่างกันมากพอโพสต์ด้วยตัวเอง
Luis Mendo

1
Nah cF6Lt&(32=~รู้สึกคล้ายกับคำตอบของคุณโดยเฉพาะอย่างยิ่งถ้าผมเขียนเป็น อย่าลังเลที่จะแก้ไขในหรือถ้าไม่เราก็สามารถทิ้งไว้ในความคิดเห็น
sundar - Reinstate Monica


1

Canvas , 17 15 ไบต์

4[↷K;}┐){SL]∑4≡

ลองที่นี่!

คำอธิบาย (ASCII-fied สำหรับ monospace):

4[↷K;}┐){SL]∑4=  full program; pushes the input to the stack.
4[   }           repeat 4 times
  ↷                rotate ToS clockwise. This also pads the input with spaces
   K;              take off the last line and put it below the item
      ┐          pop the remaining of the input (the center)
       )         and wrap the rest (the sides) in an array
        {  ]     map over those
         S         split on spaces - should result to one item in the array
          L        and get the length
            ∑    sum those lengths together
             4=  check if equal 4

4
ฉันพบว่ามันน่าขันที่ตัวอักษร UTF8 เหล่านี้ในแบบอักษรที่เหมือน monospace ให้ความรู้สึกว่ามีช่องว่างมากมายในแหล่งที่มา (อย่างน้อยพวกเขาทำในเบราว์เซอร์ของฉัน)
Arnauld

1
@Arnauld อักขระเต็มความกว้างทำเช่นนั้น และนั่นคือสาเหตุที่ฉันทำแบบอักษรให้ล่ามของฉันเพื่อทำให้พวกเขาสวยขึ้น: p
dzaima


1

สีแดง , 216 191 ไบต์

func[s][d:(length?(first(s:(split(s)"^/"))))sp:
func[a][none = find a" "]b: on foreach c s[b: b
and(d = length? c )and(c/1 <>" ")and(" "<> last
c)]res:(sp(first(s)))and(sp(last(s)))and(b)res]

ลองออนไลน์!

ฉันใส่วงเล็บจำนวนมากไม่จำเป็นในแถวแรกและแถวสุดท้าย


0

เยลลี่ขนาด 17 ไบต์

Ỵµ.ịЀ;ịɗẎ⁶e<L€E$

ลองออนไลน์!


@JonathanFrech Ah แก้ไขแล้ว > _>
Erik the Outgolfer

@MagicOctopusUrn Huh? คุณช่วยกรุณาลิงค์ไปยังอินพุตที่สิ่งนี้ทำงานไม่ถูกต้องได้ไหม?
Erik the Outgolfer

โอ้คุณไม่เรียกฉันออกไปเพราะDoes not seem to enforce equal line lengthสิ่งที่ฉันพูด
Magic Octopus Urn

ดูเหมือนจะใช้งานไม่ได้กับ" \n " ลองออนไลน์!
Angs

1
@Angs ลองอ้างมัน ดูเหมือนว่าไม่มีการแยกวิเคราะห์อะไรเลยถ้าคุณใส่แบบนั้น
Erik the Outgolfer

0

เยลลี่ 15 ไบต์

ใช้วิธีการที่พัฒนาโดย Mnemonic ใน (ปัจจุบัน - เนื่องจากความล้มเหลวของกรณีขอบ) ลบการส่ง Pyth (ถ้าตอนนี้ได้รับการแก้ไขแล้วให้ไปให้เครดิต !)

ỴµL€Eȧt€⁶ZUƊ4¡⁼

ลิงก์ monadic ยอมรับรายการของอักขระที่ส่งคืน 1 หรือ 0

ลองออนไลน์!

อย่างไร?

ỴµL€Eȧt€⁶ZUƊ4¡⁼ - Link: list of characters
Ỵ               - split at newlines (making a list of lists - the rows)
 µ              - start a new monadic chain, call that ROWS
  L€            - length of €ach row in ROWS
    E           - all equal? (an integer: 1 if so, otherwise 0)
            4¡  - repeat four times:
           Ɗ    -   last three links as a monad:
      t€⁶       -     trim spaces (⁶) from €ach row in current ROWS
         Z      -     transpose that result
          U     -     upend (reverse each new row)
     ȧ          - logical AND (0 if L€E was 0 else the result of the repeated transform)
              ⁼ - equal to X? (the integer 0 is not equal to any listy of characters)

@Mnemonic - Jelly-fied :)
Jonathan Allan

0

Japt , 22 ไบต์

คำตอบที่ไม่เข้ากันได้: มีข้อบกพร่องที่รู้จักใน Japtetที่การหมุนของอาร์เรย์สองมิติตัดผลลัพธ์ เนื่องจากข้อผิดพลาดนั้นรหัสด้านล่างใช้งานได้กับอินพุตที่เป็นรูปสี่เหลี่ยมเท่านั้น หากไม่มีข้อผิดพลาดรหัสด้านล่างควรทำงานอย่างถูกต้อง

e_ʶUÌÊéUeº4o)r_z)mx}U
e_                      // Check if every line in the input array
  ʶUÌÊ                 // has the same length as the last item.
       é               // Also,
               r_z)mx}U // check if rotating and trimming the input array
           º4o)         // four times
         Ue             // is equal to the input array.

รับอินพุตเป็นอาร์เรย์ของสตริง การใช้วงเล็บแทนช่องว่างทำให้ต้องการรหัสสี่เหลี่ยมค่อนข้างง่าย ลองได้ที่นี่


0

Ruby 2.5+, 63 ไบต์

->a{!a.uniq(&:size)[1]&&a.none?(/^\s|\s$/)&&!(a[0]+a[-1])[?\s]}

รับอินพุตเป็นอาร์เรย์ของสตริง ไม่มีลิงก์ทดสอบเนื่องจากเวอร์ชันของ TIO (2.4) เก่าเกินไปสำหรับอันนี้ แต่นี่เป็นรุ่นที่ยาวกว่าเล็กน้อย (69 ไบต์) สำหรับการทดสอบ:

->a{!a.uniq(&:size)[1]&&a.none?{|l|l=~/^\s|\s$/}&&!(a[0]+a[-1])[?\s]}

ลองออนไลน์!

ความแตกต่างคือตั้งแต่ 2.5 Ruby สนับสนุนการส่งผ่านรูปแบบ Regex โดยตรงไปยังall?, any?, none?เมธอดซึ่งช่วยเราสองสามไบต์ วิธีการนั้นค่อนข้างอธิบายตนเองเราทดสอบ:

  1. หากมีขนาดบรรทัดที่ไม่ซ้ำกันเพียง 1 รายการ
  2. หากมีช่องว่างใด ๆ ในขอบเขตของเส้น
  3. หากมีช่องว่างในบรรทัดแรกและบรรทัดสุดท้าย


0

C # (. NET Core) , 145 167 ไบต์

S[0].Length>1&&S[0].IndexOf
(" ") + S[ S.Count() - 1 ].
IndexOf(" ")<-1&Array.Find(
S,x=>x[0]==' '| x [x.Length
-1]  ==  ' '  | S[0].Length
!=x.Length)==null?11>0:0>1;

ลองออนไลน์!

S[0].Length>1&                                    // And if the lenght of the first argument is more than 1 char
Array.Find(                                       // Find a string in an array
    S,                                            // The array which will be searched in
    x=>                                           // For x as the current string from the array
    x.Length!=S[0].Length|                        // If the string lenght match not the first argument lenght
    x[0]==' '|                                    // Or if the string begins with a spacer
    x[x.Length-1]==' '                            // Or if the string ends with a spacer
)==null&                                          // And if there was no string found which matched the conditions
S[0].IndexOf(" ")+S[S.Count()-1].IndexOf(" ")<-1  // And if the first and last string doesn't have a spacer
?                                                 // If all above is true do
1>0                                               // Return True
:                                                 // Else
0>1                                               // Return False

ไม่มีช่องว่างในบรรทัดแรก
FrownyFrog

@FrownyFrog S[0].IndexOf(" ")กำลังค้นหาช่องว่างในบรรทัดแรกและS[S.Count()-1].IndexOf(" ")กำลังค้นหาในบรรทัดสุดท้าย หากมีพื้นที่ในบรรทัดแรกและครั้งสุดท้ายไม่เป็น -2 -2 < -1ซึ่งเป็นความจริงแล้ว
Hille

2
ฉันหมายถึงความท้าทายรหัสของคุณมีข้อ จำกัด เหมือนกันดังนั้นคุณจึงไม่มีช่องว่างในบรรทัดแรก
FrownyFrog

1
รหัสของคุณจะต้องส่งคืนTrueเมื่อส่งผ่านไปยังโปรแกรมของคุณ มันเป็นข้อ จำกัด เพิ่มเติมในความท้าทายนี้
FrownyFrog

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