Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: sammyMaX 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) (http://pastebin.com/2bFxiSBY)
primetest (Miller-Rabin Test) (http://pastebin.com/vv4FbsLa)
palprime (Palindrome Generator and Main Function) (http://pastebin.com/XQvW7L9t)
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).
-
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 :)
-
Maybe I should get a real Nspire CX to test my programs...oh wait that's why I entered this contest :)
-
Would an emulator work? I know that there is some software to make ROM's... <_<
-
I was using an emulator but apparently its speed is inaccurate.
-
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
-
Indeed, the speed of most emulators is not accurate at all. Benchmarking on real hardware was the only way to achieve fairness :)