Sort by

recency

|

13 Discussions

|

  • + 0 comments

    Here is Iterate It problem solution in Python Java C++ and c programming - https://programs.programmingoneonone.com/2021/07/hackerrank-iterate-it-problem-solution.html

  • + 1 comment

    Mathematically it is easy to see that the program will always terminate, because after each iteration, the maximum number from the original list will never show up in the next list and the max keeps decreasing. The challenge, of course, is to figure out the exact number of steps it will take to terminate within the bounds of limited computation resources.

  • + 1 comment

    I've solved the psuedocode , but the thing is I am not able to find the solution if the loop never ends {i.e., -1 . Its a bit tricky}.

    If any one can find the solution please do reply back.

    def iterateIt(a):
        emp = []
        rep = 0
    
        while True:
            b = []
            for x in a:
                for y in a:
                    if x != y:
                        temp = abs(x-y)
                        b.append(temp)
            a = b
            rep = rep + 1
    
            if a == emp:
                return rep
    
  • [deleted]
    + 1 comment

    Could anyone please tell me what's the problem statement means actually?

  • + 1 comment

    OK, so I get the looping through twice, once for X and once for Y. I am passing SOME test cases, but not all of them. In that the call is aborted any time where the process never terminates. Understandable, but what is it I'm to be looking for that indicates something will NOT terminate?