Skip to content

Commit c905ca4

Browse files
authored
2025-04-25 v. 9.3.4: added "3280. Convert Date to Binary"
2 parents 6a114e6 + 9fd6adf commit c905ca4

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
464464
| 3136. Valid Word | [Link](https://leetcode.com/problems/valid-word/) | [Link](./lib/easy/3136_valid_word.rb) | [Link](./test/easy/test_3136_valid_word.rb) |
465465
| 3151. Special Array I | [Link](https://leetcode.com/problems/special-array-i/) | [Link](./lib/easy/3151_special_array_i.rb) | [Link](./test/easy/test_3151_special_array_i.rb) |
466466
| 3210. Find the Encrypted String | [Link](https://leetcode.com/problems/find-the-encrypted-string/) | [Link](./lib/easy/3210_find_the_encrypted_string.rb) | [Link](./test/easy/test_3210_find_the_encrypted_string.rb) |
467+
| 3280. Convert Date to Binary | [Link](https://leetcode.com/problems/convert-date-to-binary/) | [Link](./lib/easy/3280_convert_date_to_binary.rb) | [Link](./test/easy/test_3280_convert_date_to_binary.rb) |
467468
| 3498. Reverse Degree of a String | [Link](https://leetcode.com/problems/reverse-degree-of-a-string/) | [Link](./lib/easy/3498_reverse_degree_of_a_string.rb) | [Link](./test/easy/test_3498_reverse_degree_of_a_string.rb) |
468469

469470
### Medium

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 = '9.3.3'
8+
s.version = '9.3.4'
99
s.license = 'MIT'
1010
s.files = ::Dir['lib/**/*.rb'] + %w[README.md]
1111
s.executable = 'leetcode-ruby'
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
# https://leetcode.com/problems/convert-date-to-binary/
4+
# @param {String} date
5+
# @return {String}
6+
def convert_date_to_binary(date)
7+
result = []
8+
9+
date.split('-').each do |line|
10+
result << format('%b', line.to_i)
11+
end
12+
13+
result.join('-')
14+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../test_helper'
4+
require_relative '../../lib/easy/3280_convert_date_to_binary'
5+
require 'minitest/autorun'
6+
7+
class ConvertDateToBinaryTest < ::Minitest::Test
8+
def test_default_one
9+
assert_equal(
10+
'100000100000-10-11101',
11+
convert_date_to_binary(
12+
'2080-02-29'
13+
)
14+
)
15+
end
16+
17+
def test_default_two
18+
assert_equal(
19+
'11101101100-1-1',
20+
convert_date_to_binary(
21+
'1900-01-01'
22+
)
23+
)
24+
end
25+
end

0 commit comments

Comments
 (0)