You're probably right. I didn't expect Wikipedia to contain redirects from an incorrect spelling to a correct one and though that "Machavellian" is used in some language or region. In any case, "Machavellian" gets a lot of hits on Google, so it looks like this incorrect form is in a quite widespread use.
Ah. My fault. It was misspelt in the subject too. Corrected.
Ivan Jozsef Balazs
Joined: May 22, 2012
The word comes from the name Niccolò Machiavelli so there is not much freedom how to spell it.
Joined: Mar 05, 2008
Winston Gutkowski wrote:
Jesper de Jong wrote:Here's another super horrible ugly solution.
Hate to burst your bubble, but the original post did say "without using any built in length methods or length properties".
I appreciate its dastardly approach though; particularly the UTF-16 and '/ 2'.
I was disappointed to see Jesper's contribution above, if only because it was essentially the same as the idea I came up with, and days before I came along. However, I offer improvements: One, a way to avoid the "built in length methods or length properties" (as much as any of these do, anyway). And two, a minor bug fix: UTF-16 allows an optional byte order mark, which can give you an off by one error - it did show up on my Mac, but not on my Linux box. This is eliminated by using UTF-16LE or UTF-16BE instead. Oh, there's also three: this method should be considerably more performant, avoiding file I/O.
Joined: Mar 05, 2008
I also question why it was necessary to split this off from the original thread - anything other than simply using length() is a silly waste of time, in a professional setting. The whole premise is really fodder for Programming Diversions.
I also note that almost all these methods also use length internally - we're just delegating the "dirty" work to other standard libraries. The only potential exception I see is Martin's contribution - if we eliminate the "Multiply it 4096 times" loop, it actually does seem to not rely on any internal length properties. Of course it then becomes very imprecise. But for a long enough string, it can at least give an approximation. Kudos for a truly original idea there.
Mike Simmons wrote:I also question why it was necessary to split this off from the original thread...
Maybe overkill on my part; I'm still relatively new to this moderating business. It just seemed to me that we'd got the message across to OP that not using length() wasn't a great idea, and that the rest was more suitable as a fun thread for the PD forum.