You are not logged in. Login Now
 0-24   16-40   41-45        
 
Author Message
5 new of 45 responses total.
cross
response 41 of 45: Mark Unseen   Feb 14 23:02 UTC 2007

Another day, and no additional posts.  Okay, here's the Java version:

/**
 * Test of something for John Remmers.
 */

public class Find1stBlank {

        /**
         * Find the first all-blank string in the passed regular expression.
         */
        public static int Find1stBlank(String[] strings) {
                for (int i = 0; i < strings.length; i++)
                        if (strings[i].matches("^\\s+$"))
                                return(i);
                return(-1);
        }

        /**
         * Main program entry point.
         */
        public static void main(String[] args) {
                String[] strings = { "This ", " is", "a", "string" };
                System.out.println("Find1stBlank == " + Find1stBlank(strings));
                String[] strs = { " But this ", " is ", "   ", " a blank." };
                System.out.println("Find1stBlank == " + Find1stBlank(strs));
        }
}
remmers
response 42 of 45: Mark Unseen   Apr 8 11:31 UTC 2007

Responses #40 and #41 illustrate the effect of language primitives (in 
this case, regular expressions) on the shape of a solution.

(Aside:  This item has showed up as a shared bookmark on del.icio.us.  
Have a look at http://del.icio.us/tag/grex/  and
http://del.icio.us/url/93a9640a15e68aef7b1d7837f006cc01 ...)
yecril71pl
response 43 of 45: Mark Unseen   Dec 3 13:23 UTC 2007

How is it that nobody has come up with a solution that uses "come from"?
nharmon
response 44 of 45: Mark Unseen   Dec 3 13:51 UTC 2007

I've never liked "come from" because it can really confuse you when
you're debugging something. Like, you'll be wondering why a certain line
was never executed only to find out later that it was because the line
before it was associated with a "come from" much later on in the program.
mkay
response 45 of 45: Mark Unseen   Apr 23 10:55 UTC 2013

Here is my C solution, an example for good readability :D :

int i = 0, j = 0;
while ((j = (j + 1) * !matrix[i][j]) < N && (i += !!matrix[i][j]) < N)
        ;
if (i < N)
        printf("First all-zero row is %d\n", i);


 0-24   16-40   41-45        
Response Not Possible: You are Not Logged In
 

- Backtalk version 1.3.30 - Copyright 1996-2006, Jan Wolter and Steve Weiss