inline bool form3(int a, int b, int c, int d, int op1, int op2, int op3) { // (a op1 b) op2 (c op3 d) if (a > b && swapable(op1)) return false; if (c > d && swapable(op3)) return false; bool div_zero = false; double r = eval(op2, eval(op1, a, b, &div_zero), eval(op3, c, d, &div_zero), &div_zero); if (!div_zero && eq(r, 24)) { fprintf(stdout, "(%d %c %d) %c (%d %c %d)\n", a, char(op1), b, char(op2), c, char(op3), d); return true; } return false; }
inline bool form4(int a, int b, int c, int d, int op1, int op2, int op3) { // a op1 ((b op2 c) op3 d) if (b > c && swapable(op2)) return false; // already covered by form1 in this case if (swapable(op1)) return false; bool div_zero = false; double r = eval(op1, a, eval(op3, eval(op2, b, c, &div_zero), d, &div_zero), &div_zero); if (!div_zero && eq(r, 24)) { fprintf(stdout, "%d %c ((%d %c %d) %c %d)\n", a, char(op1), b, char(op2), c, char(op3), d); return true; } return false; }
void Field::swap(int x1, int y1, int x2, int y2) { if (DEBUGIT_FIELDSWAP) logfile << "Field::swap " << x1 << " " << y1 << " " << x2 << " " << y2 << std::endl; int w = getwidth(); int idx1 = y1*w+x1; int idx2 = y2*w+x2; Block *Block1 = this->blocks[idx1]; Block *Block2 = this->blocks[idx2]; if ((!Block1 && !Block2) || !(swapable(x1,y1) && swapable(x2,y2))) return; if (!Block1 && Block2) { if (DEBUGIT_FIELDSWAP) logfile << "Field::swap We're moving a block from left to right, right space is currently empty." << std::endl; this->swapStack->swap(Block2, x2,y2,x1,y1, 1, this); } else if (Block1 && !Block2) { if (DEBUGIT_FIELDSWAP) logfile << "Field::swap We're moving a block from right to left, left space is currently empty." << std::endl; this->swapStack->swap(Block1, x1,y1,x2,y2, 1, this); } else if (Block1 && Block2) { if (DEBUGIT_FIELDSWAP) logfile << "Field::swap We're switching two blocks." << std::endl; this->swapStack->swap(Block1, x1,y1,x2,y2, 0, this); this->swapStack->swap(Block2, x2,y2,x1,y1, 1, this); } else { logfile << "Field::swap -=-WARNING-=- We got in the else-part!" << std::endl; } }
SIPHeaderTokens& SIPHeaderTokens::operator=(const SIPHeaderTokens& tokens) { SIPHeaderTokens swapable(tokens); swap(swapable); return *this; }
ZMQMessage& ZMQMessage::operator=(const ZMQMessage& message) { ZMQMessage swapable(message); swap(swapable); return *this; }