devGYU World
[Exercism Dart] Leap 솔루션 본문

본 예제는 윤년의 여부를 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
'etc > exercise' 카테고리의 다른 글
[Exercism Dart] Armstrong Numbers 솔루션 (0) | 2022.03.18 |
---|---|
[ Exercism Dart] Scrabble Score 솔루션 (0) | 2022.03.18 |
[ Exercism Dart] Difference Of Squares 솔루션 (0) | 2022.03.18 |
[Exercism Dart] Two Fer 솔루션 (0) | 2022.03.18 |
[Exercism Dart] Hello World 솔루션 (0) | 2022.03.18 |
Comments