dedupe-app

Service that removes duplicates from array of strings

dedupe

Removes Duplicates from Array of Strings

Usage

Building the Docker Image

docker build -f Dockerfile -t dedupe .

Running the Docker Container

docker run --name dedupe -p 7777:7777 -d dedupe

Dedupe Core Algorithm

module Dedupe
  def self.remove_duplicates(list : Array(String))
    temp_hash = {} of String => Int32
    result = [] of String

    list.each do |str|
      unless temp_hash[str]?
        temp_hash[str] = 1
      end
    end

    temp_hash.each do |k, v|
      result << k
    end

    result
  end
end

Dedupe.remove_duplicates(["sameaton11@gmail.com", "sameaton11@gmail.com"])

Running Specs

# install crystal deps
shards install
# run specs
crystal spec --release

Contributors

Repository

dedupe-app

Owner
Statistic
  • 1
  • 0
  • 0
  • 0
  • 1
  • over 7 years ago
  • August 22, 2017
License

MIT License

Links
Synced at

Sat, 21 Dec 2024 19:22:26 GMT

Languages