title: How can I effectively and efficiently count integer matches in a large array and store those counts for later use?
body: <p>For an assignment, I have to take a large number of "lottery" values from an Excel sheet (individually, a little over 2,300 integers, but they're grouped in six) and create an algorithm to try and predict the most likely next six numbers that will be drawn. So far, I have split up 396 six-number/six-slot combinations into arrays. </p>
  
  <p>My plan was to count how many times each number (possible values, 1-75) shows up in each slot and divide it by 396, but I'm not exactly sure how to go through each slot array, count the matches, and store the percentages for each possible value. </p>
  
  <p>The only way I have been able to count the matches was a super simple but absolutely humongous block of code (I created a variable for each possible 1-75 and made a for loop with a nested if loop that would simply add a count to the correct variable) that I couldn't figure out how to condense and is horrible to try and use to complete algorithm. I still have it, but I'm not going to post that part since it is horrible. But the rest of my code, I'll put down below:</p>
  
  <pre class="lang-py prettyprint-override"><code># Open the Lottery_Data.csv and return the raw data.
  def open_csv_file():
      file = open("Lottery_Data.csv", "r")
      csv_data = file.read()
      csv_data = csv_data.split("\n")
      file.close()
      return csv_data
  
  
  # Main Function
  def main():
      # Copy raw data from CSV file into a variable.
      csv_data = open_csv_file()
  
      # Create a separate array for the date (day and specific date), and the six lottery number-slots.
      lottery_date_day = []
      lottery_date_specific = []
      lottery_col_1 = []
      lottery_col_2 = []
      lottery_col_3 = []
      lottery_col_4 = []
      lottery_col_5 = []
      lottery_col_6 = []
  
      # Split the raw data from csv_data and spread them into the arrays
      for i in range(len(csv_data)-2):
          line = csv_data[i].split(",")
          l_d_d = line[0]
          l_d_s = line[1]
          l1 = line[2]
          l2 = line[3]
          l3 = line[4]
          l4 = line[5]
          l5 = line[6]
          l6 = line[7]
  
          lottery_date_day.append(l_d_d)
          lottery_date_specific.append(l_d_s)
          lottery_col_1.append(l1)
          lottery_col_2.append(l2)
          lottery_col_3.append(l3)
          lottery_col_4.append(l4)
          lottery_col_5.append(l5)
          lottery_col_6.append(l6)
  
      # Go into lottery arrays 1-6 and find how many matches for numbers 1-75 there are
  
      # Divide the total matches from the total entries for each number's percentage
  
  
  main()```
  </code></pre>