### https://theweeklychallenge.org/blog/perl-weekly-challenge-265/ """ Task 1: 33% Appearance Submitted by: [45]Mohammad Sajid Anwar __________________________________________________________________ You are given an array of integers, @ints. Write a script to find an integer in the given array that appeared 33% or more. If more than one found, return the smallest. If none found then return undef. Example 1 Input: @ints = (1,2,3,3,3,3,4,2) Output: 3 1 appeared 1 times. 2 appeared 2 times. 3 appeared 4 times. 3 appeared 50% (>33%) in the given array. Example 2 Input: @ints = (1,1) Output: 1 1 appeared 2 times. 1 appeared 100% (>33%) in the given array. Example 3 Input: @ints = (1,2,3) Output: 1 1 appeared 1 times. 2 appeared 1 times. 3 appeared 1 times. Since all three appeared 33.3% (>33%) in the given array. We pick the smallest of all. Task 2: Completing Word """ ### solution by pokgopun@gmail.com def ota(ints: tuple): l = len(ints) for i in set(ints): if ints.count(i)/l >= 0.33: return i return None import unittest class TestOta(unittest.TestCase): def test(self): for inpt, otpt in { (1,2,3,3,3,3,4,2): 3, (1,1): 1, (1,2,3): 1, (1,2,3,4): None, }.items(): self.assertEqual(ota(inpt),otpt) unittest.main()