LoginSignup
0
0

More than 3 years have passed since last update.

Leetcode 1108: Defanging an IP Address

Posted at
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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0