tag:blogger.com,1999:blog-19079401306779189892023-11-15T08:57:29.561-08:00Programming FundamentalsMAhttp://www.blogger.com/profile/15647592837919229742noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-1907940130677918989.post-86074125458555759322011-01-18T22:46:00.000-08:002011-01-18T22:46:33.004-08:00Fixing the pipelineWe have to make a pipeline (gas pipeline). We have some pieces of pipes that is on the same line we want the pipeline on. But they are scattered on the entire line and are different sizes- <br />
<br />
Now we have to move all the pieces and solder to make one single piece- so that we can order a single piece for the remaining legth-<br />
<br />
Now we want to do this with least movement of the pieces- The larger the piece the more the cost- Cost is same for long distance or long distance because the most costly operation is loading and unloading the pipe on the truck-<br />
<br />
<br />
Input:<br />
3 integers each line separated by comma- <br />
piece number , length of the piece, the starting position<br />
<br />
Output-<br />
<br />
2 integers each line separated by comma-<br />
piece number, move to position-<br />
<br />
While moving you can not move a large piece in a small gap of two pieces-<br />
<br />
Sample input:<br />
1, 10, 5<br />
2, 30, 30<br />
3, 90, 5<br />
4, 130, 20<br />
<br />
Sample output:<br />
1, 0<br />
2, 5<br />
4, 10MAhttp://www.blogger.com/profile/15647592837919229742noreply@blogger.com0tag:blogger.com,1999:blog-1907940130677918989.post-53965657108185617442010-09-13T21:09:00.000-07:002010-09-13T21:09:23.202-07:00AnagramsFind all anagrams from a dictionary.<br />
<br />
Anagram of a word is another word that is just rearrange of the letters of first word-<br />
<br />
pots, stop, tops are anagrams of each other.MAhttp://www.blogger.com/profile/15647592837919229742noreply@blogger.com0tag:blogger.com,1999:blog-1907940130677918989.post-26844182616537410862010-09-13T21:04:00.000-07:002010-09-13T21:06:27.043-07:00Rotation of a stringWe have a string "ABCDEFGH". Write a program that rotates the string to make it "DEFGHABC". We have rotated the string by 3. You can not use any extra space except a few constant length primitive ones.MAhttp://www.blogger.com/profile/15647592837919229742noreply@blogger.com1tag:blogger.com,1999:blog-1907940130677918989.post-44026524728975430922010-09-01T13:55:00.000-07:002010-09-01T13:55:18.899-07:00What is the base of a number<h3>Problem Description</h3>We use letters (A-Z) and digits (0-9) to represent a number. For example A0 in hexadecimal number is equal to 160 in decimal number and 240 in octal number. Given 2 numbers which are equal in two different base and given base of one number you have to find out base of another number.<br />
<br />
<h3>Input</h3>Three words in each line separated by spaces: first word is first number and second word is base of first number in decimal and third word is a number that is equal to first number for some different base. Letters will be capital always.<br />
<br />
<h3>Output</h3><br />
Print out the base of second number in decimal and zero if can not find any base that is 2-36.<br />
<br />
<h3>Sample input</h3>A0 16 160<br />
160 10 240<br />
<br />
<h3>Sample Output</h3>10<br />
8MAhttp://www.blogger.com/profile/15647592837919229742noreply@blogger.com1tag:blogger.com,1999:blog-1907940130677918989.post-36758584052812208072010-08-30T11:27:00.000-07:002010-08-31T04:45:34.373-07:00The first problem<h3>Problem Description</h3>Write a program that takes two integer numbers and find the distance between them.<br />
<br />
<h3>Input</h3><br />
Sequence of two numbers that fits in 4 byte integer in a computer in each line separated by whitespace character.<br />
<br />
<h3>Output</h3><br />
Distance between each pair in each line.<br />
<br />
<br />
<h3>Sample input</h3>1 2<br />
5 7<br />
<br />
<h3>Sample Output</h3>1<br />
2MAhttp://www.blogger.com/profile/15647592837919229742noreply@blogger.com0