ShadowMage Posted October 1, 2010 Author Share Posted October 1, 2010 The challenge of array splice is that every element after the deleted element gets reindexed. So if you're using a counter as an index, elements are no longer where you think they are. That's why my original technique looped through the array backwards. Your original technique avoided the problem by breaking out of the loop every time array_splice was called.In your new experiment, I think you're also breaking the array_walk rules. You are changing the structure of the array, and this will lead to unpredictable results. So says the manual. I suspect it just iterates like 0, 1, 2, 3 and doesn't make the allowances that array_filter does.Hmm....Yes, indeed, the manual does say that doesn't it....I really hope we can keep this 'contest' going. This is kinda fun. And very educational. Who's got next week's challenge? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 1, 2010 Share Posted October 1, 2010 The next challenge is to create Facebook in as few lines of code as possible. Entries are due Wednesday. Link to comment Share on other sites More sharing options...
jeffman Posted October 1, 2010 Share Posted October 1, 2010 I wondered when jsg was going to show up in this thread. Somehow I've been imagining you laughing at the whole thing.I would totally recode Facebook if I gave a rat's ass about it and all its mediocre ilk. May they perish from the earth. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 1, 2010 Share Posted October 1, 2010 I was going to post a thinly-disguised attempt to get everyone to do my work for me. How about an algorithm to "most reliably" strip replied-to text out of an email, sent from as many different clients as possible? Sounds fun, right? Yeah, I would have liked to have developed a nice little sieve, but this is a busy week for me with work. Between working, eating, and Sid Meier, my free time is at a premium right now. Link to comment Share on other sites More sharing options...
jeffman Posted October 1, 2010 Share Posted October 1, 2010 A lot of my sieve-time came when I needed to get away from my spousal unit. Sadly, this is often. And no, your task sounds like a regex from hell. Link to comment Share on other sites More sharing options...
Fmdpa Posted October 8, 2010 Share Posted October 8, 2010 Although I came across this thread too late to participate, I think the idea of having contests like this is a good one. As long as they stay good-natured and educational. I learned something just by reading this thread: that is, the range() function. Just like ShadowMage said, it could save many lines of code. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.