Geeks With Blogs
They call me Big Papa 4 kids and counting October 2007 Entries
C# 2.0* and Telnet - Not As Painful As It Sounds

A Telnet session is really nothing but a Socket to a server on port 23 in .NET-speak. This article applies to .NET 1.1, 2.0, and 3.0, I just wrote my version in 2.0.

Posted On Monday, October 8, 2007 1:43 PM

Who is this BigPapa guy?
For anyone wondering "Who is this guy and where did he come from?" I have an answer. I have been posting for a few months on Blogger but didn't really see any fruits of my labor- no comments, no way of knowing how many hits I was getting, etc. So, I found GWB and have relocated my stuff here. So that brings me back to the original question. Part 1: Who am I? I'm a developer with the power company in SC. I love to teach and hope to be able to move into an instructor/evangelist position some day. Part ......

Posted On Tuesday, October 2, 2007 11:49 AM

Coding Challenge - Date Me
Given the day of the year and the year (both as ints), return the date in “m/d/yyyy” (string) format without using the System.DateTime namespace or any other built-in date/time handler. One solution (1858 IL characters) static string g(int d, int y) { int l; int i = 0; if (d < 0) { i = 13; } l = ((y % 400 == 0) | ((y % 100 != 0) & (y % 4 == 0))) ? 1 : 0; int[] m = new int[13] { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }; while (i < 13) { if (i > 1) { m[i] = m[i] + l; ......

Posted On Monday, October 1, 2007 8:09 AM

Coding Challenge - Color My World
Given a color string in one of the formats listed below, return an array of the RGB elements that make it up. For Example: "RGB(255,255,255)" "#FFFFFF" "#FFF" All of these examples return [255, 255, 255] - Case does not matter - #abc translates to #aabbcc - There will be no spaces in the string One solution (73 IL): s = s.Replace("RGB(", "").Replace(")", "").Replace("#", ""); if (s.Contains(",")) { return s.Split(','); } int[] a = new int[3]; int i = 0; do { a[i] = (s.Length == 3 ? 17 : 1) * Convert.ToInt32(s.Substring(i ......

Posted On Monday, October 1, 2007 8:09 AM

Coding Challenge - String 'Em Up
Implement 2 algorithms and place them in separate methods. 1) Given a sentence, write an algorithm to reverse the order of the words. Example: “My name is Chris” becomes “Chris name is My”. 2) Given the same sentence as in #1, write an algorithm to reverse each individual word, but not their order. Example: “My name is Chris” becomes “yM eman si sirhC”. Winner: public static string W(string s){ char[] c = s.ToCharArray(); Array.Reverse(c); return O(new string(c)); } public static string O(string ......

Posted On Monday, October 1, 2007 8:08 AM

Coding Challenge - Can I get a dollar?
Given an arbitrary number of coins to use, print out a combination using that number that will add up to a dollar. For instance, using the number 4: Q : 4 D : 0 N : 0 P : 0 If the number is invalid, such as 5: Invalid Number - The method must take an Integer value with no restrictions. - All data structures must be instantiated within the method. - Only Pennies, Nickels, Dimes, and Quarters can be used. (No Half Dollars) - The lowest IL wins. One solution (103 IL) static void Amount(int total) { ......

Posted On Monday, October 1, 2007 8:07 AM

Coding Challenge - Prime Challenge
Write a method that takes two parameters, both positive integers, and returns each prime number that falls on or between these two numbers. Each number printed out should be on its own line, so that if the parameters were 1 and 20, the results would be: 2 3 5 7 11 13 17 19 The method must be able to handle both parameters being the same number. It should also be able to handle the first number passed being bigger or smaller than the second. EVERYTHING must happen within this method. Your Main should ......

Posted On Monday, October 1, 2007 8:06 AM

Coding Challenge - Triangular
Given the lengths of the sides of a triangle, compute the area of the triangle.

Here's one implementation (based completely off a geometry formula):

double printArea(double a, double b, double c)
{
double s = (a + b + c) / 2;
return Math.Sqrt(s * (s - a) * (s - b) * (s - c));
}

Posted On Monday, October 1, 2007 8:05 AM

Coding Challenge - Sorted Extraction
Given a sorted list with duplicates, print out a list of just the unique elements. For example: Given (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9), the result would be (1, 3, 5, 9). Here's one implementation: int[] nums = new int[] { 1, 1, 1, 1, 2, 3, 3, 3, 4, 5, 5, 5, 5, 5, 6, 9, 9, 9, 9 }; int n = 1; Console.Write(nums[0]); do { Console.Write(nums[n] == nums[++n] ? "" : nums[n].ToString()); } while (n < nums.Length); ......

Posted On Monday, October 1, 2007 8:04 AM

LogParser is powerful and feels familiar
SITUATION: I needed to find out how many people hit and stayed on an internal company site per day on average. So, I looked through the many MANY IIS log analyzers available on the nets to help me with the task. SOLUTION: While I was looking for a decent one I found the LogParser tool by Microsoft, which caught my eye because it's free. I ended up using a 30-day eval copy of something else, but I kept monkeying with LogParser because it survived the 30 days. INFO: http://www.logparser.com/ - The ......

Posted On Monday, October 1, 2007 8:01 AM

Coding Challenge - Fizzbuzz
A friend and mentor of mine took me to lunch one afternoon and asked me, over a plate of wings (mmmmm), this question: If you wrote a program to print out the numbers 1-100 on one line each, replacing every number divisible by 3 with the word "fizz", every number divisible by 5 with the word "buzz", and every number divisible by both 3 and 5 with the word "fizzbuzz", how would you do that? I didn't answer his question during that lunch, but the question stuck with me. He told me that his group has ......

Posted On Monday, October 1, 2007 7:50 AM

Copyright © baileyrt | Powered by: GeeksWithBlogs.net