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.12 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.11 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.10 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.9 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.8 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.7 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.6 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.5 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.4 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.3 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.2 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.1 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.1.0 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.0.6 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.0.5 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.0.4 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.0.3 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.0.2 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.0.1 tracks/dart/exercises/difference-of-squares/lib/example.dart
trackler-2.2.0.0 tracks/dart/exercises/difference-of-squares/lib/example.dart