Vamsi Pavan’s Place

When curiousity outbursts …..

3 black hats and 2 white hats

June 18th, 2008 · 1 Comment · Placements, Puzzles

Four
men are lined up on some steps. They are all facing in the same
direction. A wall seperates the fourth man from the other three.
So to summarise :-

Man 1 can see men 2 and 3.
Man 2 can see man 3.
Man 3 can see none of the others.
Man 4 can see none of the others.
The
men are wearing hats. They are told that there are two white hats and
two black hats. The men initally don’t know what colour hat they are
wearing. They are told to shout out the colour of the hat that they are
wearing as soon as they know for certain what colour it is.
They are not allowed to turn round.

They are not allowed to talk to each other.

So the question is -
Who is the first person to shout out and why?

can anybody help? best of all answers comes here …

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

→ 1 CommentTags:

Create a function, called findZeros(), that will compute the number of zeros in the decimal representation of n!

June 18th, 2008 · No Comments · Algorithms, Google

For example, 5! = 1.2.3.4.5= 120 has one zero and 10! = 1.2.3.4.5.6.7.8.9.10 = 3628800 and has two zeros.

can anybody help? best of all answers comes here …

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

→ No CommentsTags:·

Create a function, called powerSet(), that will output the power set of the input set.

June 18th, 2008 · No Comments · Algorithms, Google

The power set in Algebra theory is the set of all subsets of a set
(no..bull-set!) If a set has N elements then the power set will have
2^N elements. So if a set is denoted by {a,b} with a,b as elements then
the power set is { {},{a},{b},{a,b} }.
The {} is the empty set.

Can anybody help? best of all answers comes here…

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

→ No CommentsTags:···

Coin weighing and finding defective

June 16th, 2008 · No Comments · Placements, Puzzles

There are 9 coins. Out of which one is odd one i.e weight is less or more. How many iterations of weighing are required to find odd coin?

Try yourself first and finally, Select all to know the answer.

Answer

It is always possible to find odd coin in 3 weighings and to tell whether the odd coin is heavier or lighter.

  1. Take 8 coins and weigh 4 against 4.
    • If both are not equal, goto step 2
    • If both are equal, goto step 3

  1. One of these 8 coins is the odd one. Name the coins on heavier side of the scale as H1, H2, H3 and H4. Similarly, name the coins on the lighter side of the scale as L1, L2, L3 and L4. Either one of H’s is heavier or one of L’s is lighter. Weigh (H1, H2, L1) against (H3, H4, X) where X is one coin remaining in intial weighing.
    • If both are equal, one of L2, L3, L4 is lighter. Weigh L2 against L3.
      • If both are equal, L4 is the odd coin and is lighter.
      • If L2 is light, L2 is the odd coin and is lighter.
      • If L3 is light, L3 is the odd coin and is lighter.

    • If (H1, H2, L1) is heavier side on the scale, either H1 or H2 is heavier. Weight H1 against H2
      • If both are equal, there is some error.
      • If H1 is heavy, H1 is the odd coin and is heavier.
      • If H2 is heavy, H2 is the odd coin and is heavier.

    • If (H3, H4, X) is heavier side on the scale, either H3 or H4 is heavier or L1 is lighter. Weight H3 against H4
      • If both are equal, L1 is the odd coin and is lighter.
      • If H3 is heavy, H3 is the odd coin and is heavier.
      • If H4 is heavy, H4 is the odd coin and is heavier.

  1. The remaining coin X is the odd one. Weigh X against the anyone coin used in initial weighing.
    • If both are equal, there is some error.
    • If X is heavy, X is the odd coin and is heavier.
    • If X is light, X is the odd coin and is lighter.
Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

→ No CommentsTags:··

Common BPEL Errors

June 11th, 2008 · No Comments · Oracle SOA Suite, Oracle Tech

Few common errors in BPEL of Oracle SOA suite are:

1. No domain available for the current user

This occurs due to failure to contact Olite database instance while loading SOA suite in the system. As this db has the all meta info regarding the domain names etc. within the server.

You need to run Olite database bat files for this.

Generally the path to these files would be
D:\product\10.1.3.1\OracleAS_2\bpel\install\bin

These are bat files and file names contains olite string. ex: reg_olite.bat

These names and paths might change based on the version of SOA suite. This configuration exists for 10.1.3.1

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

→ No CommentsTags:

Adding new responsibility to an user

June 11th, 2008 · No Comments · Oracle Apps

Choose the responsibility as System Administrator,

1. Navigate to Security -> User -> Define.

2. Search for the user for which you want to add new responsibility.

3. Bottom page shows the current responsibilities attached to current user. There you create a new record with the desired responsibility and then save.

4. Logout of the Apps. And login after sometime as most cases, it take some time to update its cache.

5. Next time, when you login with that user, you can see that new responsibility in your welcome page.

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

→ No CommentsTags:··

Typical Unix/Linux recursive search commands

June 9th, 2008 · No Comments · Algorithms, Linux

The Typical one is - to find the files with some pattern recursively in a given directory.

$ find path/to/dir -name “*.html”

You can replace the “*.html” to your own filename pattern.

Another one is, in addition to above I need the text lines inside those files starting with letter t.


$ find path/to/dir -name “*.html” -exec grep “^t” {} \;

Another version with output filename plus greped text content is

$ find path/to/dir -name “*.html” | xargs grep “^t”;

-exec and xargs are the two helped commands to extend the main command functionality.

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

→ No CommentsTags:···

Empty links in javascript

May 28th, 2008 · No Comments · Java Script

Best of way of writing empty links in javascript is

<a href=”javascript:void(0);” onMouseOver=”status=”;return true” onClick=”myPopup();” >

here, due to onMouseOver attribute, it won’t display the link location in the browser status bar. Otherwise, you see the ugly location to “javascript:void(0)” in status bar.

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

→ No CommentsTags:·

Setup TortoiseSVN & Subversion on local windows

May 19th, 2008 · No Comments · Tools

http://justaddwater.dk/2007/04/26/howto-create-a-temporary-local-subversion-repository/

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

→ No CommentsTags:···

Core Java: StringBuffer and StringBuilder

May 15th, 2008 · No Comments · Java

StringBuffer is used to store character strings that will be changed (String objects cannot be changed). It automatically expands as needed. Related classes: String, CharSequence.

StringBuilder was added in Java 5. It is identical in all respects to StringBuffer except that it is not synchronized, which means that if multiple threads are accessing it at the same time, there could be trouble. For single-threaded programs, the most common case, avoiding the overhead of synchronization makes the StringBuilder very slightly faster.

No imports are necessary because these are both in the java.lang package.

Efficiency of StringBuffer compared to String

Because a StringBuffer object is mutable (it can be changed), there is no need to allocate a new object when modifications are desired. For example, consider a method which duplicates strings the requested number of times.

// Inefficient version using String.
public static String dupl(String s, int times) {
    String result = s;
    for (int i=1; i<times; i++) {
        result = result + s;
    }
    return result;
}

If called to duplicate a string 100 times, it would build 99 new String objects, 98 of which it would immediately throw away! Creating new objects is not efficient. A better solution is to use StringBuffer.

// More efficient version using StringBuffer.

public static String dupl(String s, int times) {
    StringBuffer result = new StringBuffer(s);
    for (int i=1; i<times; i++) {
        result.append(s);
    }
    return result.toString();
}

This creates only two new objects, the StringBuffer and the final String that is returned. StringBuffer will automatically expand as needed. These expansions are costly however, so it would be better to create the StringBuffer the correct size from the start.

// Much more efficient version using StringBuffer.

public static String dupl(String s, int times) {
    StringBuffer result = new StringBuffer(s.length() * times);
    for (int i=0; i<times; i++) {
        result.append(s);
    }
    return result.toString();
}

Because this StringBuffer is created with the correct capacity, it will never have to expand. There is no constructor which allows both an initial capacity to be specifed and an initial string value. Therefore the loop has one extra iteration in it to give the correct number of repetitions.

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

→ No CommentsTags:···