If you want others to read your code you need to space it out better and stop massively overusing parentheses, which just produces clutter.
Anyway, the problem is a harder than you think. If you move a card over 3 positions then you need to check not only if it can move again from that position leftwards, but also if the card to its right might be able to move now, etc., etc.
You're not using the atLeast1Swap and atLeast1Additional variables. You set atLeast1Swap but don't actually use it anywhere.
Don't use global variables unless there's a good reason to.
temp is a meaningless turd of a name that should be avoided whenever possible. In your case, you could call it card instead.
Hi, in the parts of the code (detection if card has a move)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
while(1) {
curSize=stacks.size();
if (compTo-3>=0&&compTo<curSize) {
if ((((stacks[compTo]).front())[0]==((stacks[compTo-3]).front())[0]) ||
(((stacks[compTo]).front())[1]==((stacks[compTo-3]).front())[1])) {
temp=(stacks[compTo]).front();
(stacks[compTo]).pop_front();
(stacks[compTo-3]).push_front(temp);
atLeast1Swap=true;
if ((stacks[compTo]).empty()) {
stacks.erase(stacks.begin()+compTo);
}
compTo=1;
continue; // here I restart the search for moves from 1 if a card swaps
}
}
//...
compTo++;
}
is there something I'm doing wrong when restarting the check for moves?