Puzzles

1. You have 3 bags of mislabeled marbles in front of you. One says "Black," one says "White," and one says "Mixed." What's the least number of marble(s) you need to pick from what bag(s) to ascertain the contents of all three?

2. You are given 10 seeds. What will the configuration look like if you have to use those 10 seeds to plant 5 rows with 4 seeds in each row?

3. You are standing in front of a mote. You are in the desert. There are no trees, castles, or anything. The mote is 100 feet wide and 100 feet deep. The mote is empty. You are given two things to get across the mote: a 10 foot wooden ladder and an infinite amount of rope. How do you get across the mote?

4. You have 4 people to get across 1 bridge in the dark night. You have 1 flashlight. Person 1 takes 1 minute to cross. Person 2, 2 minutes. Person 3, 14 minutes. Person 4, 15 minutes. You can only have 2 people on the bridge at any one time. You only have 24 minutes to get all 4 people across the bridge. How do you do it?

5. You have one fuse that burns at an inconsistent rate and burns out completely in one hour. How can you be sure when you’ve reached the 30 minute point?

5a. You have two fuses, each that burns at an inconsistent rate and each that burns out completely in one hour. How do you know when you’ve reached the 45 minute point?

6. You have 9 marbles, all the same size, but one weighing more than the other 8. You have a scale (a balance). What is the least number of tries you’ll need to ascertain the weightier marble?

7. You have a 5 gallon jug and an 8 gallon jug. Both are empty. You are given a faucet with an unlimited water supply. Without any measuring devices other than the jugs themselves, how can you ensure that the 8 gallon jug is half-full?

Puzzle. You are given a square 4x6 of integer numbers. You must fill the cells with integers in the way that the sum of elements on all rows are equal between them and are equal with sum of elements on all columns. You have to find out if this is possible to do, prove that it is possible, or prove that it is not possible. The only possibility to make this happen is to fill the square with 0. Otherwise it is not possible, because the sum of sums on columns and on rows should be equal. And the square is 4X6. Respectively there is no integer X that is the sum of elements on columns and rows that will satisfy the equation: 4*X=6*X

5. Puzzle - You have 25 horses and you can run them in groups of 5 only find out the top 3 in the minimum number of races.

4. Riddle question, There is two empty cans, one is 5 liter and another one is 7 liter

How can I get 4 liter of water using those two cans?

* Asked me about various .net technologies used at my work. Most Challenging work.

* Showed me a game & asked me to write a logic to find the winner at any given point of the game

I don't know the name of the game, it has 6 rows & 7 columns. We can place either Red or Yellow coins in each slot. If any one color coins appear in a sequence of 4 in a row or straight or diagonal , we have a winner.

I took a two dimensional char array (6,7) & iterated each row & cell to find the solution, but he wanted more efficient solution. Suggested me to you interger array instead.

Q: (Puzzle) You have 9 bags of coins with 10 coins in each bag. One bag has some fake coins that weigh less than the real coins. Given a balancing scale how can you determine which bag contains the fake coins?

A: Put 3 bags of coins on each side of the balance. If the scale balances then the fake bag is among the 3 bags not on the scale. If the scale doesn’t balance then you know which set of 3 bags contains the fake coins. Then put one bag on each side of the scale and you’ll know which of the 3 bags contains the fake coins.

Q: (Puzzle) What is the maximum amount of coinage you can have and not be able to produce exactly one dollar.

A. 3 Quarters, 4 Dimes, 4 Pennies = $1.19

You have 12 stacks of coins and one of the stacks is of counterfeit coins. The difference is detectable by weight. The genuine coins weigh like ten grams each and the counterfeit are like nine grams. You have a scale but you can only weigh one time. How do you find which coins are counterfeit. What he left out of his explanation of the problem is the fact that the one time weight event can be of any combination of coins from any or all of the stacks. As soon as I understood this the answer was obvious.

The answer: Take one coin from the first stack two from the second thee from the third etc.. until you have 1 - 12 coins from each stack( not arbitrary but sequential). Calculate the weight that the stack should weigh if all the coins where 10 grams. The difference will between what the stack should be and a 1-12 gram difference will tell you which stack, 1-12, is counterfeit.

1) Given a bag of 10 white marbles, 12 red marbles,

> and 16 black marbles, how many marbles would you

> have

> to remove to be sure and get 3 of one color?

>

> 2) Given a ladder with N rungs, and you can take a

> step of either 1 or 2 rungs, how many ways are there

> to climb the ladder with N rungs?

>

> 3) You have two 6 sided dice with numbers on them,

> and

> you want to display the day of the month, 03, 12,

> 19... What numbers would be on each die?

>

> 4) given the picture...

> b w b w

> > | < < <

> A B C D

> Where A is looking at a wall, and B is looking at

> the

> wall, C is looking at B and the wall... Each of them

> have a hat on. There are two hats that are black,

> and

> two that are white. If in the first ten minutes

> someone can say what color there hat is, they will.

> They cannot turn, the wall is not a mirror. After

> the

> ten minutes are up, who will know what color their

> hat

> is and how can they be 100% sure of it?

>

> 5) |-|-|

> |-|-|-|-|

> |-|-|-|-|

> |-|-|

> Looking at this as 3 rows, 2 columns in the top

> row,

> 4 middle, and 2 bottom. Place the numbers 1 thru 8

> in

> this drawing where no two numbers which are in

> sequence can be either adjacent or diangle from each

> other.

ASP.NET 2.0

What are the new Data Controls in Asp.net 2.0?

Data access in ASP.NET 2.0 can be accomplished completely declaratively (no code) using the new data-bound and data source controls. There are new data source controls to represent different data backends such as SQL database, business objects, and XML, and there are new data-bound controls for rendering common UI for data, such as gridview, detailsview, and formview.

What are the new Navigation Controls in Asp.net 2.0?

The navigation controls provide common UI for navigating between pages in your site, such as treeview, menu, and sitemappath. These controls use the site navigation service in ASP.NET 2.0 to retrieve the custom structure you have defined for your site.

What are the new Login Controlsin Asp.net 2.0?

The new login controls provide the building blocks to add authentication and authorization-based UI to your site, such as login forms, create user forms, password retrieval, and custom UI for logged in users or roles. These controls use the built-in membership and role services in ASP.NET 2.0 to interact with the user and role information defined for your site.

What are the new Web Part Controls in Asp.net 2.0 ?

Web parts are an exciting new family of controls that enable you to add rich, personalized content and layout to your site, as well as the ability to edit that content and layout directly from your application pages. These controls rely on the personalization services in ASP.NET 2.0 to provide a unique experience for each user in your application.

What are Master Pages?

This feature provides the ability to define common structure and interface elements for your site, such as a page header, footer, or navigation bar, in a common location called a "master page", to be shared by many pages in your site. In one simple place you can control the look, feel, and much of functionality for an entire Web site. This improves the maintainability of your site and avoids unnecessary duplication of code for shared site structure or behavior.

What are Themes and Skins in 2.0, explain usgae scenario?

The themes and skins features in ASP.NET 2.0 allow for easy customization of your site's look-and-feel. You can define style information in a common location called a "theme", and apply that style information globally to pages or controls in your site. Like Master Pages, this improves the maintainability of your site and avoid unnecessary duplication of code for shared styles.

What is a profile object, why is it used?

Using the new personalization services in ASP.NET 2.0 you can easily create customized experiences within Web applications. The Profile object enables developers to easily build strongly-typed, sticky data stores for user accounts and build highly customized, relationship based experiences. At the same time, a developer can leverage Web Parts and the personalization service to enable Web site visitors to completely control the layout and behavior of the site, with the knowledge that the site is completely customized for them. Personalizaton scenarios are now easier to build than ever before and require significantly less code and effort to implement.

What is Configuration API?

ASP.NET 2.0 contains new configuration management APIs, enabling users to programmatically build programs or scripts that create, read, and update Web.config and machine.config configuration files.

What is MMC Admin Tool?

ASP.NET 2.0 provides a new comprehensive admin tool that plugs into the existing IIS Administration MMC, enabling an administrator to graphically read or change common settings within our XML configuration files.

Explain the use of Pre-compilation Tool?

ASP.NET 2.0 delivers a new application deployment utility that enables both developers and administrators to precompile a dynamic ASP.NET application prior to deployment. This precompilation automatically identifies any compilation issues anywhere within the site, as well as enables ASP.NET applications to be deployed without any source being stored on the server (one can optionally remove the content of .aspx files as part of the compile phase), further protecting your intellectual property.

How is application management and maintenance improved in Asp.net 2.0?

ASP.NET 2.0 also provides new health-monitoring support to enable administrators to be automatically notified when an application on a server starts to experience problems. New tracing features will enable administrators to capture run-time and request data from a production server to better diagnose issues. ASP.NET 2.0 is delivering features that will enable developers and administrators to simplify the day-to-day management and maintenance of their Web applications.

What are Provider-driven Application Services? explain in detail?
ASP.NET 2.0 now includes built-in support for membership (user name/password credential storage) and role management services out of the box. The new personalization service enables quick storage/retrieval of user settings and preferences, facilitating rich customization with minimal code. The new site navigation system enables developers to quickly build link structures consistently across a site. As all of these services are provider-driven, they can be easily swapped out and replaced with your own custom implementation. With this extensibility option, you have complete control over the data store and schema that drives these rich application services.

Explain Server Control Extensibility with reference to Asp.net 2.0 ?
ASP.NET 2.0 includes improved support for control extensibility, such as more base classes that encapsulate common behaviors, improved designer support, more APIs for interacting with client-side script, metadata-driven support for new features like themes and accessibility verification, better state management, and more.

What are the Data Source Controls?
Data access in ASP.NET 2.0 is now performed declaratively using data source controls on a page. In this model, support for new data backend storage providers can be easily added by implementing custom data source controls. Additionally, the SqlDataSource control that ships in the box has built-in support for any ADO.NET managed provider that implements the new provider factory model in ADO.NET.

What are Compilation Build Providers?
Dynamic compilation in ASP.NET 2.0 is now handled by extensible compilation build providers, which associate a particular file extension with a handler that knows how to compile that extension dynamically at runtime. For example, .resx files can be dynamically compiled to resources, .wsdl files to web service proxies, and .xsd files to typed DataSet objects. In addition to the built-in support, it is easy to add support for additional extensions by implementing a custom build provider and registering it in Web.config.

What is Expression Builders, why would you use it?
ASP.NET 2.0 introduces a declarative new syntax for referencing code to substitute values into the page, called Expression Builders. ASP.NET 2.0 includes expression builders for referencing string resources for localization, connection strings, application settings, and profile values. You can also write your own expression builders to create your own custom syntax to substitute values in a page rendering.

Is ASP.NET 64-Bit enabled? how?
ASP.NET 2.0 is now 64-bit enabled, meaning it can take advantage of the full memory address space of new 64-bit processors and servers. Developers can simply copy existing 32-bit ASP.NET applications onto a 64-bit ASP.NET 2.0 server and have them automatically be JIT compiled and executed as native 64-bit applications (no source code changes or manual re-compile are required).

Explain how Caching in Asp.net 2.0 is different from Caching in Asp.net 1.1?
ASP.NET 2.0 also now includes automatic database server cache invalidation. This powerful and easy-to-use feature allows developers to aggressively output cache database-driven page and partial page content within a site and have ASP.NET automatically invalidate these cache entries and refresh the content whenever the back-end database changes. Developers can now safely cache time-critical content for long periods without worrying about serving visitors stale data.

Garbage collection

Please explain how the garbage collector works in managed code.

The garbage collector checks to see if there are any objects in the heap that are no longer being used by the application. If such objects exist, then the memory used by these objects is reclaimed. When the garbage collector starts running, it makes the assumption that all objects in the heap are garbage. It assumes that none of the application's roots refer to any objects in the heap. The garbage collector starts walking the roots and building a graph of all objects reachable from the roots. Once all the roots have been checked, the garbage collector's graph contains the set of all objects that are somehow reachable from the application's roots, any objects that are not in the graph are not accessible by the application, and are therefore considered garbage. The garbage collector now walks through the heap linearly, looking for contiguous blocks of garbage objects. The garbage collector then shifts the non garbage objects down in memory (using the standard memory function), removing all of the gaps in the heap. Of course, moving the objects in memory invalidates all pointers to the objects. So the garbage collector must modify the application's roots so that the pointers point to the objects new locations. After all the garbage has been identified, all the non-garbage has been compacted, and all the non-garbage pointers have been fixed-up, the NextObjPtr is positioned just after the last non-garbage object.

What is reflection? Give an example of when you would want to use it.

Reflection in .NET makes it possible to explore the CLR type system programmatically. Reflection allows you to find what types are in an assembly, the methods of a type, how many arguments a method has, and so on.

In situations where we don't have access to a Dll until runtime or have no interface contract with any assembly etc., we can programmatically look up the supported properties and methods inside the assembly & then invoke any method at runtime.

Another example would be where I can write a small Test application that tests a Dll. I can use reflection apis to display a list of supported classes, properties and methods and my Test application can invoke each of this method programmatically.

What is a delegate?

A delegate in C# is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked.