Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Perl, (削除) 93+2=95 (削除ここまで)(削除) 90+1=91 (削除ここまで) 83+1= 84 bytes

Perl, (削除) 93+2=95 (削除ここまで)(削除) 90+1=91 (削除ここまで) 83+1= 84 bytes

Apparently the output doesn't need comma-separating

Invoke with perl -n chair.pl chairInput (1B penalty for the flag).

END{print$b,2+$u-$o,$a,$.-$b-2,$o-1}$u+=s/_//g;$o+=s/O//g;s/^\|//&&$b++&&/\|/&&$a++

Ungolfed:

END{ # Put the END block first to save 1 ;
 print
 $b, 
 2+$u-$o,
 $a,
 $.-$b-2, # $. is the number of lines total
 $o-1
}
$u+=s/_//g; # count _s incrementally
$o+=s/O//g; # count Os incrementally
s/^\|// && $b++ # it's backrest if it starts with |
 && /\|/ && $a++ # and it's armrest if it has another one

Previous version:

##Previous version: InvokeInvoke with perl -0n chair.pl < chairInput

s/^\|//&&$b++?/\|/&&$a++:$h++for split"
",$_;,ドル=",";print$b,2+s/_//g-($o=s/O//g),$a,$h-3,$o-1

Explanation:

s/^\|// && $back++ # the backrest is all lines starting with |
 ? /\|/ && $arm++ # the armrest is all of those lines with another |
 : $height++ # otherwise it counts for the seat height
 for split"
",$_; # literal newline for 1 byte saved
,ドル=","; # output separator
print
 $back,
 2+s/_//g-($o_count=s/O//g), # you can find the seat size
 # from the different between the number
 # of Os and _s
 $arm,
 $height-3,
 $o_count-1

#Perl, (削除) 93+2=95 (削除ここまで)(削除) 90+1=91 (削除ここまで) 83+1= 84 bytes

Apparently the output doesn't need comma-separating

Invoke with perl -n chair.pl chairInput (1B penalty for the flag).

END{print$b,2+$u-$o,$a,$.-$b-2,$o-1}$u+=s/_//g;$o+=s/O//g;s/^\|//&&$b++&&/\|/&&$a++

Ungolfed:

END{ # Put the END block first to save 1 ;
 print
 $b, 
 2+$u-$o,
 $a,
 $.-$b-2, # $. is the number of lines total
 $o-1
}
$u+=s/_//g; # count _s incrementally
$o+=s/O//g; # count Os incrementally
s/^\|// && $b++ # it's backrest if it starts with |
 && /\|/ && $a++ # and it's armrest if it has another one

##Previous version: Invoke with perl -0n chair.pl < chairInput

s/^\|//&&$b++?/\|/&&$a++:$h++for split"
",$_;,ドル=",";print$b,2+s/_//g-($o=s/O//g),$a,$h-3,$o-1

Explanation:

s/^\|// && $back++ # the backrest is all lines starting with |
 ? /\|/ && $arm++ # the armrest is all of those lines with another |
 : $height++ # otherwise it counts for the seat height
 for split"
",$_; # literal newline for 1 byte saved
,ドル=","; # output separator
print
 $back,
 2+s/_//g-($o_count=s/O//g), # you can find the seat size
 # from the different between the number
 # of Os and _s
 $arm,
 $height-3,
 $o_count-1

Perl, (削除) 93+2=95 (削除ここまで)(削除) 90+1=91 (削除ここまで) 83+1= 84 bytes

Apparently the output doesn't need comma-separating

Invoke with perl -n chair.pl chairInput (1B penalty for the flag).

END{print$b,2+$u-$o,$a,$.-$b-2,$o-1}$u+=s/_//g;$o+=s/O//g;s/^\|//&&$b++&&/\|/&&$a++

Ungolfed:

END{ # Put the END block first to save 1 ;
 print
 $b, 
 2+$u-$o,
 $a,
 $.-$b-2, # $. is the number of lines total
 $o-1
}
$u+=s/_//g; # count _s incrementally
$o+=s/O//g; # count Os incrementally
s/^\|// && $b++ # it's backrest if it starts with |
 && /\|/ && $a++ # and it's armrest if it has another one

Previous version:

Invoke with perl -0n chair.pl < chairInput

s/^\|//&&$b++?/\|/&&$a++:$h++for split"
",$_;,ドル=",";print$b,2+s/_//g-($o=s/O//g),$a,$h-3,$o-1

Explanation:

s/^\|// && $back++ # the backrest is all lines starting with |
 ? /\|/ && $arm++ # the armrest is all of those lines with another |
 : $height++ # otherwise it counts for the seat height
 for split"
",$_; # literal newline for 1 byte saved
,ドル=","; # output separator
print
 $back,
 2+s/_//g-($o_count=s/O//g), # you can find the seat size
 # from the different between the number
 # of Os and _s
 $arm,
 $height-3,
 $o_count-1
added 21 characters in body
Source Link
alyx-brett
  • 1.6k
  • 8
  • 14

#Perl, (削除) 93+2=95 (削除ここまで) 90+1 = 91(削除) 90+1=91 (削除ここまで) 83+1= 84 bytes

Apparently the output doesn't need comma-separating

Invoke with perl -n chair.pl chairInput (1B penalty for the flag).

END{,ドル=",";print$bprint$b,2+$u-$o,$a,$.-$b-2,$o-1}$u+=s/_//g;$o+=s/O//g;s/^\|//&&$b++&&/\|/&&$a++

Ungolfed:

END{ # Put the END block first to save 1 ;
 ,ドル=","; # output field separator
 print
 $b, 
 2+$u-$o,
 $a,
 $.-$b-2, # $. is the number of lines total
 $o-1
}
$u+=s/_//g; # count _s incrementally
$o+=s/O//g; # count Os incrementally
s/^\|// && $b++ # it's backrest if it starts with |
 && /\|/ && $a++ # and it's armrest if it has another one

##Previous version: Invoke with perl -0n chair.pl < chairInput

s/^\|//&&$b++?/\|/&&$a++:$h++for split"
",$_;,ドル=",";print$b,2+s/_//g-($o=s/O//g),$a,$h-3,$o-1

Explanation:

s/^\|// && $back++ # the backrest is all lines starting with |
 ? /\|/ && $arm++ # the armrest is all of those lines with another |
 : $height++ # otherwise it counts for the seat height
 for split"
",$_; # literal newline for 1 byte saved
,ドル=","; # output separator
print
 $back,
 2+s/_//g-($o_count=s/O//g), # you can find the seat size
 # from the different between the number
 # of Os and _s
 $arm,
 $height-3,
 $o_count-1

#Perl, (削除) 93+2=95 (削除ここまで) 90+1 = 91 bytes

Invoke with perl -n chair.pl chairInput (1B penalty for the flag).

END{,ドル=",";print$b,2+$u-$o,$a,$.-$b-2,$o-1}$u+=s/_//g;$o+=s/O//g;s/^\|//&&$b++&&/\|/&&$a++

Ungolfed:

END{ # Put the END block first to save 1 ;
 ,ドル=","; # output field separator
 print
 $b, 
 2+$u-$o,
 $a,
 $.-$b-2, # $. is the number of lines total
 $o-1
}
$u+=s/_//g; # count _s incrementally
$o+=s/O//g; # count Os incrementally
s/^\|// && $b++ # it's backrest if it starts with |
 && /\|/ && $a++ # and it's armrest if it has another one

##Previous version: Invoke with perl -0n chair.pl < chairInput

s/^\|//&&$b++?/\|/&&$a++:$h++for split"
",$_;,ドル=",";print$b,2+s/_//g-($o=s/O//g),$a,$h-3,$o-1

Explanation:

s/^\|// && $back++ # the backrest is all lines starting with |
 ? /\|/ && $arm++ # the armrest is all of those lines with another |
 : $height++ # otherwise it counts for the seat height
 for split"
",$_; # literal newline for 1 byte saved
,ドル=","; # output separator
print
 $back,
 2+s/_//g-($o_count=s/O//g), # you can find the seat size
 # from the different between the number
 # of Os and _s
 $arm,
 $height-3,
 $o_count-1

#Perl, (削除) 93+2=95 (削除ここまで) (削除) 90+1=91 (削除ここまで) 83+1= 84 bytes

Apparently the output doesn't need comma-separating

Invoke with perl -n chair.pl chairInput (1B penalty for the flag).

END{print$b,2+$u-$o,$a,$.-$b-2,$o-1}$u+=s/_//g;$o+=s/O//g;s/^\|//&&$b++&&/\|/&&$a++

Ungolfed:

END{ # Put the END block first to save 1 ;
 print
 $b, 
 2+$u-$o,
 $a,
 $.-$b-2, # $. is the number of lines total
 $o-1
}
$u+=s/_//g; # count _s incrementally
$o+=s/O//g; # count Os incrementally
s/^\|// && $b++ # it's backrest if it starts with |
 && /\|/ && $a++ # and it's armrest if it has another one

##Previous version: Invoke with perl -0n chair.pl < chairInput

s/^\|//&&$b++?/\|/&&$a++:$h++for split"
",$_;,ドル=",";print$b,2+s/_//g-($o=s/O//g),$a,$h-3,$o-1

Explanation:

s/^\|// && $back++ # the backrest is all lines starting with |
 ? /\|/ && $arm++ # the armrest is all of those lines with another |
 : $height++ # otherwise it counts for the seat height
 for split"
",$_; # literal newline for 1 byte saved
,ドル=","; # output separator
print
 $back,
 2+s/_//g-($o_count=s/O//g), # you can find the seat size
 # from the different between the number
 # of Os and _s
 $arm,
 $height-3,
 $o_count-1
added 7 characters in body
Source Link
alyx-brett
  • 1.6k
  • 8
  • 14

#Perl, (削除) 93+2=95 (削除ここまで) 90+1=91B90+1 = 91 bytes

Invoke with perl -n chair.pl chairInput (1B penalty for the flag).

END{,ドル=",";print$b,2+$u-$o,$a,$.-$b-2,$o-1}$u+=s/_//g;$o+=s/O//g;s/^\|//&&$b++&&/\|/&&$a++

Ungolfed:

END{ # Put the END block first to save 1 ;
 ,ドル=","; # output field separator
 print
 $b, 
 2+$u-$o,
 $a,
 $.-$b-2, # $. is the number of lines total
 $o-1
}
$u+=s/_//g; # count _s incrementally
$o+=s/O//g; # count Os incrementally
s/^\|// && $b++ # it's backrest if it starts with |
 && /\|/ && $a++ # and it's armrest if it has another one

##Previous version: Invoke with perl -0n chair.pl < chairInput

s/^\|//&&$b++?/\|/&&$a++:$h++for split"
",$_;,ドル=",";print$b,2+s/_//g-($o=s/O//g),$a,$h-3,$o-1

Explanation:

s/^\|// && $back++ # the backrest is all lines starting with |
 ? /\|/ && $arm++ # the armrest is all of those lines with another |
 : $height++ # otherwise it counts for the seat height
 for split"
",$_; # literal newline for 1 byte saved
,ドル=","; # output separator
print
 $back,
 2+s/_//g-($o_count=s/O//g), # you can find the seat size
 # from the different between the number
 # of Os and _s
 $arm,
 $height-3,
 $o_count-1

#Perl, (削除) 93+2=95 (削除ここまで) 90+1=91B

Invoke with perl -n chair.pl chairInput (1B penalty for the flag).

END{,ドル=",";print$b,2+$u-$o,$a,$.-$b-2,$o-1}$u+=s/_//g;$o+=s/O//g;s/^\|//&&$b++&&/\|/&&$a++

Ungolfed:

END{ # Put the END block first to save 1 ;
 ,ドル=","; # output field separator
 print
 $b, 
 2+$u-$o,
 $a,
 $.-$b-2, # $. is the number of lines total
 $o-1
}
$u+=s/_//g; # count _s incrementally
$o+=s/O//g; # count Os incrementally
s/^\|// && $b++ # it's backrest if it starts with |
 && /\|/ && $a++ # and it's armrest if it has another one

##Previous version: Invoke with perl -0n chair.pl < chairInput

s/^\|//&&$b++?/\|/&&$a++:$h++for split"
",$_;,ドル=",";print$b,2+s/_//g-($o=s/O//g),$a,$h-3,$o-1

Explanation:

s/^\|// && $back++ # the backrest is all lines starting with |
 ? /\|/ && $arm++ # the armrest is all of those lines with another |
 : $height++ # otherwise it counts for the seat height
 for split"
",$_; # literal newline for 1 byte saved
,ドル=","; # output separator
print
 $back,
 2+s/_//g-($o_count=s/O//g), # you can find the seat size
 # from the different between the number
 # of Os and _s
 $arm,
 $height-3,
 $o_count-1

#Perl, (削除) 93+2=95 (削除ここまで) 90+1 = 91 bytes

Invoke with perl -n chair.pl chairInput (1B penalty for the flag).

END{,ドル=",";print$b,2+$u-$o,$a,$.-$b-2,$o-1}$u+=s/_//g;$o+=s/O//g;s/^\|//&&$b++&&/\|/&&$a++

Ungolfed:

END{ # Put the END block first to save 1 ;
 ,ドル=","; # output field separator
 print
 $b, 
 2+$u-$o,
 $a,
 $.-$b-2, # $. is the number of lines total
 $o-1
}
$u+=s/_//g; # count _s incrementally
$o+=s/O//g; # count Os incrementally
s/^\|// && $b++ # it's backrest if it starts with |
 && /\|/ && $a++ # and it's armrest if it has another one

##Previous version: Invoke with perl -0n chair.pl < chairInput

s/^\|//&&$b++?/\|/&&$a++:$h++for split"
",$_;,ドル=",";print$b,2+s/_//g-($o=s/O//g),$a,$h-3,$o-1

Explanation:

s/^\|// && $back++ # the backrest is all lines starting with |
 ? /\|/ && $arm++ # the armrest is all of those lines with another |
 : $height++ # otherwise it counts for the seat height
 for split"
",$_; # literal newline for 1 byte saved
,ドル=","; # output separator
print
 $back,
 2+s/_//g-($o_count=s/O//g), # you can find the seat size
 # from the different between the number
 # of Os and _s
 $arm,
 $height-3,
 $o_count-1
Source Link
alyx-brett
  • 1.6k
  • 8
  • 14
Loading

AltStyle によって変換されたページ (->オリジナル) /