10

Jelly, 19 13 12 bytes OZ%3;ƲḂŒgẎ§Ṁ Try it online! Takes input as a list of lines/a character matrix First attempt, can probably be improved by a lot. Ports wasif's Vyxal answer for the conversion to 1/0 matrices, so make sure you drop them an upvote as well. -1 byte thanks to Jonathan Allan! How it works OZ%3;ƲḂŒgẎ§Ṁ - Main link. Takes a matrix M on the ...


9

JavaScript (ES10), 88 bytes Expects a matrix of ASCII codes. m=>Math.max(...m.map(r=>r.map(H=(v,x)=>[m.map(V=r=>V=r[x]%3%2*-~V),H=v%2*-~H])).flat(3)) Try it online! How? Given an ASCII code \$v\$, we use \$v\bmod 2\$ and \$(v\bmod 3)\bmod 2\$ to identify horizontal and vertical characters respectively. char. | code | % 2 | % 3 % 2 -------+------...


8

05AB1E, 9 bytes ø3%«É€γOZ Try it online! -2 thanks to @ovs Takes charcode matrix This takes inspiration from Arnauld answer: Modulo input matrix by 2 (Or is odd number) to get horizontal lines. (Run of 1) Take the input matrix again and transpose (to get the columns) then Modulo by 3 are odd numbers? (Vertical runs) Pair them, for each Group consecutive ...


7

Dyalog APL, 31 27 bytes {≢⍉↑↑⊆⍨¨(↓⍵∊'-+'),↓⍉⍵∊'|+'} -4 thanks to ovs. Try it online! Expects a matrix of characters. ⍵∊'-+' Turn - and + into 1s and other characters into 0s ↓ and split the matrix into individual rows. ⍵∊'|+' Take the original matrix, turn | and + into 1s, ...


5

05AB1E, 17 16 bytes …-+|ü2Iδå`ø«€γOà Input as a matrix of characters. Port of @cairdCoinheringaahing's Jelly answer, so make sure to upvote him as well. Try it online or verify all test cases. Explanation: …-+| # Push string "-+|" ü2 # Create overlapping pairs of this string: ["-+","+|"] δ ...


4

GolfScript, 52 bytes n/.zip]"-":a;{{{.a"+"+\?-1>*}%"ø"%{,}/}/"|":a;}%$-1= Try it online! Explanation: n/. split input on newline .zip duplicate and zip(transpose rows and columns) the copy ] put them in an array "-":a; has "-" for first copy and "|" for the zipped copy { ...


4

Dyalog APL, 16 14 bytes Solution - Takes in number of lines as input from user, and returns a string of diagonal line. ' \'[1+∘.=⍨⍳⎕] Explanation ⎕ ⍝ ⎕ takes input from the user (number of lines) ⍝ In the below explanation, I have assumed ⎕ = 9 as input ⍳⎕ ⍝ 1 to 9 : [1,2,3,4,5,6,7,8,9] ∘.= ⍝ Outer Product with ...


4

R, 87 86 bytes Or R>=4.1, 72 bytes by replacing two function appearances with \s. -1 byte thanks to @Dominic van Essen. function(s,b=function(x,r=rle(x))max(r$l[r$v==1]))max(apply(s%%2,1,b),apply(s%%3,2,b)) Try it online! That turned out shorter than I expected. Takes input as matrix of character codes. Explanation function(s, # function takes s as ...


4

Java (JDK), 192 175 169 167 bytes n->{int i,r,l=0,b,h[]=new int[n[0].length];for(var a:n)for(r=i=0;i<a.length;i++){l=(r=(b=a[i])==45|b==43?r+1:0)>l?r:l;l=(h[i]=b>45|b==43?h[i]+1:0)>l?h[i]:l;}return l;} Try it online! -6 thanks to Kevin Cruijssen; -2 thanks to Celingcat!


3

Python 3, 114 109 bytes -5 bytes thanx to Alex Waygood lambda i,j=''.join:max(map(len,g('[-+]+',i)+g('[|+]+',j(map(j,zip(*i.split('\n'))))))) import re g=re.findall Try it online!


2

Mathematica, 39 bytes We save some bytes by using an infix Array over Range, Table over StringRepeat, and Echo over Print. We also cut it down to 33 bytes in TIO, because user input for Mathematica wasn't working :) Echo[Table[" ",#]<>"\\"]&~Array~Input[] Try it online!


2

K (ngn/k), 17 bytes {"# "x*/:x#:!x-1} Try it online! Or tacit, 20 bytes: " #"@|/(+|:)\^ :':=: "# "@&/(+|:)\=':1|=: / similar Try it online!


2

Zsh, 90 bytes try it online! for i ({1..$#1}){for j ({1..$#1}){((i==j||j+i==$#1+1))&&z=${1[j]}||z=\ printf $z\ } echo}


2

Pip, 26 bytes MX#*:(J*ZgR'-sALgR'|s)Jn^w Try it online! (Uses the -r flag to take input as lines of stdin, but would also work without the flag if input lines were given as command-line arguments.) Explanation MX#*:(J*ZgR'-sALgR'|s)Jn^w g is lines of input; s is space; n is newline; w is regex matching ...


2

Retina, 74 bytes Lw$`([-+]+)|[|+]((?<=(.)*.).*¶(?<-3>.)*(?(3)^)[|+])* $1¶_$#2* %C`. N^` 0G` Try it online! Explanation: Lw`([-+]+)|[|+]((?<=(.)*.).*¶(?<-3>.)*(?(3)^)[|+])* List all overlapping matches of either horizontal or vertical lines. A .NET balancing group is used to ensure that all of the characters in the vertical line are in the ...


2

C++ (gcc), 124 bytes int f(char*a){char*b=a,*c=a,l=0,h=0;for(;*a;++a)*a%2?l=l>++h?l:h:h=0,*a>10?*a%5>2?*a=0,l=l>++*c?l:*c:*c=0,++c:c=b;return l;} Try it online! This is my first time submitting a code here, so I'm open to any improvements. I don't think I used anything past C++98. The function takes a C-string as input and modifies it. ...


1

Charcoal, 35 bytes WS⊞υιIL⌈⁺Eυ⌈⪪⭆ι№-+λ0E§υ⁰⌈⪪⭆υ№|+§λκ0 Try it online! Link is to verbose version of code. Takes input as a list of newline-terminated strings. Explanation: WS⊞υι Input the strings into an array. IL⌈⁺ Output the length of the maximum line in either of the following: Eυ⌈⪪⭆ι№-+λ0 For each string in the array, replace each character with 1 if ...


1

Wolfram, 98 bytes Max[Length/@Flatten[Map[r|->SequenceCases[r,{#2..}],#]&@@@{{#,"-"|"+"},{Transpose@#,"|"|"+"}},2]]& Explanation Max[ Max of Length /@ Flatten[ Length of Map[r |-> ...


1

Perl 5, 94 bytes sub{$s=$_=pop;max((map y///c,/[-+]+/g),map{map$c=/[|+]/?$c+1:0,$s=~/^.{0,$_}(.?)/mg}0..y///c)} Try it online!


1

Ruby, 103 bytes ->m{eval"(m#{e=".map{|x|x+[' ']}.join.gsub('"}|',' ')+m.transpose#{e}-',' ')).split.map(&:length).max"} Try it online! takes a 2d array as input. We use eval to repeat e two times by interpolation. e= adds a column of spaces, joins and calls gsub.. to swap | or - with a space, we do it on both input and input ...


1

Vyxal G, 14 bytes ∷¹ǒ∷ÞT"ƛ0ZfĠv∑ Try it Online! -7 thanks to @AaronMiller and @emanresuA


1

Dyalog APL, 20 bytes {' #'[1+∘.∨⍨1⍵∊⍨⍳⍵]} Try it online! This is an improved version on my first attempt suggested by dzaima on the APL Orchard, so all credit goes to him. Takes an integer n as input. Using 5 as an example: ⍳⍵ integers from 1 to n 1 2 3 4 5 1⍵∊⍨ check whether each integer is 1 or n ...


1

Python 2, 47 bytes Works for all n greater than 1. lambda n:'#'*n+('#%*s'%(n,'#\n')*~-n)[n:]+'#'*n Try it online!


1

Jelly, 31 28 27 bytes Takes input as a list of lines. Incredibly slow. œẹⱮ⁾+#ŒP;€¥/Œ!ạƝ§ṀƊ€ṂƊÞḢL_2 Try it online! Comments (slightly outdated): ạƝ§=1Ạ -- helper function: is this a connected path? ạƝ -- element-wise absolute differences of adjacent coordinates §=1Ạ -- do all differences sum to 1? Ɱ⁾+# -- call with right arguments '+' and '#'...


1

Zsh, 86 bytes Port of the PHP solution. Try it online! sed 's|0|/_/_/_/|;s|1|\\/|g;s|2|\\_\\_\\_|'<<<' _ _ _ 0\ 01\ 011\ 2111 211 21' But the naïve approach only costs 1 extra, for 87 bytes ... <<<' _ _ _ /_/_/_/\ /_/_/_/\/\ /_/_/_/\/\/\ \_\_\_\/\/\/ \_\_\_\/\/ \_\_\_\/'


1

Self-modifying Brainfuck, 86 bytes Replace the ␀ with an actual null byte (0x00). <[.<]␀/\_\_\_\ /\/\_\_\_\ /\/\/\_\_\_\ \/\/\/_/_/_/ \/\/_/_/_/ \/_/_/_/ _ _ _ Try it online! Explanation Another literal output answer. <[.<] - Print the source code in reverse until a NULL byte is found. ␀ - ...


1

Vyxal j, 33 32 bytes -1 bytes thanks to Aaron Miller »\!¡øoΠ¥⅛831‟½ø↲p∇±₀WṀ»‛_ k/+τ7/ Explanation »\!¡øoΠ¥⅛831‟½ø↲p∇±₀WṀ» - Push a base-4 number containing the cube ‛_ k/+τ - Change to custom base, replacing the numbers with the symbols. 7/ - ...


Only top voted, non community-wiki answers of a minimum length are eligible