Thursday, September 20, 2007

Not all of them will have a solution !!

While i take sometime to explain the code i have written to generate the same using flex, i was thinking if all the puzzles that get generated randomly will have a solution or not?

Well the Answer is NO... Not all of them will lead to a solution...

Can i prove it?

There are different ways of proving it.

a) What are the possible number of cubes that can come of this format. 9! (nine factorial - Empty cube can occur in 9 positions and all the other 8 numbers can come at each position without repetetion i.e., 9x8! = 9!). We have to prove all 9! cubes will lead to a solution..

b) Prove using induction. Say Cube n has a solution, Cube k+1 has a solution if, k+n has a solution then all 9! cubes will have a solution

c) Proof by contradiction. Find one cube among the 9! that does not have a solution which proves that not all of them will have a solution....

 

I tried the third way - "Proof by Contradiction"... (not sure if this is the name i have to give it for)..

If you start looking at a 2X2 Cube. You will find that there is one possible way by which you cannot reach to a solution... What is it ?? See below:

    

Can you arrange it in the order so that it becomes 1,2,3 (1 and 2 in the first row in that order)?

No you cannot. Reason... Imagine 2x2 Cube elements as running in circle... (circular list!) 1->3->2 and remember even if you go back or forth, possible combinations are the following

  • 1->3->2
  • 2->1->3
  • 3->2->1

Its very simple that we cant get any order other than this. So we cannot reach 1->2->3 state at all.

Now i say that every Cube will have atleast one 2X2 cube inside it. See the example below for a 3x3 cube where assume all the other cells have "Valid Data already filled" and only this 2X2 data forms a circular loop... Now does it have a solution? I say NO.

Here is an application if you want to try it out...


Small Game in Flex

Download the game here... by right click and choose "Save AS" and save the SWF.. Open the SWF in your browser.. if it doesnt play then you are running an older version of flash player.. please upgrade to Flash player 9 and it works pretty fine...

An Enhanced version of the same is here again:

Download the game here... by right click and choose "Save AS" and save the SWF.. Open the SWF in your browser.. if it doesnt play then you are running an older version of flash player.. please upgrade to Flash player 9 and it works pretty fine...


Tuesday, September 11, 2007

Ajax and RIAs

I was welcomed today in my office with conference room GOA where Ananth (my Sr. Engg. mgr) and Rakshit (Coldfusion developer) set the agenda for giving insight into the world of RIAs.

Ajax techniques - Hidden frame technique, Hidden iFrame technique, XMLHttp technique.. Ajax - XML-Dom Parser, Ajax Patterns... XPath, XSLT... JSON Data Format, Firebug, REST, XML RPC, SOAP, AjaxStub... Coldfusion for Ajax, Spry framework, spry effects, AIR introduction, hello world sample, Packaging AIR Apps, Using Dreamweaver or Flex Builder to build apps.. Building mashup applications using Ajax, AIR ... It was an awesome training atleast for a beginner like me.. i feel this is a real good start to start from this...

I have worked on developing database driven, web based applications using J2EE... But wow.. Ajax is the Web 2.0 now taking it to the next level... Let me also take some time to understand how Silverlight and JavaFaces work... I my next posts i would try to describe my understanding of each of them with an example to the best of my knowledge...

Monday, September 10, 2007

Apache Projects

If you think you know about "Apache Web Server" and "Apache Tomcat"... here is the complete list of apache projects... They are wide spread... http://www.apache.org/dyn/closer.cgi

Float vs Double in Java

float x=2.3;

if(x>2.2) {
System.out.println("X is greater than 2.3");
}


What is the output of this program in Java..
Ans: Compilation fails.
Solution: 'x' is a float variable. and '2.2' gets converted to 'double'. we cannot compare a float and a double. We need to mention it as 'x>2.2f' for the above code to print the output.

Sun Certifications

If you plan to take up - This is the ladder for you...


Read here for a complete overview of the same - http://www.sun.com/training/certification/java/index.xml

J2EE Design Patterns

http://java.sun.com/developer/technicalArticles/J2EE/despat/ is one good place to study about the J2EE Design patterns. They are very good. Design patterns help you solve a business problem (depending upon your requirement, you choose which pattern - which was already implemented successfully by some one - suits you and you just choose that one)... its very good to learn the design patterns immediately after you are done with your learning of specific technologies or may be in parallel.

boolean vs int in Java

Some of us might think C and Java might behave the same manner...
for example, the code below:

int x = 3;
if(x=4) {
System.out.println("X is assigned value 4");
}

if(x) {
System.out.println("Value of X is 4");
}

What is the output of the above programs in Java?
Ans: Compilation fails.
Reason: The 'if()' Condition in java expects a boolean argument. when we assign x=4, it returns an integer which is the value of 'x' i.e., 4.

Welcome

Having come across a lot of stuff related to the technologies i am working on, i have decided to jot down some of the thoughts (intricacies involved) in some of them where ever i encounter. I would also make sure this would serve as a simple teasers as well. Its hard to get everything at one place, but yes.. this is not a place for you to learn about something which is already existing else where... probably somethings that i encounter and i feel its worth noting it down (if its not so simple to understand)... Let me kick off... Sorry about my wierdo thoughts in these programming languages.. definately this would make you feel interesting in some or the other manner... There i go...