Omnimaga

Calculator Community => Other Calculators => Topic started by: persalteas on April 04, 2013, 05:14:28 am

Title: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: persalteas on April 04, 2013, 05:14:28 am
Hello everyone,

It has been time TI-Planet have not organized a contest, and here is the lack filled ;)
So we organize a contest, about 5 weeks, well mixing arithmetic and algorithmics.


Introduction:
In mathematics, a prime palindom number is a number which is both prime and palindromic.

A prime number is an integer that only admits two positive and integer divisors (which are 1 and itself).
This definition excludes 1, which has only one positive and integer divisor ; it excludes 0 too, which is divisible by all the positive integers.
For example 6 = 2 × 3 is not prime and 21 = 3 × 7 or 7 × 3 either. But 11 is prime because 1 and 11 are the only divisors of 11.
So, the prime numbers are, in order, 2, 3, 5, 7, 11...

A palindromic number is a number whose writing (in base 10) is read in the same way from left to right and from right to left.
For example, all the 1-digit numbers are palindromic: 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.
The 2-digit palindroms are: 11, 22, 33, 44, 55, 66, 77, 88 and 99.
101 is a 3-digit palindromic number.

So, the prime palindromic numbers are: 2, 3, 5, 7, 11, 101, 131...

Subject :
Make a program fastest as possible to find the n-th prime palindromic number.

Plateform :
The candidate will perform its participation:
Categories:
The candidate's production will be judged in one of those categories:
Languages :
NB: on TI-82Stats/83/84,TI-Basic and assembly combinations are allowed.

Constraints :
On TI-82Stats/83/84/76, the program will catch n in the 'Ans' variable, and will send the nth prime palindromic number as a result in Ans.
For example, to obtain the 42th prime, we will type:
In each case, the program should send the result 18181 in Ans, reusable in the home screen for calculations.


On TI-Nspire, the main program should be a function which take the n parameter and which sends the result. For example, palprem(42) should answer 18181.

YOU MUST NOT USE a pre-calculated list of prime palindromic numbers in your program, directly under penalty of disqualification.

YOU MUST NOT USE functions like isPrime() which would provide a direct response, it destroys the value of algorithmic thinking, and it would be unfair to those who don't have this function... ;)

The program MUST run on not-CAS TI-Nspires.

Notation :
The final score will be on 20 points, and the scale is as follows:
Jury :
Participations are rated on an equitable basis according to a common scale by a jury whose composition is as follows:
When ? :
The contest starts Monday the 1st of April 2013 and finishs Sunday the 12th of May, 23h59 (GMT+1)

How ? :
To participate, candidates must send to the email address [email protected] :
The e-mail correctly send is taken as an entry.

Lots :
Through our partnership with TI-France and Jarrety, the winners of the contest (one winner per category) will be rewarded with:
1st price in the Nspire category: a TI-Nspire CX (not CAS)
1st price in the TI-82/83/84 category : a TI-84 Pocket.fr

Complete rules:
The complete rules for this contest, legally registered to an usher, are available on
TI-Planet (http://tiplanet.org/forum/archives_voir.php?id=12093) or the  UPECS website (http://upecs.org/upload/R%C3%A8glement_concours_TI-Planet_2013.pdf). (French)


See you soon on TI-Planet !

PS: I know I'm a bit late, because the contest has started...
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Spyro543 on April 04, 2013, 06:46:58 am
So no Casio calcs then? :|

Maybe I could still make one for the fun of it :3
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Xeda112358 on April 04, 2013, 06:50:51 am
Oh my gosh, this sounds fun o.o I probably won't have time, though, but if I do, I will try!

Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: dinosteven on April 04, 2013, 07:51:59 am
Even though it says no pre-calculated lists... Can we use one for 2 and 3? The fastest algorithm I've got disregards 2 and 3...
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: TIfanx1999 on April 04, 2013, 08:32:51 am
Ok I'm confused. The PDF lists the prizes as:
Quote from: The rules translated
ARTICLE 6: Staffing
Competitions organized by TI-Planet will feature several awards. All lots, specified below
below, will be shared between the events of the competition.
● 5x (five) TI-Nspire CX CAS (unit value: 150 €)
● 3x (three) TI-Nspire CX (unit value: € 13 0)
● 2x (two) TI-84 Pocket.fr (unit value: 100 €)
● 3x (three) TI-83 Plus.fr (unit value: € 90)
● 3x (three) TI-82 Stats.fr (unit value: € 70)
● 3x (three) TI-Collège Plus (unit value: € 18)
The website reserves the right to add additional lots.

Your post however only lists two prizes. Which is correct?
I also want a clarification, are there only two categories? One being Nspire and one being Z80? It looks as though all Z80 regardless of language is being judged together. If someone who's judging could answer, that'd be great.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Dapianokid on April 04, 2013, 10:10:45 am
I'm SOOOO IN!
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Adriweb on April 04, 2013, 10:22:32 am
Ok I'm confused. The PDF lists the prizes as:
Quote from: The rules translated
ARTICLE 6: Staffing
Competitions organized by TI-Planet will feature several awards. All lots, specified below
below, will be shared between the events of the competition.
● 5x (five) TI-Nspire CX CAS (unit value: 150 €)
● 3x (three) TI-Nspire CX (unit value: € 13 0)
● 2x (two) TI-84 Pocket.fr (unit value: 100 €)
● 3x (three) TI-83 Plus.fr (unit value: € 90)
● 3x (three) TI-82 Stats.fr (unit value: € 70)
● 3x (three) TI-Collège Plus (unit value: € 18)
The website reserves the right to add additional lots.

Your post however only lists two prizes. Which is correct?
I also want a clarification, are there only two categories? One being Nspire and one being Z80? It looks as though all Z80 regardless of language is being judged together. If someone who's judging could answer, that'd be great.

The PDF file is the rules for the 2013 event (which is, actually : several contests during the year). The prizes for this specific contest are the one listed on this topic.
(the meaning in english is that all the prizes specified below will be shared between the several TI-Planet 2013 contests."
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: TIfanx1999 on April 04, 2013, 10:30:56 am
Alright, thank you for the clarification. :) What about the categories? It's just two right?
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: chickendude on April 04, 2013, 02:27:51 pm
What size numbers should we be expected to handle? 16-bit?
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Lionel Debroux on April 04, 2013, 02:29:46 pm
Clearly more than 16 bits.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: CVSoft on April 04, 2013, 02:50:48 pm
The first 70 palindromic primes are less than 65536, but anything after requires larger integers.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: chickendude on April 04, 2013, 03:47:26 pm
That's a little more complicated for the z80 :/
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Adriweb on April 04, 2013, 05:08:12 pm
What size numbers should we be expected to handle? 16-bit?
Well, we'll test against several numbers, from low to mid to big ones, so ... :P
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Deep Toaster on April 04, 2013, 08:29:27 pm
What size numbers should we be expected to handle? 16-bit?
Well, we'll test against several numbers, from low to mid to big ones, so ... :P
Are we allowed to ask how big the biggest numbers are? ;D
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: DJ Omnimaga on April 04, 2013, 09:20:06 pm
mathematics

What are mathematics? Are they a new program release for the TI-84 Plus adding extra functionality to that video gaming console? O.O

Seems like an interesting contest, though. Good luck to whoever participates! :)
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Runer112 on April 04, 2013, 09:39:05 pm
I have multiple questions:


EDIT: One more question, can we store some prime palindromes as long as it's not just a straightforward list of them? If so, are there restrictions?
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Adriweb on April 05, 2013, 02:25:58 am
How large of numbers do we have to handle?[/li][/list]
We did not specify a specific range. We'll test against a number of values (positive integers), from small to bigger ones.

How will speed be measured? Does our algorithm need to be fast for small numbers, large numbers, or both? If both, does one matter more than the other?[/li][/list]
I guess we'll be measuring speed among the same kind of programs, by launching them with the same number, and measuring with a chronometer each one, from the "enter" key pressed to the end of the program. We'll do that, as said, for multiple numbers ranging from small to bigger ones.
About the second question, I guess it would have to work for both in order to have the maximum amount of points. But obviously, if your algorithm is the one (or one of the few) that really works well for big numbers, and relatively fast, well, that'll be good.

Is there some limit on program size, or does size somehow factor into judging?[/li][/list]
We did not specify any program size, since we'll mainly test against speed. However, a 1k (<- I just invented this size) program will probably have a better grade than a 10k one...

Can we use pre-calculated data that isn't a list of prime palindromes? And if so, is there a limit to what/how much we can use?[/li][/list]
There was discussion too about this on TI-Planet, what got out of that was that as long as it's mainly not a list of "things" (palindromes, directly, primes directly, or RLE-encoded things) that would be used to search through ( / parse / decode ) to directly give the answer for the requested number.

And a non-technical question, can we submit entries for multiple platforms/languages?[/li][/list]
Nope, sorry.

EDIT: One more question, can we store some prime palindromes as long as it's not just a straightforward list of them? If so, are there restrictions?
See my previous answer, I guess ?
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Adriweb on April 05, 2013, 07:15:39 am
I'm translating critor's post from TI-Planet ( http://tiplanet.org/forum/viewtopic.php?p=137928#p137928 )

Quote
Hello,

We have disccused yesterday evening about the issue [of asm/basic being judged the same way]

In the z80 category :
  • we receive valid ASM and Basic entries
  • the majority of ASM entries would yield faster results than Basic ones
So, we are ready to actually make it so there are 3 categories ((TI-Basic z80, Asm z80, TI-Nspire)), and so we add another TI-84 Pocket.fr to win.

That should appease your fear, and you should't worry any more about a possible unfairness, of course if we receive quality ASM entries.

A hybrid program (asm + basic) will be considered ASM.

For now, we only have received one entry, and we couldn't really compare anything.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: TIfanx1999 on April 05, 2013, 07:27:09 am
Thank you for all your answers. Sounds good! :)
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Runer112 on April 05, 2013, 11:08:18 am
About the size thing again, surely there must be some established limit? For instance, the Ans variable on the 82/83/84 can only store integers up to 14 digits without loss of information, so there has to be at least a hard limit for that. And chances are finding nth palindromes that are that long would take far too long anyways. It would also be helpful for assembly programmers to know a limit; it doesn't seem right to leave us in the dark in a speed competition, encouraging us to gamble on using smaller numbers for faster math. Someone may have an advantage just because they guessed the minimal number size that still works, and someone else's efforts may completely be wasted if they used numbers slightly too small and their program ended up not passing the tests at all.

Another follow-up question, can we get a bit more information about how scoring will work? I'm especially wondering about things like how speed for varying number sizes will be scored. How will the speed of assembly programs be compared for small values, considering they may complete the computation in a fraction of a second? And if one program uses a heavy but high-end-optimized algorithm that takes, say, 0.7 seconds, 2 seconds, 8 seconds, and 36 seconds on tests while another program that uses a lighter but less high-end-optimized algorithm takes 0.2 seconds, 0.7 seconds, 5 seconds, and 114 seconds for the same tests, which would win?
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Adriweb on April 05, 2013, 11:50:25 am
About the size thing again, surely there must be some established limit? For instance, the Ans variable on the 82/83/84 can only store integers up to 14 digits without loss of information, so there has to be at least a hard limit for that. And chances are finding nth palindromes that are that long would take far too long anyways. It would also be helpful for assembly programmers to know a limit; it doesn't seem right to leave us in the dark in a speed competition, encouraging us to gamble on using smaller numbers for faster math. Someone may have an advantage just because they guessed the minimal number size that still works, and someone else's efforts may completely be wasted if they used numbers slightly too small and their program ended up not passing the tests at all.

Another follow-up question, can we get a bit more information about how scoring will work? I'm especially wondering about things like how speed for varying number sizes will be scored. How will the speed of assembly programs be compared for small values, considering they may complete the computation in a fraction of a second? And if one program uses a heavy but high-end-optimized algorithm that takes, say, 0.7 seconds, 2 seconds, 8 seconds, and 36 seconds on tests while another program that uses a lighter but less high-end-optimized algorithm takes 0.2 seconds, 0.7 seconds, 5 seconds, and 114 seconds for the same tests, which would win?
I completely agree with you about the first paragraph, however for the details about notation, I'd let Critor and/or Lionel reply.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Runer112 on April 05, 2013, 01:21:04 pm
I guess I have one or two more questions for now... Sorry for the slew of questions but hopefully they'll help clear things up for people besides myself as well.

Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Jim Bauwens on April 05, 2013, 02:02:02 pm
I guess I have one or two more questions for now... Sorry for the slew of questions but hopefully they'll help clear things up for people besides myself as well.

  • I'm assuming that we are allowed to pre-calculate and store the values of the first few prime palindromes, like the ones with 2 or fewer digits (2, 3, 5, 7, 11), correct? Some algorithms can't really find some of these on their own and instead depend upon them being given. Storing these special cases should take less space and running time than modifying the algorithm to find them itself, and in some ways modifying the algorithm to find specific values is more or less the same thing, right?
  • Related to the question above, should we agree upon some hard rule about what values can be pre-calculated and stored? I assume this rule would either have to allow a precise set of values or an maximum amount of values.

Yes, I've been wondering this too. In my current approach I have 2 and 3 hardcoded, and use 5 as a starting point. Not having them predefined would make things much more complex.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: critor on April 05, 2013, 03:11:30 pm
I guess I have one or two more questions for now... Sorry for the slew of questions but hopefully they'll help clear things up for people besides myself as well.

  • I'm assuming that we are allowed to pre-calculate and store the values of the first few prime palindromes, like the ones with 2 or fewer digits (2, 3, 5, 7, 11), correct? Some algorithms can't really find some of these on their own and instead depend upon them being given. Storing these special cases should take less space and running time than modifying the algorithm to find them itself, and in some ways modifying the algorithm to find specific values is more or less the same thing, right?
  • Related to the question above, should we agree upon some hard rule about what values can be pre-calculated and stored? I assume this rule would either have to allow a precise set of values or an maximum amount of values.


There is no hard-rule, but we perfectly understand that you have to start the algorithm by intialising some variables to the 1st prime numbers.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Runer112 on April 05, 2013, 03:19:37 pm
Can we pre-calculate and store answers that aren't the very first values, as long as it's not a straightforward list of all the answers? I had an idea of speeding mine up by storing, say, every 100th prime palindrome and using them as base points for calculations to reduce computation time for large inputs/outputs. If this isn't allowed, I think it should probably be made clear that except for a few starting values, your algorithm must go through all prime palindromes to get up to the target.

EDIT: Also, do we have an official ruling yet on the largest input our programs need to work on? They could certainly be different for different platforms/languages, but establishing some would be really nice.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Xeda112358 on April 07, 2013, 09:40:49 am
So, I am curious, too, with what Runer is asking. For example, in TI-BASIC, although we could make a program to handle arbitrary precision, can we safely assume that we will only be using up to 14-digit numbers?
Spoiler For My Current Results:
(TI-BASIC, TI-84+SE)
Currently, my program can find the following values in the following time:
42:prgmPALPREM , 23 seconds, returns 18181
100:prgmPALPREM , 88 seconds, returns 94049
290:prgmPALPREM , 682 seconds, returns 1958591

These are big improvements over previous versions:
42 : 44→40→30→27→23
100: 280→199→135→101→88
290: 4700→2256→1375→732→682

So it has been getting a lot faster for larger numbers, but it still takes 12.2 minutes to compute the 290th term XD I have only been modifying the prime testing routine each time, but maybe if I can make the palindrome generating routine faster, I can get better times o.o
EDIT: Updated stats with version 5
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Lionel Debroux on April 07, 2013, 11:21:49 am
Given the figures you're posting, spending time on handling numbers larger than 14 digits is, indeed, unnecessary - at least for a TI-Z80 BASIC program. I don't know what the benchmarks look like for Nspire BASIC.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Xeda112358 on April 07, 2013, 11:36:40 am
Dapianokid said his took 11 seconds to compute the 42nd prime palindrome, but from the conversation, he may have a much more efficient algorithm for larger values. I think his was also running at 150MHz, so I am not sure.

Has anybody set any benchmarks for other languages?
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: compu on April 07, 2013, 03:56:44 pm
Here are my current results for Nspire Basic, but I am not very good at things like this ;D
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: sammyMaX on April 07, 2013, 04:27:41 pm
What do the rows mean? Are the upper rows the times for earlier versions of the program, and the lower rows the times for later versions?
Edit: now that I think about it, that wouldn't make sense. What do the rows mean?
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: compu on April 07, 2013, 04:44:12 pm
The last row is the latest version of the program. The columns show the time in seconds to calculate the n-th (22, 150, 50, 250) palindromic prime on a classic CAS OS or the student software.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: sammyMaX on April 07, 2013, 06:53:17 pm
Ah, I see. The computer software is not an exact emulator then, and it runs faster?

I made my program in the Nspire emulator. Is there any way to extract the TNS file from the emulator? Right now, there is only a saved flash image.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Dapianokid on April 07, 2013, 08:39:03 pm
Dapianokid said his took 11 seconds to compute the 42nd prime palindrome, but from the conversation, he may have a much more efficient algorithm for larger values. I think his was also running at 150MHz, so I am not sure.

Has anybody set any benchmarks for other languages?

I was running at 264MHz. Also, mine exponentially gets slower with bigger numbers,
so I'm rewriting it to be roughly the same for all possible Nspire values.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Xeda112358 on April 09, 2013, 02:07:47 pm
I refined my algorithm for prime testing. Now my current speeds are:
42nd palprime : 22 seconds, 18181
100th palprime : 84 seconds, 94049
290th palprime : 552 seconds, 1958591

Yesterday, my record for the 290th was something like 682 seconds, so it improved by 130 seconds o_o My new algorithm will prove exponentially faster (I believe) for larger values.
EDIT: Again, TI-BASIC, z80 on a TI-84+
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Streetwalrus on April 09, 2013, 04:01:34 pm
Are we allowed to use 15mhz in axe/asm ? :devil:
Also 32 bit math in ASM isn't very hard so we can get pretty large values (the biggest 32 bit palindrome is 4 294 994 924). Means that BASIC will be slower but in ASM we get numbers a bit smaller.
I'm trying my hand at axe right now to see how feasible it is. Then I'll introduce some ASM for 32 bit stuff. ;D I'm not Runer though. :P

And since ASM will be so fast that we can't stopwatch it, I believe that cycles will be counted ?
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Dapianokid on April 09, 2013, 06:07:21 pm
Streetwalker, I do'nt believe it will be that fast when you test out much larger numbers like 1777771.
I refined mine and the size does not matter, and I invented a new algorithm for primality!
Average time: .028 seconds per digit.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Xeda112358 on April 09, 2013, 06:10:18 pm
I did a rough estimate and I think that z80 assembly with 32-bit stuff ought to go through 300 palindromes per second at 6MHz.

Also, I wonder what your method is? >:D
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: DrDnar on April 09, 2013, 09:23:40 pm
I prefer to heat up my calculator with overclocking.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Streetwalrus on April 10, 2013, 02:16:21 am
Lol I'm currently using the exact same algorithm as in BASIC and now it takes 4.5 secs to find the 1000th prime (15mhz Axe). :P
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Nick on April 10, 2013, 03:21:05 am
Dammit, I hate it to hear you guys just throwing those tiny numbers at my face, while I'm just sitting here, wondering how to even start :)
Good luck, seems like there'll be a lot of competition around here...
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Adriweb on April 10, 2013, 03:41:22 am
Lol I'm currently using the exact same algorithm as in BASIC and now it takes 4.5 secs to find the 1000th prime (15mhz Axe). :P
But palindromic too ? :P
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Streetwalrus on April 10, 2013, 04:28:00 am
Nope just regular old boring primes. Result is 7919. I'm thinking of a good way to make palindromes. Are binary ones allowed ? :P
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: TIfanx1999 on April 10, 2013, 05:14:22 am
Although I don't see mention of it, the first post list all its examples in decimal. Judging by that, I'd say that they want the output in decimal format.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Xeda112358 on April 10, 2013, 06:16:57 am
So, my calculation of "300 per second" was off by quite a bit. I forgot to calculate in non-primes and the wasted cycles there :P I only get about 30 primes per second, but my algorithm could be better refined XD

(And this is at 6MHz)
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Streetwalrus on April 10, 2013, 06:58:24 am
Although I don't see mention of it, the first post list all its examples in decimal. Judging by that, I'd say that they want the output in decimal format.
I understand this, what I was asking was if we were allowed to use numbers that are palindromes in binary but that was just a joke. :P
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: TIfanx1999 on April 10, 2013, 07:21:00 am
I got that, but missed the joke. :P
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Streetwalrus on April 11, 2013, 11:22:37 am
I finally got around making the palindrome generator. that was easy. 8)
Stats :
The first five (2, 3, 5, 7, 11) are hardcoded because my palindrome gen wont work with less than 3 digits.
42nd palprime : 18181, 164/512 = 0.32 seconds 155/512 = 0.3 seconds.
70th palprime : 39293, 428/512 = 0.84 seconds 381/512 = 0.74 seconds. Unfortunately, that's the furthest we can go with 16 bits.
This is an Axe program that works with 16 bits integers at full speed.

I measure the speed with the max speed interrupt running theta++ every time. I display the value of theta at the end. Since this is a 512Hz interrupt, I just have to divide by 512 to know the time it took. ;)

Edit : Dropped in a crazy optimization that brought my times down by a fair amount. :P
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Runer112 on April 11, 2013, 12:42:31 pm
Can we pre-calculate and store answers that aren't the very first values, as long as it's not a straightforward list of all the answers? I had an idea of speeding mine up by storing, say, every 100th prime palindrome and using them as base points for calculations to reduce computation time for large inputs/outputs. If this isn't allowed, I think it should probably be made clear that except for a few starting values, your algorithm must go through all prime palindromes to get up to the target.

EDIT: Also, do we have an official ruling yet on the largest input our programs need to work on? They could certainly be different for different platforms/languages, but establishing some would be really nice.

Can we get some official rulings on these two questions? I'm especially concerned about the first one, because unless it is specified that the search algorithm has to pass through every prime palindrome up to the target (except perhaps for the first five, which I know some algorithms take as given and wouldn't even be able to find some of them), then people will start using the method of storing "checkpoints" to drastically reduce the number of steps to get to an answer. The issue with this is that the competition would just become more of a battle of who can fit in the most checkpoints, rather than a battle of who can create the best searching algorithm.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Streetwalrus on April 11, 2013, 12:46:31 pm
I totally agree with you Runer, checkpoints are unfair and even though they decrease max computing time, they make searching time random depending on wether you're just before a checkpoint or just after.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Dapianokid on April 11, 2013, 01:42:24 pm
Well I believe there should be a check for the 10th, 50th, and 100th palindromes, or three within a certain range, depending on the model. That way, everybody can fairly compare. :)
I lost my function! Rewriting it now...
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: sammyMaX on April 11, 2013, 04:56:22 pm
I really don't think such checkpoints should be allowed. It wouldn't contribute anything to the algorithmic thinking the competition is supposed to promote. Suppose checkpoints were allowed. Competitors would need to use them to keep up with other programs that use checkpoints, so all the good entries have them.

If, like  Dapianokid said, people could only store the 10th, 50th, and 100th palindromic primes, then all the programs would still start testing with the same number (say if we wanted the 74th prime palindrome, everyone would start with the 50th one), so the winner would be the person with the most efficient algorithm. That person still would have won if they started testing numbers from the beginning, so why not just start testing numbers from the beginning? It makes the programs simpler, smaller, and more "pure" anyways.

Meanwhile, if people could store whatever palindromic primes they wanted, the winner would be either:
a) lucky that he/she happened to store the palindromic primes just below the numbers wanted
b) someone who precomputed a huge number of palindromic primes
And both a) and b) imply that the efficiency of the actual algorithm used to search for palindromic primes is not important, which is bad.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Dapianokid on April 11, 2013, 05:06:43 pm
I meant "check" as in test, so that timings were based off of those numbers.

I do not advocate checkpoints.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: sammyMaX on April 11, 2013, 05:08:24 pm
Okay, I agree with having official numbers to get timings.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Dapianokid on April 11, 2013, 05:09:42 pm
If somebody could come up with a closed form function (which I am close to.. It's approximate..) then Sammy would be happy.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: dinosteven on April 24, 2013, 08:08:07 am
I have a question: What program do we submit if we're doing Axe? The compiled executable, or the source?
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Adriweb on April 24, 2013, 08:17:57 am
I have a question: What program do we submit if we're doing Axe? The compiled executable, or the source?
You'd have to give both.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: dinosteven on April 24, 2013, 10:24:44 am
Okay, thanks.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: jacobly on April 30, 2013, 01:08:52 am
I have a question: What program do we submit if we're doing Axe? The compiled executable, or the source?
You'd have to give both.
I assume this applies to z80 assembly also?

So, my calculation of "300 per second" was off by quite a bit. I forgot to calculate in non-primes and the wasted cycles there :P I only get about 30 primes per second, but my algorithm could be better refined XD

(And this is at 6MHz)
According to my calculations, this is almost exactly the worst-case speed I am getting (29.78 pps). :o

Edit: Runer suggested that I don't post timings so as not to discourage anyone, so I'll just say that my program can get the 5953rd palprime in under an hour. ;)
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Hayleia on April 30, 2013, 11:19:27 am
Edit: Runer suggested that I don't post timings so as not to discourage anyone, so I'll just say that my program can get the 5953rd palprime in under an hour. ;)
Lol, that is too late, I got discouraged when I learnt that Runer and you were participating, no need to post your timings :P
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Xeda112358 on May 10, 2013, 06:26:05 am
Wow, I thought this was already done and I hadn't submitted in time! I have my last exams today, so maybe I can work on my programs a little more.
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Adriweb on May 10, 2013, 07:30:16 am
You still have semething like 58 hours :P (at the time of this post)
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Xeda112358 on May 12, 2013, 09:38:47 am
Today is the final day I think there are about 8 hours left!
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Lionel Debroux on May 12, 2013, 12:47:13 pm
A bit more than five hours left... don't forget to send the files in ;)
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Xeda112358 on May 12, 2013, 02:10:18 pm
I have sent mine. Now I will probably think of some super awesome optimisation that I could have done XD
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Lionel Debroux on May 12, 2013, 02:33:00 pm
You can send multiple versions (in fact, some people have), we'll keep the latest one :)
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: sammyMaX on May 12, 2013, 07:40:44 pm
The contest ended and we are allowed post code/discuss now, right?
Title: Re: [TI-Planet Contest] Heat up your calc with arithmetic !
Post by: Lionel Debroux on May 29, 2013, 08:31:53 am
(reading and replying to posts after the weeks of broken e-mail notifications which caused me to miss lots of topic updates)

Yup, the submissions were published on TI-Planet, and people can discuss :)