Python Forum

Full Version: Solution to this task
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Write a function that takes an array of integers and returns the number of triplets in the array.
class Solution:

    def find_triplets(self, input):
        If (

from solution import Solution
import unittest

class SolutionTests(unittest.TestCase):

    
    def test1(self):
        solution = Solution()
        self.assertEqual(solution.find_triplets([ 5, 5, 5, 5, 5, 5 ]), 2)

    def test2(self):
        solution = Solution()
        self.assertEqual(solution.find_triplets([ 4, 3, 3, 3, 6, 1, 1, 1 ]), 2)

if __name__ == '__main__':
    unittest.main()
We're not going to write it for you. Please make an effort to write it yourself, and we will help you fix the problems you run into.

Problem #1: 'if' is not capitalized.