Ad
Games
Arrays
Data Types
Algorithms
Logic
Code
Diff
  • fn required_energy(heights: Vec<i64>) -> i64 {
        heights
            .iter()
            .skip(1)
            .zip(heights.iter())
            .map(|(y2, y1)| (y2 - y1).abs())
            .sum::<i64>()
    }
    • using System;
    • public static class Kata
    • {
    • public static int CalculatingTheAmountEnergy(int[] coordinates)
    • {
    • // here's your code
    • }
    • fn required_energy(heights: Vec<i64>) -> i64 {
    • heights
    • .iter()
    • .skip(1)
    • .zip(heights.iter())
    • .map(|(y2, y1)| (y2 - y1).abs())
    • .sum::<i64>()
    • }