+ 6

What's wrong with this code?

I am trying to calculate the Greatest Common Divisor (GCD) for every pair of numbers inputted. Thereafter, i want to ouput the numbers not separated by a comma, and there should be in a single output line with the GCD. I want my output to look like this (sample input & output for test case T = 4): 2, 1 GCD 1 3, 4 GCD 1 5, 5 GCD 5 10, 4 GCD 2 Please help. Here's my output for a trial i did on Jupyter(Anaconda). It gives an error where am i going wrong. Please help. here is a screenshot for the trial i ran on Jupyter: https://ibb.co/6sNqf1g (uploaded on imgbb Here is the full code: https://code.sololearn.com/cN1XtZxHOB35/?ref=app

30th Sep 2022, 10:39 AM
Takudzwa A Svosve
Takudzwa A Svosve - avatar
10 Respostas
+ 6
gcd = gcd(a,b) # this will shadow gcd() function so on next call it is 'with variable with braces' is not function call with parameters.. . Take different names for function and variable.
30th Sep 2022, 12:20 PM
Jayakrishna 🇼🇳
+ 5
Yes, i think you've put it quite perfectly Maisu, how can i loop through my conditions and using standard code. The code i wrote is literally junk lol. So yes, thats the answer
3rd Oct 2022, 7:27 AM
Takudzwa A Svosve
Takudzwa A Svosve - avatar
+ 4
Jayakrishna🇼🇳 thanks you for the correction🙏 . I have changed and it works fine. Now time to work on more features.
1st Oct 2022, 2:01 PM
Takudzwa A Svosve
Takudzwa A Svosve - avatar
+ 4
Hie guys. So still on this question, actually i got it from Hackerearth its a practice question. I have manage to solve all the test cases and a one more test block of three needed to completely submit it. I dont know where I'm going wrong, please help. The link to the original question is 👇 https://www.hackerearth.com/practice/algorithms/dynamic-programming/2-dimensional/practice-problems/algorithm/gcd-game-11/ So i created two projects both serving the same purpose. 1. It is for submission purposes only and its not user friendly but I have written comments in it. It's link is 👇 https://code.sololearn.com/cN1XtZxHOB35/?ref=app 2. The second one is easier to work with as a user, it gives out prompt messages when working with it and here is its link below 👇 https://code.sololearn.com/cew3r1yZW7Jk/?ref=app
2nd Oct 2022, 9:44 PM
Takudzwa A Svosve
Takudzwa A Svosve - avatar
+ 4
Maisu, you mean i shouldn't have imported the gcd moduleđŸ€”đŸ€”đŸ€­.. Ooops that's my bad.
3rd Oct 2022, 7:25 AM
Takudzwa A Svosve
Takudzwa A Svosve - avatar
+ 4
Sure thing Maisu, let me try the work around
4th Oct 2022, 8:30 AM
Takudzwa A Svosve
Takudzwa A Svosve - avatar
+ 3
I guess I would wrap the conditions in a while loop. Then I would create a control variable and you change its value depending if you want to repeat or not.
3rd Oct 2022, 10:08 AM
Maisu
Maisu - avatar
+ 1
Why do you import the gcd form math ? I though the challenge was to compute it by yourself.
3rd Oct 2022, 5:12 AM
Maisu
Maisu - avatar
+ 1
Actually, you want to find a way how to loop through your conditions ?
3rd Oct 2022, 5:15 AM
Maisu
Maisu - avatar