Wednesday, February 27, 2019

IEEEXtreme Mysterious Maze

Mysterious Maze (Link)

or visit the Link

There is a valuable treasure that is hidden below a complex maze. The maze is made of rooms and are square in shape, and a maze of size N will have N × N rooms with all of them closed initially. When a room is open, one can enter into it from any of its adjacent open rooms; two rooms are adjacent if they share a common wall.
The maze was built in a way that it opens itself by opening its rooms randomly. A maze is said to be open if there is at least one path from any one of the rooms facing the top of the maze to any room on the bottom side facing the treasure. Anyone, who attempts to enter the maze without being able to reach the treasure and return, will be cruelly killed by the maze.
The local government has spent years researching the maze and figured out a way to determine the sequence of rooms being opened in almost real time. Based on this data, the government has posed the following challenge, with a small percentage of the treasure to whomever solves the problem:
Given the sequence of room openings, determine when the maze becomes open, or if it remains closed throughout.
Input Format
Input begins with a single integer N, which denotes the size of maze.
All of the next lines (except the last one) denotes the sequence of the rooms the maze is opening. Each line contains 2 integers X and Y which denotes the row and column of the room opened by the maze. The last line just includes -1 and marks the end of input.
Constraints
1 <= XY <= N <= 1000
Output Format
Output a single integer R based on the final status of the maze. R denotes the number of room openings that occur before the maze first becomes open, or -1 if the maze remains closed.
Sample Input
4
1 4
2 3
3 2
4 3
4 1
2 1
1 1
-1
Sample Output
-1
Explanation
It is easy to understand if you plot the maze. The following is the state of the maze at the end of the inputs. Xindicates that a room is closed and O that a room is open. Note that there is no path from the top of the maze to the bottom of the maze.
O X X O
O X O X
X O X X
O X O X
Consider the second input sample (which is available if you click on the Run Code button):
4
1 4
2 3
3 2
4 3
4 1
2 1
1 1
3 1
3 4
2 2
-1
Below is a figure with the maze after 7 rooms are open. Note that there is no path from the top of the maze to the bottom of the maze, and therefore the maze is closed.
O X X O
O X O X
X O X X
O X O X
However, after 8th room is open, there is a path, as shown below:
O X X O
O X O X
O O X X
O X O X
Thus, the expected output is: 8

-----------------------------------------------------------------------------------
Solution
Get the whole solution with Explanation ( Link)

Explanation





IEEEXtreme9.0 Problem : Digit Fun

Xtreme9.0 - Digit Fun! (Link )


or try this link

Recurrence relations are an important tool for the computer scientist. Many algorithms, particularly those that use divide and conquer, have time complexities best modeled by recurrence relations. A recurrence relation allows us to recursively define a sequence of values by defining the nth value in terms of certain of its predecessors.
Many natural functions, such as factorials and the Fibonacci sequence, can easily be expressed as recurrences. 

The function of interest for this problem is described below.
Let |An| denote the number of digits in the decimal representation of An. Given any number A0, we define a sequence using the following recurrence:
Ai = |Ai-1| for i > 0
The goal of this problem is to determine the smallest positive i such that Ai = Ai-1.

Input Format
Input consists of multiple lines, each terminated by an end-of-line character. Each line (except the last) contains a value for A0, where each value is non-negative and no more than a million digits. The last line of input contains the word END.
Output Format
For each value of A0 given in the input, the program should output one line containing the smallest positive such that Ai = Ai-1.
Sample Input
9999
0
1
9999999999
END
Sample Output
3
2
1
4
Explanation
The first input value is A0 = 9999, resulting in A1 = |9999| = 4. Because 4 does not equal 9999, we find A2 = |A1| = |4| = 1. Since 1 is not equal to 4, we find A3 = |A2| = |1| = 1. A3 is equal to A2, making 3 the smallest positive i such that Ai = Ai-1.
The second input value is A0 = 0, resulting in A1 = |0| = 1. Because 0 does not equal 1, we find A2 = |A1| = |1| = 1. A2 is equal to A1, making 2 the smallest positive i such that Ai = Ai-1.
The third input value is A0 = 1, resulting in A1 = |1| = 1. A1 is equal to A0, making 1 the smallest positive i such that Ai = Ai-1.
The last input value is A0 = 9999999999, resulting in A1 = |9999999999| = 10. Because 10 does not equal 9999999999, we find A2 = |A1| = |10| = 2. Since 2 is not equal to 10, we find A3 = |A2| = |2| = 1. Since 1 is not equal to 2, we find A4 = |A3| = |1| = 1. A4 is equal to A3, making 4 the smallest positive i such that Ai = Ai-1.

----------------------* Solution *------------------------------------------------


Tuesday, April 3, 2018

How to Make Your First Web Page using PhP

This blog is made to help students with creating first webpage in PhP. 

Prerequisite 

1. Already the tool XAMPP is installed if not click this Link For XAMPP.
2. Notepad or any text editor should be available . Links for the some are Sublime (Link) or Brackets (Link)

The process is divide into three steps

1. Steps to start Xampp
2.  Creating Your First Webpage
3. Opening your First Webpage
4. Small Activity
--------------------------------------------

Steps to Start Xampp

1. Open the XAMPP control panel as shown below


2. Click Start



3. And the following screen will appear




4. The status should be running else if error something will appear in red. If you have error trying close the applications like Skype, Oracle as they might be using the same port. Or we can change port for localhost in our case

Then click Explore to go to the folder htdocs . This folder contains your all webpage



You are good to go with it , well done

Step 2 : Creating Your First Webpage


1. Open a Notepad of any texteditor of your choice and copy the following code as shown below


<!DOCTYPE html>
<html>
<body>
<?php
echo "My first PHP script!";
?>
</body>
</html>

-------------------------------------

2 . Save the file as FirstTry.php as shown below



Make sure to store the file in your htdocs as shown below


3. Once you saved the file , you are good to watch your very own first 
web-page


Step 3: Opening your First Webpage


1. Open Google Chrome or Internet Explorer and type the following as shown also in picture 

http://localhost/myfirstweb/FirstTry.php

2. You can see your webpage




Test Activity


Create another page titled "MyName.php" and add your name instead of myscript