5 ms·
PhpGolf - solve problems in as few bytes as possible
- ryanwaggoner 16y agoI understand why they wouldn't allow it for competitive reasons, but being able to view others' code seems like it would be a great way to learn.
- deleted 16y ago[deleted]
- olegkikin 16y agoEveryone then would just submit variations of the winning solution, which would make the leaderboard useless.
- Deestan 16y agoCode golfing may seem like just a fun nerdy "sport", but it's actually really useful practice in keeping your code terse and your unnecessary abstractions to a minimum. I recommend everyone to try to do really well in a few code golfing challenges. http://codegolf.com/ http://codegolf.com/ also accepts a couple more languages than PHP if that's not your style.
- seles 16y agoand http://golf.shinh.org/ http://golf.shinh.org/ accepts even more languages (80) but it is 'less refined'
- noodle 16y agoat least the 99 bottles challenge looks to be a direct ripoff of codegolf. or vice versa.
- photon_off 16y agoI would disagree. There's a point where code terseness and abstractionlessness come at the cost of code readability, and these competitions cause you to go way beyond this point. There's no sense in practicing how to write confusing code that is very short, other than the problem-solving aspect of it. I think code golf is just another form of a puzzle. So, whatever benefit you get from solving a puzzle, or mind bender, or whatever, you'll get from code golf. Hopefully you'll have the sense not to golf production code.
- Deestan 16y agoI said "practice in keeping your code terse". Actually trying to golf production code would just be insane. Programmers commonly put in completely unnecessary abstractions "just in case", and a golfing mindset will help you avoid a lot of these.
- petervandijck 16y agoCode that focuses on being short is often pretty unreadable though, using really short variable names, lots of unnecessary tricks, no comments and other uglyness.
- bartl 16y agoYes. That's why it's a game, and not a serious programming practice.
- petervandijck 16y agoFair enough :)
- bl4k 16y agoMost of these challenges test how good you are with regex hacking, rather than general code or php. To reach within a few points of the best score, for most challenges you need regex
- jacquesm 16y agoI tried very hard to resist the temptation to do that on the 99 bottles problem because I suspect it's a dead-end. It's down to 189 bytes now, I'm curious if someone will have beaten me by morning. That was fun to do. My first attempt was absolutely horrible :)
- r13ckj 16y ago189?! I've been trying for ages and the best I can do is 233. Any pointers? I can't compete with that, but would be great to have an idea why I'm so far off :)
- stefs 16y agowhoever this "helge" guy is, if i should ever meet him, i'll slap him.
- jacquesm 16y agoThe way to slap him is to beat him.
- stefs 16y agothat's impossible. i fear i have to resort to causing bodily harm because of that.
- jacquesm 16y agoBad loser :) Think of it as a challenge. I'm just trying to figure out how he ever got to 55 on that primes challenge, at least now I know that it's possible, all I have to do is figure out why. It's a nice argument for software patents actually (and this is coming from someone that is morbidly against them), if you know that something is possible but not how you should be able to figure out how it's done. Bodily harm to someone that is simply better at you is so gradeschool :)