Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9fd6adf

Browse files
committed
2025年04月25日 v. 9.3.4: added "3280. Convert Date to Binary"
1 parent 6a114e6 commit 9fd6adf

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

‎README.md‎

Lines changed: 1 addition & 0 deletions
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‎

Lines changed: 1 addition & 1 deletion
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'
Lines changed: 14 additions & 0 deletions
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
Lines changed: 25 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /