![]() |
Been thinking of [URL="http://rosettacode.org/wiki/Sierpinski_triangle"]this[/URL] 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. |
1 Attachment(s)
order 6 Sierpinski triangle ?
|
[url]http://rosettacode.org/wiki/Repeat_a_string[/url]
[url]http://rosettacode.org/wiki/Keyboard_Input/Obtain_a_Y_or_N_response[/url] [url]http://rosettacode.org/wiki/Reverse_a_string[/url] [url]http://rosettacode.org/wiki/Read_entire_file[/url] 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: [B]unenlightening[/B] theres a reason. |
[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() ) ) ) ); } [/CODE] This should work last i checked but it doesn't. It seems to have trouble with [CODE]if(e=="e",break())[/CODE] 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. |
[CODE](b)-> {
my(c=0,d=b,a=0); [COLOR="Red"]for(x=1,b,[/COLOR] [COLOR="DarkOrange"]a=random(b);[/COLOR] [COLOR="Lime"]for(y=1,b, if(a<c||a==c||a==d||a>d, a=random(b), break() ) );[/COLOR] [COLOR="red"]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() ) ) ) )[/COLOR]; }[/CODE] [url]http://rosettacode.org/wiki/Guess_the_number/With_feedback_(player[/url]) The dark orange is a line that can be taken out. |
[url]http://rosettacode.org/wiki/Conditional_structures[/url]
this one is a long list lol; addhelp alias allocatemem apply [COLOR="Lime"]break [/COLOR] default error extern [COLOR="lime"]for fordiv forell forprime forstep forsubgroup forvec[/COLOR] getheap getrand getstack gettime global [COLOR="lime"]if [/COLOR] input install [COLOR="Lime"]kill[/COLOR] local my [COLOR="lime"]next[/COLOR] print print1 printp printp1 printtex quit read readvec return select setrand system [COLOR="lime"]trap[/COLOR] type [COLOR="lime"] until [/COLOR] whatnow [COLOR="lime"]while [/COLOR] write write1 writebin writetex |
[QUOTE][url]http://rosettacode.org/wiki/Repeat_a_string[/url][/QUOTE]
[CODE]repeat(string,x)=for(y=1,x,print1(string))[/CODE] done lol |
[QUOTE=science_man_88;239685][url]http://rosettacode.org/wiki/Repeat_a_string[/url]
[url]http://rosettacode.org/wiki/Keyboard_Input/Obtain_a_Y_or_N_response[/url] [url]http://rosettacode.org/wiki/Reverse_a_string[/url] [url]http://rosettacode.org/wiki/Read_entire_file[/url] 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: [B]unenlightening[/B] theres a reason.[/QUOTE] 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 [i]you[/i] 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. |
[QUOTE=CRGreathouse;239704]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 [i]you[/i] 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.[/QUOTE] [CODE]reverse(string)=my(v=Vec(Str(string)),c="");forstep(y=#v,1,-1,c=concat(c,v[y]));c[/CODE] done the reverse. |
[QUOTE=science_man_88;239701][CODE]repeat(string,x)=for(y=1,x,print1(string))[/CODE]
done lol[/QUOTE] I think you need to return the result as a string rather than print multiple copies. |
[QUOTE=science_man_88;239706][CODE]reverse(string)=my(v=Vec(Str(string)),c="");forstep(y=#v,1,-1,c=concat(c,v[y]));c[/CODE]
done the reverse.[/QUOTE] 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. |
| All times are UTC. The time now is 23:09. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.