Today
Total
08-27 17:48
관리 메뉴

devGYU World

[Exercism Dart] Leap 솔루션 본문

etc/exercise

[Exercism Dart] Leap 솔루션

devGYU 2022. 3. 18. 12:44

 

본 예제는 윤년의 여부를 bool 타입으로 반환하면 되는 예제이다.

모든 윤년은 기재된 조건과 같이 4년마다 돌아오며, 100년마다 나눠지는 형태는 아니지만 400년 마다 나눠져야 한다.

해당 조건들을 반영한 코드는 아래와 같다.

 

class Leap {
  bool leapYear(int year) {
    if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
      return true;
    else
      return false;
  }
}

 

참고

 

 

Leap in Dart on Exercism

Can you solve Leap in Dart? Improve your Dart skills with support from our world-class team of mentors.

exercism.org

 

GitHub - gyu0710/dart: Exercism Dart Solutions

Exercism Dart Solutions. Contribute to gyu0710/dart development by creating an account on GitHub.

github.com

 

Comments