DEV Community

Discussion on: Coding Puzzles: Week of 4/8

Collapse
 
jellebekker profile image
Jelle Bekker

Not a one liner like you guys but C#:

using System;
public class Kata
{
  public static long StairsIn20(int[][] stairs)
  {
    long sum = 0;
    foreach (var weekday in stairs)
        foreach (var steps in weekday)
          sum += steps;

    return sum * 20;
   }           
}
Collapse
 
jellebekker profile image
Jelle Bekker

Okay, I couldn't help myself:

using System;
using System.Linq;

public class Kata
{
  public static long StairsIn20(int[][] stairs)
  {
    return stairs.SelectMany(x => x).Sum() * 20;
  }
}