- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Great, someone triggered the creationist bot. Looks at Bob
Admin
Admin
Admin
I never said it was. I don't have Britannica, but if something as big as outright fraud (which you allege) was true, it would surely have found it's way into Wikipedia. It hasn't because you're full of shit. Take your fairy tales somewhere else.
Admin
Hi Bob! :p
Admin
http://www.creationtips.com/shroud.html
Yup, akismet says that's spam. Let's try again!
Admin
If you're writing your own version of RemoveCharacters to collapse up to N spaces, you probably want to replace SQRT(N) spaces with 1. For example, if your input is limited to 100 consecutive spaces, then replacement of 7 spaces or 14 spaces with 1 could still leave you with 19 spaces, but the worst case for between 8 to 13 spaces would only be 18. You then need to choose an appropriate replacement to deal with up to 18 consecutive spaces and so on.
Admin
Admin
It's even in the php manual page at preg_replace:
<?php $str = 'foo o'; $str = preg_replace('/\s\s+/', ' ', $str); // This will be 'foo o' now echo $str; ?>Admin
But why would anyone want to do that?
Admin
Admin
I swear there's a line of code in the human brain that says something like "once you've decided what you want to think, seek evidence supporting it".
If we can all agree that's a WTF, the next question is why did our Brainware Developer put it there?
Admin
duck
Admin
That doesn't do what the original WTF does, which is replace multiple space characters (ASCII 32) with a single space.
That regex replaces any sequence of white space characters (including tabs) with a single space.
Admin
I've extended this.
For 6 Replace calls the sequence should be 232, 22, 7, 4, 3, 2. This will handle all cases up to 53,590 contiguous spaces.
For 7 Replace calls the sequence should be 50426, 232, 22, 7, 4, 3, 2. This will handle all cases up to 199,790,977 contiguous spaces.
For now I am unable to calculate the sequence for 8 Replace calls. I've roughly estimated the next size increment to be >35 billion, and that it would handle all cases up to at least ~250 trillion contiguous spaces.
Admin
Admin
What's really sad is what a simple tiny little one-liner this is in Perl...
Admin
There, now it is more efficient and will work for strings bigger than 1000 whitespaces long!
Admin
my god, someone actually took the time to go through the math on this (in a visual basic context, too): http://www.tech-archive.net/Archive/VB/microsoft.public.vb.general.discussion/2004-04/1076.html
Admin
Why do shopping sites insist on having the credit card number input as a long string of digits without hyphens or spaces? Why do developers find it so hard to strip such things out of the data?
This is why.
Captcha (is reporting them still en vogue?) = 𝅗𝅥
Admin
Admin
That would have just resulted in a ClassNotFoundException. The code says it was written in '01, commons.lang version 1.0 was released in October of '02.
Admin
First, no, the Wikipedia is not that definitive. Second, according to the National Geographic program I watched when I was bored some time ago, discrepancies were found in the area used for carbon dating. It wasn't necessarily fraud, but repairs to the shroud had been made on the area that was tested back in the 16th century, so its very possible the results were wrong. Third, the wikipedia does indeed mention this controversy: http://en.wikipedia.org/wiki/Radiocarbon_14_dating_of_the_Shroud_of_Turin#Chemical_properties_of_the_sample_site
Its still not a definitive source. Fourth, something being old does not mean it is a genuine religious relic. Otherwise I could get people to worship the sandwich in my fridge.
There, everyone now properly offended, or did I miss someone?
Admin
Admin
That's a nice find.
Actually there are multiple solutions for each n-ary case. The math and code in the referenced article appears to produce just the first possibility. If you look you will notice similarities and differences from the sequence I provided. For example my sequence doesn't contain repeated values.
The sequence that I gave 50426, 232, 22, 7, 4, 3, 2, optimizes first for handling all cases up to maximum possible 199,790,977 contiguous spaces, then optimizes for handling the maximum number of cases beyond that up to the largest possible string of 43,238,883,072 contiguous spaces. For those two constraints, this should be the optimal solution to the nested 7 Replace problem.
Admin
Admin
The best sequence is not unique, you always have two choices (except for the last, which has to be 2), for 6 iterations, {231,232}, {21,22}, {6,7}, {3,4}, {2,3}, 2. The first few:
Second component is smallest number of contiguous spaces not reduced to a single space by the sequence.
Admin
FTFY
Captcha commoveo = What you do to whitespace.
Admin
The second one is almost a reasonable algorithm. The lack of a regular expression isn't making the code unweildy; it's still short and simple. The problem is that the replacement numbers were clearly not well thought out. If it replaced 3 twice it would be able to handle thousands of spaces in a row, but as it's set up it can barely handle 200 despite replacing up front 100:1. This was not thought through.
Admin
You, sir, you got me there.
Admin
Admin
Also according to this source, during the middle ages the shroud's whereabouts are unknown but one major theory is that it was being kept in a monastery that was partially destroyed in a fire. It makes sense that the catholic church would keep one major relic locked in a "vault" with silver and other valuables.
Note however that, while I do not endorse this source (since I didn't run tests on Pompeii's artifacts or even read this from any other source) and that I can't even remember where I read it, I do agree that this explanation seems plausible and scientifically possible, which is enough to shut up accusations of fraud by both groups.
Gee, have we just jumped from code discussion to religious bigotry (including atheists, which can be fanatical zealots as much as any theist) in a couple of posts? I feel like I'm on slashdot.
Admin
Admin
Good catch, I made some assumptions in my code, it is very possible I missed that case.
After my post I started thinking that 50426 handling 199,790,977 contiguous spaces looked hinky. Up to that point the sequence values had been very close to sqrt(first failing case ).
I point that out in a previous comment.
I optimize for two constraints, the first is to maximize the first failing case, and the second is to maximize the total number of cases handled. There appears to be a single optimal answer for this ordered pair of constraints. This appears to be larger value of each of your pairs.
Nice work.
Admin
It's always sad when so-called "developers" do not know how to solve a problem with recursion. Not that you even need it here:
Admin
You meant older, not younger. An item cannot be packaged before it exists.
Admin
Spaces - the final frontier.
Admin
Admin
Admin
That is one of the most perverse statements I have ever read.
Anyone still coding in VB6 should be shot, either for willingly using VB6, or to mercifully put them out of their misery.
Anyone demanding new code in VB6 (instead of a port to something better) should be slowly tortured to death for the sake of poetic justice.
Admin
I loved the comment, though. Most people lack the curiosity to apply common sense in questioning "scientific" conclusions.
Admin
GOOD ONE! I do all my string processing with the whole string in memory, too. Nothing could possibly go wrong...
[OUT OF MEMORY]
Admin
Admin
Of course the most efficient is something like this:
(use arrays to your liking)
Admin
Admin
Admin
But since the Internet is your god, I will answer you on his terms. Go to snopes.com, and you will see no article refuting the Clairton Controversy. Barring that, I don't invite boors over to my house to view my Encyclopedias...you'll have to make a stop at your local library.
Admin
I thought the replace logic was fairly straightforward.
Admin
StringUtils is a very common (pardon the pun) code lib to use, i've been using it for ages and i'm sure that I could probably find a large number of developers who use it on a routine basis :-)
Admin
Interesting logic, yessiree...