

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, slapdowns and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Cofounder
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 Cofounder
Microsoft C++ MVP





I am currently working on a procedurally generated game, and vaguely remember having read a book/paper/article in which it was said that there exists a published algorithm which can generate high quality game board games with a random set of rules, which are as good as human designed game board games. The algorithm was NOT limited to a single game such as Sudoku or Crossword puzzles, it rather would generate a set of rules for the players to play by, so it could potentially generate tic tac toe, checkers or 4 inarow wins and variations of all 3 games.
I think the article was published between 1980's and 2006ish
and that it was published in a journal.
Sadly I cannot remember where I read the article, only that it must've been in the last 8 months. If you know about this algorithm or something similar to it, please post.
Thanks a bundle,
Mark io





Hi i have this Algorithm, could anyone help me figure out the answer to it, and how?
Create a recurrence function to represent the following algorithm's time complexity and use the master method to analyse the following algorithm:
/* The function f(x) is unimodal over the range [min, max] and can be evaluated in Θ(1) time
* ε > 0 is the precision of the algorithm, typically ε is very small
* max > min
* n = (max  min)/ε, n > 0, where n is the problem size */
Algorithm(max, min)
{
if ((max  min) < ε)
{
return (max  min)/2 // return the answer
}
leftThird = (2 * min + max) / 3 // represents the point which is 1/3 of the way from min to max
rightThird = (min + 2 * max) / 3 // represents the point which is 2/3 of the way from min to max
if (f(leftThird) < f(rightThird))
{
return Algorithm(leftThird, max) // look for the answer in the interval between leftThird and max
}
else
{
return Algorithm(min, rightThird) // look for the answer in the interval between min and rightThird
}
}





Your homework is set to test what you know, not how good you are at convincing strangers to do your work for you!
The questions will be based on the material you have covered in your course. If you really don't know where to start, then you need to talk to your teacher.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
 Homer






This is your HomeWork. You are the one that have to work, not us.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein





If you are familiar with idle game or incremental games like Adventure Capitalist or Clicker Heroes you know that after a while you are dealing with very large numbers. If you are not aware basically you earn points in these games which you invest so that you can earn more points even quicker, rinse and repeat.
I wrote a small game of this style myself but didn't leave the range that a double couldn't handle but it did get me thinking on how to deal with extraordinarily large numbers.
Just to play around I figured a quick and easy way was to just keep a list with ints, each index represents a higher power and you can easily go higher if needed. index zero keeps numbers between 0999 and index 1 then starts at 10^3. So index 5 would be ^7 etc.
Except for numbers 0999 if you want to increase the number I have a function where you specify what number 19 you want to add and to which power. If you add say 9^5 to 3^5 it sorts this out by becoming 2^5 and 1^6.
So far I haven't accounted for subtraction yet in my little project but that should be fairly easy in a similar manner.
I think this shouldn't be too computationally heavy unless if used to run addition between several large lists.
Should I want to use this in a game I think it could also be easily adapted to use some approximation to reduce unnecessary work. For example if you have an entity in the game which adds 10^15 points per second and one that adds 10^3 and you show 5 decimals instead of doing all the background computations of adding those smaller numbers every second you just approximate how many seconds before they add as much so that it shows and then go from there if I made myself clear.
public void AddNumber(int value, int power) {
if (power == 0)
{
NumberContainer[0] += value;
while (NumberContainer[0] >= 1000)
{
NumberContainer[0] = 1000;
AddNumber(1, 1);
}
} else if(power < mPower)
{
NumberContainer[power] += value;
while( NumberContainer[power] >= 10)
{
NumberContainer[power] = 10;
AddNumber(1, power + 1);
}
}else
{
}
}
public static NumberControl operator +(NumberControl c1, NumberControl c2)
{
int mMaxp = c1.mPower;
if (c2.mPower > mMaxp) mMaxp = c2.mPower;
NumberControl nc = new NumberControl(mMaxp);
for(int i = 0;i < c1.NumberContainer.Count;i++)
{
nc.AddNumber(c1.NumberContainer[i], i);
}
for (int i = 0; i < c2.NumberContainer.Count; i++)
{
nc.AddNumber(c2.NumberContainer[i], i);
}
return nc;
}
Here is how I add numbers. Thinking about this really got me wondering about how others would choose to solve it instead.
Number container is just a list.
I'm planning on profile how well it handles a few different scenarios, for example if you have a list that goes to the power of 100 and have say 80 "generators" which adds a number at different power levels each second how will it will hold out compared to if I approximate those that are smaller than a certain range from the biggest number.
Reading the numbers is done by specifying how many decimals I want shown and then just walk backwards in the list and adding to a string so unless I want full precision it also works fairly well.





This forum is for asking questions. What you've got there looks more like a Tip.
Submit a new Article  CodeProject[^]
You might also want to see how your code compares to the builtin BigInteger structure[^].
Eric Lippert did a series of blog posts[^] covering how you could implement integer operations without using the builtin number types, which is also worth a read.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
 Homer





Maybe but then it would need a bit more polish and I'm not sure it would fit, maybe a small blog post and carry with it some test results and discussion around it.
When I started thinking about how to solve this I had a nagging suspicion that there already was something readily available but I couldn't figure out what search terms to use to find it so I turned it in to code instead. That blog post was interesting I admire how some people can go so indepth in a subject.





Member 11683251 wrote: Thinking about this really got me wondering about how others would choose to solve it instead. My solution here[^].
Not the most efficient way
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]






It may be a good idea to create a struct or class I'll call it LN which has a private vector with intergers VEC in the range of 0 to 9. The class has functions for Algebraic operations (+,,*,/) to add two LN together. These functions must:
 determine the sizes of both VEC and resize accordingly.
 iterate though both VEC and execute the operation digit by digit.
Since vectors are dynamically allocated, you have virtually no cap on how many digits the number has (accept for RAM).
You'll have to replace all score related constant values in your code with LN 's
I'm not sure how your game mechanics are designed, but if you have many hundreds of entities which add some constant value per second, it might be a good idea to have a single variable X which is added to the game score S every second, instead of iterating through all entities and adding the constant value to S . That is, when an entity is created, it adds it value per second constant E to X and when the entity is destroyed it subtracts E from X .
In every game step you then add X to S . This therefore only requires a single addition operation per game step and of course an addition operation when creating or destroying an entity.





i've got this homework problem which i tried to solve and didnt succeed so far. it goes like this:
Given k sets of integers A1,A2,..,Ak of total size O(n), you should determine whether exist a1A1, a2A2,...,akAk, such that a1+a2+..+ak1 =ak. Your algorithm should run in Tk(n) time, where Tk(n) = O(n^(k/2)*log n) for even k, and O(n^((k+1)/2)) for odd values of k.





If you want help then you need to make some effort. No one here is going to do all your work for you.





I have to implement 3 data compression algorithms. I was thinking about LZW, Deflate and Bzip2. I can't find any good documentation for these algorithms. Do you know any data compression algorithms with good documentation, samples etc.?





I find that extremely hard to believe. A TON of documentation and discussion comes up with a simple Google for "LZW compression algorithm" "Deflate compression algorithm" and "bzip2 compression algorithm".
If you were looking for copy'n'paste code, yeah, that's going to get you a failing grade in class.





Agreed
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein





Member 12146827 wrote: I can't find any good documentation for these algorithms. Learn to use Google ! really !
Member 12146827 wrote: Do you know any data compression algorithms with good documentation, samples etc.? Yes, but your claims are just impossible, so you will have to search again. Don't fool us, April fools was 1 week ago.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein





Can anyone say which subjects and chapters in mathematics I need to know (thorough or basic) for learning algorithms? Also help me find a book on this mathematical subjects and a good book on algorithms for beginner?





If you type "algorithms" into Google you will find a wealth of information.





The information on google is all about how to make them, But I want the mathematics needed for it and there's no clear answer i got on google for that reason.





If you go and do some reading on the subject you will discover where the gaps in your knowledge are.





The general definition of "algorithm", in simple terms, is: A sequence of instructions to solve a problem. I can write an algorithm for how to clean my house. Or for picking apples from a tree. Or for flying a plane. There are as many potential algorithms as there are ideas what to do in this world and the variety of required skills to handle all of them is vast. The same holds true when entering the domain of computer science: There are algorithms for all sorts of stuff. Obviously, logical thinking and some sense for numbers won't hurt. In fact, most algorithms I've come across should be understandable by noncomputer scientists if only written down in normal language instead of a programming language. Of course there are algorithms for which you will need very specific mathematical knowledge but the intersection of required skills for understanding arbitrary algorithms remains as simple as: Logical thinking and some sense for numbers.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson





The guy behind C++ wrote two books,
The C++ Programming Language is something I believe any serious C++ connoisseur should have chewed on for longer periods of time.
Algorithms in a Nutshell by George T. Heineman, and others is something I just started to read, and so far its good.





I'm looking for an algorithm to find all the possible combinations of meetings (details in attached photo). I would like to introduce the teams algorithm calculates all threrefore combinations of matches, or better yet, I could enter the value to the team as the level of play by all the teams and I got all the options from the most probably
Tournament tree: http://prntscr.com/aoukzm[^]
Sorry for my english





Eric Lippert did a series of blog posts on generating permutations and combinations in C#:
permutations  Fabulous adventures in coding[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
 Homer





Check out my "Alternative Tip": Subset  Sum Problem with Numeric Collections [^]
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
 G.K. Chesterton





Hi,
The problem at first seems to be simple but it is not, al least form me...
Have array/set/group of numbers,
for example:
(3,2,7,1,9,5,5,2,8,6,3,1)
I need to make groups of these numbers, so that each group has element(s) that sum is euqal or max close to certain value, for example 10. Of course I understand that there are lots of solutions, but I need only one.
So, for this set I should get:
A  2,7,1 > 10
B  9,1 > 10
C  2,8 > 10
D  5,5 > 10
E  6,3 > 9
F  3 > 3
of course this is one of possible solution, but I don't need super optimalization for this algorithm.
If anyone has some idea how to approach to this problem I would be very grateful for help.





Sounds like a backtracking[^] candidate problem to me.
You would have to extend that classical approach to allow suboptimal groupsolutions (where sum < 10 or maybe also where sum > 10 up to a certain maximum)* , temporarily store all potential overallsolutions and when the backtracking is done, pick the best based on some criteria that you have to define. E.g. where the sum of differences from 10 is smallest (would be 8 in your example). Or, as you don't need the best possible solution, you could cancel the process once a satisfactory overallsolution has been found.
* : Which means that the evaluation should continue even after finding a potential groupsolution until exceeding the tolerable limit.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson





I'd go for a rather simple implementation; sort the values, highest value first. In a loop, fetch a number from the array. Move right and keep adding numbers until you hit maximum. At maximum, fetch new number.
That's a rather blunt way of doing it though  backtracking would give a better result.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]





This looks a lot like the SubsetSum problem, but not exactly...
Check out my "Alternative Tip": Subset  Sum Problem with Numeric Collections [^]
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
 G.K. Chesterton





Hi all,
I'm a long time reader and lurker of codeproject articles in the Daily Build. I really enjoy that some articles are quite simple and as I've progressed through my career, I've been able to learn from more indepth thoughtful articles. I'm wondering if anyone has a similar place for mathematics. It would be nice if the articles would come to my email, but I'd like for it to have a wide array of expertise. Also, I'm not looking for a question/answer site, but rather somewhere people can share their ideas and findings that are not quite at the level of novel academic research (i.e. I'd like to understand what I'm reading). Does anyone know of a place?
Matthew Schmidt
Computational Physicist
Rhode Island Hospital






Hi!
So..i have some objects in set with integers properties.
player1 = {endurance:5,ovr:7},
player2 = {endurance:9,ovr:3},
....
I have to divide this set into 2 very well balanced subsets about their properties if 0 is min endurance and ovr and 10 is max endurance and ovr are the limits.
At first I had only one property and that was easy.First take the biggest and put it in the set A.The next biggest put it in the set B and etc..
So..Is there an algorithm that can solve my problem for 2 properties in this case? Thank you,guys!





What about using the same method you used before but basing it on the sum, or product (or other kind of operation) of endurance and ovr?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson






<pre lang="C#">
Adam works in the in networking security cell. He wants to generate secret keys
following a pattern. The pattern consists of the characters X and Y.
where X means increasing and Y means decreasing. Help him devise an
algorithm to generate the secret key which is the minimum number encoded
following that pattern. Digits from 19 and digits can’t repeat.
Sample Input: Sample Output:
X 12
YXYX 21435
YYXYYXXY 321654798
</pre>





Your homework should serve the purpose that you learn something. And that something isn't supposed to be how to get other people to doing your homework for you.
Your assignments will get more difficult over time  so if you don't start doing them yourself now you'll never be able to.
So sit down, think about it and try something. If you then encounter a specific problem, feel free to ask  that's the idea of these forums.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson





Please, how decode a file ASN.1 (binary file) to a file readable in (c++, java)?
Thank you for response.





It depends what you mean by decode, and what the file contains. Please edit your question and add some proper detail.





Check out: NCBI ToolBox[^]
It includes a tool to convert ASN.1 to XML.
You could either modify the tool to produce what you want, or
use XSLT[^] to convert the XML to whatever format you want!
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
 G.K. Chesterton





Here is a thread about parsing the file in Java, Parsing ASN.1 binary data with Java  Stack Overflow[^]
But, it would also be possible in C++. Just read the standard specifications for the file type.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out  Eminem
~! Firewall !~





when using master theorem
i know that a = the number of subproblems
b = size of the subproblem
d = time takes to combine the solutions
when b, the size of the subproblem is given as n1, a = 2, d=1
how do you work out T(n)??
What I have tried:
T(n) = aT(n/b) + O(n)
T(n) = 4T(n1) + O(n)





Hi
How can I decrypt the following message? Only information I have is that it might be encrypted with a program named Sec..or Crypt...something. Password might be PIN. It should have a wwwpage in it.
Any help would really be appreciated!
b3 43 67 9a 52 8a bb ef f8 d6 f5 c4 b0 5e f8 17 64 a9 55 cb 5b 17 cc e8 ba e7 32 0f a8 04 cf e0
f8 32 57 02 ca b7 88 66 69 c2 d7 0c bd 0e 46 84 98 c8 21 bd 92 b1 5d 27 a3 49 6c 80 58 0d f0 ce
cf 84 10 dd f5 f0 49 9a 80 70 23 51 f2 0e c2 f4 f5 77 e1 51 64 39 8e ee 8f a8 d1 b7 db fe aa d8
01 e0 aa 81 1d 69 ae





Sorry, but you won't get any help here for decrypting messages. Maybe your intention isn't nonethical, maybe it is, we don't know.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson





Message Removed
modified 24Mar16 13:04pm.





What school?
Even if brute force would be applied, you'd be testing each password for each available algorithm.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]





You need to discuss this with your teacher. You cannot easily decrypt anything without the algorithm or the key. I suspect there is some other piece of information that you need.





If this indeed a school assignment, it is presumably encrypted using one of the algorithms that you learnt about in the class, using a key that you should be able to guess.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time  a tremendous whack.
Winston Churchill



