.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Mars Bar Challenge

Posted By:      Posted Date: October 14, 2010    Points: 0   Category :ASP.Net

A colleague has set us a challenge - winner get a mars bar.


To be honest, I'm not bothered about the bar but the questions has stumped me and I am really curious to see if this can be done because I cannot think of way at all.....


Write a class that will take in a list of any type and return a sorted list of any type.

So for example, if I feed in a list of integers, it should return me a sorted list of integers

or if I feed in a list of DateTimes, it should return me a sorted list of DateTimes


This is where I break down, what if you feed in a list of a class I have written e.g. "MyClass". How can you return a sorted list of "MyClass"



Anyone have any ideas?

View Complete Post

More Related Resource Links

Don't Get Me Started: Mars and Venus


It's a fact that men and women don't think alike-remember this when designing software for the half of users that aren't like you.

David Platt

MSDN Magazine August 2010

Vrooooom: How .NET and C# Drove an Entry in the DARPA Grand Challenge


Find out how the .NET Framework, a team of programmers, and a bunch of people from Carnegie Mellon University built an automated car to compete in the DARPA Grand Challenge. Along the way you get some inside tips on building an extensible real-time control architecture based on a whiteboard metaphor and implementing an accurate GPS-synchronized timer component for .NET.

John Hind

MSDN Magazine December 2004

Query challenge

I have a database table that conains the columns directoryPath, albumArtist, and albumTitle.  There are duplicates in the table.  I want to display the rows where the albumArtist and albumTitle are the same but the directoryPath is different.  Can you help me with the magic bullet query? Thanks in advance for any answers, Mark

Try your optimizing skills on Phil Factor Speed Phreak challenge

Can you provide a better solution to this problem? So far nobody has been able to come up with a non-cursor based T-SQL solution. http://ask.sqlservercentral.com/questions/17499/phil-factor-speed-phreak-challenge-6-the-stock-exchange-order-book-state-problem Johan Åhlén http://blogical.se/blogs/jahlen

Try your SQL CLR optimization skills on Phil Factor Speed Phreak challenge

Who can provide a better solution to this problem? http://ask.sqlservercentral.com/questions/17499/phil-factor-speed-phreak-challenge-6-the-stock-exchange-order-book-state-problem Johan Åhlén http://blogical.se/blogs/jahlen

Login challenge

Last Thursday after the email virus came to visit my machine was scanned and declared safe for society. However, now I get a challenge when opening SharePoint sites on particular corporate machines on the internal network.  I am in the owner group with full control on both.  Once I log in there is no evidence of trouble.  It has been suggested that this is only an annoyance, but it is more than that because I have a number of web service calls to SharePoint which are now not working. Only I am experiencing the issue and if I log in to another machine I can access it without the login.  I am thinking some setting in IE is causing the problem.  We are still on IE 7

what is the difference between SqlDataReader.NextResult() and MARS



While i have been working with application perfomance tuning part i found an article for doing the same from Microsoft. it suggests me to reduce the round trip between application and database by using Sqlbatch statements. i got two ways to achieve it 

1. SqlDataReader.NextResult() - we can use single connection to execute sql batch statements

2. MARS (Multiple Active Result Sets) - we can use single connection to open multiple readers and execute the batch statements

MARS is having both advantages and disadvantages like Multiplexing and Thread Safety (no).

i like to know the difference between both of them , why do we need MARS instead of SQLReader.NextResult() while it solves our batch execution using a single connection?

Challenge with PropertyGrid


Hi friends.

1-When I Choose WPF template that PropertyGrid show the TextHelp for the Window Properties but when I choose a control such as   TextBox,Button  the PropertGrid dose n't show TextHelp for control Properties.

2-in the XAML view when I  move the mouse to the properties it show the class hierarchy and dose n't show the description of property.and I want show description

example: Height property show FrameworkElement.Height


Please help me with this challenge.... I need to figure this out bad. How do I calculate balance?


I have two tables that stores balance and transaction information about an account.

The first table stores all the transaction with transaction amount and effective date. The transaction has a code that differentiates deposit or withdrawal.

The other table stores balance but this balance is not historical. It is a rolling balance. It keeps on updating every time there is a transaction.

There is no place that stores the historical balance information after each transaction.

How do I calculate balance after each transaction in the history table using the current balance and the transaction code? Below is the example…

This is how the balance is stored


The incoming tabular data stream (TDS) protocol stream is incorrect. The MARS TDS header contained e


Below error occured like 100 times today morning , have no clue where to start looking into.

Any ideas?




Exception of type 'System.Web.HttpUnhandledException' was thrown.


The incoming tabular data stream (TDS) protocol stream is incorrect. The MARS TDS header contained errors.


   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

Sending Email using MD5 Challenge-Reponse Authentication


hello, Im trying to send email using MD5 Challenge Response, but it is not working with me, heres the code i am trying:

            System.Net.Mail.MailMessage mMsg = new System.Net.Mail.MailMessage("bshouman@gmail.com", "bshouman@gmail.com", "test", "test");
            mMsg.IsBodyHtml = true;
            System.Net.Mail.SmtpClient smtpC = new System.Net.Mail.SmtpClient();   
            smtpC.Host = "mail.***.com";
            smtpC.Port = 465;
            smtpC.EnableSsl = true;
            smtpC.UseDefaultCredentials = false;
            System.Net.NetworkCredential creds = new System.Net.NetworkCredential("sales@***.com", "***", "***.com");
            smtpC.Credentials = creds.GetCredential("mail.***.com", 465, "CRAM-MD5"); ;

This is the error Im getting:
System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed. at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller) at System.Net.Mail.S

Extranet windows authentication being challenge


Getting challenge for user credential when accessing extranet AAM public URL.

I have setup test environment; server1 active directory with sqlserver and server2 with Moss 2007.  I map AAM with a public URL. 

Do I need an ISA server to fix this issue?

SQL Statement Challenge



I have Two Tables and 1 ListBox

First Table Contain Names of all staff ("EMP")

Second table saves the attendance of the Staff ("Newatt")

and List box contain dates with a special criteria that match the current month

What i need to do is to take every date within the Listbox and take the names of all the staff (that stored in table EMP) and check if the the name of the employee were found within table "newatt" so that's okay if not so I need it to create a view that contain name of the employee and the date that he did not attend

Hope that explanation is clear

Please help..

hereunder my code

    For i As Integer = ListBox1.Items.Count - 1 To 0 Step -1

      Call conec()
      cmd.Connection = conn
      cmd.CommandType = CommandType.Text
      cmd.CommandText = "drop view Cheating"
      dr = cmd.ExecuteReader

      Call conec()
      cmd.Connection = conn
      cmd.CommandType = CommandType.Text

      Dim s As String

      s = "CREATE VIEW Cheating as SELECt DISTINCT bdate,Badgeholder from newatt n INNER JOIN Emp E on n.badgeholder=e.EmpName where E.empname not in (Select Badgeholder from newatt where bdate ='" & ListBox1.Items(i) & "')"

Verify Worflow step with login challenge


I have a customer that requires a password validation during a workflow process.  Similar to a sign-off for a particular step.  I have tried to convince them it seems redundant, but its required based on some outside policies in regards to the nature of the data.

I’ve not been able to find anything close to a similar solution.  Anyone have something similar?

Interesting date table challenge


I have a date table that has a ShippingDay column. This column is an incremental number per month (It starts at 1 at the beginning of each month). However, each Weekend, the number repeats what Friday was because we don't ship on the weekend. So it looks something like this

Date DayOfWeek DayOfWeek DayOfMonth ShippingDay

HELP!! GURU please come in to help us generate dynamic bin value, challenge?Interest?Discussion?


hi expert,

we want to generate a dimension like usage bin , but no idea how to implement it.

we have the data like this:

tblDimUser: userkey, UserId

tblDimDate: datekey, year, month, day

tblFactEvent: userkey, eventId, datekey

we try to create a dimension table tblDimUsageBin including a bin key, the bin should reflect the number of users who have a specific number of events. For example, Bin =1 means the user count who has less than 5 events, Bin = 2 means the user count who have less than 10 events.

We tried to use name query to create a fact table to include the bin key, but it could not reflect when adding the filter of date.

For example, we have the following data

UserId | Date | Event

1, 2010-10-11, event1

1,2010-10-12,  event2

So when we create name query by default as (count(*) ..... group by User ID), we use group by UserId to count the Event then categorized the count number to bin value like '1' means count = 1, '2' means count > 1. So by default, the name query can get the following collect set:

User ID|Date|Event|EventCountByUid|Bin Value

1,2010-10-11,event1, 2,2

1, 2010-10-12, event2,2,2

At this point, everything seems OK, BUT when user uses date key as a filter and uses bin key to slice distinct U

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend