Skip to content

Commit

Permalink
r/leap: 1st iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
vpayno committed Apr 9, 2024
1 parent 270eea0 commit ef22893
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
1 change: 1 addition & 0 deletions r/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
## [Exercises](https://exercism.org/tracks/r/exercises)

- [raindrops](./raindrops/README.md)
- [leap](./leap/README.md)
7 changes: 6 additions & 1 deletion r/leap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ Your task is to determine whether a given year is a leap year.

### Based on

CodeRanch Cattle Drive, Assignment 3 - https://coderanch.com/t/718816/Leap
CodeRanch Cattle Drive, Assignment 3 - https://coderanch.com/t/718816/Leap

### My Solution

- [leap.R](./leap.R)
- [run-tests](./run-tests-r.txt)
12 changes: 12 additions & 0 deletions r/leap/leap.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
leap <- function(year) {
if (year %% 400 == 0) {
return(TRUE)
}

if (year %% 100 == 0) {
return(FALSE)
}

if (year %% 4 == 0) {
return(TRUE)
}

return(FALSE)
}
65 changes: 65 additions & 0 deletions r/leap/run-tests-r.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Running automated test file(s):


===============================================================================

Running: ../../.github/citools/r/r-test

Running R Tests

R versions:

R version 4.3.3 (2024-02-29) -- "Angel Food Cake"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.


Rscript (R) version 4.3.3 (2024-02-29)


==============================================================================

Running: Rscript test_leap.R

Test passed 🎉
Test passed 🎉
Test passed 🎉
Test passed 🎉

real 0m0.586s
user 0m0.525s
sys 0m0.063s


==============================================================================

Exit code: 0

real 0m0.790s
user 0m0.619s
sys 0m0.185s

real 0m0.794s
user 0m0.622s
sys 0m0.187s

===============================================================================

Running: misspell ./leap.R ./test_leap.R

real 0m0.018s
user 0m0.014s
sys 0m0.012s

===============================================================================

/home/vpayno/git_vpayno/exercism-workspace/r

===============================================================================

0 comments on commit ef22893

Please sign in to comment.