require 'test/unit'
require 'pry'
class DefanginAnIpAddress < Test::Unit::TestCase
# https://leetcode.com/problems/defanging-an-ip-address/
# Qiita:
def test_defang_i_paddr
input = "1.1.1.1"
output = "1[.]1[.]1[.]1"
assert_equal(output, defang_i_paddr(input))
input = "255.100.50.0"
output = "255[.]100[.]50[.]0"
assert_equal(output, defang_i_paddr(input))
end
def defang_i_paddr(address)
address.gsub('.', '[.]')
end
end
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
00