Skip to content

2024-04-23 v. 5.5.2: added "2325. Decode the Message" #609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,3 +412,4 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
| 2309. Greatest English Letter in Upper and Lower Case | [Link](https://leetcode.com/problems/greatest-english-letter-in-upper-and-lower-case/) | [Link](./lib/easy/2309_greatest_english_letter_in_upper_and_lower_case.rb) |
| 2315. Count Asterisks | [Link](https://leetcode.com/problems/count-asterisks/) | [Link](./lib/easy/2315_count_asterisks.rb) |
| 2319. Check if Matrix Is X-Matrix | [Link](https://leetcode.com/problems/check-if-matrix-is-x-matrix/) | [Link](./lib/easy/2319_check_if_matrix_is_x_matrix.rb) |
| 2325. Decode the Message | [Link](https://leetcode.com/problems/decode-the-message/) | [Link](./lib/easy/2325_decode_the_message.rb) |
2 changes: 1 addition & 1 deletion leetcode-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require 'English'
::Gem::Specification.new do |s|
s.required_ruby_version = '>= 3.0'
s.name = 'leetcode-ruby'
s.version = '5.5.1'
s.version = '5.5.2'
s.license = 'MIT'
s.files = ::Dir['lib/**/*.rb'] + %w[bin/leetcode-ruby README.md LICENSE]
s.executable = 'leetcode-ruby'
Expand Down
9 changes: 9 additions & 0 deletions lib/easy/2325_decode_the_message.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

# https://leetcode.com/problems/decode-the-message/
# @param {String} key
# @param {String} message
# @return {String}
def decode_message(key, message)
message.tr(key.chars.uniq.join.gsub(/\s+/, ''), 'a-z')
end
24 changes: 24 additions & 0 deletions test/easy/test_2325_decode_the_message.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

require_relative '../test_helper'
require_relative '../../lib/easy/2325_decode_the_message'
require 'minitest/autorun'

class DecodeTheMessageTest < ::Minitest::Test
def test_default
assert_equal(
'this is a secret',
decode_message(
'the quick brown fox jumps over the lazy dog',
'vkbs bs t suepuv'
)
)
assert_equal(
'the five boxing wizards jump quickly',
decode_message(
'eljuxhpwnyrdgtqkviszcfmabo',
'zwx hnfx lqantp mnoeius ycgk vcnjrdb'
)
)
end
end
Loading