About Me

My photo
Northglenn, Colorado, United States
I'm primarily a BI Developer on the Microsoft stack. I do sometimes touch upon other Microsoft stacks ( web development, application development, and sql server development).

Monday, June 26, 2006


Source: http://www.ocf.berkeley.edu/~wwu/riddles/hard.shtml

An evil king has 1000 bottles of wine. A neighboring queen plots to kill the bad king, and sends a servant to poison the wine. The king's guards catch the servant after he has only poisoned one bottle. The guards don't know which bottle was poisoned, but they do know that the poison is so potent that even if it was diluted 1,000,000 times, it would still be fatal. Furthermore, the effects of the poison take one month to surface. The king decides he will get some of his prisoners in his vast dungeons to drink the wine. Rather than using 1000 prisoners each assigned to a particular bottle, this king knows that he needs to murder no more than 10 prisoners to figure out what bottle is poisoned, and will still be able to drink the rest of the wine in 5 weeks time. How does he pull this off?

First thing I noticed was that 2^10 is approx 1000 and saw that this dealt with some sort of binary solution. I then broke the question down into a smaller one. Dealing with 8 bottles of wine and 3 prisioners, assuming that the 2^10 has something to do with the solution.

So, I came up with this basic solution:

Bottle 1: Prisoner 1 drinks
Bottle 2: Prisoner 2 drinks
Bottle 3: Prisoner 3 drinks

Bottle 4: Prisoner 1 & 2 drinks
Bottle 5: Prisoner 1 & 3 drinks
Bottle 6: Prisoner 2 & 3 drinks

Bottle 7: Prisoner 1 & 2 & 3 drinks

Bottle 8: No one drinks.

So for example if prisoner 1 & 3 dies, then you know it must be bottle 5 that was poisoned.

I guess this could be looked at as some type of Venn diagram, and/or combinatorics. I don't know if this solution would work for 1000 bottles and 10 prisoners.

Wednesday, June 21, 2006

How to redirect a page, the right way.

Good information to keep in mind for updating websites, using the 301.

Since, I'm developing mostly in ASP.Net, here is his sample code on how to use it.

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
Response.Status = "301 Moved Permanently";


Here is a good source of Algorithms that are most commonly used in computer science. http://www.cse.ucsd.edu/~dasgupta/mcgrawhill/

I could probably add a couple, but I haven't look through the whole thing. I believe he is making this a book, but I believe their is already an algorithm book out there. Anyway, check it out, looks like a good find.

Friday, June 09, 2006

Way to execute a file through an ASP.Net page.

Very simple and quick:


Friday, June 02, 2006

Multiple Control Validator

Ok, so I have to come up with a validation control that would validate two textboxes to see if either one has been populated. The custom validator, unfortuntly, only validates if something has been entered into one of the textboxes. To get around this I set up two private boolean values to represent if text has been entered or not.

private bool TxtBox1 = false;
private bool TxtBox2 = false;

I then have my two custom validator functions, which are similar, except for the name of the second validator and it's TxtBox2:

protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
if (args.Value == "")
TxtBox1 = false;
TxtBox1 = true;
args.IsValid = getValidation();

So, I just check if there was a value entered and set my private variables.
I then call a function to assign the validation.

private bool getValidation()
if (TxtBox1 TxtBox2)
return true;
return false;

Now to deal with the textboxes being both empt

protected void ButtonSubmit_Click(object sender, EventArgs e)
if (TxtBox1 == false && TxtBox2 == false)
this.CustomValidator1.IsValid = false;
this.CustomValidator2.IsValid = false;

First validate the other controls, then validate our custom controls to see if both were left blank.
If so, then set both validators to false.

This is what I came up with so far, I might find a way to improve the summary, so that it would only give one line as the error instead of 2.