Python Forum
Solution to this task
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solution to this task
#1
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()
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020