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.139 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.138 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.137 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.136 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.135 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.134 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.133 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.132 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.131 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.130 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.129 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.128 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.127 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.126 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.125 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.124 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.123 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.122 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.121 tracks/d/exercises/leap/example/leap.d
trackler-2.2.1.120 tracks/d/exercises/leap/example/leap.d