Sha256: 791d5eb6e3cb5b4cc3c166ecdb512fdf86c54009645dd90a424e466ac0f56fc2
Contents?: true
Size: 513 Bytes
Versions: 4
Compression:
Stored size: 513 Bytes
Contents
# frozen_string_literal: true class Statistics def stats(list) difficulties = list.group_by { |score| score[:difficulty] } %w[hell medium easy].reduce([]) do |sorted_difficulties, difficulty_name| if difficulties[difficulty_name] sorted_difficulties + stats_sort(difficulties[difficulty_name]) else sorted_difficulties end end end private def stats_sort(scores) scores.sort_by! { |score| [score[:attempts_used], score[:hints_used]] }.reverse end end
Version data entries
4 entries across 4 versions & 2 rubygems