mersenneforum.org  

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

Reply
 
Thread Tools
Old 2010-12-02, 02:16   #1915
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Been thinking of this one for a while now. I see the concept hard part is implementing what I know enough lol.

never mind lol I didn't fully get the concept, However I semi get it now.

Last fiddled with by science_man_88 on 2010-12-02 at 02:48
science_man_88 is offline   Reply With Quote
Old 2010-12-02, 16:04   #1916
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

order 6 Sierpinski triangle ?
Attached Thumbnails
Click image for larger version

Name:	Picture 5.jpg
Views:	55
Size:	71.2 KB
ID:	5936  
science_man_88 is offline   Reply With Quote
Old 2010-12-02, 16:52   #1917
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

203008 Posts
Default

http://rosettacode.org/wiki/Repeat_a_string
http://rosettacode.org/wiki/Keyboard..._or_N_response
http://rosettacode.org/wiki/Reverse_a_string
http://rosettacode.org/wiki/Read_entire_file

Since when are these not doable in PARI!. Just by looking I know 3 of them and if read(file) does read the full file it covers the last one lol. never mind lol:

unenlightening theres a reason.

Last fiddled with by science_man_88 on 2010-12-02 at 16:53
science_man_88 is offline   Reply With Quote
Old 2010-12-02, 17:35   #1918
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

838410 Posts
Default

Code:
(b)-> {
my(c=0,d=b,a=0);
for(x=1,b,a=random(b);
      for(y=1,b,
           if(a<=c||a>=d,
              a=random(b),
              break()
                  )
            );
          print("I guess "a" am I h,l,or e ?");
          e=Str(input());
                  if(e=="h",
                        d=a,
                     if(e=="l",
                         c=a,
                         if(e=="e",
                            break()
                            )
                        )
                     )
            );
}
This should work last i checked but it doesn't. It seems to have trouble with
Code:
if(e=="e",break())
I've tried form break() to break(4) no success. Never mind it's because I messed up the loop to check a and I used e both as a value and variable name I guess. I got it working.

Last fiddled with by science_man_88 on 2010-12-02 at 17:43
science_man_88 is offline   Reply With Quote
Old 2010-12-02, 17:50   #1919
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Code:
(b)-> {
my(c=0,d=b,a=0);
for(x=1,b,
     a=random(b);
     for(y=1,b,
          if(a<c||a==c||a==d||a>d,
             a=random(b),
             break()
            )
          );
        print("I guess "a" am I h,l,or e ?");
        g=input();
           if(g==h,
               d=a,
               if(g==l,
                  c=a,
                  if(g==e,
                  break()
                  )
                )
             )
  );
}

http://rosettacode.org/wiki/Guess_th...edback_(player) The dark orange is a line that can be taken out.

Last fiddled with by science_man_88 on 2010-12-02 at 18:07
science_man_88 is offline   Reply With Quote
Old 2010-12-02, 18:14   #1920
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

http://rosettacode.org/wiki/Conditional_structures

this one is a long list lol;

addhelp alias allocatemem apply break default error extern for fordiv forell forprime forstep forsubgroup forvec getheap getrand getstack gettime global if input install kill local my
next print print1 printp printp1 printtex quit read readvec return select setrand system
trap type until whatnow while write write1 writebin writetex
science_man_88 is offline   Reply With Quote
Old 2010-12-02, 18:17   #1921
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

838410 Posts
Default

Code:
repeat(string,x)=for(y=1,x,print1(string))
done lol
science_man_88 is offline   Reply With Quote
Old 2010-12-02, 18:21   #1922
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
http://rosettacode.org/wiki/Repeat_a_string
http://rosettacode.org/wiki/Keyboard..._or_N_response
http://rosettacode.org/wiki/Reverse_a_string
http://rosettacode.org/wiki/Read_entire_file

Since when are these not doable in PARI!. Just by looking I know 3 of them and if read(file) does read the full file it covers the last one lol. never mind lol:

unenlightening theres a reason.
I think I was the one who put each of those in PARI/GP/Omit.

Read entire file: Not possible* in GP. It can't distinguish between a file containing 1+1 and a file containing 2, for example.
Reverse a string: Unenlightening, as you guessed. But you may very well want to do this one, even though I didn't want to.
Get Y/N: Impossible* in GP, since the task requires that only Y or N, not Enter, be pressed.
Repeat a string: Unenlightening. Again, feel free to do this anyway.

* Not possible without using extern() or system(), as far as I know.
CRGreathouse is offline   Reply With Quote
Old 2010-12-02, 18:25   #1923
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

838410 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
I think I was the one who put each of those in PARI/GP/Omit.

Read entire file: Not possible* in GP. It can't distinguish between a file containing 1+1 and a file containing 2, for example.
Reverse a string: Unenlightening, as you guessed. But you may very well want to do this one, even though I didn't want to.
Get Y/N: Impossible* in GP, since the task requires that only Y or N, not Enter, be pressed.
Repeat a string: Unenlightening. Again, feel free to do this anyway.

* Not possible without using extern() or system(), as far as I know.
Code:
reverse(string)=my(v=Vec(Str(string)),c="");forstep(y=#v,1,-1,c=concat(c,v[y]));c
done the reverse.
science_man_88 is offline   Reply With Quote
Old 2010-12-02, 18:27   #1924
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
Code:
repeat(string,x)=for(y=1,x,print1(string))
done lol
I think you need to return the result as a string rather than print multiple copies.
CRGreathouse is offline   Reply With Quote
Old 2010-12-02, 18:28   #1925
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
Code:
reverse(string)=my(v=Vec(Str(string)),c="");forstep(y=#v,1,-1,c=concat(c,v[y]));c
done the reverse.
Great! Add it.

You may also want to register on RC so that your contributions show up under your name (or rather your chosen pseudonym) instead of under your IP address.
CRGreathouse is offline   Reply With Quote
Reply

Thread Tools


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 22:59.


Fri Aug 6 22:59:27 UTC 2021 up 14 days, 17:28, 1 user, load averages: 4.09, 4.16, 4.02

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.