Skip to main content
Use Attempt This Online for python 3.10 solution
Source Link
Mukundan314
  • 13.7k
  • 1
  • 19
  • 62

Python 3.10, 58 bytes

lambda m,i=0:sum(r[i:=i-1]+r[~i]*(~i!=len(m)+i)for r in m)

Attempt This Online!


Python 3, 62 bytes

lambda m:sum(r[i]+r[~i]*(i!=len(m)+~i)for i,r in enumerate(m)) 

Try it online!

Explanation

lambda m: for i,r in enumerate(m) # iterate m with i = row index and r = row +r[~i]*(i!=len(m)+~i) # add r[len(m) - i - 1] if the index does not equal i r[i] # add r[i] sum( ) # sum numbers generated by the loop 

Python 3.10, 59 58 bytes

lambda m,i=0:sum(r[i:=i-1]+r[~i]*(~i!=len(m)+i)for r in m) 

If you know a online python 3.10 executor which allows sharing code snippets please leave a comment.

Python 3, 62 bytes

lambda m:sum(r[i]+r[~i]*(i!=len(m)+~i)for i,r in enumerate(m)) 

Try it online!

Explanation

lambda m: for i,r in enumerate(m) # iterate m with i = row index and r = row +r[~i]*(i!=len(m)+~i) # add r[len(m) - i - 1] if the index does not equal i r[i] # add r[i] sum( ) # sum numbers generated by the loop 

Python 3.10, 59 58 bytes

lambda m,i=0:sum(r[i:=i-1]+r[~i]*(~i!=len(m)+i)for r in m) 

If you know a online python 3.10 executor which allows sharing code snippets please leave a comment.

Python 3.10, 58 bytes

lambda m,i=0:sum(r[i:=i-1]+r[~i]*(~i!=len(m)+i)for r in m)

Attempt This Online!


Python 3, 62 bytes

lambda m:sum(r[i]+r[~i]*(i!=len(m)+~i)for i,r in enumerate(m)) 

Try it online!

Explanation

lambda m: for i,r in enumerate(m) # iterate m with i = row index and r = row +r[~i]*(i!=len(m)+~i) # add r[len(m) - i - 1] if the index does not equal i r[i] # add r[i] sum( ) # sum numbers generated by the loop 
added 20 characters in body
Source Link
Mukundan314
  • 13.7k
  • 1
  • 19
  • 62

Python 3, 62 bytes

lambda m:sum(r[i]+r[~i]*(i!=len(m)+~i)for i,r in enumerate(m)) 

Try it online!

Explanation

lambda m: for i,r in enumerate(m) # iterate m with i = row index and r = row +r[~i]*(i!=len(m)+~i) # add r[len(m) - i - 1] if the index does not equal i r[i] # add r[i] sum( ) # sum numbers generated by the loop 

Python 3.10, 5959 58 bytes

lambda m,i=-1i=0:sum(r[i:=i+1]+r[~i]*=i-1]+r[~i]*(i~i!=len(m)+~i+i)for r in m) 

If you know a online python 3.10 executor which allows sharing code snippets please leave a comment.

Python 3, 62 bytes

lambda m:sum(r[i]+r[~i]*(i!=len(m)+~i)for i,r in enumerate(m)) 

Try it online!

Explanation

lambda m: for i,r in enumerate(m) # iterate m with i = row index and r = row +r[~i]*(i!=len(m)+~i) # add r[len(m) - i - 1] if the index does not equal i r[i] # add r[i] sum( ) # sum numbers generated by the loop 

Python 3.10, 59 bytes

lambda m,i=-1:sum(r[i:=i+1]+r[~i]*(i!=len(m)+~i)for r in m) 

If you know a online python 3.10 executor which allows sharing code snippets please leave a comment.

Python 3, 62 bytes

lambda m:sum(r[i]+r[~i]*(i!=len(m)+~i)for i,r in enumerate(m)) 

Try it online!

Explanation

lambda m: for i,r in enumerate(m) # iterate m with i = row index and r = row +r[~i]*(i!=len(m)+~i) # add r[len(m) - i - 1] if the index does not equal i r[i] # add r[i] sum( ) # sum numbers generated by the loop 

Python 3.10, 59 58 bytes

lambda m,i=0:sum(r[i:=i-1]+r[~i]*(~i!=len(m)+i)for r in m) 

If you know a online python 3.10 executor which allows sharing code snippets please leave a comment.

added 139 characters in body
Source Link
Mukundan314
  • 13.7k
  • 1
  • 19
  • 62

Python 3, 62 bytes

lambda m:sum(r[i]+r[~i]*(i!=len(m)+~i)for i,r in enumerate(m)) 

Try it online!

Explanation

lambda m: for i,r in enumerate(m) # iterate m with i = row index and r = row +r[~i]*(i!=len(m)+~i) # add r[len(m) - i - 1] if the index does not equal i r[i] # add r[i] sum( ) # sum numbers generated by the loop 

Python 3.10, 59 bytes

lambda m,i=-1:sum(r[i:=i+1]+r[~i]*(i!=len(m)+~i)for r in m) 

If you know a online python 3.10 executor which allows sharing code snippets please leave a comment.

Python 3, 62 bytes

lambda m:sum(r[i]+r[~i]*(i!=len(m)+~i)for i,r in enumerate(m)) 

Try it online!

Explanation

lambda m: for i,r in enumerate(m) # iterate m with i = row index and r = row +r[~i]*(i!=len(m)+~i) # add r[len(m) - i - 1] if the index does not equal i r[i] # add r[i] sum( ) # sum numbers generated by the loop 

Python 3, 62 bytes

lambda m:sum(r[i]+r[~i]*(i!=len(m)+~i)for i,r in enumerate(m)) 

Try it online!

Explanation

lambda m: for i,r in enumerate(m) # iterate m with i = row index and r = row +r[~i]*(i!=len(m)+~i) # add r[len(m) - i - 1] if the index does not equal i r[i] # add r[i] sum( ) # sum numbers generated by the loop 

Python 3.10, 59 bytes

lambda m,i=-1:sum(r[i:=i+1]+r[~i]*(i!=len(m)+~i)for r in m) 

If you know a online python 3.10 executor which allows sharing code snippets please leave a comment.

added 441 characters in body
Source Link
Mukundan314
  • 13.7k
  • 1
  • 19
  • 62
Loading
Source Link
Mukundan314
  • 13.7k
  • 1
  • 19
  • 62
Loading