<- function(arr){
findSmallestInt min(arr)
}
16 Find the smallest integer in the array
8kyu Tantangan #16/366 - 01 Mar 2024
https://www.codewars.com/kata/55a2d7ebe362935a210000b2
16.1 Instruction
Given an array of integers your solution should find the smallest integer.
For example:
Given [34, 15, 88, 2]
your solution will return 2
Given [34, -345, -1, 100]
your solution will return -345
You can assume, for the purpose of this kata, that the supplied array will not be empty.
16.2 YouTube Video
16.3 Solution Code
<- min findSmallestInt
16.4 Test
library(testthat)
test_that("Sample Tests", {
expect_equal(findSmallestInt(c(78,56,232,12,11,43)), 11)
expect_equal(findSmallestInt(c(78,56,-2,12,8,-33)), -33)
expect_equal(findSmallestInt(c(0, -1-.Machine$integer.max)), -1-.Machine$integer.max)
})
Test passed 🎊