mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   PARI/GP (https://www.mersenneforum.org/forumdisplay.php?f=155)
-   -   PARI's commands (https://www.mersenneforum.org/showthread.php?t=13636)

science_man_88 2010-11-28 16:01

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

[url]http://rosettacode.org/wiki/Towers_of_Hanoi[/url]

CRGreathouse 2010-11-28 16:41

[QUOTE=science_man_88;239048]just picked a number I thought would take a while to test with.[/QUOTE]

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 2010-11-28 16:42

[QUOTE=science_man_88;239049]the list hasn't been updated in a while lol:

[url]http://rosettacode.org/wiki/Create_a_file[/url][/QUOTE]

If you can code it, go right ahead. No one has so far in Pari/GP.

science_man_88 2010-11-28 21:55

[QUOTE=CRGreathouse;239055]If you can code it, go right ahead. No one has so far in Pari/GP.[/QUOTE]

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 2010-11-28 23:05

[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)))[/CODE]

is my attempt at long multiplication.

science_man_88 2010-11-28 23:21

why is [URL="http://rosettacode.org/wiki/Guess_the_number/With_Feedback"]this[/URL] not complete lol, it only took [B][U][I][SIZE="4"]ME[/SIZE][/I][/U][/B] 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")[/CODE]

CRGreathouse 2010-11-29 00:27

[QUOTE=science_man_88;239081]It's the directory part that has stumped me because all of ms-dos make directory commands apparently are internal only use grrrr.[/QUOTE]

Right. Also making it work cross-platform if possible: not using ~ in Windows, for example.

CRGreathouse 2010-11-29 00:28

[QUOTE=science_man_88;239086][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)))[/CODE]

is my attempt at long multiplication.[/QUOTE]

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.

science_man_88 2010-11-29 00:30

[QUOTE=CRGreathouse;239098]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.[/QUOTE]

I used eval so people could use powers not the full written number., and yes it's incomplete.

CRGreathouse 2010-11-29 00:30

[QUOTE=science_man_88;239087]why is [URL="http://rosettacode.org/wiki/Guess_the_number/With_Feedback"]this[/URL] not complete lol, it only took [B][U][I][SIZE="4"]ME[/SIZE][/I][/U][/B] 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")[/CODE][/QUOTE]

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.

science_man_88 2010-11-29 00:31

[QUOTE=CRGreathouse;239100]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.[/QUOTE]

the site isn't updating I added the guessing script, and the rate counter lol.


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

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