Lines Matching refs:op
175 int left, op, right, result;
178 op = keys[arc4random_uniform(nkeys)];
179 if (op != '/')
180 right = getrandom(rangemax + 1, op, 1);
183 switch (op) {
185 left = getrandom(rangemax + 1, op, 0);
189 result = getrandom(rangemax + 1, op, 0);
193 left = getrandom(rangemax + 1, op, 0);
197 right = getrandom(rangemax, op, 1) + 1;
198 result = getrandom(rangemax + 1, op, 0);
210 (void)printf("%d %c %d = ", left, op, right);
236 penalise(right, op, 1);
237 if (op == 'x' || op == '+')
238 penalise(left, op, 0);
240 penalise(result, op, 0);
279 * Add a penalty for the number `value' to the list for operation `op',
284 penalise(int value, int op, int operand)
288 op = opnum(op);
291 p->next = penlist[op][operand];
292 penlist[op][operand] = p;
293 penalty[op][operand] += p->penalty = WRONGPENALTY;
299 * of operation `op'. The random number we generate is either used directly
304 getrandom(uint32_t maxval, int op, int operand)
309 op = opnum(op);
310 value = arc4random_uniform(maxval + penalty[op][operand]);
324 for (pp = &penlist[op][operand]; (p = *pp) != NULL; pp = &p->next) {
327 penalty[op][operand]--;
345 /* Return an index for the character op, which is one of [+-x/]. */
347 opnum(int op)
351 if (op == 0 || (p = strchr(keylist, op)) == NULL)
352 errx(1, "bug: op %c not in keylist %s.", op, keylist);