Sort by

recency

|

1552 Discussions

|

  • + 0 comments

    I totally agree! When I had just read the problem, I thought that I probably could get it in one line of code. Just like planning a basement renovation requires breaking down the work into manageable steps, focusing on reducing equipment failure as a mindset, I broke the entire problem into just a few steps and was able to get a solution that only took one line of code!

  • + 0 comments

    I totally agree! When I had just read the problem, I thought that I probably could get it in one line of code. Focusing on reducing equipment failure as a mindset, I broke the entire problem into just a few steps and was able to get a solution that only took one line of code!

  • + 0 comments

    Here is Sequence equation solution in Python, java, c++, c and javascript - https://programmingoneonone.com/hackerrank-sequence-equation-problem-solution.html

  • + 0 comments

    My solution

    def permutationEquation(p): return [p.index(p.index(x) + 1) + 1 for x in sorted(p)]

    I am just learning Python, so the syntax where I use one line with the for cycle at the end is new to me. Originally I wrote:

    def permutationEquation(p): answer = []

    for x in sorted(p):
        answer.append(p.index(p.index(x) + 1) + 1)    
    
    print(answer)
    
  • + 0 comments

    I totally agree! When I had just read the problem, I thought that I probably could get it in one line of code. Focusing on reducing equipment failure as a mindset, I broke the entire problem into just a few steps and was able to get a solution that only took one line of code!