+ 2

Can i solve the problem below using python

1729 can be written as 10^3+9^3 can i make a program where i will give a number and it will show it as a sum of two cube numbers if yes then how

22nd Aug 2019, 3:27 AM
Mazhabul Islam Abir
Mazhabul  Islam Abir - avatar
15 odpowiedzi
22nd Aug 2019, 3:56 AM
David Ashton
David Ashton - avatar
+ 11
David Ashton You're so kind to do his homework. 👌
22nd Aug 2019, 5:15 AM
David Carroll
David Carroll - avatar
+ 10
David Carroll I know, I know, but it was a cool problem and I couldn't resist 😁
22nd Aug 2019, 5:17 AM
David Ashton
David Ashton - avatar
+ 7
David Ashton TBH... I was about to start working on it myself until I saw you did. I typically like to let them know I have a solution and then share it only after seeing their attempt. I sometimes mention others on the thread to review the private code and then discuss it in the main thread where the OP can see the discussion. It's what I like to refer to as motivational torture. 🤣😂
22nd Aug 2019, 5:33 AM
David Carroll
David Carroll - avatar
+ 6
David Ashton Well... he could have at least done you the courtesy of marking your answer as accepted. I just marked your answer as the accepted one. 😉
22nd Aug 2019, 5:37 AM
David Carroll
David Carroll - avatar
+ 4
Yes, you can. We believe in you.
22nd Aug 2019, 3:50 AM
Fermi
Fermi - avatar
+ 4
David Carroll Way cool! That's a GM superpower I didn't know about 💪
22nd Aug 2019, 8:35 AM
David Ashton
David Ashton - avatar
+ 4
HonFu [#GoGetThatBugChamp!] Yeah... I find these assignments fun to do when I have a few minutes to think them through. They're good for simple mental exercises for sure.
22nd Aug 2019, 5:21 PM
David Carroll
David Carroll - avatar
+ 3
David Ashton I know the feeling😅
22nd Aug 2019, 5:31 AM
Trigger
Trigger - avatar
+ 3
David Carroll "You can do it...you have no choice😋"
22nd Aug 2019, 5:36 AM
Trigger
Trigger - avatar
+ 2
An exhaustive way is to try the cubes of all combinations of two numbers less than the given number but that's very inefficient.
22nd Aug 2019, 3:53 AM
Sonic
Sonic - avatar
+ 2
David Carroll lol. That is admin voodoo🤣
22nd Aug 2019, 5:38 AM
Trigger
Trigger - avatar
+ 2
Thomas Williams Indeed 🤓 David Ashton '...with great power there must also come -- great responsibility!" 😂🤣
22nd Aug 2019, 12:18 PM
David Carroll
David Carroll - avatar
+ 2
@Sonic: It would be sufficient if you only test numbers up to cube root of n. That is still pretty slow but not quite as slow. And it might make sense to build all cubes of numbers up to cube root of n and test them with the cubes of numbers starting at 1 and stop when the sum has reached n. This is what it would look like: https://code.sololearn.com/cBbHLkMx070L/#py (Even here on sl n can be up to 2 * 10**9 whereas the naive approach only gets up to n = 2000.)
22nd Aug 2019, 12:54 PM
Thoq!
Thoq! - avatar
+ 2
David Carroll, Thomas Williams, David Ashton, I remember there was a girl here once who posted a series of 13 or 14 easy questions about recursion here. I ended up doing 2/3 of her homework - and finally got a basic grasp of recursion as a result. I posted them as codes here on Sololearn, but I didn't link them in her questions, so probably, although technically the solutions were all there, she had to do them on her own anyway. 😜 In many cases we could just tell them: 'Please look up the solution to your homework in Code Playground - dozens of people may have already done it.'
22nd Aug 2019, 5:12 PM
HonFu
HonFu - avatar