Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Wednesday, November 25, 2009

Quick and Dirty Filtered Copy

Have you ever found that you needed all of a certain type of file in a file path only to discover that they are among dozens of other file types in varying levels of folders in the path? Did you want to copy only these files to another drive so you could work with them independently?

Set Files=*.txt
Set DestDrive=X

For /f "delims=" %%i in ('dir /a-d/s/b %Files%') Do md "%DestDrive%:%%~pi" & copy "%%i" "%DestDrive%:%%~pnxi"

This is a fairly simple script where you loop through each of the items found in a dir then create the directory structure on the new drive to mirror the original and copy each file.

This is more the kind of script to come up with when you just need to get something written quickly to just get it done and don't need to think of how fast or slow it runs. Robocopy provides all interfaces to copy quicker, though it requires a little more work in understanding the command.

Friday, October 23, 2009

Deseret Translator Prototype

Deseret Translator With Windows 7 being released, which along with the latest in Apples OSs, can display Deseret characters I thought I would have a little fun with it and see if I could make a Latin alphabet English to Deseret alphabet English translator. I made it as far as being able to replace all of the consonants preserving capitalization and a handful of token combinations before I realized the huge problem would be in trying to figure out how to translate the vowels. If it weren't for all of the exceptions to rules in Latin alphabet English it might be a bit of a simple task.

I had thought it might be a fun and simple project to put up, but it looks like it will take some extra thought and work before it is ready. At least it sort of works.

Monday, October 5, 2009

Intentional Software

Woah! This is a fascinating video! (http://msdn.microsoft.com/en-us/oslo/dd727740.aspx) A few years ago I wished that .net code could be saved in some intermediary language which could be swapped between syntaxes on the fly. This looks like my dream come true! Woo hoo!

Monday, September 28, 2009

RoboCopy

So you have a huge number of files that you want to copy from one place and put them somewhere else. Perhaps you have updated some of the files and want to make sure the changes are copied but you don't remember which files were changed.

The easiest way to do this would be to drag and drop the folders to merge them but if you have done this before you probably know that this is likely to take long enough that you wonder if there might be a better way.

Fortunately for those using Windows Server 2008, Vista or Windows 7 there is. Robocopy to the rescue! For Windows XP and Server 2003 you can get it via a download from Microsoft.

For this purpose robocopy has some advantages over it's predecessors copy and xcopy and it's alternate bitsadmin in that it copies folders, it has the ability to check to see if a file needs to be copied before copying and it is relatively easy to use.

In my example I will take clipart stored on c:\ and copy it to z:\ I want to log the results and I don't want to copy the thumbnail database so here is my command line.

Set Source=c:\Images\Clipart
Set Dest=z:\Images\Clipart
Set LogFile=ClipartCopyLog.txt
Set SkipFile=Thumbs.db

robocopy "%Source%" "%Dest%" /E /LOG:%LogFile% /TEE /V /FP /XF %SkipFile%

The /E switch tells robocopy to copy empty folders. /LOG is the switch which tells where to write a log to. /TEE logs the results both the the log and displays in the console window. /V presents verbose output which is good for debugging but not needed to run. /FP is also for logging instructing to use full path names. /XF is what allows Thumbs .db to be skipped in the file copy. For more information type robocopy /? in an open command window.

The biggest advantage by far is that if the file already exists and is up to date then it won't try to copy the file which speeds things up quite a bit when merging folders.

Thursday, September 10, 2009

Filtering the Path

This is a little project I have been trying to figure out ever since I read a line in the help for the "For" command:

%~$PATH:I   - searches the directories listed in the PATH
               environment variable and expands %I to the
               fully qualified name of the first one found.
               If the environment variable name is not
               defined or the file is not found by the
               search, then this modifier expands to the
               empty string

Running multiple scripts that continually add to the path list can muck up the path list. I hoped I could design a function that searches to find out if a path exists in the path list and if it does it wont add the new one.

@Echo Off

PATH=C:\WINNT\system32\;C:\WINNT\;C:\Program Files\Test1\

    Call :AddToPath "C:\Program Files\Test1\"
    Call :AddToPath "C:\Program Files\Test2\LICENSE.txt"
    Call :AddToPath "C:\Program Files\Test3\"
    Call :AddToPath "C:\Program Files\Test4"

    Echo %Path%

GoTo :EOF

:AddToPath
    If Not ""=="%~x1" Call :SetToPath "%~dp1"
    If "%~1"=="%~dp1" Call :SetToPath "%~1"
    If "%~nx1"=="%~n1" If Not ""=="%~nx1" Call :SetToPath "%~1\"
GoTo :EOF

:SetToPath
    Set t=%path%
    @Rem Deleting the path if it exists
    Call Set t=%%t:%~1=%%
    If "%path%"=="%t%" Path %Path%;%~1
GoTo :EOF

This is as far I have been able to get the script. For the most part it works except if the new path is already part of the path of another path in the path list. There may be better ways to implement this.

One thing to note is that it is best that the path being added has already been created. Sometimes splitting out the different parts doesn't work if it doesn't exist.

Wednesday, September 9, 2009

32 Bit on 64 Bit Program Files

When 32 bit programs install on a 64 bit Windows they are dumps %ProgramFiles% into %ProgramFiles(x86)% and the default command line in 64 bit Windows is the one that is 64 bit which directs %ProgramFiles% to %ProgramFiles%. So if you want to access a 32 bit program you have to use %ProgramFiles(x86)%. This can really complicate matters if you need to access the same program on both 32 bit and 64 bit Windows. So what can you do? Try this:

@Echo Off

Set Programs=%ProgramFiles%

If "%PROCESSOR_ARCHITECTURE%" == "x86" Set Programs=%ProgramFiles%
If "%PROCESSOR_ARCHITECTURE%" == "AMD64" Set Programs=%ProgramFiles(x86)%
If "%PROCESSOR_ARCHITECTURE%" == "IA64" Set Programs=%ProgramFiles(x86)%

CD /d %Programs%

This method is extensible so that you can add any additional operating system processor types as they become available and it allows you to select the correct path for each one.

One little fun note is in the dummy CD call I'm using /d which changes the current drive as well as changing the directory for the drive. Fun!

Wednesday, September 2, 2009

Rebooting a Remote Machine

It is quite common for me at work to be remoting into a computer working on it and realize I need to reboot it for one reason or another only the machine I'm remoting into is a client OS (Windows XP, Windows Vista, Windows 7) that has the reboot icon removed from the start menu in the remote desktop window.

If the machine is under my desk I can just switch over to it to reboot or hard reboot with the button on the front but sometimes the machine is in another room in another building in another city in another state or another country. Then I have no access to the physical machine.

On occasion if I'm using a Lab machine they will have some interface that I can use to reboot but not always. So what do you do?

It's actually quite simple, open up an elevated command window and run the following command:

Shutdown /r /t 0

The flag to restart is /r, then the flag /t plus a number sets the time delay before the command restarts the machine, a value of "0" reboots immediately.

For more information on this command run "Shutdown /?" from a command prompt.

Tuesday, September 1, 2009

Get a File's Date and Time

Have you ever come across the need to log the date and time a file was created only to discover dir doesn't do it?

I did. I spent a couple of days frustratingly trying to find a way to capture the information with little luck. Finally I found documentation in the call command that explained that "%~t1"  expands %1 to date/time of file. This gave me enough information that I could come up with the following script:

@Echo Off

    Call :FileTimeDateSize "MyDate" "MyTime" "MySize" "%WinDir%\notepad.exe"
    @Echo:%MyDate%
    @Echo:%MyTime%
    @Echo:%MySize%

GoTo :EOF

:FileTimeDateSize
    Call :AsignDateTimeSize "%~1" "%~2" "%~3" %~t4 "%~z4"
GoTo :EOF

:AssignDateTimeSize
    Set %~1=%~4 & Set %~2=%~5 %~6 & Set %~3=%~7 bytes
GoTo :EOF

I was able to extract the date and time using "%~t3" but I wanted the date separated from the time so I wrote the second function to split out the date and the time by feeding "%~t3 to the function :AsignDateTime without quotes so that it will be split out into three tokens which are assigned independently to the desired variables to be used later.

If you run the script you can see that it is working because the date Notepad was built appears on one line and then the time on the next. I have also expanded this so that it reports the file size as well.

Now all I have to do to log the date and time so I can parse it later is @Echo:%MyDate%,%MyTime%,%MySize%>>LogFile.log

Monday, August 31, 2009

Batch Script Rename Files with Spaces

In the previous article I introduced how to use batch to search and replace text in strings but what can you do with it?

Let's say you have a whole bunch of files that you want to work with but you are using some old program that frustratingly refuses to allow you to open files that have spaces in their names. Luckily this is a rare case now days but I recently came across such circumstances.

You could rename them by hand, but if you have lots of files it could get old fast. Believe me, renaming thousands of files by hand is a pain in the wrists.

The first possibility is that you could delete the spaces such as in the following:

DeleteSpaces.bat

@Echo Off
SetLocal EnableExtensions

@Echo Renaming all files in the folder to remove spaces.
For /f "delims=" %%a In ('dir /a-d /s /b *.*') Do Call :DeleteSpaces "%%~a"

GoTo :EOF

:DeleteSpaces
    Set t=%~n1
    Call Set t=%%t: =%%
    Ren "%~1" "%~dp1%t%%~x1"
GoTo :EOF

But deleting spaces may not be what you want to do, after all you are deleting valuable information that spaces bring. What about replacing the spaces with underscores_ instead?:

UnderscoreSpaces.bat

@Echo Off
SetLocal EnableExtensions

Echo Renaming all files in the folder Replacing spaces with Underscores.
For /f "delims=" %%a In ('dir /a-d /s /b *.*') Do Call :UnderscoreSpaces "%%~a"

GoTo :EOF

:UnderscoreSpaces
    Set t=%~n1
    Call Set t=%%t: =_%%
    Ren "%~1" "%~dp1%t%%~x1"
GoTo :EOF

What these both do is retrieve a list of tiles then use modifications of the find and replace function and replaces spaces either with nothing or an underscore then rename the files accordingly.

One thing I made certain to do is limit the renaming only to the filename and not the rest of the string. This is done by setting "t=%~n1" the n flag pulls only the filename. When the rename is done it is all put back together using "%~dp1%t%%~x1" the flags d and p are drive and path then %t% is the filename and it completes it using the flag x for extension.

note that SetLocal keeps the variables set in either script contained within the scripts so that they don't spill out into other scripts.

Saturday, August 29, 2009

Precision

I used to argue with my dad on the matter of precision. My dad is and engineer in education and personality as was his dad and his dad's dad and so on, so I inherited the mentality critical thinking and interest in mechanics, processes and technology of an that such a personality brings (Which sadly doesn't help with personal relationships:).

At one point I had decided I wanted to design my own game engine. I had decided I wanted to use the most precise decimal system I could find in 'cough' VB for storing the locations of points. In the process of designing the basics of the engine I tried to find pi to the most decimals that would fit in the desired unit. I had learned the 22/7 trick from my Drafting instructor but was completely unsatisfied with the accuracy of only 2 decimal points.

My dad asked why I thought I needed any precision beyond two decimal points; in the mechanical engineering world two or three decimals are usually considered accurate enough for almost any consumer products, as anything more precise makes little difference, and just the expansion and contraction of materials alone exceeds the difference such precision would bring. 

But I was using a computer and despite what the 1950s and the movie industry hope to tell you, computers are inherently inaccurate at least when it comes to trying to calculate decimal and floating point numbers.

If you use floats for storing points in a world you can move around in, you would find that the precision of the locations of points in the center of the world is quite high, but the farther away you move from the center the less precision you have because the whole number portion of the value is getting filled with the larger numbers sacrificing the precision and storage space of the decimal portion. So at the edge of a large map you could end up with unexpected gaps in your world.

Well, okay if you were to only use integers the gaps could be reduced, but when you want to try to copy the nature of your surroundings you might find you want more precision. The thought might come up to use fixed point, sure it could work but you would have to be very careful with your rounding and your geometry.  You also end up with geometry that can look a little blocky depending on the resolution of your values.

But I never got far enough along to be able to see any degradation. So now days, I've stopped caring. Well almost, when I go back and play with old geometry code I am still tempted to write everything as doubles rather than singles, but now I've learned to think processor capacity and the effects on speed too.

Friday, August 28, 2009

Batch Script Search and Replace

A while back I thought I would try to share some of my favorite batch script snippets from my Google notebook but the shared notebook was quickly flagged as potentially dangerous and I didn't feel like contesting the flag so I pulled the snippets back into my private notebook.

I still want to share a few of my most useful snippets, so here is my favorite which I have heavily adapted it to fit many needs

Replace.bat

@Echo Off

Set /p Source=Text you would like to search:
Set /p Search=Text you would like to find:
Set /p Replace=Text to replace "%Search%" with:
Set Dest=

Call :Replacer "%Source%" "%Search%" "%Replace%" "Dest"

@Echo.%Dest%

GoTo :EOF

:Replacer
    Set t=%~1
    Call Set t=%%t:%~2=%~3%%
    Set %~4=%t%
GoTo :EOF


So what's going on here?

Well, first you provide a string to search, what you are looking for, then what you want to replace it with.  The script then calls a function which replaces all instances of the search term with the desired replace term. Simple right?

The interesting part comes in the line which does the search and replace.

variable t is a temporary variable which gets set as the source string then it is replaced with the new string in a call set statement in this strange part "Call Set t=%%t:%~2=%~3%%" which could be written as "Call Set Destination=%%t:%Search%=%Replace%%%".

What it expands to is fascinating as it double expands. Say you want to replace "is" with "was" in the string "This is your search string". You would end up with "Call Set t=%%This is your search string:is=was%%" which needs to be expanded one more time as it is now an environment variable replacer which the call statement executes to replace the instance of "is" with "was" so you end up with "This was your search string".

The final confusing piece of code sets the result to an arbitrary variable name which you feed the function in this case "Dest", this allows you to reuse the code with any destination variable you would like.

This has been a fascinating  howbeit confusing piece of batch script that I have found to be very useful in so many situations.

Now for a few notes about batch code hygiene in which this sample employs.

  1. Never wrap strings used in set statements with quotes "". doing so will make string cleanup difficult. Set will set a variable to the entire line after the equals = sign.
  2. In batch, all variables are global, so work with them accordingly. You may end up with confusing results if you don't understand this.
  3. Create empty variables for readability. If you have a set of variables where one will be set later but you can set it blank near the top then fill it later, this is only for readability.
  4. When you pass a string to a function, even if you are passing a variable, quote "" it. You never know when you will be passing a string with spaces or some other weird characters, so in order to make sure it is all kept together quote it.
  5. When you retrieve a variable from a function use the tilde ~ eg. %~1. the tilde removes the surrounding quotes from a string passed through a function.
  6. When echoing a variable use "@Echo.". This prevents displaying the echo state such as "Echo off" if the variable ends up being empty. The @ prevents echoing the command if Eco is on.

Thursday, March 20, 2008

Software Complications

I think I finally understand some of the strange things which complicate the creation of software.

I was involved in testing a small piece of internal software written by one person then handed over to a small group to finish. It mostly worked when he handed it over but was missing some stabilization and fit and finish. Being handed over it fell into a strange mix of complications.

Number of coders When there is one coder, there is one opinion and one style. The program should theoretically be consistent. Adding other coders throws a wrench in the works. Each coder has a different style and a different background. Not to mention they aren't familiar with the other coder's code.

Language complexity The complexity of the language can make things more difficult by hiding useful elements of the language in places some programmers wouldn't think to find or wouldn't know it even existed causing programmers to wrap their own solutions to things which already exist.

Language stability The stability of the language helps quite a bit. If a language is a type-safe language with garbage collection it is more difficult to have more disastrous consequences. Where in a language like C++, if you are not careful the program can leak and corrupt memory.

Project Complexity It is impossible to write a program which does not have errors. There will always be bugs in any program. Even a simple program will have some kind of way it can fail. The more code a program has and the more pieces it accumulates the more bugs it is likely to have. So the number of possible bugs is somewhat proportional to the complexity of the program.

Coder's Programing skill No two programmers have the same skill set or experience. Some have years of college and work experience, while others are new but well taught. Others are self taught, gleaning on the histories of others. As such the ways code is written will vary deeply depending on who codes.

Coder's Language familiarity The familiarity a coder has with a language certainly helps with how well they can code. A lot of languages have a very similar structure so someone familiar with a similar language can generally be somewhat efficient in another. But there are things such as libraries and learning the gotchas of a language which differ. For instance Someone who was educated in C++ can program in C# but they are likely to make things more difficult than necessary. And Someone who was trained in C# is likely to need to heavily use references to get much dome.

All of these things and others can make things difficult. A Programmer who is handed a project but is not familiar with how a program works is likely to unknowingly break parts which work perfectly well, while trying to fix some other part.

It was amazing to see how all of these factors can play into how a program eventually ends up. And the quality of it.

Sunday, January 13, 2008

Reverse

While helping my office mate prepare for his Interviews a whole bunch of us were coming up with questions and challenges for him. We were really hoping he would make it. One of the challenges asked was to reverse a string.

Having been asked to do it in an interview before (I did it in VB then) I had, had the time to come up with other possible solutions to the challenge. Here is a C# version of the method from memory:

/// <summary>
/// Reverses a sequence of chars in a string.
/// </summary>
/// <param name="value">String to Reverse</param>
/// <returns>the reverse of the provided string.</returns>
/// <remarks>
/// Reverse by back stepping through each char in the string 
/// and filling a StringBuilder with the result.
/// </remarks>
public string reverseStringFill(string value)
{
    StringBuilder temp = new StringBuilder();
    // Iterate backwards through each char and copy 
    // it's equivalent from the source string.
    for (int index = value.Length - 1; index >= 0; index--)
     {
         temp.Append(value[index]);

     }
     return temp.ToString();

}

Here is another variation:

/// <summary>
/// Reverses a sequence of chars in a string.
/// </summary>
/// <param name="value">String to Reverse</param>
/// <returns>the reverse of the provided string.</returns>
/// <remarks>
/// Reverse by back stepping through each char in the string 
/// and filling the resulting array.
/// </remarks>
public string reverseStringBFill(string value)
{
    char[] temp = value.ToCharArray();
    int length = value.Length - 1;
    // Iterate backwards through each char and copy 
    // it's equivalent from the source string.
    for (int index = length; index >= 0; index--)
    {
        temp[index] = value[length - index];
                
    }
    return new string(temp);

}

My Office mate having learned in C/C++ most of school came up with a swap method that he had learned in class, but when he tried to run it in C# it had compile errors. because he was trying to do things the C way in a type safe language. After a hint about casting he figured it out. What he ended up with is something similar to the following:

/// <summary>
/// Reverse String using Swap
/// </summary>
/// <param name="value">String to Reverse</param>
/// <returns>the reverse of the provided string.</returns>
/// <remarks>
/// This is how a C/C++ programmer would reverse a string in C#
/// </remarks>
public string reverseStringSwap(string value)
{
    char[] returns = value.ToCharArray();
    int index = 0;
    while (index < value .Length / 2)
    {
        // Swap chars
        char temp = returns[index];
        returns[index] = returns[(value.Length-1) - index];
        returns[(value.Length-1) - index] = temp;
        index++;

     }
     return new string(returns);

}

While he worked at the problem I was thinking of a similar way to do the same thing from a managed perspective:

/// <summary>
/// Reverses a sequence of chars in a string.
/// </summary>
/// <param name="value"></param>
/// <returns>the reverse of the provided string.</returns>
/// <remarks>
/// This is similar to the swap method except it
/// only pulls it's chars from the source string.
/// </remarks>
public string reverseStringBSwap(string value)
{
   char[] temp = value.ToCharArray();
   int length = value.Length - 1;
   int half = length / 2;

   for (int index = 0; index < length; index++)
   {
      temp[index] = value[length - index];
      temp[length - index] = value[index];
                
    }
    return new string(temp);

}

He had written his in a console app and I in a GUI app so rather than  return new string(returns); His actually used Console.Write(returns); I stumbled around for a little while trying to remember how to cast to a string. But eventually found it, hopefully I can remember it now. I have changed the methods so they work the same in a GUI and a Console app as I like a clean Modular design.

While at it I found Array.Reverse(""); and this nice little, simple, clean and tidy, method ensued:

/// <summary>
/// Reverses a sequence of chars in a string.
/// </summary>
/// <param name="value"></param>
/// <returns>the reverse of the provided string.</returns>
/// <remarks>
/// This is the simple way to reverse a string.
/// Simply by using the power of the Framework.
/// </remarks>
public string reverseStringArray(string value)
{
   // Copy to an array
   char[] temp = value.ToCharArray();
   // Reverse
   Array.Reverse(temp);
   // Return casting the array as a string
   return new string(temp);

}

Now for the real fun. Recursion (Where a method calls it's self over and over until it finishes it's work, then backs out to provide the results.). This method ends up being fairly simple, but it is slower, has potential to crash and is somewhat difficult to wrap one's head around. But it looks clean and impressive.

/// <summary>
/// Recursive String Reverse
/// </summary>
/// <param name="value">String to Reverse</param>
/// <returns>the reverse of the provided string.</returns>
/// <remarks>
/// This method Reverses a string by calling it's self recusively 
/// The method used here is certainly not the fastest method avalible
/// as it uses slow string concatenation and has the possibility of
/// having a buffer overflow recursing to many levels if using a 
/// string which is to long. But the idea is just so fun.
/// </remarks>
public string reverseStringRecursive(string value)
{
    if (value != "")
    {
        // Recurse the incoming string, minus the first char, then return 
        // the resulting string, appending the first char to the end.
        return reverseStringRecursive(value.Remove(0,1)) + value[0];

    }
    else
    {
        return "";

    }

} 

Ah, this was fun! One of these days I should revisit one of my old favorite sites (http://www.xbeat.net/vbspeed/) and try to work out a method for timing the methods and try a few other speedy ideas.

One of the odd things from that site is that you learn that simplicity is not always equal to speed. Rather often the reverse is true. There are some strangely long code snippets setup just for improvement with speed.

Sunday, October 7, 2007

Aw. No Analytics report

Aw. It looks like I didn't install the Analytics tracking script correctly, or something. I happen to know there were at least two hits over the past week.

I had thought that maybe those that read, might be doing so via. RSS Feed. It is quite possible but then I went looking for the tracking script I had placed and, it was gone. Whoops. This time I placed it in a place where I know it should go.

But then if Javascript is turned off in a browser it won't be tracked. Actualy, I wonder what this page looks like without JavaScript. Google relies on it heavily.

Sunday, June 17, 2007

Safari Testdrive

Okay I decided to download Safari to add it to my testing tool belt. I'm writing this post from Safari now. It was definitely not designed for Windows. The resizing borders are missing, It feels naked like this. Eek! Give me my borders please! It also added a desktop Icon without an option to not install one. One of my pet Peeves. Off you go to hide in the Quick Launch.

One thing I noticed, that I do like, is that it seems to have some interaction with the OS, or at least other browsers. I started typing the address to get to this blog and it actually showed up in the list.

Gasp! The middle click worked! It opened a new tab! Shocking! coming from an Apple product. Okay now to test the Print Preview on my Blog. Something FireFox can't handle... Cool. It works about like Opera with Print Preview. that is good.

One of the first pages I had to try of course was the Recipe page I had been working on. And... It looks just the same in Safari as it does on Opera, FireFox, and Netscape. IE and Maxthon look a little different because of a little bit of an odd spacing issue, but I think it is cool that I don't need to change that design to get it to work is Safari.

The metallic grey interface is a little depressing. I really started to love the tan color of Windows XP Luna Blue. Vista's Black is depressing too though. I specifically went online searching for a Desktop Wallpaper with a little color in it, a few weeks ago just for that cause.

I think I will stick with IE as my choice of browser it still loads faster than any of the others and I have become comfortable with IE7. I will keep it on my tool belt though to test websites against.

Wednesday, February 21, 2007

I had an interview with the Virtual PC team.

Okay, I went through the interview. I was interviewed by a panel of three people, on the Virtual PC team. It started outgoing pretty good. Then, they started asking questions… I was asked to name what a number of DOS Command-line script commands do. There were a few that I didn’t recognize. One of them PushD I remembered afterwards what it did. Let's see if I can rebuild the list this time with discriptions.

MD = Creates a directory. PATH = Displays or sets a search path for executable files. DIR = Displays a list of files and subdirectories in a directory. NET LOCALGROUP = Retrive/modify users on the computer. PUSHD = Saves the current directory then changes it. Restored using POPD START = Starts a separate window to run a specified program or command. IPCONFIG = Windows IP Configuration. PROMPT = Changes the Windows command prompt. DEL = Deletes one or more files.

Next I was asked to test these two applications one was a very simple calculator, the other a Triangle determinater. I did okay I brought up a few good tests but on reflection there is something I should have brought up; I was with the Virtual PC Team. I should have thought to test their applications on different platforms. Duh! Why didn't I think of that on the spot!

After that I was given a Microsoft famous Brain teaser question, even though they are supposed to be discouraged now days. I was given a problem where a balance scale was drawn up on the white board and nine balls. One of the balls is lighter than the others which are all alike. All of the balls are the same size. I was asked to find the lighter ball. Boy did I flounder on that one. Here "http://sakharov.net/puzzle/weight.html?SRC=sakharov&STAT=9Z2&TTL=2" See if you can work it out before continuing on to the answer.

One thought I had while heading home was to bounce them and the one that bounced higher or lower could be the one. But that is not the answer. So what is the answer?

Separate the balls into 3 groups of 3. Place 3 balls on the left side of the scale and 3 balls on the right. If they balance out, you know that the heavier ball is not one of those 6. If one side is heavier, you know that the heavier ball is one of those 3. Then once you know which set of 3 has the heavier ball, you choose any 2 of them and weigh one on each side. If they balance out you know the final ball is heavier. If they don't balance, well, obviously the heavier ball is the one you are looking for. From: Casey, Yahoo! Answers

I was sort of close at one point but, I had for some reason assumed that I had to weigh every time to get the solution. I have realy never been very good with this kind of Brain teaser puzzle. Oh well. Next time, maybe.

I really don't think I have the job. Which could actually be a good thing since when I read the email all the way through I found out that it would only be a three month contract, which could put me with a hundred day break allot sooner than would be good.

Update: 21 Feb 2007 5:22 PM, I recived word on the interview. "Hey Alma, The team decided to go with a no hire decision. I will provide more feedback tomorrow. Zeshan"

Tuesday, February 20, 2007

I have another Job Interview tomorrow.

Woo, hoo. I have another Job interview with Volt, at Microsoft on Virtual PC, tomorrow. One of the requested skills is C#, So I'm not very expectant about getting the job, but I'm hopeful.

They also want Kernal Debugging skills, Hmm. Maybe I should try to learn to connect the Debugger to IE and try to figure out what the problem is I have been seeing lately.