Re: [PHP] Help converting C to PHP
On Fri, September 22, 2006 7:40 pm, Rory Browne wrote: Fair enough. Prime Number Script Competition ( for Bragging Rights ). I challenge the readers of this list to produce the necessary code to find the lowest prime number higher than a certain inputted number. The script must be web based, and ask the user to enter a number. The script must then calculate the lowest Prime Number above that number. Scripts will be rated on Functional Accuracy ( the program must correctly perform its required function ), Code Maintainability(eg Presence of Comments, etc ), Ease of Use, and Code Efficiency, in that order. Brownie points may be earned through use interesting or original ideas or methodologies, provided they do not compromise the previous four criteria. The submitted script will be rated by volunteers from this list. Submitting an entry disqualifys you as a volunteer judge, whilst judging someone elses code disqualifys you as a candidate. Deadline for submissions is 12:00 (Noon) (CEST UTC + 2 Hours) on Friday 29 September. Interesting to see (a) if anyone enters, and (b) what the code will be like. I think it would be a lot of fun if well executed. I'm in. What's the submission process? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help converting C to PHP
Whoops - sorry replied directly to Richard instead of to the list. Submission process is simply to post to the list. It's probably a good idea ( and acceptable ) to just post an SHA1(MD5 for this purpose is compromised) hash of your code before the deadline, and submit your actual code shortly after the deadline. The result must be greater than the input. For 2 as an input, I'd expect 3 as output. Rory
RE: [PHP] Help converting C to PHP
[snip] Codegolf... heh.. nice little twist. [/snip] At least we weren't asked to help someone write his homework. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help converting C to PHP
On 9/22/06, Kevin Waterson [EMAIL PROTECTED] wrote: This one time, at band camp, Curt Zirzow [EMAIL PROTECTED] wrote: what about using: php.net/pi note the precision description. or are we talking about a different pi. The goal of the codegolf.com challenge is to print pi to 1000 places. The programmer to do it in the least keystrokes is the winner. I personally don't think this is a very healthy contest. It discourages comments, and use of whitespace to make code readable. I'd perfer a contest that rewarded code readability, and maintainability as well as minimal keystrokes. After all you only enter the aforementioned keystrokes once. Perhaps one like codegolf, with an enforced coding style ( eg KR Style, or GNU Style)
Re: [PHP] Help converting C to PHP
At 2:38 PM +0200 9/22/06, Rory Browne wrote: On 9/22/06, Kevin Waterson [EMAIL PROTECTED] wrote: The goal of the codegolf.com challenge is to print pi to 1000 places. The programmer to do it in the least keystrokes is the winner. I personally don't think this is a very healthy contest. It discourages comments, and use of whitespace to make code readable. I'd perfer a contest that rewarded code readability, and maintainability as well as minimal keystrokes. After all you only enter the aforementioned keystrokes once. Perhaps one like codegolf, with an enforced coding style ( eg KR Style, or GNU Style) Agreed, but our old ways remain to haunt us. tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help converting C to PHP
2006/9/22, Rory Browne [EMAIL PROTECTED]: On 9/22/06, Kevin Waterson [EMAIL PROTECTED] wrote: This one time, at band camp, Curt Zirzow [EMAIL PROTECTED] wrote: what about using: php.net/pi note the precision description. or are we talking about a different pi. The goal of the codegolf.com challenge is to print pi to 1000 places. The programmer to do it in the least keystrokes is the winner. I personally don't think this is a very healthy contest. It discourages comments, and use of whitespace to make code readable. I'd perfer a contest that rewarded code readability, and maintainability as well as minimal keystrokes. After all you only enter the aforementioned keystrokes once. Perhaps one like codegolf, with an enforced coding style ( eg KR Style, or GNU Style) I completely agree. This kind of contests do not provide any measure of the good qualities of a programmer working as part of a team. The objectives ussualy end up being something of the sort: let's see who can fit the most in a for declaration. Anyway... as you say, it would be nice to have a contest that rewards readability and maintainability... but, how can we messure that qualities in this type of games? Should your code be praised by others and voted on? Is that reliable? I think enforcing a coding style is too restrictive... Also, how do we measure the declarativity of var and function names?
Re: [PHP] Help converting C to PHP
Martin Alterisio wrote: 2006/9/22, Rory Browne [EMAIL PROTECTED]: On 9/22/06, Kevin Waterson [EMAIL PROTECTED] wrote: This one time, at band camp, Curt Zirzow [EMAIL PROTECTED] wrote: what about using: php.net/pi note the precision description. or are we talking about a different pi. The goal of the codegolf.com challenge is to print pi to 1000 places. The programmer to do it in the least keystrokes is the winner. I personally don't think this is a very healthy contest. It discourages comments, and use of whitespace to make code readable. I'd perfer a contest that rewarded code readability, and maintainability as well as minimal keystrokes. After all you only enter the aforementioned keystrokes once. Perhaps one like codegolf, with an enforced coding style ( eg KR Style, or GNU Style) I completely agree. This kind of contests do not provide any measure of the good qualities of a programmer working as part of a team. The objectives ussualy end up being something of the sort: let's see who can fit the most in a for declaration. Anyway... as you say, it would be nice to have a contest that rewards readability and maintainability... but, how can we messure that qualities in this type of games? Should your code be praised by others and voted on? Is that reliable? I think enforcing a coding style is too restrictive... Also, how do we measure the declarativity of var and function names? The value of these games is that they give you interesting problems to solve without forcing you to maintain the code. That's the entire point. It's exactly the sort of thing that's fun to write when you have to make a living from your code the rest of the time. If you want to write quality software in your free time then you start/join an FOSS project and put the code to good use. Nobody is claiming that this is a good way to write code or a good way to learn PHP, it's just for fun. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help converting C to PHP
Hello all, I personally don't think this is a very healthy contest. It discourages comments, and use of whitespace to make code readable. Anyway... as you say, it would be nice to have a contest that rewards readability and maintainability... but, how can we messure that qualities in this type of games? Should your code be praised by others and voted on? Is that reliable? I think enforcing a coding style is too restrictive... Also, how do we measure the declarativity of var and function names? For some real trouble, try the International Obsfucated C Code Contest: http://www.ioccc.org/ These contests like Code Golf are just for fun, I can't say that they encourage bad practice as long as you understand what the contest is about. That aside, I think that it would be very beneficial to the community as a whole if a contest was started that encouraged readability and good practices. The scoring and judging could be done by a panel, but I think that it would be more fun if the community itself was able to vote on various attributes; readability, efficiency, general approach, originality, etc. Allow people to comment on each entry. I don't know about the winner getting anything besides bragging rights, but it if gets large enough maybe there can be a few corporate sponsors giving away licenses or something. Who knows? I think it would be a lot of fun if well executed. -K.Bear -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help converting C to PHP
2006/9/22, Tom Atkinson [EMAIL PROTECTED]: Martin Alterisio wrote: 2006/9/22, Rory Browne [EMAIL PROTECTED]: On 9/22/06, Kevin Waterson [EMAIL PROTECTED] wrote: This one time, at band camp, Curt Zirzow [EMAIL PROTECTED] wrote: what about using: php.net/pi note the precision description. or are we talking about a different pi. The goal of the codegolf.com challenge is to print pi to 1000 places. The programmer to do it in the least keystrokes is the winner. I personally don't think this is a very healthy contest. It discourages comments, and use of whitespace to make code readable. I'd perfer a contest that rewarded code readability, and maintainability as well as minimal keystrokes. After all you only enter the aforementioned keystrokes once. Perhaps one like codegolf, with an enforced coding style ( eg KR Style, or GNU Style) I completely agree. This kind of contests do not provide any measure of the good qualities of a programmer working as part of a team. The objectives ussualy end up being something of the sort: let's see who can fit the most in a for declaration. Anyway... as you say, it would be nice to have a contest that rewards readability and maintainability... but, how can we messure that qualities in this type of games? Should your code be praised by others and voted on? Is that reliable? I think enforcing a coding style is too restrictive... Also, how do we measure the declarativity of var and function names? The value of these games is that they give you interesting problems to solve without forcing you to maintain the code. That's the entire point. It's exactly the sort of thing that's fun to write when you have to make a living from your code the rest of the time. If you want to write quality software in your free time then you start/join an FOSS project and put the code to good use. Nobody is claiming that this is a good way to write code or a good way to learn PHP, it's just for fun. You're right, it's just for fun but... they could still be fun and be useful. These kind of games could easily be used for education and training. We all know that the quest/mob grinding factor can be very addictive, why don't use all that energy for the good? You could still learn how to do a good job while having fun...
Re: [PHP] Help converting C to PHP
On Thu, September 21, 2006 9:32 pm, Curt Zirzow wrote: On 9/21/06, Tom Atkinson [EMAIL PROTECTED] wrote: Hello, I am attempting to convert this code for generating the digits of pi from the original C (below) to PHP. long k=4e3,p,a[337],q,t=1e3; main(j){for(;a[j=q=0]+=2,--k;) for(p=1+2*k;j337;q=a[j]*k+q%p*t,a[j++]=q/p) k!=j2?:printf(%.3d,a[j-2]%t+q/p/t);} wow this is rather bad. it would probably be better to write this in asm, it would be easier to read than the way it is in C. I converted this to a more readable form: what about using: php.net/pi note the precision description. or are we talking about a different pi. We're probably talking about that silly contest started the other day to calculate pi to 1000 digits... :-) My best guess is that the C code is relying on type-casting to hack something somewhere. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help converting C to PHP
On Fri, September 22, 2006 11:59 am, Martin Alterisio wrote: Anyway... as you say, it would be nice to have a contest that rewards readability and maintainability... but, how can we messure that qualities in this type of games? If you think of the Open Market of software out there as the game and people's decisions to use or not use it, then you've got a pretty good contest. And PHP is winning. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help converting C to PHP
That aside, I think that it would be very beneficial to the community as a whole if a contest was started that encouraged readability and good practices. The scoring and judging could be done by a panel, but I think that it would be more fun if the community itself was able to vote on various attributes; readability, efficiency, general approach, originality, etc. Allow people to comment on each entry. I don't know about the winner getting anything besides bragging rights, but it if gets large enough maybe there can be a few corporate sponsors giving away licenses or something. Who knows? Fair enough. Prime Number Script Competition ( for Bragging Rights ). I challenge the readers of this list to produce the necessary code to find the lowest prime number higher than a certain inputted number. The script must be web based, and ask the user to enter a number. The script must then calculate the lowest Prime Number above that number. Scripts will be rated on Functional Accuracy ( the program must correctly perform its required function ), Code Maintainability(eg Presence of Comments, etc ), Ease of Use, and Code Efficiency, in that order. Brownie points may be earned through use interesting or original ideas or methodologies, provided they do not compromise the previous four criteria. The submitted script will be rated by volunteers from this list. Submitting an entry disqualifys you as a volunteer judge, whilst judging someone elses code disqualifys you as a candidate. Deadline for submissions is 12:00 (Noon) (CEST UTC + 2 Hours) on Friday 29 September. Interesting to see (a) if anyone enters, and (b) what the code will be like. I think it would be a lot of fun if well executed.
Re: [PHP] Help converting C to PHP
On Fri, September 22, 2006 7:40 pm, Rory Browne wrote: The script must be web based, and ask the user to enter a number. The script must then calculate the lowest Prime Number above that number. I would like to have one point clarified: By above that number do you literally mean or would = be deemed the correct interpretation? E.g. for an input of '2' do you expect '2' or '3' as the answer? Or is our ability to correctly interpret this as part of the exercise?... Ooops. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help converting C to PHP
Hello, I am attempting to convert this code for generating the digits of pi from the original C (below) to PHP. long k=4e3,p,a[337],q,t=1e3; main(j){for(;a[j=q=0]+=2,--k;) for(p=1+2*k;j337;q=a[j]*k+q%p*t,a[j++]=q/p) k!=j2?:printf(%.3d,a[j-2]%t+q/p/t);} I converted this to a more readable form: long k=4e3; int p; int a[337]; int q; int t=1e3; main(j){ for(;a[j=q=0]+=2,--k;){ for(p=1+(2*k);j337;q=(a[j]*k)+((q%p)*t),a[j++]=(q/p)){ if (j2 k==1) printf(%.3d,(a[j-2]%t)+((q/p)/t)); } } } and then changed it to PHP syntax $k=4e3; $p=0; $a=array(); $q=0; $t=1e3; for(;$a[$j=$q=0]+=2,--$k;){ for($p=1+(2*$k);$j337;$q=($a[$j]*$k)+(($q%$p)*$t),$a[$j++]=($q/$p)){ if ($j2 $k==1) printf(%.3d,($a[$j-2]%$t)+(($q/$p)/$t)); } } The C code correctly gives me pi, but the PHP code gives me some other number which is not pi. What am I missing? Tom. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help converting C to PHP
This one time, at band camp, Tom Atkinson [EMAIL PROTECTED] wrote: Hello, I am attempting to convert this code for generating the digits of pi from the original C (below) to PHP. is this for codegolf? Kevin -- Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help converting C to PHP
Yes, it is. Kevin Waterson wrote: This one time, at band camp, Tom Atkinson [EMAIL PROTECTED] wrote: Hello, I am attempting to convert this code for generating the digits of pi from the original C (below) to PHP. is this for codegolf? Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help converting C to PHP
On 9/21/06, Kevin Waterson [EMAIL PROTECTED] wrote: This one time, at band camp, Tom Atkinson [EMAIL PROTECTED] wrote: heh.. nice little twist. Curt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help converting C to PHP
On 9/21/06, Tom Atkinson [EMAIL PROTECTED] wrote: Hello, I am attempting to convert this code for generating the digits of pi from the original C (below) to PHP. long k=4e3,p,a[337],q,t=1e3; main(j){for(;a[j=q=0]+=2,--k;) for(p=1+2*k;j337;q=a[j]*k+q%p*t,a[j++]=q/p) k!=j2?:printf(%.3d,a[j-2]%t+q/p/t);} wow this is rather bad. it would probably be better to write this in asm, it would be easier to read than the way it is in C. I converted this to a more readable form: what about using: php.net/pi note the precision description. or are we talking about a different pi. Curt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help converting C to PHP
This one time, at band camp, Curt Zirzow [EMAIL PROTECTED] wrote: what about using: php.net/pi note the precision description. or are we talking about a different pi. The goal of the codegolf.com challenge is to print pi to 1000 places. The programmer to do it in the least keystrokes is the winner. Kevin -- Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help converting C to PHP
pi() does not give me enough decimal places, I need the first 1000. Curt Zirzow wrote: On 9/21/06, Tom Atkinson [EMAIL PROTECTED] wrote: Hello, I am attempting to convert this code for generating the digits of pi from the original C (below) to PHP. long k=4e3,p,a[337],q,t=1e3; main(j){for(;a[j=q=0]+=2,--k;) for(p=1+2*k;j337;q=a[j]*k+q%p*t,a[j++]=q/p) k!=j2?:printf(%.3d,a[j-2]%t+q/p/t);} wow this is rather bad. it would probably be better to write this in asm, it would be easier to read than the way it is in C. I converted this to a more readable form: what about using: php.net/pi note the precision description. or are we talking about a different pi. Curt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help converting C to PHP
Definitely looks like a grouping and/or precedence problem. Wish I had more time to examine it. Fine-tooth those parens again. -Christopher -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php