#Mathematica, 135 bytes
Max[(s=#;r=#2;Max[Tr/@Partition[#,r,1]&/@Join[s,Diagonal[s,#]&/@Range[-(t=Tr[1^#&@@s])+2,t-1]]])&@@@{{Transpose@#,#2},{Reverse@#,#2}}]&
ZaMoC
- 25.5k
- 2
- 32
- 87
Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange#Mathematica, 135 bytes
Max[(s=#;r=#2;Max[Tr/@Partition[#,r,1]&/@Join[s,Diagonal[s,#]&/@Range[-(t=Tr[1^#&@@s])+2,t-1]]])&@@@{{Transpose@#,#2},{Reverse@#,#2}}]&