If you understand list comprehensions, then this might be of some help:

>>> def numberedSquare(n):
    for j in range(n,0,-1):
        print (''.join([str(i) for i in range(j,j+n)]))

>>> numberedSquare(9)
91011121314151617
8910111213141516
789101112131415
67891011121314
5678910111213
456789101112
34567891011
2345678910
123456789
>>> numberedSquare(5)
56789
45678
34567
23456
12345

@JeffGrigg: Can you please elaborate what are you trying to say..?! I mean are you trying to explain the concept of symmetry?

and I don't code in Java (for your advice on JUnit). I prefer C,C++ (if the concepts are deep) or Python otherwise, which has good support for testing.. Anyways I never asked for any help on tools, so you might have assumed it..

ok, I was actually asking for some test cases (maybe my selection of words wasn't good) for which this approach may fail, and luckily I got one myself..

you might wanna skip things like:
[CODE]letters = str(encrypted) ## you have taken encrypted as input from raw_input. So it would be a string anyways.[/CODE]

And you can change lowercase to a set rather than a list. Checking for characters in it would become faster.

you might wanna skip things like:
[CODE]letters = str(encrypted) ## you have taken encrypted as input from raw_input. So it would be a string anyways.[/CODE]

And you can change lowercase to a set rather than a list. Checking for characters in it would become faster.

you can check the limits for your system in limits.h
To get through your confusions, try to put those limits in binary form and you will yourself find that they are not clashing..

I was trying to find a solution for checking the symmetry of a tree.
I would like to get some comments on the approach.. I am trying to do it by modifying the inorder traversal thing..
The pseudo code is:
[CODE]
// since the structure should be similar
string in1,in2;

func inorder (root): //normal inorder traversal
static int i;
if root==NULL: return;
if (root->left!=NULL):
in1[i++] = 'L';
inorder(root->left);
if (root->right!=NULL):
in1[i++] = 'R';
inorder(root->right);

func modified_inorder (root):

// modified inorder traversal. This one flips the traversal order from (root,left,right) to (root,right,left).

static int i;
if root==NULL: return;
if (root->right!=NULL):
    in1[i++] = 'L';
    inorder(root->right);
if (root->left!=NULL):
    in1[i++] = 'R';
    inorder(root->left);

string_compare(in1,in2); //this should provide the result by comparing the strings formed by traversals.

[/CODE]

Now, would this work?

If you are getting that error at cmd, then you have not installed python correctly, or most probably you haven't added python to your environment variables.
please look at: [URL="

Oh thanks, :)
Will take some time to see and understand the whole code. (Will need to remember the C things).

It would be great if someone already knowing about it could give me a better answer. I always try to get my answers from the source code and am left dazzled by the code in C. (last time I was trying to see how long was implemented)

[QUOTE]def print_lol(movies):
for each in movies:
if isinstance(each,list):
print_lol(each)
else:
print(each)[/QUOTE]
[CODE]>>> def print_lol(movies):
for each in movies:
if isinstance(each,list):
print_lol(each)
else:
print(each)

[/CODE]
This worked for me.
I wanted to ask that if movies is not a list here ( you are checking via isinstance ), then what are you iterating through? (maybe you have strings in that list movies).

I was looking around the time module. The time.sleep(no_of_seconds) sleeps the program for no_of_seconds seconds.
I don't think this is busy wait. It must be scheduling the process at a later time. Just curious of how this is working.! :)

Oh, I was handling files separately.
Thanks for all the help.

I am using codeblocks on windows machine. So, it would be better if you could tell me the linking way too on IDEs.
On linux, if i am not wrong,
[CODE]gcc 2.c 1.o[/CODE]
would suffice.?

Yes, you can use a call to getch() or getche() and check for the ASCII values.

OK, so the file inclusion makes the two files lump together, and is then served to the compiler as one "translation unit".
So, is their any other way round too, to access a global variable from a file without including it? (for which static plays its role)

[CODE]#include "1.c"[/CODE]
This would put the whole code in that file(1.c) as it is to this file(2.c).
I understand your point, but I am confused with the statement. According to my interpretation, a global variable in a file, if declared static, should not be shown (be accessible) in other files that link to the file having the variable.
I am now more confused!! Can you please just explain the statement.

Even after looking at a lot of books, I am not able to understand the problem in the following code:

[CODE]
//1.c
static int y=23;

void abc(int a){
printf("%d\n",a);
}
[/CODE]

[CODE]
//2.c

include<stdio.h>

include "1.c"

int main(){
abc(12);
printf("\n");
printf("%d\n",y);
return 0;
}
[/CODE]

I can understand that the functions abc is accessible to this file, but how is this variable y accessible here?
[QUOTE]The static declaration, applied to an external variable or function, limits the scope of that object to the rest of the source file being compiled.
from: dennis ritchie[/QUOTE]
So, how is this static variable in 1.c printed here?? :-/

very good answer momerath..
I must really start using these boolean operators.. :)

I was looking at a question:
Q. Given n numbers of which all numbers are repeated (at least once) other than one. We have to find that number.

Numbers range is to 10^9, thus using count sort would do no good.!

Adding the numbers one by one to a dictionary was another option (and a good one as the complexity is O(n)). But this has high implementation requirements.!

Can someone suggest some better answer to this problem.? :-/

I just wanted to learn to create facebook applications using python.I am new to web development of any sorts, so everything seems to be weird right now.
Here is what i acquired by google searching pages:
This is the facebook developers page:
[url]http://developers.facebook.com/opensource/[/url]
Only one link to python..
[url]https://github.com/facebook/python-sdk[/url]
The downloaded file contains a small amount of python files, but they are asking for another module: google.appengine amongst others.
I tried to search for some previous applied code using google code, but alas, it all made no sense to me..!
If someone has ever worked on it before, then please give me some tips on how to move..

listening to "airplanes" by B.o.b.
Good music with some great lyrics...

I am not using STL here because this program is to be converted to C. (after it starts functioning like I want it to). So, maybe you understand this "last century C-like approach". ;)
Anyways, I tried using your way of passing the pointer on a test program:
[CODE]#include<iostream>
using namespace std;

void prnt(int * a,int i,int j){
for(int k=0;k<i;++k)
for(int l=0;l<j;++l)
cout<<a[k][l];
}

int main(){
int a[3][4];
for(int k=0;k<3;++k)
for(int l=0;l<4;++l)
a[k][l]=kl;
prnt(a,3,4);
return 0;
}
[/CODE]
The errors include:
[CODE]||In function `void prnt(int
, int, int)':|
7|error: invalid types int[int]' for array subscript| |In functionint main()':|
15|error: cannot convert int (*)[4]' toint' for argument 1' tovoid prnt(int, int, int)'|
||=== Build finished: 2 errors, 0 warnings ===|
[/CODE]
So, can you please be more clear with your approach on pointers as I have never been too comfortable with these dangerous pointers.. :(
Any help would seem good.

And yes, The methods you stated seem to be for arrays, but I am asking for multidimensional arrays. So, please try to stick to the area of concern...

I was trying to code the assembly line sheduling problem using the dynamic programming approach. I have coded the program but i am facing problem with the 2-dimensional arrays I am using. For testing purpose, I wanted to initialize the array, but I was not able to get it. Moreover, as most of the arrays I am using are dynamically allocated, They were not getting passed to functions.
Though I have made the program working with some tricks but I would really appreciate if someone helps me improve it.

[CODE]#include<iostream>
using namespace std;

//Had to make much of the variables global so
//as to sought out the problem of functions.

int n=6,i;
int a[2][6],t[2][6-1],e[2],x[2];
int f1[6],f2[6],l[2][6],fe,le;

void prnt_statns(){//int f1[],int f2[],int l[][],int fe,int le,int n){
int i=le;
cout<<"line "<<i<<" station "<<n<<"\n";
for(int j=n-1;j>0;--j){
i=l[i-1][j];
cout<<"line "<<i<<" station "<<j<<"\n";
}
}

void fast_way(){//int a[][n],int t[][n],int e[],int x[],int n){
//int f1[n],f2[n],l[2][n],fe,le;
f1[0]=e[0]+a[0][0];
f2[0]=e[1]+a[1][0];
for(int j=1;j<n;++j){
if( (f1[j-1]+a[0][j]) <= (f2[j-1]+t[1][j-1]+a[0][j]) ){
f1[j]=f1[j-1]+a[0][j];
l[0][j]=1;
}
else{
f1[j]=f2[j-1]+t[1][j-1]+a[0][j];
l[0][j]=2;
}
if( (f2[j-1]+a[1][j]) <= (f1[j-1]+t[0][j-1]+a[1][j]) ){
f2[j]=f2[j-1]+a[1][j];
l[1][j]=2;
}
else{
f2[j]=f1[j-1]+t[0][j-1]+a[1][j];
l[1][j]=1;
}
}
if( (f1[n-1]+x[0]) <= (f2[n-1]+x[1]) ){
fe=f1[n-1]+x[0];
le=1;
}
else{
fe=f2[n-1]+x[1];
le=2;
}
prnt_statns();//f1,f2,l,fe,le,n);
}

int main(){
cout<<"This program gives the fastest way through a factory of n machines..\n";
cout<<"Enter number of machines.. ";
/int n,i;
n=6;//cin>>n;
int a[2][n],t[2][n-1],e[2],x[2];
/
cout<<"Enter the entry times..\n1. ";
e[0]=2;//cin>>e[0];
cout<<"2. ";
e[1]=4;//cin>>e[1];
cout<<"Enter the exit times..\n1. ";
x[0]=3;//cin>>x[0];
cout<<"2. ";
x[1]=2;//cin>>x[1];
cout<<"Enter the station times of row 1:\n";
//a[0][]={7,9,3,4,8,4};//
for(i=0;i<n;++i) cin>>a[0][i];
cout<<"Enter the station times of row ...

[QUOTE]
while (b=false)[/QUOTE]
You are using the assignment operator here. This would assign the value false to b and continue in the loop.
Rather try an use:
[CODE]
while(b==false){
//code to be used
}[/CODE]

Rather use this code:

[CODE]bool b;
cin>>birth; //remember to put in ';'
b=isdigit(birth);
while (b!=false)
{
cout<<"Please Enter a positive value (a digit):"<<endl;
cin>>birth;
b=isdigit(birth);
}[/CODE]

maybe you are getting confused with your very own variables...
Take it like this:
you firstly initialize the variables with.:
[CODE]int X=1, Y=2, Z=3, A=4, B=5, C=6, A1=7, A2=8, A3=9;
[/CODE]
Then you call a function F with arguments: (X, Y, Z, A, B, C) or (1,2,3,4,5,6)
Fine..
Now the function is called like (arguments X,Y,Z by value and arguments A,B,C by reference). If you are clear with difference between call by value and call by reference then follow..
[CODE]

//In your function, value pointed to by &A is now given by A1

void F2(int X, int Y, int Z, int&A1, int& A2, int&A3)
{
X=X+5; //no matter to X as called by value
A1=A1A1; // Value of A changes to AA=4*4=16
A2=(Y + Z)/2; // Value of B changes to (2+3)/2=5/2=2
A3= (Y-Z)/2; // Value of C changes to (2-3)/2=-1/2=0
return;
}[/CODE]

And as your main() function's values of A1,A2,A3 are not manipulated in any ways, they remain the same..

@rpdm: sorry, but actually at that time I could not at all understand what were these 'boolalpha' and 'noboolalpha'.. now some google search has shown me [URL="

Sorry, but can you please explain your program cause at my system it is not working for any of +,- or *. The program is not using the operator anywhere...

@rpdm Don't get offensive/angry!! I was just pointing to some loop holes you were having in your program.. I believe that is what we are here for, helping each other..?
@mods maybe this thread is going off the topic, I would request you for it's closure..

Ok, so I was correct that they are defined using preprocessor #define. ;)
So, I assume there ain't any solution to getting the input as "true" and making the program think it to be 1 except than using strings...