Click here to Skip to main content
14,360,151 members
Rate this:
Please Sign up or sign in to vote.
See more:
DOes any one can help me to convert pseudo code to code in c#

Pseudocode:
1. Let X be the variable currently being assigned.
2. Let x be the value being assigned to X.
3. Find all the binary constraints that are associated with X.
4. For each constraint:
1. For each neighbor variable, Y, connected to X by a binary constraint.
1. For each variable value y in Y's domain
1. If constraint checking fails for X=x and Y=y
1. Remove y from Y's domain
2. If the domain of Y is reduced down to the empty set, then the
entire check fails: return False.
5. If all constraints passed declare success, return True


THNX
Posted
Updated 8-Nov-19 6:34am
Comments
DinoRondelly 20-Dec-12 11:09am
   
Have you attempted this? What are you having a problem with?
Adam R Harris 20-Dec-12 11:13am
   
He's having a problem with writing the code ... gee whiz why you gotta break balls. Just convert his pseudo code into C# - didn't you read his question? He doesn't want to learn this stuff he just wants you to do the work for him. Is that too much to ask?
h5h6 20-Dec-12 11:18am
   
I have tried that:
private bool IsValidPosition(int row, int column)
{
for (int rowIndex = 0; rowIndex < row; rowIndex++)
{
//There should be no queens in the row / column / diagonals.
if (Queens[rowIndex] == column
|| Math.Abs(row - rowIndex) == Math.Abs(column - Queens[rowIndex]))
{
return false;
}
}
return true;

But it is only the part where I write constraints...
If u dont mind try that part to write pseudo code please
DinoRondelly 20-Dec-12 11:29am
   
What exactly are you stuck on? Sorry to break it to you but this is programming your going to have to try. If you get stuck with a specific issue then post that question. You cant ask people on this site to just do it for you. Most of the people here are at work and taking the time to help other people when they hit a road block. They are not here to make your life\Job easier. I think you need to read solution one and really think about what Griff has said.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!
   
Comments
Adam R Harris 20-Dec-12 11:15am
   
You are much nicer than i am ... i was going to tear him a new one but then again i have been called an a$$ more than once and i'm not in the best mood :(
h5h6 20-Dec-12 11:20am
   
Yes, I dont want to do my homework, my home work is a big project in fact there are a lots of code line... and I have done that... but I need also this part of pseudo code to implement in my project and I am telling the truth I cant adapt in c# code.
belive me.
DinoRondelly 20-Dec-12 11:26am
   
If you dont want to do your homework then switch courses,
Adam R Harris 20-Dec-12 11:35am
   
We don't want to do your homework either man.
h5h6 20-Dec-12 11:38am
   
ok ok, I understand. I just ask for a little help with 4-5 line of code for that pseudo code. But it is ok, sory all.

Sincerely

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100