-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathActualCount.py
More file actions
30 lines (23 loc) · 937 Bytes
/
Copy pathActualCount.py
File metadata and controls
30 lines (23 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Dawsin Blanchard, Sam Braga, Brian Couture, and Ethan Trott
# COS226 University of Maine
import time
import csv_parser
# this function is O(n^2). this would take a *very* long time to run on our dataset
# we will not use this, except for subsets
def count_all_unique_plates(filename, total_entries):
unique = []
for plate in csv_parser.get_plates(filename):
if plate not in unique:
unique.append(plate)
return len(unique)
# determines the exact amount of unique elements using set() to remove duplicates
# this is **much** faster than count_all_unique_plates()
def get_exact_unique_using_set(filename):
#to sort we must load all entries into an array
entries = []
for plate in csv_parser.get_plates(filename):
entries.append(plate)
#use set() to remove duplicates
entries = set(entries)
#return the number of elements that aren't duplicates
return len(entries)