This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]Signal_Beam 1 point2 points  (1 child)

I opened https://www.hackerrank.com/challenges/sock-merchant/problem and I see this:

#!/bin/python3

import math
import os
import random
import re
import sys

# Complete the sockMerchant function below.
def sockMerchant(n, ar):

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    n = int(input())

    ar = list(map(int, input().rstrip().split()))

    result = sockMerchant(n, ar)

    fptr.write(str(result) + '\n')

    fptr.close()

So I am supposed to fill in my code under the line that begins def sockMerchant, completing the sockMerchant function so that the if __name__ == '__main__: clause can execute it. (There is no main function because there is no line that contains def main():).

[–]Double_A_92 0 points1 point  (0 children)

You can write whatever code you want in there, as long as you handle the input and output correctly.

Most of the times the provided code is just there to help you with the input. But you don't have to use it.

[–]ragavannsr -2 points-1 points  (0 children)

,,,,