For Question
Since there are 5 cards, at least two will have to be of same suite. So
I keep one of them and pass the other one as the first card. This way
the second guy will know the suite.
With the three remaining cards
that needs to be passed on, I will establish an absolute ordering
between them (breaking ties on number based on suite). So lets call the
largest card C3, the second largest C2 and smallest card C1. I can
arrange these in 3! = 6 ways. I can use these to represent 6 numbers.
The second prisoner needs to guess only one of 12 numbers (since the
first card passed to him will eliminate one number). By passing the
first card face up or face down, the first prisoner can tell the second
one whether the number to be guessed is in the first half (1 - 7) or
second half (7 - 13). He can encode the number using C1, C2 and C3 in a
particular permutation.
Case 1: what if the prisoners are not allowed to pass the card facing a
particular direction (the jailer just hands over the card to the other
prisoner without maintaining any configuration?
Then send the first card + the difference between first and second (on
a circular scale from 1 to 13) by encoding using C1, C2 and C3.
Difference can never be more than 6 so it can be encoded using the
other 3 cards.
Key part here is to arrange C1, C2 and C3 such that the circular differences (always less than 6 for 3 cards) starting from first card is equal to missing card.
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags:
Two prisoners were sentenced to death by King Xuan of Zhou and were
kept in two different inaccessible cells. They were to be put to the
gallows the day after. However, King Xuan wanted to give them a last
chance. Since he was very fond of riddles, he came up with one for the
prisoners which if they solved, they would be set free. The prisoners
were told that they would be put into a single cell for a day when they
can discuss their strategy, after which they would again be sent back
to their respective cells. One of the prisoners would then be given 5
playing cards out of the pack of 52 cards. He can send four of these
five cards to the other prisoner through the jailor one by one after
which the second prisoner has to guess the one card (number and suit)
which is left with the first prisoner. If he guesses right, both the
prisoners would be set free but if not they would be hanged the same
day.
What strategy could they possibly come up with which could save them?
To know the solution .
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags:
Recently, I came across this scenario that when ever I open any word files which copy from different system, word getting crashed with error ‘Microsoft Word has encountered a problem and needs to close error’ . After a small search, I figured out that it is well known issue to the rest of world.
Checking Microsoft web site for the problem, it told me it was the normal.dot template that was corrupted, but how could the normal.dot template could be corrupted when it never had been open before? Then I realized the problem; Microsoft word was open when I ran the File and Settings Transfer Wizard on the old computer, and because of that a temporary normal.dot got copied to the new computer.

that (picture above) temporary normal.dot file is created when word is open, and if you run the File and Settings Transfer wizard while it is open, it will get copied to the new computer, creating conflicts in the new computer with word.
The normal.not file can be found at your computer profile path at: C:\Documents and Settings\yourprofilename\Application Data\Microsoft\Templates if you are having the same issue I had, delete everything under the template folder.
Microsoft word will recreate the files automatically when you open it up. Remember that is not a good practice to have applications open when you run Files and Settings Transfer Wizard on computers to transfer data.

Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags:
If you get this error while trying to create a foreign key, it can
be pretty frustrating. The error about not being able to create a .frm
file seems like it would be some kind of OS file permission error or
something but this is not the case. This error has been reported as a
bug on the MySQL developer list for ages, but it is actually just a
misleading error message.
In every case this is due to something about the relationship that
MySQL doesn’t like. Unfortunately it doesn’t specify what the exact
issue is. Here is a running list of causes that people have reported
for the dreaded errno 150. I’ve tried to put them in order based on the
frequency that I hear about a particular cause.
You may want to start by running the MySQL command “SHOW INNODB
STATUS” immediately after receiving the error. This command displays
log info and error details. (Thanks Jonathan for the tip)
Known Causes:
- The two key fields type and/or size doesn’t match exactly. For
example, if one is INT(10) the key field needs to be INT(10) as well
and not INT(11) or TINYINT. You may want to confirm the field size
using SHOW CREATE TABLE because Query Browser will sometimes visually
show just INTEGER for both INT(10) and INT(11). You should also check
that one is not SIGNED and the other is UNSIGNED. They both need to be
exactly the same.
- One of the key field that you are trying to reference does not have
an index and/or is not a primary key. If one of the fields in the
relationship is not a primary key, you must create an index for that
field.
- The foreign key name is a duplicate of an already existing key.
Check that the name of your foreign key is unique within your database.
Just add a few random characters to the end of your key name to test
for this.
- One or both of your tables is a MyISAM table. In order to use
foreign keys, the tables must both be InnoDB. (Actually, if both tables
are MyISAM then you won’t get an error message - it just won’t create
the key.) In Query Browser, you can specify the table type.
- You have specified a cascade ON DELETE SET NULL, but the relevant
key field is set to NOT NULL. You can fix this by either changing your
cascade or setting the field to allow NULL values. (Thanks to Sammy and
J Jammin)
- Make sure that the Charset and Collate options are the same both at
the table level as well as individual field level for the key columns.
- You have a default value (ie default=0) on your foreign key column (Thanks to Omar for the tip)
- One of the fields in the relationship is part of a combination
(composite) key and does not have it’s own individual index. Even
though the field has an index as part of the composite key, you must
create a separate index for only that key field in order to use it in a
constraint. (Thanks to Alex for this tip)
- You have a syntax error in your ALTER statement or you have
mistyped one of the field names in the relationship
- The name of your foreign key exceeds the max length of 64 chars.
The MySQL documentation includes a page explaining requirements for foreign keys.
Though they don’t specifically indicate it, these are all potential
causes of errno 150. If you still haven’t solved your problem you may
want to check there for deeper technical explanations.If you run into
this error and find that it’s caused by something else, please leave a
comment and I’ll add it to the list.
To Find detailed error message in Mysql
If you get for example:
ERROR 1005 at line 12: Can’t create table ‘./database/users.frm’ (errno: 150)
You can find out the real reason by executing bin/perror 150 in the MySQL directory.
This will give you a nice error message:
MySQL error: 150 = Foreign key constraint is incorrectly formed
Collected from here directly.
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags:
After my upgrade to hardy, firefox always starts with offline mode and it’s really hectic to keep change it back to online and refresh the each saved session tabs.
Also in parallel, I find my NM (network manager) applet showing status as not connected even though I connect by dhcp setting through dhcp-client.
After googling for some time, I understood that above too are inter-related. Firefox checks the nm status through d-bus and based on that it’ll change the mode while starting. Same is the case with pidgin, evolution and other internet based applications. So, issue lies with nm applet as it’s not showing the correct status even though I connect by dhcp config.
Finally, I figured out the fix for this.
I disabled roaming mode for wired connections from the Network manager and then enabled automatic configuration (DHCP) option. Now, everything started working. Firefox starts online mode now.
What a default config. Ubuntu release should have come by the proper default config atleast for very commonly used things like NM etc.
Also, I found that the issue not exists in earlier versions of firefox as well as NM. Also, by down-grading the kernel version fixed this. But, of all these, the above one is the easiest.
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags:
Name
find — Searching for files and possibly executing commands on them
Examples
-
To list all files below a given directory, say /home/user/some-directory
find /home/user/some-directory
-
To find all pdf files below that directory
find /home/user/some-directory -name “*.pdf”
-
To find files containing “tutorial” in their name
find /home/user/some-directory -name “*tutorial*”
-
To find files below the current directory changed in the last 3 days
find . -ctime -3
-
To find files that haven’t changed in the last 365 days
find . -ctime +365
-
To find all unreadable files in the current directory
find . ! -perm +444
-
Same as above, but limit to the current directory and one subdirectory deep
find . ! -perm +444 -maxdepth 2
-
Make all the files found in the above search readable by user and group (Assumes that you are the owner of all such files or that you are root)
find . ! -perm +444 -maxdepth 2 -exec chmod ug+r {} \;
-
Two ways of searching for all .c or .h files that contain the string “gtk”. The two methods are equivalent, although xargs has mutliple options that could be used to alter its behavior and thus would be considered the more flexible method.
grep “gtk” `find . -name *.[ch]`
find . -name *.[ch] | xargs grep “gtk”
Collected from gnome developer site.
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags:
Similar exceptions are :
1. java.io.IOException: Io exception: Unexpected packet
2. java.sql.SQLException: Protocol violation
3. java.sql.SQLException: Io exception: Bad packet type
4. java.sql.SQLException: Bigger type length than Maximum
5. java.sql.SQLException: Io exception: Invalid Packet Lenght
6. java.sql.SQLException: Closed Connection
7. java.sql.SQLException: Closed Statement
8. java.sql.SQLException: Refcursor value is invalid
9. java.sql.SQLException: Io exception: Size Data Unit (SDU) mismatch
10. java.sql.SQLException: Must be logged on to server
All these occur almost with same reason. It is caused when more than one thread is trying to make simultaneous use of the thin Oracle JDBC driver via the same Connection object.
To correct this problem we have to ensure that only one thread of execution was making use of the JDBC driver at a time through the same Connection OR upgrade to a later version of the driver.
Further investigation says, with JDBC driver version is 9.2.0.2.0 it is reproducible and 9.2.0.3.0 is free from this. Any ways, it is advisable to go with latest jdbc driver version i.e. 10.2.0.4 which can solve this issue.
Multi-thread programming needs this as quick note.
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags:
An interesting exception faced while parsing xml content. Also, on further analysis on this error caused below similar issues started to raise.
Another similar exception is:
java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence
Here, I am trying to parse an xml string using byte array from the xml string, and give that array as input to xml reader stream. I have used java.lang.String.getBytes() for this.
Unfortunately, I got a chinese (other UTF-8) characters as a value of one node in the xml. Hence, I got up with the above error. Later, I found that getBytes() method supports only the western encoding, not UTF-8. So by using java.lang.String.getBytes("UTF-8") method, we solved the issue.
Good to note this in XML Programming
.

Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags:
When you are working with an MNC, it’s pretty common to have interactions with onsite team Vs offsite teams. Problems comes when your calender tool not properly convert the appointments between the time zones. These are the very common Time conversions used perticularly by professionals from Indian Sub Continent.
Time Zone Standard Time & Summer Time Daylight Saving
India Standard Time (IST) +5.5 hours
Eastern Standard Time (EST)(EDT) -5 hours -4 hours
Central Standard Time (CST)(CDT) -6 hours -5 hours
Mountain Standard Time (MST)(MDT) -7 hours -6 hours
Pacific Standard Time (PST)(PDT) -8 hours -7 hours
For example, to convert between IST and PST, from the above table you can easily figure out that the difference between those two time zones is 13.5 hours.
ie. Today 9 AM (IST) = Prev Day 7:30 PM (PST)
Simple rule is: PST is 13.5 hours behind IST.
So to catch a person in PST between 6AM to 6PM from IST is very difficult in day time
. As it comes to next day 7:30PM to next next day 7:30AM from IST.
Hope it helps you. For more time zones http://www.souledout.org/nightsky/time/ut.html .
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags:
In my PL/SQL procedure I had to add a text including newline (\n in
java, ascii #10) in a text to be read by a java application. Tried with
the code
l_text := 'hello\nworld';
This did not work, the \n character behaves clearly different in PL/SQL than
in Java and only wrote ‘\n’, probably the same as writing a String in
Java using \\n. To add the newline character, I had to use chr(10),
that worked.
l_text := 'hello' || chr(10) || 'world';
I guess the same goes for newline-carriage return as well, in Java \n\r in PL/SQL writes char(10) || chr(13).
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags: