|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
Hi all hacking members I am new join
|
|
|
|
|
Wrong site: this is not a hacking site, and we do not condone, support, or assist in the production of malicious code in any way, form, or manner. This is a professional site for professional developers.
You will get no help hacking anything here.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
That's why I didn't add a report in S&A.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
What's wrong with hacking? I had a parrot doing it all the time!
|
|
|
|
|
In the words of Biff Tannen: "I think you've got the wrong car, McFly."
|
|
|
|
|
I like hacking. That's one of the best ways to learn how things work. Do you have a question?
|
|
|
|
|
Learning how to exploit a vulnerability teaches not how to code.
Been doing development for over 20 years, and a "little" paranoid. Sporting my own hostfile and delivering updates to multiple hosts.
I like education.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: Learning how to exploit a vulnerability teaches not how to code. Sure it can.
Just like SQL injection. That's hacking but we talk about it all the time. Hacking is a good way to learn how things work.
|
|
|
|
|
20212 wrote: Sure it can. No, it doesn't; it teaches nothing about patterns, not even about security, it only shows where breaches are.
20212 wrote: Just like SQL injection Thank you for proving my point.
20212 wrote: That's hacking but we talk about it all the time. Hacking is a good way to learn how things work. It's a way of learning to know about weaknesses, not about how things work. Here an analogy for ya; you claim you can run an atomic power plant, because you know an unguarded door. In my opinion, you not even less qualified than any real programmer, but a liability.
And you know you are; that's why I post under my real name, and you don't dare too.
--edit
From a real criminal; do you have any questions?
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: Thank you for proving my point. I don't think you understand your point then.
If all we told people is to use parameterized queries but did not explain why, the lesson would not be learned as well. Explaining how non-parameterized queries can allow someone to hack your db is magnitudes more valuable than just telling them to use parameters.
Eddy Vluggen wrote: that's why I post under my real name, and you don't dare too. 1. You can't prove that it's your real name.
2. You can't prove this is not my real name.
|
|
|
|
|
20212 wrote: I don't think you understand your point then. Not my problem, is it?
20212 wrote: If all we told people is to use parameterized queries but did not explain why, the lesson would not be learned as well. Explaining how non-parameterized queries can allow someone to hack your db is magnitudes more valuable than just telling them to use parameters. Again, thanks for proving my point
20212 wrote: 1. You can't prove that it's your real name. I can, there's a photograph on here from me. Look it up. No, no record government linking me to that, I not that much of a fool.
20212 wrote: 2. You can't prove this is not my real name. Easy, that's not even a legal name; you're not allowed to name children like that.
I been a developer for over 20 years. Been concerned with security for the same time. We "know a bit" about the subject
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
20212 wrote: Just like SQL injection. I am so old that I find the very idea of SQL injection completely crazy. Why would anyone even get close to the idea of passing SQL code ahead, without parsing it and consider it against authorization restrictions?
I know. "Because it would reduce performance". So then you could make two versions of your SQL based application: One HighPeformance version to use when benchmarking or comparing against alternatives. When you boost multiplatform and high availability, there is another, "safe" version with all the flexibility and functionality ruining performance, but beneficial in a lot of other ways.
|
|
|
|
|
trønderen wrote: I am so old that I find the very idea of SQL injection completely crazy. Why would anyone even get close to the idea of passing SQL code ahead, without parsing it and consider it against authorization restrictions? Because often there's none such restriction. Looking at you VB programmers.
trønderen wrote: I know. "Because it would reduce performance" Not in any way. So proven you don't know.
The rest of your drivel I not gonna answer to. You entitled to your petty opinions, and that's why I'm paid more.
Any other questions?
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: The rest of your drivel I not gonna answer to. You entitled to your petty opinions, and that's why I'm paid more. Fine. I'll keep your comment in mind when judging the quality of other utterings your make at CP.
|
|
|
|
|
trønderen wrote: Fine. I'll keep your comment in mind Do that.
trønderen wrote: when judging the quality of other utterings your make at CP. You not in any position to judge me.
Go ahead. It's a free world.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: You not in any position to judge me If you are seriously suggesting that I am morally or professionally "obliged" to take your utterings at face value, with no critical evaluation, assessment or judgement, then your utterings are utterly without any trace of value. Certainly to me - and I think many others would agree.
My comment was a response to your response, referring to my post as "drivel" and "petty opinions". That does not put you in any strong position to reject judging opinions about your posts. Feel free to declare yourself as inviolable, but don't expect the rest of the world to honor your wish.
|
|
|
|
|
Excellent when you are in Cairns we can have a game of golf, I'm only an average hacker though!
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
If you meant "mincing meat", then yes.
Otherwise, BGS9.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
The hacking comes from too much vaping.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hello everyone. I am just a beginner programmer.
I am learning recursion and dynamic programming.
I realized that even for Fibonacci numbers, recursion is not suitable - and there you need to use dynamic programming.
:thumbsup:
Well, I looked at the tutorials, it's good when you can deduce the recurrent relation and then everything is clear...
But if we cannot do it, how then?
????
For example, I took the famous task "Knight's tour" and solved it using recursion.
using System;
namespace KnightChess
{
class Field
{
public int index { get; set; }
public Field(int _index)
{
index = _index;
}
}
class Board
{
int height;
int width;
public (int, int) curKnightPos;
int value;
public Field[,] boardArr;
public static bool CanMoveKnight1(Board Board)
{
return (Board.width > Board.curKnightPos.Item1 + 1) && (Board.height > Board.curKnightPos.Item2) &&
(Board.boardArr[Board.curKnightPos.Item1 + 1, Board.curKnightPos.Item2].index == -1);
}
public static Board MoveKnight1(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1 += 2;
Transformed.curKnightPos.Item2++;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static bool CanMoveKnight2(Board Board)
{
return (Board.width > Board.curKnightPos.Item1) && (Board.height > Board.curKnightPos.Item2 + 1) &&
(Board.boardArr[Board.curKnightPos.Item1, Board.curKnightPos.Item2 + 1].index == -1);
}
public static Board MoveKnight2(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1++;
Transformed.curKnightPos.Item2 += 2;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static bool CanMoveKnight3(Board Board)
{
return (Board.curKnightPos.Item1 > 1) && (Board.height > Board.curKnightPos.Item2 + 1) &&
(Board.boardArr[Board.curKnightPos.Item1 - 2, Board.curKnightPos.Item2 + 1].index == -1);
}
public static Board MoveKnight3(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1--;
Transformed.curKnightPos.Item2 += 2;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static bool CanMoveKnight4(Board Board)
{
return (Board.curKnightPos.Item1 > 2) && (Board.height > Board.curKnightPos.Item2) &&
(Board.boardArr[Board.curKnightPos.Item1 - 3, Board.curKnightPos.Item2].index == -1);
}
public static Board MoveKnight4(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1 -= 2;
Transformed.curKnightPos.Item2++;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static bool CanMoveKnight5(Board Board)
{
return (Board.curKnightPos.Item1 > 2) && (Board.curKnightPos.Item2 > 1) &&
(Board.boardArr[Board.curKnightPos.Item1 - 3, Board.curKnightPos.Item2 - 2].index == -1);
}
public static Board MoveKnight5(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1 -= 2;
Transformed.curKnightPos.Item2--;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static bool CanMoveKnight6(Board Board)
{
return (Board.curKnightPos.Item1 > 1) && (Board.curKnightPos.Item2 > 2) &&
(Board.boardArr[Board.curKnightPos.Item1 - 2, Board.curKnightPos.Item2 - 3].index == -1);
}
public static Board MoveKnight6(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1--;
Transformed.curKnightPos.Item2 -= 2;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static bool CanMoveKnight7(Board Board)
{
return (Board.width > Board.curKnightPos.Item1) && (Board.curKnightPos.Item2 > 2) &&
(Board.boardArr[Board.curKnightPos.Item1, Board.curKnightPos.Item2 - 3].index == -1);
}
public static Board MoveKnight7(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1++;
Transformed.curKnightPos.Item2 -= 2;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static bool CanMoveKnight8(Board Board)
{
return (Board.width > Board.curKnightPos.Item1 + 1) && (Board.curKnightPos.Item2 > 1) &&
(Board.boardArr[Board.curKnightPos.Item1 + 1, Board.curKnightPos.Item2 - 2].index == -1);
}
public static Board MoveKnight8(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1 += 2;
Transformed.curKnightPos.Item2--;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static void Print(Board Board)
{
for (int i = Board.width - 1; i >= 0; i--)
{
for (int j = 0; j < Board.height; j++)
{
Console.Write(Board.boardArr[i, j].index + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
public static bool isFull(Board Board)
{
foreach(var el in Board.boardArr)
{
if (el.index == -1)
{
return false;
}
}
return true;
}
public Board(Board Board)
{
height = Board.height;
width = Board.width;
curKnightPos = Board.curKnightPos;
value = Board.value;
boardArr = new Field[width, height];
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
boardArr[i, j] = new Field(Board.boardArr[i, j].index);
}
}
}
public Board(int _height, int _width, (int, int) _curKnightPos)
{
height = _height;
width = _width;
curKnightPos = _curKnightPos;
value = 1;
boardArr = new Field[_width, _height];
for(int i = 0; i < _width; i++)
{
for (int j = 0; j < _height; j++)
{
boardArr[i, j] = new Field(-1);
}
}
boardArr[_curKnightPos.Item1 - 1, _curKnightPos.Item2 - 1].index = 1;
}
}
class Program
{
static void Main(string[] args)
{
#region input and define
Console.WriteLine("Please enter board's width");
string temp;
temp = Console.ReadLine();
int width;
bool success;
success = int.TryParse(temp, out width);
if (!success)
{
Console.WriteLine("Width be natural a number");
return;
}
Console.WriteLine("Please enter board's height");
temp = Console.ReadLine();
int height;
success = int.TryParse(temp, out height);
if (!success)
{
Console.WriteLine("Height be natural a number");
return;
}
Console.WriteLine("Please enter board's curKnightPosX");
temp = Console.ReadLine();
int curKnightPosX;
success = int.TryParse(temp, out curKnightPosX);
if (!success)
{
Console.WriteLine("CurKnightPosX be natural a number");
return;
}
Console.WriteLine("Please enter board's curKnightPosY");
temp = Console.ReadLine();
int curKnightPosY;
success = int.TryParse(temp, out curKnightPosY);
if (!success)
{
Console.WriteLine("CurKnightPosY be natural a number");
return;
}
if ((curKnightPosX > width) || (curKnightPosY > height))
{
Console.WriteLine("curKnightPos out of range");
return;
}
Board Board = new Board(height, width, (curKnightPosX, curKnightPosY));
#endregion
GetTransformsMap(Board);
Console.ReadKey();
}
private static void GetTransformsMap(Board board)
{
if (!Board.CanMoveKnight1(board) && !Board.CanMoveKnight2(board) && !Board.CanMoveKnight3(board) && !Board.CanMoveKnight4(board) &&
!Board.CanMoveKnight5(board) && !Board.CanMoveKnight6(board) && !Board.CanMoveKnight7(board) && !Board.CanMoveKnight8(board))
{
if (Board.isFull(board))
{
Board.Print(board);
}
}
if (Board.CanMoveKnight1(board))
{
GetTransformsMap(Board.MoveKnight1(board));
}
if (Board.CanMoveKnight2(board))
{
GetTransformsMap(Board.MoveKnight2(board));
}
if (Board.CanMoveKnight3(board))
{
GetTransformsMap(Board.MoveKnight3(board));
}
if (Board.CanMoveKnight4(board))
{
GetTransformsMap(Board.MoveKnight4(board));
}
if (Board.CanMoveKnight5(board))
{
GetTransformsMap(Board.MoveKnight5(board));
}
if (Board.CanMoveKnight6(board))
{
GetTransformsMap(Board.MoveKnight6(board));
}
if (Board.CanMoveKnight7(board))
{
GetTransformsMap(Board.MoveKnight7(board));
}
if (Board.CanMoveKnight8(board))
{
GetTransformsMap(Board.MoveKnight8(board));
}
}
}
}
We enter the size of the board and the coordinates of the initial position of the knight - after which the calculation takes place.
Video attached
DropMeFiles – free one-click file sharing service[^]
As you can see from the video for 8x8, we get one of the solutions in a reasonable amount of time.
But if the task is to get all the solutions?
Even for 6x6 it already freezes - everything depends on memory, I have 8GB of RAM.
:) :) :)
Help, how can this example be optimized to get ALL solutions?
Will it change anything if rewritten in C ++ or there in python?
|
|
|
|
|
I'm not getting it: How could anyone even consider doing the Fibonacci sequence recursively? For printing it backwards?
|
|
|
|
|
You really surprised me. I watched a lot of tutorials - on recursion and almost everyone has an example with Fibonacci
static int fib(int n, int a , int b )
{
if (n == 0)
return a;
if (n == 1)
return b;
return fib(n - 1, b, a + b);
}
|
|
|
|
|