Author Topic: sammyMaX's Nspire PalPrime  (Read 3299 times)

0 Members and 1 Guest are viewing this topic.

Offline sammyMaX

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 204
  • Rating: +9/-0
    • View Profile
sammyMaX's Nspire PalPrime
« on: May 14, 2013, 05:59:36 pm »
darn my code is waayyy longer than Jim Bauwens's and Xeda's...

My submission was in Nspire basic, and it had two helper functions along with the main palprime function. The main function generates palindromes and gives them to the prime tester. The prime tester uses the Miller-Rabin algorithm, which requires modular exponentiation, so there is also a modular exponentiation function. My code for each:
exprem (Modular Exponentiation)
primetest (Miller-Rabin Test)
palprime (Palindrome Generator and Main Function)
It takes around 2 seconds to calculate the 100th palprime, 6 seconds for the 250th palprime, 16 seconds for the 500th palprime, and 39 seconds for the 1000th palprime. The times were taken from an emulated Nspire CX running OS 3.1.0, at 100% emulation (normal speed).

Are you wondering who Sammy is? My avatar is Sammy.
   

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: sammyMaX's Nspire PalPrime
« Reply #1 on: May 15, 2013, 06:14:26 am »
It takes around 2 seconds to calculate the 100th palprime, 6 seconds for the 250th palprime, 16 seconds for the 500th palprime, and 39 seconds for the 1000th palprime. The times were taken from an emulated Nspire CX running OS 3.1.0, at 100% emulation (normal speed).

Having finished to time the Nspire entries, I can say your emulated Nspire wasn't at 100% (or, well, the emulation speed display was clearly inaccurate).
On a real CX 3.1, n=1000 took 2mins 33secs 5tenth.
But you really don't have to worry, each program was tested on the same calc (hardware and software) following a strict protocol ensuring performance fairness for everyone :)
« Last Edit: May 15, 2013, 06:15:17 am by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline sammyMaX

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 204
  • Rating: +9/-0
    • View Profile
Re: sammyMaX's Nspire PalPrime
« Reply #2 on: May 15, 2013, 07:04:22 am »
Maybe I should get a real Nspire CX to test my programs...oh wait that's why I entered this contest :)

Are you wondering who Sammy is? My avatar is Sammy.
   

Offline Joshuasm32

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 142
  • Rating: +19/-7
    • View Profile
    • Network
Re: sammyMaX's Nspire PalPrime
« Reply #3 on: May 15, 2013, 07:07:01 am »
Would an emulator work?  I know that there is some software to make ROM's...   <_<
My name is Josh and I a developer at Moonzean. I enjoy Radiohead, web development, Java, and cryptograms.
Spoiler For No Surprises, by Radiohead:
A heart that's full up like a landfill
A job that slowly kills you
Bruises that won't heal

You look so tired unhappy
Bring down the government
They don't, they don't speak for us

I'll take a quiet life
A handshake of carbon monoxide

And no alarms and no surprises
No alarms and no surprises
No alarms and no surprises
Silent, silent

This is my final fit
My final bellyache

With no alarms and no surprises
No alarms and no surprises
No alarms and no surprises please

Such a pretty house
And such a pretty garden

No alarms and no surprises
No alarms and no surprises
No alarms and no surprises please

Offline sammyMaX

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 204
  • Rating: +9/-0
    • View Profile
Re: sammyMaX's Nspire PalPrime
« Reply #4 on: May 15, 2013, 07:17:49 am »
I was using an emulator but apparently its speed is inaccurate.
« Last Edit: May 15, 2013, 07:20:06 am by sammyMaX »

Are you wondering who Sammy is? My avatar is Sammy.
   

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: sammyMaX's Nspire PalPrime
« Reply #5 on: May 15, 2013, 02:01:00 pm »
Yeah, the speed isn't very accurate. Accessing the RAM for example is much faster than on a real calc.

It's still much, much faster than my entry  :o

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: sammyMaX's Nspire PalPrime
« Reply #6 on: May 15, 2013, 02:05:58 pm »
Indeed, the speed of most emulators is not accurate at all. Benchmarking on real hardware was the only way to achieve fairness :)
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.