Everything2
Near Matches
Ignore Exact
Full Text
Everything2

brute force

"brute force" is also a: user

created by stanis

(idea) by stanis (?) (print)   ?   (I like it!) Sat Nov 13 1999 at 8:49:20

Brute force is an algorithm often used in Computer Science for searching sets of data for an answer. The idea is to take every possible answer, and test it to see if it is correct. Brute force is equivalent to trying every possible combination on a pad lock in order to open it. Although sub-optimal, brute force will find a solution if one exists given enough time.

(idea) by ggould (7.9 y) (print)   ?   (I like it!) 1 C! Sat Nov 13 1999 at 8:49:20

The last refuge of the incompetent, the first refuge of the competent. While sub-optimal in terms of computation or breaking things, it is generally the fastest-implemented and least error-prone method of searching a space or opening a broken toaster.

(thing) by Jargon (1.8 y) (print)   ?   (I like it!) Fri Apr 28 2000 at 9:41:39

BRS = B = brute force and ignorance

brute force adj.

Describes a primitive programming style, one in which the programmer relies on the computer's processing power instead of using his or her own intelligence to simplify the problem, often ignoring problems of scale and applying naive methods suited to small problems directly to large ones. The term can also be used in reference to programming style: brute-force programs are written in a heavyhanded, tedious way, full of repetition and devoid of any elegance or useful abstraction (see also brute force and ignorance).

The canonical example of a brute-force algorithm is associated with the `traveling salesman problem' (TSP), a classical NP-hard problem: Suppose a person is in, say, Boston, and wishes to drive to N other cities. In what order should the cities be visited in order to minimize the distance travelled? The brute-force method is to simply generate all possible routes and compare the distances; while guaranteed to work and simple to implement, this algorithm is clearly very stupid in that it considers even obviously absurd routes (like going from Boston to Houston via San Francisco and New York, in that order). For very small N it works well, but it rapidly becomes absurdly inefficient when N increases (for N = 15, there are already 1,307,674,368,000 possible routes to consider, and for N = 1000 -- well, see bignum). Sometimes, unfortunately, there is no better general solution than brute force. See also NP-.

A more simple-minded example of brute-force programming is finding the smallest number in a large list by first using an existing program to sort the list in ascending order, and then picking the first number off the front.

Whether brute-force programming should actually be considered stupid or not depends on the context; if the problem is not terribly big, the extra CPU time spent on a brute-force solution may cost less than the programmer time it would take to develop a more `intelligent' algorithm. Additionally, a more intelligent algorithm may imply more long-term complexity cost and bug-chasing than are justified by the speed improvement.

Ken Thompson, co-inventor of Unix, is reported to have uttered the epigram "When in doubt, use brute force". He probably intended this as a ha ha only serious, but the original Unix kernel's preference for simple, robust, and portable algorithms over brittle `smart' ones does seem to have been a significant factor in the success of that OS. Like so many other tradeoffs in software design, the choice between brute force and complex, finely-tuned cleverness is often a difficult one that requires both engineering savvy and delicate esthetic judgment.

--Jargon File, autonoded by rescdsk.

EDIT ME!
The Everyone Project.
Log in: "everyone" Password: "everyone"
First created by: rescdsk
Modified by: (nobody)


(idea) by wharfinger (6.4 y) (print)   ?   (I like it!) 1 C! Fri Oct 27 2000 at 1:15:52

On the Usenet newsgroup comp.lang.c, I once saw a newbie ask how to find out whether a number is odd or even (in C, I mean). In C, this is delightfully simple: Just have a squint at the low-order bit; if that's turned "on", it's an odd number:

if ( n & 0x00000001 ) 
    puts( "It's odd . . . DAMNED odd . . ." ); 

Well, some smartass offered the following hilarious solution (those who don't speak C can skip ahead over this typewriter font stuff; there's a plain English explanation afterwards):

int is_odd( int n )
{
    unsigned long i;

    for ( i = 0; i <= 4294967295; i += 2 )
        if ( n == i )
            return 0;

    return 1;
}

Now, what that code does is it compares a number (n) to every even number that the computer can reasonably deal with: 4294967295 is the largest integer you can express in thirty-two bits. So in some cases, that code would make more than two billion comparisons before coming up with an answer. I thought converting 0xffffffff into decimal was a nice touch.

That's brute force, baby.


printable version
chaos

brute force and ignorance password cracker Infinite monkeys theorem bignum
ha ha only serious NP- Infinite Monkeys algorithm
brute force uploading Password paradigms computer go Solving a maze
The 48 Laws of Power reality hacker canonical piercing gun
The Chinese Lottery Concussive Maintenance /etc/passwd Cracking a Master Lock
David Essner Mathematics Competition CSS G4 Cube Content Scrambling System
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Drink up!
Collateral
neutron
The Art of Bitchcraft
Choosing to be gay
wart removal
Genghis Khan
Wanted: Supervillain minions
Lesbia
logical punctuation
Fuck plate tectonics
Dye laser
power structure
Spam
New Writeups
Heitah
Posthumous Oscar(thing)
ignis_glaciesque
University of South Florida(place)
ignis_glaciesque
Flogstaskriket(idea)
liveforever
Caesar's last breath(idea)
dagnyswaggart
she wants to believe(personal)
antigravpussy
he doesn't know, but her eyes widen too far(thing)
dagnyswaggart
Wild tides guard her secrets(poetry)
Lord Brawl
Caesar's last breath(poetry)
locke baron
Forgotten things in space(fiction)
sitaraika
Colours(idea)
etouffee
Wild tides guard her secrets(poetry)
Lord Brawl
Dr. Horrible's Sing-Along Blog(review)
a8ksh4
regret(idea)
Heisenberg
Editor Log: July 2008(log)
sam512
halfway homes, catacombs, twilight zones(fiction)
This affordable entertainment brought to you by The Everything Development Company