Sha256: 93f8e1f1aea10a9e5294562312ae9777e967292299ef76f20750370eae1b414e

Contents?: true

Size: 544 Bytes

Versions: 66

Compression:

Stored size: 544 Bytes

Contents

use "collections"

class Squares
  let _max: U32

  new create(max: U32) =>
    _max = max + 1

  fun square_of_sums(): U32 =>
    var sum: U32 = 0
    let rng: Range[U32] = Range[U32](1, _max)

    while rng.has_next() do
      sum = sum + rng.next()
    end

    sum * sum

  fun sum_of_squares(): U32 =>
    var sum: U32 = 0
    let rng: Range[U32] = Range[U32](1, _max)

    while rng.has_next() do
      var t: U32 = rng.next()
      sum = sum + (t * t)
    end

    sum

  fun difference(): U32 =>
    square_of_sums() - sum_of_squares()

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
trackler-2.0.6.10 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.6.9 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.6.8 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.6.7 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.6.6 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.6.5 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.6.4 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.6.3 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.6.2 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.6.1 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.6.0 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.5.18 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.5.17 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.5.16 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.5.15 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.5.14 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.5.13 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.5.12 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.5.11 tracks/pony/exercises/difference-of-squares/example.pony
trackler-2.0.5.10 tracks/pony/exercises/difference-of-squares/example.pony