We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#!/bin/python3importmathimportosimportrandomimportreimportsys## Complete the 'stones' function below.## The function is expected to return an INTEGER_ARRAY.# The function accepts following parameters:# 1. INTEGER n# 2. INTEGER a# 3. INTEGER b#defstones(n,a,b):# Write your code hereresults=set()foriinrange(n):result=i*a+(n-1-i)*bresults.add(result)returnsorted(results)if__name__=='__main__':fptr=open(os.environ['OUTPUT_PATH'],'w')T=int(input().strip())forT_itrinrange(T):n=int(input().strip())a=int(input().strip())b=int(input().strip())result=stones(n,a,b)fptr.write(' '.join(map(str,result)))fptr.write('\n')fptr.close()
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Manasa and Stones
You are viewing a single comment's thread. Return to all comments →
My solution using Python.