Monday (8KYU): How many stairs will Suzuki climb in 20 years?
codewars.com/kata/56fc55cd1f5a93d6...
def stairs_in_20(stairs): return 20*sum(sum(stairs, []))
Javascript (ES6):
function stairs_in_20(stairs) { return stairs.reduce((steps, day) => steps.concat(day)).reduce((sum, count) => sum + count) * 20; }
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; } }
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; } }
My Python solution:
def stairs_in_20(stairs): return sum(i for sublist in stairs for i in sublist) * 20
Practicing TypeScript for my upcoming internship. And I figured out how to add code highlighting!
function stairsIn20(stairs : number[][]) : number { let totalStairs : number = 0; for(let day of stairs) { totalStairs += day.reduce((total, num) => total + num); } return totalStairs * 20; }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Monday (8KYU): How many stairs will Suzuki climb in 20 years?
codewars.com/kata/56fc55cd1f5a93d6...
Javascript (ES6):
Not a one liner like you guys but C#:
Okay, I couldn't help myself:
My Python solution:
Practicing TypeScript for my upcoming internship. And I figured out how to add code highlighting!