You have re-invented the Pigeonhole sort.

The wiki page on sorting algorithms has a separate section for non-comparison integer sorts like this. Its main disadvantage is that its running time and its memory requirements depend on max, not just on n.

## Search found 521 matches

- Sat Dec 15, 2018 5:48 am
- Forum: Discrete Mathematics
- Topic: Sorting...
- Replies:
**4** - Views:
**50**

- Fri Nov 16, 2018 3:47 pm
- Forum: Clarifications on Project Euler Problems
- Topic: Problem 351
- Replies:
**13** - Views:
**4260**

### Re: Problem 351

If you ever need more than, say, 600MB of data, then you are probably doing it wrong. You are either using the wrong solving method, or maybe you just don't need to have all of that data in memory at the same time.

- Fri Nov 16, 2018 2:09 pm
- Forum: Clarifications on Project Euler Problems
- Topic: Problem 351
- Replies:
**13** - Views:
**4260**

### Re: Problem 351

Cheers Jaap, I'm afraid I'll have to confess my ignorance on the first question (I'll google that though). I do use vectors, yes, but I would have thought it would pose problems of efficiency too as it will take up a lot of memory. I'll try that approach over the weekend though and see what happens...

- Fri Nov 16, 2018 1:33 pm
- Forum: Clarifications on Project Euler Problems
- Topic: Problem 640
- Replies:
**5** - Views:
**965**

### Re: Problem 640

Sure, go ahead.LarryBlake wrote: ↑Fri Nov 16, 2018 12:55 pm@jaap, may I PM you my assumptions and a question? I believe I'm having the same difficulty tuple describes.

- Fri Nov 16, 2018 10:31 am
- Forum: Clarifications on Project Euler Problems
- Topic: Problem 351
- Replies:
**13** - Views:
**4260**

### Re: Problem 351

On my system and using C/C++, defining an array this size immediately causes a 'Segmentation fault' - and the number spaces required only get larger on some of the more difficult problems on PE. Am I missing something? Do you know the difference between the stack and heap memory? Do you know how to...

- Thu Nov 08, 2018 10:30 am
- Forum: Clarifications on Project Euler Problems
- Topic: Problem 640
- Replies:
**5** - Views:
**965**

### Re: Problem 640

It seems I'm having the same problem as tuple, as I get those answers too.

Edit: Solved it now. I had made an assumption that was not true in every situation, and from reading the problem's thread, many others did so too.

Edit: Solved it now. I had made an assumption that was not true in every situation, and from reading the problem's thread, many others did so too.

- Wed Oct 17, 2018 8:46 am
- Forum: Number
- Topic: "Fixed Points"
- Replies:
**5** - Views:
**1218**

### Re: "Fixed Points"

Oh, it's the unmistakable work of Raymond Smullyan. The strings we are working with are expressions. Just like an ordinary arithmetical expression like "4+5" can be evaluated to yield "9", these strings have their own type of arithmetic that can be used to evaluate them and yield another string. You...

- Tue Oct 16, 2018 6:30 am
- Forum: Number
- Topic: "Fixed Points"
- Replies:
**5** - Views:
**1218**

### Re: "Fixed Points"

In what case? In what context do you have strings that are also functions?kenbrooker wrote: ↑Mon Oct 15, 2018 9:47 pmIn this case, X is a string and X is a function, a function of itself.

It is hard to tell what misunderstandings you might have if you don't show the original text that you might be misunderstanding.

- Tue Oct 02, 2018 12:36 pm
- Forum: Resources
- Topic: Please Help re UVa @ https://uva.onlinejudge.org
- Replies:
**7** - Views:
**1177**

### Re: Please Help re UVa @ https://uva.onlinejudge.org

Main.java:2: error: class aUVa100 is public, should be declared in a file named aUVa100.java It IS "declared in a file named aUVa100.java" but... I don't know the online IDE/compiler this site uses, and I don't think I can access it without becoming a member. It clearly thinks it is in a file calle...

- Mon Oct 01, 2018 7:57 am
- Forum: Resources
- Topic: Please Help re UVa @ https://uva.onlinejudge.org
- Replies:
**7** - Views:
**1177**

### Re: Please Help re UVa @ https://uva.onlinejudge.org

Maybe you need to make the class public for it to run:

Code: Select all

`public class aUVa100`

- Tue Sep 25, 2018 6:14 pm
- Forum: News, Suggestions, and FAQ
- Topic: Progress Page turned orange.
- Replies:
**1** - Views:
**773**

### Re: Progress Page turned orange.

See euler's post here:

viewtopic.php?f=5&t=6663#p52409

viewtopic.php?f=5&t=6663#p52409

- Fri Sep 07, 2018 12:03 pm
- Forum: Clarifications on Project Euler Problems
- Topic: Problem 012
- Replies:
**99** - Views:
**21048**

### Re: Problem 012

The question is not asking for the first one with 112 divisors, but forsriramrajan wrote: ↑Fri Sep 07, 2018 9:04 amMy answer has112 divisors / factorsand is the first one in the series but was declared wrong.

... the first triangle number to haveover five hundreddivisors?

- Sat Jul 28, 2018 11:42 am
- Forum: News, Suggestions, and FAQ
- Topic: Mark problems that can be figured out through math alone
- Replies:
**3** - Views:
**948**

### Re: Mark problems that can be figured out through math alone

There is a thread on this forum discussing which problems can be solved with paper and pencil:

viewtopic.php?f=12&t=1982

viewtopic.php?f=12&t=1982

- Thu Jul 19, 2018 9:53 am
- Forum: News, Suggestions, and FAQ
- Topic: Add problem categories
- Replies:
**1** - Views:
**827**

### Re: Add problem categories

This has been asked before. Here is a previous answer:

viewtopic.php?f=5&t=3837&p=41793#p41793

viewtopic.php?f=5&t=3837&p=41793#p41793

- Tue Jul 10, 2018 1:49 pm
- Forum: Number
- Topic: an old maths olympiad question
- Replies:
**27** - Views:
**2632**

### Re: an old maths olympiad question

... hence $\sin 4x=\sin 3x$ implies $\sin(\pi-4x)=\sin 3x$ Nicely done. This is the trick that I missed. I thought we would have to go all the way up to $\sin(7x)$, which would be horrible. NOTE: All this in hindsight knowing that n should be 7. To derive it in an Olympiad is close to impossible fo...

- Mon Jul 09, 2018 3:21 pm
- Forum: Number
- Topic: an old maths olympiad question
- Replies:
**27** - Views:
**2632**

### Re: an old maths olympiad question

So people here can't solve an Olympiad question I probably could but I can't be bothered. Spending a couple of minutes here and there during breaks at work is rather different from actually solving it in Olympiad. Olympiad questions are often hard until some specific insight hits you, and it can ta...

- Mon Jul 09, 2018 12:28 pm
- Forum: Number
- Topic: an old maths olympiad question
- Replies:
**27** - Views:
**2632**

### Re: an old maths olympiad question

I can derive a cubic equation that cos(x) must satisfy where x is half the central angle, i.e. x=180/n. It is straightforward to see that: A1A2 = 2sin(x) A1A3 = 2sin(2x) A1A4 = 2sin(3x) Substituting this in the equation, and using the angle sum formulae sin(a+b)=sin(a)cos(b)+sin(b)cos(a) and cos(2a)...

- Mon Jul 09, 2018 9:02 am
- Forum: Number
- Topic: an old maths olympiad question
- Replies:
**27** - Views:
**2632**

### Re: an old maths olympiad question

Far as I know, a "regular" polygon has sides of equal length, call it length S, so: 1/A1A2 = 1/A1A3 + 1/A1A4 is the same as 1/S^2 = 1/S^2 + 1/S^2, the same as 1 = 1 + 1 so No polygon satisfies... I could be missing something but did you say there were 10 questions? A 1 , A 2 , A 3 , A 4 are consecu...

- Sun Jul 08, 2018 6:27 am
- Forum: Number
- Topic: an old maths olympiad question
- Replies:
**27** - Views:
**2632**

### Re: an old maths olympiad question

Whatever the missing question is, its answer probably relies on the fact that that polynomial can be written as (n-2)(n-1)n(n+1)(n+2)(n+3)+3. I have updated ot now. Is it my inexperience that I cannot see how to factor the polynomial? No. I cheated and typed it into Wolfram Alpha. If I were in a co...

- Sat Jul 07, 2018 2:58 pm
- Forum: Number
- Topic: an old maths olympiad question
- Replies:
**27** - Views:
**2632**