mersenneforum.org  

Go Back   mersenneforum.org > Math Stuff > Computer Science & Computational Number Theory > PARI/GP

Reply
 
Thread Tools
Old 2010-11-28, 16:01   #1761
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

here's one that works both for the thread and has something else in common with Mersenne forums:

http://rosettacode.org/wiki/Towers_of_Hanoi
science_man_88 is offline   Reply With Quote
Old 2010-11-28, 16:41   #1762
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

135338 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
just picked a number I thought would take a while to test with.
Yes, but the task is supposed to work with an arbitrary function. First, yours doesn't; second, it should really avoid such 'magic numbers'. What if, for example, the function took an hour to complete each run?
CRGreathouse is offline   Reply With Quote
Old 2010-11-28, 16:42   #1763
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

597910 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
the list hasn't been updated in a while lol:

http://rosettacode.org/wiki/Create_a_file
If you can code it, go right ahead. No one has so far in Pari/GP.
CRGreathouse is offline   Reply With Quote
Old 2010-11-28, 21:55   #1764
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
If you can code it, go right ahead. No one has so far in Pari/GP.
It's the directory part that has stumped me because all of ms-dos make directory commands apparently are internal only use grrrr.
science_man_88 is offline   Reply With Quote
Old 2010-11-28, 23:05   #1765
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

100000110000002 Posts
Default

Code:
longmultiply(a,b)= a=eval(a);b=eval(b);c=Vec(a);d=Vec(b);carry=0;answer=[];forstep(x=#d,1,[-1],if(d[x]==Vec("2"),print(yes)))
is my attempt at long multiplication.
science_man_88 is offline   Reply With Quote
Old 2010-11-28, 23:21   #1766
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

why is this not complete lol, it only took ME less than 10 minutes to work out lol.


Code:
guess_the_number(N=10)= a=random(N);print("guess the number between 0 and "N);for(x=1,N,if(x>1,print("guess again"));b=input();if(b==a,break()));print("You gueesed it correctly")

Last fiddled with by science_man_88 on 2010-11-29 at 00:08
science_man_88 is offline   Reply With Quote
Old 2010-11-29, 00:27   #1767
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

597910 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
It's the directory part that has stumped me because all of ms-dos make directory commands apparently are internal only use grrrr.
Right. Also making it work cross-platform if possible: not using ~ in Windows, for example.
CRGreathouse is offline   Reply With Quote
Old 2010-11-29, 00:28   #1768
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

175B16 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
Code:
longmultiply(a,b)= a=eval(a);b=eval(b);c=Vec(a);d=Vec(b);carry=0;answer=[];forstep(x=#d,1,[-1],if(d[x]==Vec("2"),print(yes)))
is my attempt at long multiplication.
I don't understand the program; it seems to never use c, carry, or answer. Is this just incomplete?

I certainly wouldn't use eval() unless I absolutely had to.
CRGreathouse is offline   Reply With Quote
Old 2010-11-29, 00:30   #1769
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
I don't understand the program; it seems to never use c, carry, or answer. Is this just incomplete?

I certainly wouldn't use eval() unless I absolutely had to.
I used eval so people could use powers not the full written number., and yes it's incomplete.
science_man_88 is offline   Reply With Quote
Old 2010-11-29, 00:30   #1770
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
why is this not complete lol, it only took ME less than 10 minutes to work out lol.


Code:
guess_the_number(N=10)= a=random(N);print("guess the number between 0 and "N);for(x=1,N,if(x>1,print("guess again"));b=input();if(b==a,break()));print("You gueesed it correctly")
So post it to the site! (For copyright reasons, I probably shouldn't post it there myself.)

You should break it onto multiple lines if possible first; that way it will look nice.
CRGreathouse is offline   Reply With Quote
Old 2010-11-29, 00:31   #1771
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
So post it to the site! (For copyright reasons, I probably shouldn't post it there myself.)

You should break it onto multiple lines if possible first; that way it will look nice.
the site isn't updating I added the guessing script, and the rate counter lol.

Last fiddled with by science_man_88 on 2010-11-29 at 00:32
science_man_88 is offline   Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do I sometimes see all the <> formatting commands when I quote or edit? cheesehead Forum Feedback 3 2013-05-25 12:56
Passing commands to PARI on Windows James Heinrich Software 2 2012-05-13 19:19
Ubiquity commands Mini-Geek Aliquot Sequences 1 2009-09-22 19:33
64-bit Pari? CRGreathouse Software 2 2009-03-13 04:22
Are these commands correct? jasong Linux 2 2007-10-18 23:40

All times are UTC. The time now is 23:03.


Fri Aug 6 23:03:18 UTC 2021 up 14 days, 17:32, 1 user, load averages: 3.70, 3.95, 3.96

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.