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

You are not logged in.

## #101 2013-04-21 06:03:08

Mrwhy
Member
Registered: 2012-07-02
Posts: 52

### 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
How about
1 4 7 8
1 2 5 10
2 3 6 9
and so on

I must have completely misunderstood!

Offline

## #102 2013-04-21 06:03:39

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### 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.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #103 2013-04-21 06:38:38

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,857
Website

### 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'
I'm not crazy, my mother had me tested.

Offline

## #104 2013-04-21 06:46:19

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### 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.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #105 2013-04-21 07:01:22

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,857
Website

### 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'
I'm not crazy, my mother had me tested.

Offline

## #106 2013-04-21 07:09:34

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### 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.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #107 2013-04-21 08:05:42

Mrwhy
Member
Registered: 2012-07-02
Posts: 52

### 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-21 08:09:24)

Offline

## #108 2013-04-21 11:35:11

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### 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.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #109 2013-04-21 15:56:13

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,857
Website

### 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'
I'm not crazy, my mother had me tested.

Offline

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

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### Re: Four Square

Do you have an example?

In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

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

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,857
Website

### 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'
I'm not crazy, my mother had me tested.

Offline

## #112 2013-04-22 04:18:54

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### Re: Four Square

I have a nice 9 digit number:

124701084

In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #113 2013-04-22 05:12:15

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,857
Website

### 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'
I'm not crazy, my mother had me tested.

Offline

## #114 2013-04-22 05:15:50

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### Re: Four Square

Correct a Mundo!

In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #115 2013-04-22 13:40:58

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,857
Website

### Re: Four Square

Last edited by Agnishom (2013-04-22 13: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'
I'm not crazy, my mother had me tested.

Offline

## #116 2013-04-22 16:53:10

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### Re: Four Square

You obviously got it working.

In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

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

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,857
Website

### 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'
I'm not crazy, my mother had me tested.

Offline

## #118 2013-04-23 03:51:28

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### 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.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #119 2013-04-23 03:59:00

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,857
Website

### 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'
I'm not crazy, my mother had me tested.

Offline

## #120 2013-04-23 04:03:09

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### Re: Four Square

Numbers with all 1's in them.

In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #121 2013-04-23 04:13:05

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,857
Website

### 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'
I'm not crazy, my mother had me tested.

Offline

## #122 2013-04-23 04:15:19

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### 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.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #123 2013-04-23 04:18:32

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,857
Website

### 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'
I'm not crazy, my mother had me tested.

Offline

## #124 2013-04-23 04:20:29

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

### Re: Four Square

Smart, but very rebellious.

In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

## #125 2013-04-23 04:35:19

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,857
Website

### 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'
I'm not crazy, my mother had me tested.

Offline

## Board footer

Powered by FluxBB