JavaScript (node.js)
Counts what was most popular last round and bids one less than that, wrapping to 20 and bidding 3 on the first round.
var lastRound = /[^\n]+$/.exec(process.argv[2];argv[2]);
var numbers = {};
var matchesre = /\d+/g.exec(/[^\n]+$/.exec(lastRound));g;
var i;match;
forwhile(imatch = 0; i < matchesre.length; i++) {
ifexec(matches[i] in numberslastRound) {
numbers[i]++;
} else) {
numbers[i]numbers[match] = 1;
numbers[match] >>> 0 + }1;
}
var maxKey = -1, maxValue = -1;
for(var i in numbers) {
if(maxKey === -1 || numbers[i] > maxValuenumbers[maxKey]) {
maxKey = i;
maxValue = numbers[i];
}
}
if(maxKey == 0) {
// First round. Bid 3.
console.log(3);
} else if(maxKey == 1) {
// Bid 20.
console.log(20);
} else {
// Bid one less.
console.log(maxKey - 1);
}
How to invoke:
node script.js 'the argument'