Skip to content

Commit e951ee5

Browse files
committed
2024-05-31 v. 5.7.9: added "2481. Minimum Cuts to Divide a Circle"
1 parent 83cf67f commit e951ee5

4 files changed

+30
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -439,3 +439,4 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
439439
| 2460. Apply Operations to an Array | [Link](https://leetcode.com/problems/apply-operations-to-an-array/) | [Link](./lib/easy/2460_apply_operations_to_an_array.rb) |
440440
| 2469. Convert the Temperature | [Link](https://leetcode.com/problems/convert-the-temperature/) | [Link](./lib/easy/2469_convert_the_temperature.rb) |
441441
| 2475. Number of Unequal Triplets in Array | [Link](https://leetcode.com/problems/number-of-unequal-triplets-in-array/) | [Link](./lib/easy/2475_number_of_unequal_triplets_in_array.rb) |
442+
| 2481. Minimum Cuts to Divide a Circle | [Link](https://leetcode.com/problems/minimum-cuts-to-divide-a-circle/) | [Link](./lib/easy/2481_minimum_cuts_to_divide_a_circle.rb) |

leetcode-ruby.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require 'English'
55
::Gem::Specification.new do |s|
66
s.required_ruby_version = '>= 3.0'
77
s.name = 'leetcode-ruby'
8-
s.version = '5.7.8'
8+
s.version = '5.7.9'
99
s.license = 'MIT'
1010
s.files = ::Dir['lib/**/*.rb'] + %w[bin/leetcode-ruby README.md LICENSE]
1111
s.executable = 'leetcode-ruby'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
# https://leetcode.com/problems/minimum-cuts-to-divide-a-circle/
4+
# @param {Integer} n
5+
# @return {Integer}
6+
def number_of_cuts(n)
7+
if n > 1
8+
n.even? ? n / 2 : n
9+
else
10+
0
11+
end
12+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../test_helper'
4+
require_relative '../../lib/easy/2481_minimum_cuts_to_divide_a_circle'
5+
require 'minitest/autorun'
6+
7+
class MinimumCutsToDivideACircleTest < ::Minitest::Test
8+
def test_default
9+
assert_equal(2, number_of_cuts(4))
10+
assert_equal(3, number_of_cuts(3))
11+
end
12+
13+
def test_additional
14+
assert_equal(0, number_of_cuts(0))
15+
end
16+
end

0 commit comments

Comments
 (0)