Confessions of a code junkie
 
Tuesday, July 22, 2008

Programming Job Interview Challenge #13 Answer
 
Programming Job Interview Challenge Question Week #13

Highlight the text below for the answer.

This is pretty simple, use a stack to track all open brackets and on all closed pop the stack to see if you have the correct matching bracket.

private bool AreBracketsClosedProperly(string input)
{
    Stack<char> openBrackets = new Stack<char>();
    foreach (char bracket in input)
    {
        switch (bracket)
        {
            case '(':
            case '[':
            case '<':
            case '{':
                openBrackets.Push(bracket);
                break;

            case ')':
                if (openBrackets.Pop() != ')')
                    return false;
            case ']':
                if (openBrackets.Pop() != ']')
                    return false;
            case '>':
                if (openBrackets.Pop() != '>')
                    return false;
            case '}':
                if (openBrackets.Pop() != '}')
                    return false;
                break;
        }
    }

    if (openBrackets.Count != 0)
        return false;
    else
        return true;
}


Tuesday, July 22, 2008 - 8:00 AM CST - Permalink kick it on DotNetKicks.com   Comments [1] -
Tags: Stuff


Monday, June 16, 2008

Programming Job Interview Challenge #8 Answer
 
I've been trying to keep up with the Job Interview line of posts over at dev102.com, but unfortunately I've been running out of time to do all of them. Anyway, this weeks question can be found here. Stop reading if you don't want the answer.

This problem can be solved using a Finite State Machine. The only thing you're going to store is the current state of the machine, once you reach the end of the machine, you'll alert. On initialization of the piping component, you'll build a finite state machine for the given alert sequence. Every time you are given a message you check what you should do with the state machine based on where you are currently at.

I was going to write out the code to do this, but it becomes a little tricky when you have repeating data in your alert sequence because if you get a message you're not expecting you don't necessarily want to reset the state machine to its initial state. For example, if the alert sequence was "A, A, A, A, B", and your input is "A, A, A, A, A, B", you don't want to reset the machine to the first state when you get that 5th A, you want it to stay in its current state.



Monday, June 16, 2008 - 12:48 PM CST - Permalink kick it on DotNetKicks.com   Comments [0] -
Tags: Stuff


Monday, May 19, 2008

Programming Job Interview Challenge #4 Answer
 
So one of the guys over at dev102.com has been posting job interview questions. While the most recent isn't the best interview question in the world, I thought I'd share the answer if anyone is interested.

Here is the question:
How would you implement the following method: Foo(7) = 17 and Foo(17) = 7. Any other input to that method is not defined so you can return anything you want. Just follow those rules:
  • Conditional statements (if, switch, …) are not allowed.
  • Usage of containers (hash tables, arrays, …) are not allowed.

The answer is crazy simple. Highlight the text below to reveal the answer.

public int Foo(int x)
{
    return -1 * x + 24;
}

My Algebra teacher would be so proud.


Monday, May 19, 2008 - 12:48 PM CST - Permalink kick it on DotNetKicks.com   Comments [0] -
Tags: Stuff


Saturday, February 16, 2008

What The Hell?
 
So I was never really expecting to make much money from my AdSense advertisements, if I made $10 in a year, I'd be happy. But perhaps I've only made 80 cents thus far because Google is serving absurd ads like:



What AdWords did these people buy that is displayed on my site talking about Microsoft Technologies? Is this some sort of joke perpetrated the FOSS Commie Zealots? My content might be a little crappy (or not) but C#, WPF and LINQ are simply bad-ass.

Saturday, February 16, 2008 - 11:07 AM CST - Permalink kick it on DotNetKicks.com   Comments [1] -
Tags: Stuff


Sunday, February 10, 2008

Custom Created Theme
 
Well, as you can tell I've got a new DasBlog theme I created myself. I'm not the most artistic person in the world, but I'm happy with what I've accomplished. Good lord did it take a long time, its been a while since I've pounded out HTML and CSS, but I'm glad to have it fresh in my head again but I'm totally disgusted at how differently IE and Firefox render, what a gigantic waste of time.

Have a good week!


Sunday, February 10, 2008 - 11:47 PM CST - Permalink kick it on DotNetKicks.com   Comments [0] -
Tags: Stuff


Friday, February 08, 2008

Damn It Feels Good To Write Unit Tests Again
 
That is all.


Friday, February 8, 2008 - 12:45 PM CST - Permalink kick it on DotNetKicks.com   Comments [0] -
Tags: Stuff


Friday, January 18, 2008

Free Copy of VS 2008
 
Register and attend for your local launch event and receive a free copy of Visual Studio 2008, SQL Server 2008 AND Windows Server 2008. Which by my estimate is at least $2000 in free software.

http://www.microsoft.com/heroeshappenhere/register/default.mspx

(If you're feeling generous, I would accept a 10% finders fee)


Friday, January 18, 2008 - 1:33 PM CST - Permalink kick it on DotNetKicks.com   Comments [5] -
Tags: Stuff


Saturday, November 10, 2007

Booyah - First Post
 
After battling with with all the little quirks involved with switching hosting providers, I finally have a blog engine. I originally tried installing subtext but the most recent version is using the MS AJAX extensions, thus requiring that my 1and1 have the AJAX extensions installed and unfortunately 1and1 refuses to install it. Even though its been an officially supported MS product for almost a year. Anyway, I had to go with DasBlog and things seem to be going ok thus far, it took a while to tweak all the different config files just right. By the way, those are some ginormous config files (web.config => 190k). One confusing thing about DasBlog: it doesn't use a database! I always kind of thought a sql driven blogging engine was a little overkill, and if I knew that DasBlog just wrote everything to a xml config file, I would have started with it to begin with.

Anyway, I look forward to sharing my thoughts on .Net and development in general. Feel free to drop me a line at BOOjvongillernSPAM@gmail.com


Saturday, November 10, 2007 - 6:04 PM CST - Permalink kick it on DotNetKicks.com   Comments [1] -
Tags: Stuff


 


All Content © 2008, Jon von Gillern
Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.


 


Tags

Archive

Blogroll