• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 11:53
CET 17:53
KST 01:53
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced14[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband BGE Stara Zagora 2026 announced Information Request Regarding Chinese Ladder SC: Evo Complete - Ranked Ladder OPEN ALPHA
Tourneys
$5,000+ WardiTV 2025 Championship Constellation Cup - Main Event - Stellar Fest RSL Revival: Season 3 Tenacious Turtle Tussle [Alpha Pro Series] Nice vs Cure
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation
Brood War
General
[ASL20] Ask the mapmakers — Drop your questions Which season is the best in ASL? FlaSh's Valkyrie Copium BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion
Tourneys
[Megathread] Daily Proleagues [BSL21] RO16 Group B - Sunday 21:00 CET [BSL21] RO16 Group C - Saturday 21:00 CET Small VOD Thread 2.0
Strategy
Game Theory for Starcraft How to stay on top of macro? Current Meta PvZ map balance
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile Nintendo Switch Thread Should offensive tower rushing be viable in RTS games? The Perfect Game
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread The Big Programming Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
James Bond movies ranking - pa…
Topin
Esports Earnings: Bigger Pri…
TrAiDoS
Thanks for the RSL
Hildegard
Saturation point
Uldridge
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1249 users

The Big Programming Thread - Page 186

Forum Index > General Forum
Post a Reply
Prev 1 184 185 186 187 188 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
CarelessPride
Profile Joined March 2011
United States146 Posts
November 02 2012 02:53 GMT
#3701
On November 02 2012 11:28 simcaster wrote:
Show nested quote +
On November 02 2012 11:13 CarelessPride wrote:
Hey I just started taking classes in programming and I have a few questions:
1. When video games are being developed do they create their own engine or do they buy the licenses off others already made engines? Also what are the common or efficient languages used to design video games?

The vast majority of games license an engine. C++ is commonly used to design engines and lighter scripting languages like lua and python are used for everything else.
Show nested quote +
On November 02 2012 11:13 CarelessPride wrote:
2. How long would it take to recreate a similar game to lets say starcraft 2 or Diablo 3. like no create design wise just recreate everything from scratch

It would take years and a large team to recreate a game of the quality of SC2 or D3.


How long would it take me to learn the skills needed to start?
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
November 02 2012 02:55 GMT
#3702
On November 02 2012 11:53 CarelessPride wrote:
Show nested quote +
On November 02 2012 11:28 simcaster wrote:
On November 02 2012 11:13 CarelessPride wrote:
Hey I just started taking classes in programming and I have a few questions:
1. When video games are being developed do they create their own engine or do they buy the licenses off others already made engines? Also what are the common or efficient languages used to design video games?

The vast majority of games license an engine. C++ is commonly used to design engines and lighter scripting languages like lua and python are used for everything else.
On November 02 2012 11:13 CarelessPride wrote:
2. How long would it take to recreate a similar game to lets say starcraft 2 or Diablo 3. like no create design wise just recreate everything from scratch

It would take years and a large team to recreate a game of the quality of SC2 or D3.


How long would it take me to learn the skills needed to start?

In order to work on something of SC2 scale, at least 3 years. Realistically more like 4-7 in order to get a job as a C++ software engineer at one of those studios. These are assuming you're obtaining a Bachelor's degree in CS, and a really good one at that.
chaokel
Profile Blog Joined October 2010
Australia535 Posts
November 02 2012 03:12 GMT
#3703
On November 02 2012 11:13 CarelessPride wrote:
Hey I just started taking classes in programming and I have a few questions:
1. When video games are being developed do they create their own engine or do they buy the licenses off others already made engines? Also what are the common or efficient languages used to design video games?
2. How long would it take to recreate a similar game to lets say starcraft 2 or Diablo 3. like no create design wise just recreate everything from scratch


As far as i'm aware almost all large commercial games are created in engines written primarily in C++ (with some delving down into assembly for further optimisation). A lot of companies lease these, due to the fact that creating a game engine will often cost as much if not more than what they pay to lease one, not to mention all the hassles that come with it, and the fact that it simply wont be as polished and bug free as one that has been worked on and patched for years. Though some games require a custom engine which once created can be either for solely personal use or designed in mind so that they can lease it out. A well known example of this would be the unreal engine made by epic, or cryengine developed by crytek.

Recreating any commercial game would take a lot of effort and time, something as polished (technically speaking, not balance) as starcraft and diablo would probably take a similar sized team around a few years (the main difficulty would be in recreating the game engine, which would need to be built from scratch to emulate the one blizzard has made.)

chaokel
Profile Blog Joined October 2010
Australia535 Posts
November 02 2012 03:20 GMT
#3704
On November 02 2012 11:55 CecilSunkure wrote:
Show nested quote +
On November 02 2012 11:53 CarelessPride wrote:
On November 02 2012 11:28 simcaster wrote:
On November 02 2012 11:13 CarelessPride wrote:
Hey I just started taking classes in programming and I have a few questions:
1. When video games are being developed do they create their own engine or do they buy the licenses off others already made engines? Also what are the common or efficient languages used to design video games?

The vast majority of games license an engine. C++ is commonly used to design engines and lighter scripting languages like lua and python are used for everything else.
On November 02 2012 11:13 CarelessPride wrote:
2. How long would it take to recreate a similar game to lets say starcraft 2 or Diablo 3. like no create design wise just recreate everything from scratch

It would take years and a large team to recreate a game of the quality of SC2 or D3.


How long would it take me to learn the skills needed to start?

In order to work on something of SC2 scale, at least 3 years. Realistically more like 4-7 in order to get a job as a C++ software engineer at one of those studios. These are assuming you're obtaining a Bachelor's degree in CS, and a really good one at that.


3 seems a bit optimistic, i know i wouldn't want to hire someone for a project like that straight out of college / uni. We are talking a large professional undertaking with probably multi-millions in funding. If you skipped the degree, specialised your learning and built up a portfolio (by working in the industry for a few years) demonstrating your capability in that specific field it may be possible(even then without the degree, you face the reality of being turned down for people who have both the degree and experience). Still i would say to get onto a team that size, working on a project that large you would be looking at 5-6 years at a realistic minimum.

From what i've seen companies like blizzard won't even look at hiring someone as a programmer unless they have many years of experience in the industry already. They are pretty much the cream of the crop and can afford to be picky.
EscPlan9
Profile Blog Joined December 2006
United States2777 Posts
Last Edited: 2012-11-02 06:22:54
November 02 2012 05:00 GMT
#3705
Rewrote that recursive function from the last page non-recursively here. Might have some performance hits, but no duplicates, and so no tracking for duplicates needed.

A brief summary... given a MaximumNumber and MaximumSum, calculate all the possible 1 or 2 set moves where their sum is less than or equal to MaximumSum.

ex. MaximumNumber = 4, MaximumSum = 6.
Valid moves are {1} {2} {3} {4} {1,2} {1,3} {1,4} {2,3} {2,4}, since the summation of any of them are <= MaximumSum


void generateLegalMoves()
{
vector<int>temp;

for (unsigned int d = 0; d < board.size(); ++d)
{
// finds all the single moves
if (board[d] <= maxSum)
{
temp.push_back(1);
temp.push_back(board[d]);
temp.push_back(board[d]);
legalMoves.push_back(temp);
temp.clear();
}

// finds all the double moves
if ((d + 1) < board.size() )
{
for (unsigned int n = (d + 1); n < board.size(); ++n)
{
if (board[d] + board[n] <= maxSum)
{
temp.push_back(2);
temp.push_back(board[d]);
temp.push_back(board[n]);
legalMoves.push_back(temp);
temp.clear();
}
}
}
}
}


I still feel like it can be done better recursively, but so far my efforts always end up with duplicate numbers and then trying to track for duplicate numbers which makes me think the non-recursive approach might end up performing just as well in the end.
Undefeated TL Tecmo Super Bowl League Champion
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
November 02 2012 20:41 GMT
#3706
@ESCPlan: your code examples use a board array but your problem description says you have a maximum number n and simply use (1...n) as available tokens to construct your sets -- which one is it?

also, please try to make clean code examples. Your example code looks like that whole vector pushback stuff is the complicated problem when all you are looking for is how to arrange the for loop counters and conditions..

oh and if ((d + 1) < board.size() ) is redundant. for (unsigned int n = (d + 1); n < board.size(); ++n) automatically skips that case because when you substitute the n<board.size() with the initialization n=(d+1), the for loop actually checks that exact condition automatically before executing.
Gold isn't everything in life... you need wood, too!
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2012-11-02 21:47:10
November 02 2012 21:26 GMT
#3707
On November 02 2012 14:00 EscPlan9 wrote:

+ Show Spoiler +

Rewrote that recursive function from the last page non-recursively here. Might have some performance hits, but no duplicates, and so no tracking for duplicates needed.

A brief summary... given a MaximumNumber and MaximumSum, calculate all the possible 1 or 2 set moves where their sum is less than or equal to MaximumSum.

ex. MaximumNumber = 4, MaximumSum = 6.
Valid moves are {1} {2} {3} {4} {1,2} {1,3} {1,4} {2,3} {2,4}, since the summation of any of them are <= MaximumSum


void generateLegalMoves()
{
vector<int>temp;

for (unsigned int d = 0; d < board.size(); ++d)
{
// finds all the single moves
if (board[d] <= maxSum)
{
temp.push_back(1);
temp.push_back(board[d];
temp.push_back(board[d];
legalMoves.push_back(temp);
temp.clear();
}

// finds all the double moves
if ((d + 1) < board.size() )
{
for (unsigned int n = (d + 1); n < board.size(); ++n)
{
if (board[d] + board[n] <= maxSum)
{
temp.push_back(2);
temp.push_back(board[d];
temp.push_back(board[n];
legalMoves.push_back(temp);
temp.clear();
}
}
}
}
}


I still feel like it can be done better recursively, but so far my efforts always end up with duplicate numbers and then trying to track for duplicate numbers which makes me think the non-recursive approach might end up performing just as well in the end.




It doesn't matter whether you use your recursive approach to skip the {1,1} {2,2} ... {n,n} test cases. It's not going to make any noticeable difference whether you check those or not, even if you had just put a crude if x1 != x2 to skip that case.

Judging by your code, I would really consider making another function that returns a vector vector with the elements you want. It would make the code a lot less confusing to look through. In general, it's pretty impossible to track since your variables aren't that explicit and such.

You can do a few simple optimizations here and there, but your code isn't really clear about what variables are used for what purpose. Also, no one has any idea what board.size() means but you. :/


If you loop your second loop starting from the index your already started with, you will skip all the repeating cases. Then you only have to handle the {n,n} cases, which is also slightly trivial.

+ Show Spoiler [cheating] +


// solution

vector vector legal_moves(max_num, max_sum){
for x in 1 to max_num
if x <= max_sum
vector.add(x)

for x in 1 to max_num
for y in x to max_num
if x != y
if x + y <= max_sum
vector.add( new vector {x,y} )

return vector
}



// better

vector vector legal_moves(max_num, max_sum){
for x in 1 to max_num
if x <= max_sum
vector.add(x)

for x in 1 to max_num - 1
for y in x + 1 to max_num
if x + y <= max_sum
vector.add( new vector {x,y} )

return vector
}




Something like that. The max_num - 1 means you skip the {4,n} cases since it's pointless anyways. It also allows you to start the second loop at x + 1, so you don't have to skip checking the {n,n} cases.


If you put max_number = 4 and max_sum = 6

vector should have {1} {2} {3} {4} {1,2} {1,3} {1,4} {2,3} {2,4} {3,4} in that order if I'm tracing properly.


Sure, you can improve the performance of this by a bit, but really, is it really necessary? (Actually, I'm not sure about this statement)



Again, I emphasize making a function to perform this task, even if it's just for readability.
There is no one like you in the universe.
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
Last Edited: 2012-11-02 22:28:13
November 02 2012 22:27 GMT
#3708
Hey I wrote some small C practice programs. Maybe some of you guys will have fun or find it useful to check them out: link. It'd be cool to compare solutions.
EscPlan9
Profile Blog Joined December 2006
United States2777 Posts
Last Edited: 2012-11-03 03:30:45
November 03 2012 03:19 GMT
#3709
On November 03 2012 05:41 MisterD wrote:
@ESCPlan: your code examples use a board array but your problem description says you have a maximum number n and simply use (1...n) as available tokens to construct your sets -- which one is it?

also, please try to make clean code examples. Your example code looks like that whole vector pushback stuff is the complicated problem when all you are looking for is how to arrange the for loop counters and conditions..

oh and if ((d + 1) < board.size() ) is redundant. for (unsigned int n = (d + 1); n < board.size(); ++n) automatically skips that case because when you substitute the n<board.size() with the initialization n=(d+1), the for loop actually checks that exact condition automatically before executing.


Ah, didn't think about that one line being redundant. About the confusion with board, and what it represents, and why I'm using the datatypes I'm using... well... it's a large project. Throughout this quarter I had to use a generic AI solver algorithm for various 2 player games.

I have a Solver template class that only has the SolveForBestMove(T GameType) function inside it. It solves for whatever GameType object I throw at it. Within the SolveForBestMove function, I have calls out to overloaded functions for each GameType. For instance, in the example I've been showing above, the game is called Crossout. I have a CrossoutGame class with overloaded functions from what is called within the generic Solver template. So for example, within Solver template, in it's recursive SolveForBestMove method:


if ( GameType.isFinalPosition() )
{
// If it is a tie game, return 0 for the score
if ( GameType.isTied() )
return NEUTRAL_MOVE_SCORE; // score of 0 for the move

//Checks players turn (To see if good or bad move)
if ( GameType.getTurn() == FIRST_PLAYER_TURN )
return GOOD_MOVE_SCORE; //Returns score of +1 for the move

else
return BAD_MOVE_SCORE; // Returns score of -3 for bad move
}
...
// calls GameType.getLegalMoves() and with a depth-first search recursively iterates
// through the resulting position of each move and returns the score.


And then within Crossout:


// When there are no more legalMoves remaining, the final position has been reached
// No more numbers can be crossed out. So whoever crossed out the last number
// wins the game
bool CrossoutGame::isFinalPosition() const
{
return (legalMoves.size() == 0) ? true : false;
}


I've had each GameType use a vector<vector<int>> to store the Legal Moves, so I did the same for the Legal Moves of Crossout. The SolveForBestMove function explicitly expects a vector<vector<int>> when it calls GameType.getLegalMoves(), so each GameType (CrossoutGame, Connect3Game, etc) returns a vector<vector<int>> for the LegalMoves.

I am using a vector<int> for "board" in Crossout, since the game only requires me displaying it as a single line of integers. Like with the "1 2 3 4" example, the board has a size of 4, with board[0] == 1, board[1] == 2... board[3] == 4. It is a vector rather than an array because numbers are removed throughout the game and this allows me to constantly resize the array as needed.

For other games, such as Connect3 (Connect 4 with 3-in-a-row as the winning conditions), I use a vector<vector<int>> for "board".

It's fairly lengthy to post all the code I'm using... I was more curious with the recursive approach I tried last night that ended up running into duplicates. With the newer version, I'm fine with it as is, though there may be small improvements that can be made.

Thanks for the input. I'll remove the one redundant line anyways I apologize for the lack of clarity in the code in some areas. It's a small piece of a much larger project.
Undefeated TL Tecmo Super Bowl League Champion
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
November 03 2012 09:28 GMT
#3710
@EscPlan9: It's perfectly fine to re-use algorithms in bigger projects, but when making small examples you need to a) make sure you are correct on specifications - for instance using the board array instead of just numbers (1...n) is fundamentally different as it doesn't allow you to skip ahead in the algorithm without knowing if the number sequence in the array have holes (which i just assumed they do because otherwise the array would be pointless) or even worse if it isn't even a sequence in increasing order. Also, when extracting a piece of sample code from your large project, don't just copy/paste it 1:1 - take out
the essential parts so readers can cope with the complexity as easily as possible. Yes it's a bit of extra work, but you want them to help don't you? ;D

As for your description of why array or vector: sounds a lot like you are trying to over-optimize. How many legal moves are there? if it's less than 100 i'd argue that it's completely pointless (performance wise) to aim for reducing the array size when moves become illegal. In fact, it's probably worse to do so because in addition to not having any benefits, it just makes your code needlessly harder to read, understand and maintain. As a general rule of thumb, do performance optimization after you implemented a solution, and only do it where needed. Micro-optimizations such as reducing a 100 entry array in size are generally bad.
Gold isn't everything in life... you need wood, too!
Ruscour
Profile Blog Joined April 2011
5233 Posts
November 03 2012 10:21 GMT
#3711
Hello guys, I have more dumb questions.

1) I'll be doing a robotics project for a year, I don't know anything about hardware interaction but they'll teach me, however what I do need to know is C/C++. I know C decently well and haven't touched C++ but it seems like C++ would be preferable and it's seemingly used in a lot more places than C. Should I bend to Torvalds' divine will and stick to C or is C++ as beneficial as it seems?

2) C compilers for Windows? I'm used to make doing all the work for me, and using an IDE for compilation of small doodads is a waste of time. How do gcc on Windows best? MinGW? Cygwin?
Akka
Profile Joined August 2010
France291 Posts
Last Edited: 2012-11-03 10:54:31
November 03 2012 10:45 GMT
#3712
On November 03 2012 19:21 Ruscour wrote:
Hello guys, I have more dumb questions.

1) I'll be doing a robotics project for a year, I don't know anything about hardware interaction but they'll teach me, however what I do need to know is C/C++. I know C decently well and haven't touched C++ but it seems like C++ would be preferable and it's seemingly used in a lot more places than C. Should I bend to Torvalds' divine will and stick to C or is C++ as beneficial as it seems?

2) C compilers for Windows? I'm used to make doing all the work for me, and using an IDE for compilation of small doodads is a waste of time. How do gcc on Windows best? MinGW? Cygwin?


1) What does "decently well" mean? Are you confortable with pointers? Linked lists? Threads? Sockets? Sorting? Parsing?
I don't know about C++ being used more than C, or even if it is used at all in robotics, but good knowledge of C will take you anywhere you want anyway so being very confortable with C will probably help you more than being decent in both C and C++.

2) Just use visual studio's ^^
flexgd
Profile Joined September 2011
183 Posts
November 03 2012 10:49 GMT
#3713
Hi Guys,
I work at a small software company ( only an accomodation job) and this company offers services through their website which is in php. Now my boss gave me the job to find a programm that is able to analyze php code and notice any flaws security-wise. I have found a programm called rats that would be capable but now I need to find phpcode with security flaws so i can test the programm. so my question is: does anyone have experience with automated php code analyzing and can recommend a tool for that purpose (it doesnt have to be free if its really good)? does anyone know where i can find dedicated false php code to test this rats-tool that i found?

thanks in advance
Akka
Profile Joined August 2010
France291 Posts
November 03 2012 10:58 GMT
#3714
On November 03 2012 19:49 flexgd wrote:
Hi Guys,
I work at a small software company ( only an accomodation job) and this company offers services through their website which is in php. Now my boss gave me the job to find a programm that is able to analyze php code and notice any flaws security-wise. I have found a programm called rats that would be capable but now I need to find phpcode with security flaws so i can test the programm. so my question is: does anyone have experience with automated php code analyzing and can recommend a tool for that purpose (it doesnt have to be free if its really good)? does anyone know where i can find dedicated false php code to test this rats-tool that i found?

thanks in advance


Have you had a look here : http://stackoverflow.com/questions/4156157/tool-for-php-code-analysis ?
Shenghi
Profile Joined August 2010
167 Posts
Last Edited: 2012-11-03 13:43:05
November 03 2012 12:21 GMT
#3715
On November 02 2012 14:00 EscPlan9 wrote:
Rewrote that recursive function from the last page non-recursively here. Might have some performance hits, but no duplicates, and so no tracking for duplicates needed.

A brief summary... given a MaximumNumber and MaximumSum, calculate all the possible 1 or 2 set moves where their sum is less than or equal to MaximumSum.

ex. MaximumNumber = 4, MaximumSum = 6.
Valid moves are {1} {2} {3} {4} {1,2} {1,3} {1,4} {2,3} {2,4}, since the summation of any of them are <= MaximumSum


void generateLegalMoves()
{
vector<int>temp;

for (unsigned int d = 0; d < board.size(); ++d)
{
// finds all the single moves
if (board[d] <= maxSum)
{
temp.push_back(1);
temp.push_back(board[d]);
temp.push_back(board[d]);
legalMoves.push_back(temp);
temp.clear();
}

// finds all the double moves
if ((d + 1) < board.size() )
{
for (unsigned int n = (d + 1); n < board.size(); ++n)
{
if (board[d] + board[n] <= maxSum)
{
temp.push_back(2);
temp.push_back(board[d]);
temp.push_back(board[n]);
legalMoves.push_back(temp);
temp.clear();
}
}
}
}
}


I still feel like it can be done better recursively, but so far my efforts always end up with duplicate numbers and then trying to track for duplicate numbers which makes me think the non-recursive approach might end up performing just as well in the end.

If you're only looking for subsets of size one or two, then the iterative solution is probably the best. If you insist on using a recursive solution, then here's something I threw together in a few minutes that does not produce double results:

#include <cstdio>
#include <vector>

typedef std::vector<int> vi;
typedef std::vector<vi> vvi;

// d: depth
// k: current number
// n: end of set (1,..,n)
// m: max sum
// cs: current sum
// cur: current answer
// res: resultset
void dfs(int d, int k, int n, int m, int cs, vi &cur, vvi &res)
{
if (d==2) {
res.push_back(cur);
return;
}

if (k > m) return;

if (d==1) res.push_back(cur);

for(int i=k;i<=n;++i) {
cs+=i;
if (cs > m) return;
cur.push_back(i);
dfs(d+1, k+1, n, m, cs, cur, res);
cs-=i;
cur.pop_back();
}
}

int main()
{
vvi res;
vi cur;

for(int i=4;i<20;++i) {
res.clear();
cur.clear();
printf("Solution for N=%d and M=%d\n", i, i+5);
dfs(0, 1, i, i+5, 0, cur, res);
for(int j=0;j<res.size();++j) {
for(int k=0;k<res[j].size();++k) {
printf("%d ", res[j][k]);
}
printf("\n");
}
printf("\n");
}

return 0;
}


EDIT: I just read up a few posts. This is probably useless to you. =[
People are not born stupid, they choose to be stupid. If you made that choice, please change your mind.
itsJaeger
Profile Joined March 2011
Australia17 Posts
November 03 2012 12:35 GMT
#3716
i miss old school programing. gold old c++ none of this evil java stuff.
:D
EscPlan9
Profile Blog Joined December 2006
United States2777 Posts
Last Edited: 2012-11-03 23:07:19
November 03 2012 23:06 GMT
#3717
I miss C# Taking a class that demands I use C++ this year has been painful lol. I've taken C++ previously and I'm better at it now, but still find it painful to use. So much more typing required for all the programming I want to do. Meh. I know its a religious debate topic... so... yeah... I had to learn C# at my last job and loved coding with it.
Undefeated TL Tecmo Super Bowl League Champion
white_horse
Profile Joined July 2010
1019 Posts
Last Edited: 2012-11-04 23:53:34
November 04 2012 23:51 GMT
#3718
Hey guys, I'm trying to print a 52 x 72 rectangular grid using character X's and two dimensional arrays, and I'm not sure what I'm doing wrong here. Can you see what is wrong? Thanks


const int row = 52;
const int column = 72;


void printRace(const char grid[row][column]) //prints 52 by 72 grid
{
for (int i = 0; i < row; i++)
{
for (int j = 0; j < column; j++)
{
cout << grid[i][j];
}
cout << endl;
}
}


void initRace(const char track[row][column])
{
for (int i = 0; i == 0 && i == 51; i++) //top and bottom boundary
{
for (int j = 0; j < 72; j++)
{
track[i][j] = 'X'; // <------------- COMPUTER SAYS ERROR ON THIS LINE
}
}

for (int i = 1; i == 50; i++) //left and right boundary
{
for (int j = 0; j == 0 && j == 71; j++)
{
track[i][j] = 'X'; // <------------- COMPUTER SAYS ERROR ON THIS LINE
}
}
}


int main()
{

printRace(row, column);
initRace(row, column);


return 0;


}


Translator
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
Last Edited: 2012-11-04 23:57:46
November 04 2012 23:56 GMT
#3719
On November 05 2012 08:51 white_horse wrote:

void initRace(const char track[row][column]) <--- look here
{
...
track[i][j] = 'X'; // <------------- COMPUTER SAYS ERROR ON THIS LINE
...
track[i][j] = 'X'; // <------------- COMPUTER SAYS ERROR ON THIS LINE
...
}


also an error:

printRace(row, column);
initRace(row, column);




Read the lines i left over very carefully and you should notice the problem.
HaRuHi
Profile Blog Joined November 2010
1220 Posts
Last Edited: 2012-11-05 00:53:04
November 05 2012 00:24 GMT
#3720
On November 05 2012 08:51 white_horse wrote:
initRace does so not do what you want it to do. There is no need to nest the for loops!



void initRace(const char track[row][column])
{
for (int i = 0; i == 0 && i == 51; i++) //top and bottom boundary
{
for (int j = 0; j < 72; j++)
{
track[i][j] = 'X'; // <------------- COMPUTER SAYS ERROR ON THIS LINE
}
}

....

}



I would try something like


void initRace(char track[row][column])
{
for (int j = 0; j < 72; j++)
{
track[0][j] = 'X';
track[51][j] = 'X';
}

....

}



actually 2 errors, wrong parameters and you print before you init



int main()
{

printRace(row, column);
initRace(row, column);

return 0;

}




for (int i = 0; i == 0 && i == 51; i++)

The for loop runs as long as i equals 0 and i equals 51, at the same time, not either one.

if you would use:
for (int i = 0; i == 0 || i == 51; i++)

The loop would check if i is 0 or 51, it would run 1 time, while i == 0, after that i would be 1 and the loop would end.

You could however:
for (int i = 0; i == 0 || i == 51; i+51)

but pls don'T. ;D
Prev 1 184 185 186 187 188 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 8m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Lowko463
LamboSC2 424
gerald23 50
MindelVK 39
Livibee 33
mouzHeroMarine 29
BRAT_OK 22
StarCraft: Brood War
Calm 4996
Shuttle 951
Larva 785
Mini 475
PianO 333
firebathero 317
Rush 316
Light 193
Snow 175
hero 110
[ Show more ]
Mong 36
Terrorterran 35
Movie 33
Sacsri 26
JYJ25
soO 23
HiyA 11
yabsab 10
Dota 2
Gorgc5821
qojqva3348
Dendi954
420jenkins364
Counter-Strike
fl0m9185
zeus1180
Other Games
FrodaN1620
B2W.Neo1266
hiko784
Hui .329
Liquid`VortiX203
RotterdaM181
KnowMe129
QueenE127
Mew2King119
ArmadaUGS100
Trikslyr52
oskar43
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 19 non-featured ]
StarCraft 2
• poizon28 21
• Reevou 11
• Kozan
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• intothetv
• Migwel
• IndyKCrew
StarCraft: Brood War
• FirePhoenix6
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 2568
• WagamamaTV673
• Noizen41
League of Legends
• Nemesis3444
• TFBlade981
Other Games
• Shiphtur0
Upcoming Events
StarCraft2.fi
8m
PiGosaur Monday
8h 8m
Wardi Open
19h 8m
StarCraft2.fi
1d
Replay Cast
1d 7h
The PondCast
1d 17h
Replay Cast
2 days
Korean StarCraft League
3 days
CranKy Ducklings
3 days
SC Evo League
3 days
[ Show More ]
BSL 21
4 days
Sziky vs OyAji
Gypsy vs eOnzErG
OSC
4 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
4 days
BSL 21
5 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
5 days
Wardi Open
5 days
StarCraft2.fi
5 days
Replay Cast
6 days
StarCraft2.fi
6 days
Liquipedia Results

Completed

Proleague 2025-11-28
RSL Revival: Season 3
Light HT

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
Acropolis #4 - TS3
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
Kuram Kup
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.