Skip to content

Commit ad99f8f

Browse files
committed
2024-04-23 v. 5.5.2: added "2325. Decode the Message"
1 parent 65b6ec4 commit ad99f8f

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,4 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
412412
| 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) |
413413
| 2315. Count Asterisks | [Link](https://leetcode.com/problems/count-asterisks/) | [Link](./lib/easy/2315_count_asterisks.rb) |
414414
| 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) |
415+
| 2325. Decode the Message | [Link](https://leetcode.com/problems/decode-the-message/) | [Link](./lib/easy/2325_decode_the_message.rb) |

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 = '5.5.1'
8+
s.version = '5.5.2'
99
s.license = 'MIT'
1010
s.files = ::Dir['lib/**/*.rb'] + %w[bin/leetcode-ruby README.md LICENSE]
1111
s.executable = 'leetcode-ruby'

lib/easy/2325_decode_the_message.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
# https://leetcode.com/problems/decode-the-message/
4+
# @param {String} key
5+
# @param {String} message
6+
# @return {String}
7+
def decode_message(key, message)
8+
message.tr(key.chars.uniq.join.gsub(/\s+/, ''), 'a-z')
9+
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../test_helper'
4+
require_relative '../../lib/easy/2325_decode_the_message'
5+
require 'minitest/autorun'
6+
7+
class DecodeTheMessageTest < ::Minitest::Test
8+
def test_default
9+
assert_equal(
10+
'this is a secret',
11+
decode_message(
12+
'the quick brown fox jumps over the lazy dog',
13+
'vkbs bs t suepuv'
14+
)
15+
)
16+
assert_equal(
17+
'the five boxing wizards jump quickly',
18+
decode_message(
19+
'eljuxhpwnyrdgtqkviszcfmabo',
20+
'zwx hnfx lqantp mnoeius ycgk vcnjrdb'
21+
)
22+
)
23+
end
24+
end

0 commit comments

Comments
 (0)