Skip to content

Commit d3b45c8

Browse files
committed
exercism 60
1 parent fef92b3 commit d3b45c8

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ solution of many challenges of [Leetcode](https://leetcode.com/), [Exercism](htt
277277
57. [Seive](https://github.com/kumar91gopi/Algorithms-and-Data-Structures-in-Ruby/blob/master/exercism/seive.rb)
278278
58. [Proverb](https://github.com/kumar91gopi/Algorithms-and-Data-Structures-in-Ruby/blob/master/exercism/proverb.rb)
279279
59. [Palindrome Products](https://github.com/kumar91gopi/Algorithms-and-Data-Structures-in-Ruby/blob/master/exercism/palindrome_products.rb)
280+
60. [Parallel Letter Frequency](https://github.com/kumar91gopi/Algorithms-and-Data-Structures-in-Ruby/blob/master/exercism/parallel_letter_frequency.rb)
280281

281282
<a name="leetcode"/>
282283

Diff for: exercism/parallel_letter_frequency.rb

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#Problem: https://exercism.org/tracks/ruby/exercises/parallel-letter-frequency
2+
3+
#Solution
4+
class ParallelLetterFrequency
5+
def self.count(texts)
6+
ret_val = Hash.new(0)
7+
return ret_val if texts.empty?
8+
threads = texts.map do |text|
9+
Thread.new do
10+
format_text = text.downcase.gsub(/[^\p{L}a-z]/, '')
11+
format_text.each_char { |char| ret_val[char] += 1 }
12+
end
13+
end
14+
threads.each(&:join)
15+
ret_val
16+
end
17+
end

0 commit comments

Comments
 (0)