• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 00:02
CET 06:02
KST 14:02
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns2[BSL21] Non-Korean Championship - Starts Jan 103SC2 All-Star Invitational: Jan 17-1822Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises3Weekly Cups (Dec 15-21): Classic wins big, MaxPax & Clem take weeklies3
StarCraft 2
General
Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns SC2 All-Star Invitational: Jan 17-18 Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises Chinese SC2 server to reopen; live all-star event in Hangzhou Starcraft 2 Zerg Coach
Tourneys
OSC Season 13 World Championship uThermal 2v2 Circuit WardiTV Mondays $5,000+ WardiTV 2025 Championship $100 Prize Pool - Winter Warp Gate Masters Showdow
Strategy
Simple Questions Simple Answers
Custom Maps
Map Editor closed ?
External Content
Mutation # 507 Well Trained Mutation # 506 Warp Zone Mutation # 505 Rise From Ashes Mutation # 504 Retribution
Brood War
General
I would like to say something about StarCraft BGH Auto Balance -> http://bghmmr.eu/ Data analysis on 70 million replays Empty tournaments section on Liquipedia A cwal.gg Extension - Easily keep track of anyone
Tourneys
[BSL21] Grand Finals - Sunday 21:00 CET [BSL21] Non-Korean Championship - Starts Jan 10 [Megathread] Daily Proleagues SLON Grand Finals – Season 2
Strategy
Game Theory for Starcraft Current Meta Simple Questions, Simple Answers [G] How to get started on ladder as a new Z player
Other Games
General Games
Nintendo Switch Thread Awesome Games Done Quick 2026! Should offensive tower rushing be viable in RTS games? General RTS Discussion Thread Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas Survivor II: The Amazon Sengoku Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Trading/Investing Thread The Big Programming Thread Canadian Politics Mega-thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List TL+ Announced
Blogs
Psychological Factors That D…
TrAiDoS
James Bond movies ranking - pa…
Topin
StarCraft improvement
iopq
GOAT of Goats list
BisuDagger
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1114 users

The Big Programming Thread - Page 715

Forum Index > General Forum
Post a Reply
Prev 1 713 714 715 716 717 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Acrofales
Profile Joined August 2010
Spain18170 Posts
April 01 2016 15:44 GMT
#14281
For real? Sounds like homework to me.

Hint, rewrite your equation as b^3=X. Then b = cubic root of X.

Then you loop through all integer values for a, and output when b is an integer. However, a corollary of Fermat's theorem might have something to say on how many solutions there are. I'm not too sure on number theory. In R there are an infinite number of solutions....
tofucake
Profile Blog Joined October 2009
Hyrule19188 Posts
April 01 2016 15:46 GMT
#14282
this is a relatively simple process:

you have
x = a^3 + b^3

so to find b you move a over and take the cube root:

b = cube_root(x - a^3)

now you plug in x = 6 and just pick a number for a, say -3:

b = cube_root(6 - a^3) = cube_root(6 - -27) = cube_root(33) ~ 3.2
Liquipediaasante sana squash banana
emperorchampion
Profile Blog Joined December 2008
Canada9496 Posts
Last Edited: 2016-04-01 16:01:10
April 01 2016 15:46 GMT
#14283
On April 02 2016 00:34 Manit0u wrote:
Anyone here good with maths?

How would I write a computer program to calculate (find a and b) 6 = a^3 + b^3 where a and b can be any integer (positive or negative)?

I desperately need solution to this equation and I'm too noob at this stuff...


Well you have 2 unknowns and 1 equation, so infinite possibilities. I guess you could choose any value for a, then sub back in and solve for b.

EDIT:


for a=1:step_size:N
b = (6-a^3)^(1/3);
end
TRUEESPORTS || your days as a respected member of team liquid are over
Manit0u
Profile Blog Joined August 2004
Poland17569 Posts
Last Edited: 2016-04-01 16:03:13
April 01 2016 16:01 GMT
#14284
On April 02 2016 00:46 tofucake wrote:
this is a relatively simple process:

you have
x = a^3 + b^3

so to find b you move a over and take the cube root:

b = cube_root(x - a^3)

now you plug in x = 6 and just pick a number for a, say -3:

b = cube_root(6 - a^3) = cube_root(6 - -27) = cube_root(33) ~ 3.2


The thing is, a and b HAVE to be integers. I guess I won't solve it since no one has so far

The full thing to calculate is 33 = a^3 + b^3 + c^3 (people are now at trying solutions involving integers on scale of 10^14) but I thought if I simplified it to 6 = a^3 + b^3 it could potentially be easier and my computer could handle it
Time is precious. Waste it wisely.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2016-04-01 16:36:21
April 01 2016 16:08 GMT
#14285
Can't you do a triple nested for loop? Cube each iteration of the loop and sum possible combinations (i, j, k plus or minus). If that number is 33 then you have a result that works.

There is probably some optimization you can do so you're not counting repeats as well, but forcing C to be three isn't going to help you find all the solutions.

The question to ask would be do you need any solution or all the solutions?
I'll always be your shadow and veil your eyes from states of ain soph aur.
Acrofales
Profile Joined August 2010
Spain18170 Posts
April 01 2016 16:14 GMT
#14286
So you (arbitrarily?) chose c=3 and decided to try to solve it? Maybe there's no solution for a,b or c = 3. But I understand it's a combinatorial problem. The easiest way of looping is the solution I outlined above, but if people are looking for a gigantic solutions, chances are that there is either no solution (which can probably be deduced as a corrolary from something to do with Fermat's last theorem). Either that, or there is a proof that there is a solution, but nobody has found it yet.

Just out of interest's sake: why 33? Seems like a pretty arbitrary constant?
tofucake
Profile Blog Joined October 2009
Hyrule19188 Posts
April 01 2016 16:17 GMT
#14287
Yeah there's not any sort of small integer solution to it. But if you get a big server farm you might find an answer...
Liquipediaasante sana squash banana
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2016-04-01 16:30:13
April 01 2016 16:25 GMT
#14288
On April 02 2016 01:01 Manit0u wrote:
Show nested quote +
On April 02 2016 00:46 tofucake wrote:
this is a relatively simple process:

you have
x = a^3 + b^3

so to find b you move a over and take the cube root:

b = cube_root(x - a^3)

now you plug in x = 6 and just pick a number for a, say -3:

b = cube_root(6 - a^3) = cube_root(6 - -27) = cube_root(33) ~ 3.2


The thing is, a and b HAVE to be integers. I guess I won't solve it since no one has so far

The full thing to calculate is 33 = a^3 + b^3 + c^3 (people are now at trying solutions involving integers on scale of 10^14) but I thought if I simplified it to 6 = a^3 + b^3 it could potentially be easier and my computer could handle it

I'm pretty sure there is no solution for 6 = a^3 + b^3 for integers a and b.

Reason for the case where a is positive and b is negative or vice versa:

0^3 = 0
(+-1)^3 = +-1
(+-2)^3 = +-8
(+-3)^3 = +-27
(+-4)^3 = +-64

It's obvious that the distance between 2 rows gets larger each time. So if we don't find a solution in the first few rows, by the time the distance is greater than 6, we can't find a solution at all. Which happens to be the case rather quickly.
That's because once we have a^3 calculated, we need a -(b^3) that is exactly 6 smaller than a^3. But if the closest -(b^3) is already 37 less than a^3, the further away ones certainly won't do.

To extend on this: if you were to replace the 6 with an arbitrary x, you could just start enumerating all the possible values for a^3 until the distance between two such values becomes larger than x. Then you just do a fairly simple search for a pair that is exactly x apart.

For example if x was 26, we would get the above list. 64 is already too large (distance to 27 is 37) so we stop there. Then we start at the 27 and look among the smaller numbers for the right match, which is the 1. So 26 = 3^3 + (-1)^3. If the 27 wouldn't work out, we would work our way down. Though obviously that would be pointless in this case.

With a and b having the same sign, things should work out similarly. We can restrict that to a, b and x all being positive because of logic and reasons. So now you enumerate all a^3 until the result is larger than x and look for a match. Since everything is positive, no larger numbers can work out.


Now, if you're trying to solve 33 = a^3 + b^3 + c^3, or even worse x = a^3 + b^3 + c^3, then scratch all of the above. With just a and b we were able to determine a simple criterion for when to stop iterating. That same criterion won't work for a, b and c. Maybe there's another upper limit, but it would likely be much higher.
If you have a good reason to disagree with the above, please tell me. Thank you.
Acrofales
Profile Joined August 2010
Spain18170 Posts
April 01 2016 16:29 GMT
#14289
On April 02 2016 01:25 spinesheath wrote:
Show nested quote +
On April 02 2016 01:01 Manit0u wrote:
On April 02 2016 00:46 tofucake wrote:
this is a relatively simple process:

you have
x = a^3 + b^3

so to find b you move a over and take the cube root:

b = cube_root(x - a^3)

now you plug in x = 6 and just pick a number for a, say -3:

b = cube_root(6 - a^3) = cube_root(6 - -27) = cube_root(33) ~ 3.2


The thing is, a and b HAVE to be integers. I guess I won't solve it since no one has so far

The full thing to calculate is 33 = a^3 + b^3 + c^3 (people are now at trying solutions involving integers on scale of 10^14) but I thought if I simplified it to 6 = a^3 + b^3 it could potentially be easier and my computer could handle it

I'm pretty sure there is no solution for 6 = a^3 + b^3 for integers a and b.

Reason for the case where a is positive and b is negative or vice versa:

0^3 = 0
(+-1)^3 = +-1
(+-2)^3 = +-8
(+-3)^3 = +-27
(+-4)^3 = +-64

It's obvious that the distance between 2 rows gets larger each time. So if we don't find a solution in the first few rows, by the time the distance is greater than 6, we can't find a solution at all. Which happens to be the case rather quickly.
That's because once we have a^3 calculated, we need a -(b^3) that is exactly 6 smaller than a^3. But if the closest -(b^3) is already 37 less than a^3, the further away ones certainly won't do.

To extend on this: if you were to replace the 6 with an arbitrary x, you could just start enumerating all the possible values for a^3 until the distance between two such values becomes larger than x. Then you just do a fairly simple search for a pair that is exactly x apart.

For example if x was 26, we would get the above list. 64 is already too large (distance to 27 is 37) so we stop there. Then we start at the 27 and look among the smaller numbers for the right match, which is the 1. So 26 = 3^3 + (-1)^3. If the 27 wouldn't work out, we would work our way down. Though obviously that would be pointless in this case.

With a and b having the same sign, things should work out similarly. We can restrict that to a, b and x all being positive because of logic and reasons. So now you enumerate all a^3 until the result is larger than x and look for a match. Since everything is positive, no larger numbers can work out.


Excellent point. So for c=3 there is no solution! Well proved! Now manit0u can move on to c=4, 5, ...
emperorchampion
Profile Blog Joined December 2008
Canada9496 Posts
Last Edited: 2016-04-01 16:31:19
April 01 2016 16:30 GMT
#14290
Ah missed the integer part... I tried it in Mathematica and nothing came up (Solve[6==a^3+b^3,{a,b},Integers]), so good luck!

Fairly certain there is no solution, but I am no mathematician
TRUEESPORTS || your days as a respected member of team liquid are over
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
April 01 2016 16:32 GMT
#14291
On April 02 2016 01:29 Acrofales wrote:
Excellent point. So for c=3 there is no solution! Well proved! Now manit0u can move on to c=4, 5, ...

It's not c = 3. You misread that. His general case is this:

33 = a^3 + b^3 + c^3

So it's always cubic, but one extra term.

Also I updated my post above for the general case.
If you have a good reason to disagree with the above, please tell me. Thank you.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2016-04-01 16:36:55
April 01 2016 16:34 GMT
#14292
On April 02 2016 01:25 spinesheath wrote:
Now, if you're trying to solve 33 = a^3 + b^3 + c^3, or even worse x = a^3 + b^3 + c^3, then scratch all of the above. With just a and b we were able to determine a simple criterion for when to stop iterating. That same criterion won't work for a, b and c. Maybe there's another upper limit, but it would likely be much higher.


There is no upper limit because the third value is arbitrary. If I set c to be -100 then the difference would need to be 1000033, but there is nothing stopping me from setting c to 1000 or 10000 to make the difference even larger.
I'll always be your shadow and veil your eyes from states of ain soph aur.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
April 01 2016 16:39 GMT
#14293
On April 02 2016 01:34 Blitzkrieg0 wrote:
Show nested quote +
On April 02 2016 01:25 spinesheath wrote:
Now, if you're trying to solve 33 = a^3 + b^3 + c^3, or even worse x = a^3 + b^3 + c^3, then scratch all of the above. With just a and b we were able to determine a simple criterion for when to stop iterating. That same criterion won't work for a, b and c. Maybe there's another upper limit, but it would likely be much higher.


There is no upper limit because the third value is arbitrary. If I set c to be 100 then the difference would need to be 1000033, but there is nothing stopping me from setting c to 1000 or 10000 to make the difference even larger.

But can you find a and b such that their cubes they add up to a value that is "in the right range" of c^3? Maybe the numbers grow apart too much and you just can't possibly hit that sweet spot. I can't reason for either way off the top of my head.
If you have a good reason to disagree with the above, please tell me. Thank you.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2016-04-01 16:57:14
April 01 2016 16:46 GMT
#14294
On April 02 2016 01:39 spinesheath wrote:
Show nested quote +
On April 02 2016 01:34 Blitzkrieg0 wrote:
On April 02 2016 01:25 spinesheath wrote:
Now, if you're trying to solve 33 = a^3 + b^3 + c^3, or even worse x = a^3 + b^3 + c^3, then scratch all of the above. With just a and b we were able to determine a simple criterion for when to stop iterating. That same criterion won't work for a, b and c. Maybe there's another upper limit, but it would likely be much higher.


There is no upper limit because the third value is arbitrary. If I set c to be 100 then the difference would need to be 1000033, but there is nothing stopping me from setting c to 1000 or 10000 to make the difference even larger.

But can you find a and b such that their cubes they add up to a value that is "in the right range" of c^3? Maybe the numbers grow apart too much and you just can't possibly hit that sweet spot. I can't reason for either way off the top of my head.


You should be able to make a good guess about values you need to check, but I don't think that is going to manage the size of the problem enough to matter. The trivial example of this being whether the third variable will be positive or negative, but you could do a lot better than that.

The complexity of the problem comes from the fact that you have an arbitrary list of integers to check. Reducing the values you need to check for each integer on that list isn't going to help you that much.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Acrofales
Profile Joined August 2010
Spain18170 Posts
April 01 2016 17:18 GMT
#14295
On April 02 2016 01:32 spinesheath wrote:
Show nested quote +
On April 02 2016 01:29 Acrofales wrote:
Excellent point. So for c=3 there is no solution! Well proved! Now manit0u can move on to c=4, 5, ...

It's not c = 3. You misread that. His general case is this:

33 = a^3 + b^3 + c^3

So it's always cubic, but one extra term.

Also I updated my post above for the general case.

Exactly.

But a^3 + b^3 = 6 would find you the solution to the more general problem for c=3.

You just proved that for c=3 there is no solution. By setting c=4, you have to retry and show there is no solution such that a^3 + b^3 = -53

And so forth for all c in Z
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
April 01 2016 17:28 GMT
#14296
On April 02 2016 02:18 Acrofales wrote:
Show nested quote +
On April 02 2016 01:32 spinesheath wrote:
On April 02 2016 01:29 Acrofales wrote:
Excellent point. So for c=3 there is no solution! Well proved! Now manit0u can move on to c=4, 5, ...

It's not c = 3. You misread that. His general case is this:

33 = a^3 + b^3 + c^3

So it's always cubic, but one extra term.

Also I updated my post above for the general case.

Exactly.

But a^3 + b^3 = 6 would find you the solution to the more general problem for c=3.

You just proved that for c=3 there is no solution. By setting c=4, you have to retry and show there is no solution such that a^3 + b^3 = -53

And so forth for all c in Z

Oh, now I see. I totally thought you meant for him to try 6 = a^4 + b^4 next. My bad.
If you have a good reason to disagree with the above, please tell me. Thank you.
Manit0u
Profile Blog Joined August 2004
Poland17569 Posts
April 01 2016 17:46 GMT
#14297
I always get spooked by such stuff...

Time is precious. Waste it wisely.
tofucake
Profile Blog Joined October 2009
Hyrule19188 Posts
April 01 2016 17:47 GMT
#14298
wat?

c = 4 changes the equation to -31 = a^3 + b^3, not -53...
Liquipediaasante sana squash banana
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2016-04-01 18:09:15
April 01 2016 18:06 GMT
#14299
On April 02 2016 02:46 Manit0u wrote:
I always get spooked by such stuff...

That parametric solution for 1... why go to such lengths when you can just use 1 = 1^3 + x^3 + (-x)^3 and still get infinitely many solutions? The same holds true for every single k^3 = k^3 + x^3 + (-x)^3.

Anyways, even though he didn't say so specifically, we can safely assume that there is no easy way to find an upper limit for the 33 case. Or else someone would already have found a solution.

Integer math is surprisingly hard, even though the numbers seem so much simpler than real numbers. In fact many problems are a lot easier if you're looking for solutions in the real numbers instead of integer solutions.

Long story short: if you want to solve this, you should probably head to university and delve into the field of discrete mathematics. It seems like people with way more experience and knowledge in the field than us combined have tried to find a solution.
If you have a good reason to disagree with the above, please tell me. Thank you.
Manit0u
Profile Blog Joined August 2004
Poland17569 Posts
April 01 2016 18:15 GMT
#14300
On April 02 2016 03:06 spinesheath wrote:
Show nested quote +
On April 02 2016 02:46 Manit0u wrote:
I always get spooked by such stuff...

That parametric solution for 1... why go to such lengths when you can just use 1 = 1^3 + x^3 + (-x)^3 and still get infinitely many solutions? The same holds true for every single k^3 = k^3 + x^3 + (-x)^3.

Anyways, even though he didn't say so specifically, we can safely assume that there is no easy way to find an upper limit for the 33 case. Or else someone would already have found a solution.

Integer math is surprisingly hard, even though the numbers seem so much simpler than real numbers. In fact many problems are a lot easier if you're looking for solutions in the real numbers instead of integer solutions.

Long story short: if you want to solve this, you should probably head to university and delve into the field of discrete mathematics. It seems like people with way more experience and knowledge in the field than us combined have tried to find a solution.


Yeah, I misread the the second note in the video. Thought it said "Pause and try it yourself" like the first one, but in fact it said "Definitely don't pause and try it yourself!"
Time is precious. Waste it wisely.
Prev 1 713 714 715 716 717 1032 Next
Please log in or register to reply.
Live Events Refresh
PiGosaur Cup
01:00
#63
Liquipedia
Patches Events
20:00
Patch Clash Invitational #1
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft279
RuFF_SC2 277
Ketroc 65
SortOf 36
StarCraft: Brood War
Shuttle 117
Leta 102
ZergMaN 66
Noble 16
Hm[arnc] 12
Bale 11
Icarus 7
yabsab 6
Sea 1
Dota 2
NeuroSwarm161
League of Legends
C9.Mang01015
JimRising 812
Cuddl3bear3
Counter-Strike
minikerr71
Super Smash Bros
hungrybox645
Mew2King26
Organizations
Other Games
gamesdonequick37171
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo927
• Stunt292
Other Games
• Shiphtur2177
Upcoming Events
OSC
6h 58m
Creator vs NightMare
SKillous vs SHIN
Gerald vs YoungYakov
Cure vs ReBellioN
Classic vs Percival
SOOP
22h 58m
OSC
1d 6h
OSC
2 days
SOOP
3 days
The PondCast
4 days
Sparkling Tuna Cup
5 days
IPSL
5 days
DragOn vs Sziky
Replay Cast
6 days
Wardi Open
6 days
[ Show More ]
Monday Night Weeklies
6 days
Liquipedia Results

Completed

BSL Season 21
WardiTV 2025
META Madness #9

Ongoing

C-Race Season 1
IPSL Winter 2025-26
OSC Championship Season 13
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025

Upcoming

Escore Tournament S1: W3
BSL 21 Non-Korean Championship
CSL 2025 WINTER (S19)
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Thunderfire SC2 All-star 2025
Big Gabe Cup #3
Nations Cup 2026
Underdog Cup #3
NA Kuram Kup
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.