Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#26 2013-04-13 15:30:27

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 14,847

Re: Four Square

M is Mathematica.


“Here lies the reader who will never open this book. He is forever dead.

“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

Offline

#27 2013-04-13 15:36:12

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 14,390
Website

Re: Four Square

Why not Maxima?

By the way, you also asked whether you can call bobbym as 'M'


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

#28 2013-04-13 15:40:58

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 14,847

Re: Four Square

Let me introduce you to the nomenclature:
M-Mathematica
m-bobbym and his two male predecessors.


“Here lies the reader who will never open this book. He is forever dead.

“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

Offline

#29 2013-04-13 15:43:00

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 14,390
Website

Re: Four Square

Ok

Why not Maxima?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

#30 2013-04-13 15:45:01

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 14,847

Re: Four Square

Because it is the currently used nomenclature.


“Here lies the reader who will never open this book. He is forever dead.

“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

Offline

#31 2013-04-13 17:01:19

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 81,752

Re: Four Square

In order to design an algorithm I still need an answer to the question of what numbers are permitted.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#32 2013-04-13 17:03:13

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 14,847

Re: Four Square

He answered that on the previous page...


“Here lies the reader who will never open this book. He is forever dead.

“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

Offline

#33 2013-04-13 17:07:26

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 81,752

Re: Four Square

It might be there and then again it might not.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#34 2013-04-13 17:09:44

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 14,847

Re: Four Square

Agnishom wrote:

Any thing .... Just liike bobbym does in Add 99 and post forever


“Here lies the reader who will never open this book. He is forever dead.

“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

Offline

#35 2013-04-13 17:11:32

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 81,752

Re: Four Square

Then I might suggest a greedy algorithm.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#36 2013-04-13 17:13:15

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 14,847

Re: Four Square

anonimnystefy wrote:

Have you checked this link? It can be done by recursion.


“Here lies the reader who will never open this book. He is forever dead.

“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

Offline

#37 2013-04-13 17:17:07

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 81,752

Re: Four Square

Recursion: anything done by it can always be done better in another way.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#38 2013-04-13 17:22:32

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 14,847

Re: Four Square

Maybe, but it's a start. And it is definitely better than brute force.

Speaking of recursion, does M do memoization while running a recursion?


“Here lies the reader who will never open this book. He is forever dead.

“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

Offline

#39 2013-04-13 17:25:08

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 81,752

Re: Four Square

Yes, see the examples on Fibonacci numbers I think.

I am going offline for a while.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#40 2013-04-13 17:28:05

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 14,847

Re: Four Square

Okay, see you later.


“Here lies the reader who will never open this book. He is forever dead.

“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

Offline

#41 2013-04-13 22:00:02

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 14,390
Website

Re: Four Square

Hm, A greedy algorithm is like what?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

#42 2013-04-13 23:01:36

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 14,847

Re: Four Square

Hi bobbym

If we are working in a language which does memoization in recursions, recursion will suffice.

If not, a DP type solution will do.


“Here lies the reader who will never open this book. He is forever dead.

“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

Offline

#43 2013-04-13 23:17:54

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 81,752

Re: Four Square

Hi anonimnystefy;

If not, a DP type solution will do

DP?

Hi Agnishom;

Basically, take the biggest square you can out each time.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#44 2013-04-13 23:23:37

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 14,847

Re: Four Square

Dynamic programming. Basically, we will do all values from 1 to n, and it will be O(n) because we can calculate a value in O(1) when we have the previous values.


“Here lies the reader who will never open this book. He is forever dead.

“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

Offline

#45 2013-04-13 23:32:54

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 81,752

Re: Four Square

Because he is allowing multiplicities and zero he is guaranteeing that every number is the sum of 4 squares.

17 = 4^2 + 1^2 + 0^2 + 0^2

17 = 3^2 + 2^2 + 2^2 + 0^2


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#46 2013-04-13 23:35:33

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 14,847

Re: Four Square

I was suggesting an algorithm in post #45. I do not know how you got anything else from that post...

Your greedy algorithm doesn't work for 1022 (and probably many more numbers).


“Here lies the reader who will never open this book. He is forever dead.

“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

Offline

#47 2013-04-13 23:44:16

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 81,752

Re: Four Square

Not so!

Done by hand!


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#48 2013-04-13 23:48:09

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 14,847

Re: Four Square

Yes, but that is not what your algorithm gets. The largest square below 1022 is 961=31^2.


“Here lies the reader who will never open this book. He is forever dead.

“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

Offline

#49 2013-04-13 23:50:00

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 81,752

Re: Four Square

You do not have to stop there. When 31 does not work you try 30 which does. Algorithm is very fast.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#50 2013-04-14 00:04:28

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 14,390
Website

Re: Four Square

I see, can you explain the structure of your greedy algorithm more clearly?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

Board footer

Powered by FluxBB