Skip to content

Commit 52afe4f

Browse files
committed
Fix chars_count
1 parent 8790662 commit 52afe4f

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

test/exercise/fp/solution.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,17 @@ class << self
44
# Обратиться к параметрам фильма можно так:
55
# film["name"], film["rating_kinopoisk"], film["rating_imdb"],
66
# film["genres"], film["year"], film["access_level"], film["country"]
7-
def rating(_array)
8-
array = CSV.readlines('./test/fixtures/films.csv', headers: true)
9-
7+
def rating(array)
108
rating_kinopoisk = (array.map do |film|
119
film['rating_kinopoisk'].to_f if film['country'].to_s.split(',').count > 1 && film['rating_kinopoisk'].to_i.positive?
1210
end).compact
1311
rating_kinopoisk.reduce(:+) / rating_kinopoisk.size
1412
end
1513

16-
def chars_count(_films, threshold)
17-
films = CSV.readlines('./test/fixtures/films.csv', headers: true)
18-
search_letters = films.map do |film|
19-
film['name'] if film['name'].count('и').positive? && film['rating_kinopoisk'].to_f >= threshold
20-
end.compact
21-
search_letters.map { |film| film.count('и') }.reduce(:+)
14+
def chars_count(array, threshold)
15+
(array.map do |film|
16+
film['name'].count('и') if film['name'].count('и').positive? && film['rating_kinopoisk'].to_f >= threshold
17+
end.compact).reduce(:+)
2218
end
2319
end
2420
end

0 commit comments

Comments
 (0)