Sha256: 601d36f54bc9d14284e518f5d2db4e93f4a094a931ea033f4bc1fc6713814f67

Contents?: true

Size: 251 Bytes

Versions: 213

Compression:

Stored size: 251 Bytes

Contents

bool is_leap(uint year) {
  bool div_by(uint n) {
    return year % n == 0;
  }
  return div_by(4) && (!div_by(100) || div_by(400));
}

unittest {
  assert(!is_leap(2015));
  assert(is_leap(2016));
  assert(!is_leap(2100));
  assert(is_leap(2000));
}

Version data entries

213 entries across 213 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.179 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.178 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.177 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.176 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.175 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.174 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.173 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.172 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.171 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.170 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.169 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.167 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.166 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.165 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.164 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.163 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.162 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.161 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.160 tracks/d/exercises/leap/example/leap.d