<commit_before># Calculate the mode Pairing Challenge

# I worked on this challenge [by myself, with: Eddie]

# I spent [] hours on this challenge.

# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented.



# 0. Pseudocode

# What is the input? Array of elements with various frequencies
# What is the output? (i.e. What should the code return?) most frequent element
# What are the steps needed to solve the problem?

# Create a hash within method
# Puts elements in hash paired with frequency
# Sort the hashes by frequency stored in value
# Reverse the order of hashes, so most frequent is first
# compare values of hashes,
# identifies the highest values
# returns the key(s) with the highest value

# 1. Initial Solution

def mode(array)
  frequencies = Hash.new(0)
  array.each { |word| frequencies[word] += 1 }
  frequencies = frequencies.sort_by { |a, b| b }
  frequencies.reverse!
  element = frequencies.max_by{ |k,v| v }[0] 
  p element
end


# 3. Refactored Solution




# 4. Reflection<commit_msg>final solution for calculate mode<commit_after># Calculate the mode Pairing Challenge

# I worked on this challenge [by myself, with: Eddie]

# I spent [4] hours on this challenge.

# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented.



# 0. Pseudocode

# What is the input? Array of elements with various frequencies
# What is the output? (i.e. What should the code return?) most frequent element
# What are the steps needed to solve the problem?

# Create a hash within method
# Puts elements in hash paired with frequency
# Sort the hashes by frequency stored in value
# compare values of hashes,
# identifies the highest values
# returns the key(s) with the highest value

# 1. Initial Solution

def mode(array)
  most=[]
  frequencies = Hash.new(0)
  array.each { |word| frequencies[word] += 1 }
  frequencies.each { |k,v| most.push(k) if v == frequencies.values.max }
  return most
end

# 3. Refactored Solution




# 4. Reflection
{'fraction_non_alphanumeric': 0.074487895716946, 'fraction_numerical': 0.006517690875232775, 'mean_word_length': 3.9516129032258065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6422264', 'n_tokens_mistral': 628, 'n_tokens_neox': 600, 'n_words': 298}