Nitriq is a product by
Home
|
Console Edition
|
Features
|
Getting Started
|
Documentation
|
Support
|
Blog
|
About
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
-
Comments [0]
Tags:
Stuff
Comments are closed.
Click
Download Nitriq Now
for download options on the
NimblePros download page.
RSS
Tags
Atomiq
Blend
CopyPasteKiller
Design
Flamebait
fun
Hacker News
IADNUG
Nitriq
Projects
Stuff
Tips and Tricks
Wishlist
XAML
Archive
November, 2011 (2)
April, 2011 (1)
March, 2011 (2)
November, 2010 (1)
September, 2010 (1)
July, 2010 (2)
June, 2010 (2)
May, 2010 (1)
April, 2010 (1)
March, 2010 (1)
November, 2009 (1)
October, 2009 (5)
September, 2009 (1)
August, 2009 (1)
July, 2009 (1)
June, 2009 (1)
May, 2009 (1)
April, 2009 (2)
March, 2009 (1)
February, 2009 (2)
January, 2009 (1)
October, 2008 (1)
September, 2008 (1)
August, 2008 (1)
July, 2008 (2)
June, 2008 (2)
May, 2008 (2)
March, 2008 (2)
February, 2008 (8)
January, 2008 (4)
December, 2007 (6)
November, 2007 (2)