Sha256: a136638e2497ececaaecd1b2b4f21dfc6629120834f942ed8dd859308e0986dd

Contents?: true

Size: 417 Bytes

Versions: 127

Compression:

Stored size: 417 Bytes

Contents

import "dart:math" show pow;

class DifferenceOfSquares {
  int squareOfSums(int input) => pow(_sum(input), 2);

  int sumOfSquares(int input) => _range(input).map((i) => pow(i, 2)).reduce((r, i) => r + i);

  int difference(int input) => squareOfSums(input) - sumOfSquares(input);

  int _sum(int input) => input * (input + 1) ~/ 2;

  List<int> _range(int length) => new List<int>.generate(length, (i) => i + 1);
}

Version data entries

127 entries across 127 versions & 1 rubygems

Version Path
trackler-2.2.1.92 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.91 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.90 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.89 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.88 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.87 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.86 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.85 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.84 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.83 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.82 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.81 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.80 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.79 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.78 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.77 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.76 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.75 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.74 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.73 tracks/dart/exercises/difference-of-squares/lib/example.dart