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

You are not logged in.

## #101 2013-04-22 04:03:08

Mrwhy
Full Member

Offline

### Re: Four Square

Do I understand you want 4 squares that sum to 130

I must have got summat wrong (as usual!)
The "algorithm" is "Write a program that tries ALL the numbers up to 12 (13 is to big for on its own its square exceeds 130"

Writing the prog takes 60 seconds - running it takes milliseconds.

I assume you want all different integers
1 4 7 8
1 2 5 10
2 3 6 9
and so on

I must have completely misunderstood!

## #102 2013-04-22 04:03:39

bobbym

Online

### Re: Four Square

Hey, that guy has the same name as you.

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.

## #103 2013-04-22 04:38:38

Agnishom
Real Member

Offline

### Re: Four Square

Which guy?

Hi Mrwhy,
What you are twlling me is the brute-force approach, but I need a better approach than that to tackle larger numbers

'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

## #104 2013-04-22 04:46:19

bobbym

Online

### Re: Four Square

Hi Agnishom;

I am not finding the error in the code that is leaving out 130.

We could run through your algorithm by hand checking it against mine for each step. Using the 130 as the test number.

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.

## #105 2013-04-22 05:01:22

Agnishom
Real Member

Offline

### Re: Four Square

Or maybe running the debugger..

There is only one Agnishom. That tumblr. was mine

'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

## #106 2013-04-22 05:09:34

bobbym

Online

### Re: Four Square

I know that was you. I was kidding.

You can use the debugger to single step the code.

I am taking a little break, see you in a bit.

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.

## #107 2013-04-22 06:05:42

Mrwhy
Full Member

Offline

### Re: Four Square

#### Agnishom wrote:

Which guy?

Hi Mrwhy,
What you are twlling me is the brute-force approach, but I need a better approach than that to tackle larger numbers

The best method depends on the tools you have!

How big a number
How many milliseconds do you have?

How about all N up to 100,million?

I did not even optimise my search.
What is the point in spending one minute longer writing a better algorithm just to have the prog run in 0.0001 sec instead of 0.001

We can afford MANY seconds - our computers are ever willing ever stupid and ENJOY IT!

EXPERIMENTAL MATHS is FUN - the computer does all the boring bits!
No teeth being extracted at all!

Last edited by Mrwhy (2013-04-22 06:09:24)

## #108 2013-04-22 09:35:11

bobbym

Online

### Re: Four Square

Hi;

What is the point in spending one minute longer writing a better algorithm just to have the prog run in 0.0001 sec instead of 0.001

There is only one really good reason, practice for when you need the skill. Many times problems in combinatorics will have say 20 or 25 factorial different possibilities. Number theory is even worse. You can not always plow through some immense number.

Take this problem which is really about numbers around 40000+ The 130 is just for an example. The simplest approach of 4 loops could require
200^4 checks, that is not an insignificant number. Also, the numbers are getting bigger for what he wants those squares for.

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.

## #109 2013-04-22 13:56:13

Agnishom
Real Member

Offline

### Re: Four Square

and my algorithm breaks ten digits number in less than a second, I have checked it.

'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

## #110 2013-04-22 20:50:08

bobbym

Online

### Re: Four Square

Do you have an example?

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.

## #111 2013-04-22 23:19:30

Agnishom
Real Member

Offline

### Re: Four Square

Of course, give me a number

'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

## #112 2013-04-23 02:18:54

bobbym

Online

### Re: Four Square

I have a nice 9 digit number:

124701084

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.

## #113 2013-04-23 03:12:15

Agnishom
Real Member

Offline

### Re: Four Square

8340, 7426, 2, 2

'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

## #114 2013-04-23 03:15:50

bobbym

Online

### Re: Four Square

Correct a Mundo!

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.

## #115 2013-04-23 11:40:58

Agnishom
Real Member

Offline

### Re: Four Square

Last edited by Agnishom (2013-04-23 11:43:58)

'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

## #116 2013-04-23 14:53:10

bobbym

Online

### Re: Four Square

You obviously got it working.

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.

## #117 2013-04-23 22:16:55

Agnishom
Real Member

Offline

### Re: Four Square

Is there any specific reason you call it nice?

'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

## #118 2013-04-24 01:51:28

bobbym

Online

### Re: Four Square

Yes, because it can be broken down into squares that are repunits.

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.

## #119 2013-04-24 01:59:00

Agnishom
Real Member

Offline

### Re: Four Square

Repunits?

'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

## #120 2013-04-24 02:03:09

bobbym

Online

### Re: Four Square

Numbers with all 1's in them.

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.

## #121 2013-04-24 02:13:05

Agnishom
Real Member

Offline

### Re: Four Square

I guess this is much better than Mrwhy's

'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

## #122 2013-04-24 02:15:19

bobbym

Online

### Re: Four Square

Hi;

He has a good point though. A long time ago a very brilliant kid wrote a paper entitled "Commonsense Brute Force and the Computer."
In it he outlined pretty much the same viewpoint.

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.

## #123 2013-04-24 02:18:32

Agnishom
Real Member

Offline

### Re: Four Square

Hmm, how was the kid like?

'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

## #124 2013-04-24 02:20:29

bobbym

Online

### Re: Four Square

Smart, but very rebellious.

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.

## #125 2013-04-24 02:35:19

Agnishom
Real Member

Offline

### Re: Four Square

How did he use to spend his free time?

'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