Skip to main content
added 60 characters in body
Source Link
Value Ink
  • 12.6k
  • 1
  • 17
  • 42

Ruby, 6161 55+1 = 56 bytes

Uses the -n flag. Input from STDIN.

->n{s=n.to_s;p (1..z=s.size~/$/).sum{|i|eval s[i|i|[$_[i,z]+?++s[0~/$/],$_[0,i]}+n*z,$_].sum &:to_i}

Try it online!Try it online!

Ruby, 61 bytes

->n{s=n.to_s;(1..z=s.size).sum{|i|eval s[i,z]+?++s[0,i]}+n*z}

Try it online!

Ruby, 61 55+1 = 56 bytes

Uses the -n flag. Input from STDIN.

p (1..~/$/).sum{|i|[$_[i,~/$/],$_[0,i],$_].sum &:to_i}

Try it online!

Source Link
Value Ink
  • 12.6k
  • 1
  • 17
  • 42

Ruby, 61 bytes

->n{s=n.to_s;(1..z=s.size).sum{|i|eval s[i,z]+?++s[0,i]}+n*z}

Try it online!