In this HakerRank Introduction to Sets problem, we have given an array of integers and we need to count the average of distinct values of the array and round it to 3 places after the decimal.

## HackerRank Introduction to Sets solution.

# Enter your code here. Read input from STDIN. Print output to STDOUT N = int(raw_input()) plant_list = map(int, raw_input().split()) plant_set = set(plant_list) sum = 0.0 for plant_height in plant_set: sum += plant_height average = sum / float(len(plant_set)) print average

### Second Solution

n = int(input()) nums = set(list(map(int, input().split()))) print(sum(nums) / len(nums))

## 0 Comments