Sha256: 9fb813833eb95e8fdd4bbe57995d2845fe5296a77c41a849b031a0d337955906
Contents?: true
Size: 624 Bytes
Versions: 14
Compression:
Stored size: 624 Bytes
Contents
# frozen_string_literal: true module Codebreaker module Entities class Statistics def stats(list) difficulties = list.group_by { |score| score[:difficulty] } %i[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 end end
Version data entries
14 entries across 14 versions & 2 rubygems