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

You are not logged in.

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

anonimnystefy
Real Member

Offline

### Re: Four Square

M is Mathematica.

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

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

Agnishom
Real Member

Online

### 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'
'The whole person changes, why can't a habit?' -Alokananda

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

anonimnystefy
Real Member

Offline

### Re: Four Square

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

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

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

Agnishom
Real Member

Online

### 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'
'The whole person changes, why can't a habit?' -Alokananda

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

anonimnystefy
Real Member

Offline

### Re: Four Square

Because it is the currently used nomenclature.

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## #31 2013-04-14 15:01:19

bobbym

Online

### 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.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #32 2013-04-14 15:03:13

anonimnystefy
Real Member

Offline

### Re: Four Square

He answered that on the previous page...

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## #33 2013-04-14 15:07:26

bobbym

Online

### 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.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #34 2013-04-14 15:09:44

anonimnystefy
Real Member

Offline

### Re: Four Square

#### Agnishom wrote:

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

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## #35 2013-04-14 15:11:32

bobbym

Online

### Re: Four Square

Then I might suggest a greedy algorithm.

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

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

anonimnystefy
Real Member

Offline

### Re: Four Square

#### anonimnystefy wrote:

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

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## #37 2013-04-14 15:17:07

bobbym

Online

### 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.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #38 2013-04-14 15:22:32

anonimnystefy
Real Member

Offline

### 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?

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## #39 2013-04-14 15:25:08

bobbym

Online

### 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.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #40 2013-04-14 15:28:05

anonimnystefy
Real Member

Offline

### Re: Four Square

Okay, see you later.

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## #41 2013-04-14 20:00:02

Agnishom
Real Member

Online

### 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'
'The whole person changes, why can't a habit?' -Alokananda

## #42 2013-04-14 21:01:36

anonimnystefy
Real Member

Offline

### 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.

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## #43 2013-04-14 21:17:54

bobbym

Online

### 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.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #44 2013-04-14 21:23:37

anonimnystefy
Real Member

Offline

### 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.

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## #45 2013-04-14 21:32:54

bobbym

Online

### 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.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #46 2013-04-14 21:35:33

anonimnystefy
Real Member

Offline

### 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).

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## #47 2013-04-14 21:44:16

bobbym

Online

### Re: Four Square

Not so!

Done by hand!

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #48 2013-04-14 21:48:09

anonimnystefy
Real Member

Offline

### Re: Four Square

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

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

## #49 2013-04-14 21:50:00

bobbym

Online

### 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.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

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

Agnishom
Real Member

Online

### 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'
'The whole person changes, why can't a habit?' -Alokananda