blob: 0bfbcfaff3ba56adcd571f757b496d6b53d885a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/usr/bin/env elixir
defmodule PWC do
def countAsterisks(str) do
str
|> String.replace(~r/\|[^|]+\|/, "")
|> String.replace(~r/[^*]+/, "")
|> String.length
end
def solution(str) do
IO.puts("Input: $str = \"#{str}\"")
IO.puts("Output: " <> to_string(countAsterisks(str)) )
end
end
IO.puts("Example 1:")
PWC.solution("p|*e*rl|w**e|*ekly|")
IO.puts("\nExample 2:")
PWC.solution("perl")
IO.puts("\nExample 3:")
PWC.solution("th|ewe|e**|k|l***ych|alleng|e")
|