Skip to main content
Fixed some bugs.
Source Link
Ry-
  • 5.4k
  • 1
  • 24
  • 32

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'

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 = process.argv[2];
var numbers = {};
var matches = /\d+/g.exec(/[^\n]+$/.exec(lastRound));
var i;

for(i = 0; i < matches.length; i++) {
    if(matches[i] in numbers) {
        numbers[i]++;
    } else {
        numbers[i] = 1;
    }
}

var maxKey = -1, maxValue = -1;

for(i in numbers) {
    if(numbers[i] > maxValue) {
        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'

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]);
var numbers = {};
var re = /\d+/g;
var match;

while(match = re.exec(lastRound)) {
    numbers[match] = numbers[match] >>> 0 + 1;
}

var maxKey = -1;

for(var i in numbers) {
    if(maxKey === -1 || numbers[i] > numbers[maxKey]) {
        maxKey = 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'
added 9 characters in body
Source Link
Ry-
  • 5.4k
  • 1
  • 24
  • 32

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 = process.argv[2];
var numbers = {};
var matches = /\d+/g.exec(/[^\n]+$/.exec(lastRound));
var i;

for(i = 0; i < matches.length; i++) {
    if(imatches[i] in numbers) {
        numbers[i]++;
    } else {
        numbers[i] = 1;
    }
}

var maxKey = -1, maxValue = -1;

for(i in numbers) {
    if(numbers[i] > maxValue) {
        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'

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 = process.argv[2];
var numbers = {};
var matches = /\d+/g.exec(lastRound);
var i;

for(i = 0; i < matches.length; i++) {
    if(i in numbers) {
        numbers[i]++;
    } else {
        numbers[i] = 1;
    }
}

var maxKey = -1, maxValue = -1;

for(i in numbers) {
    if(numbers[i] > maxValue) {
        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'

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 = process.argv[2];
var numbers = {};
var matches = /\d+/g.exec(/[^\n]+$/.exec(lastRound));
var i;

for(i = 0; i < matches.length; i++) {
    if(matches[i] in numbers) {
        numbers[i]++;
    } else {
        numbers[i] = 1;
    }
}

var maxKey = -1, maxValue = -1;

for(i in numbers) {
    if(numbers[i] > maxValue) {
        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'
edited body
Source Link
Ry-
  • 5.4k
  • 1
  • 24
  • 32

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 = process.argv[2];
var numbers = {};
var matches = /\d+/g.exec(lastRound);
var i;

for(i = 0; i < matches.length; i++) {
    if(i in numbers) {
        numbers[i] = 1;numbers[i]++;
    } else {
        numbers[i]++;numbers[i] = 1;
    }
}

var maxKey = -1, maxValue = -1;

for(i in numbers) {
    if(numbers[i] > maxValue) {
        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'

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 = process.argv[2];
var numbers = {};
var matches = /\d+/g.exec(lastRound);
var i;

for(i = 0; i < matches.length; i++) {
    if(i in numbers) {
        numbers[i] = 1;
    } else {
        numbers[i]++;
    }
}

var maxKey = -1, maxValue = -1;

for(i in numbers) {
    if(numbers[i] > maxValue) {
        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'

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 = process.argv[2];
var numbers = {};
var matches = /\d+/g.exec(lastRound);
var i;

for(i = 0; i < matches.length; i++) {
    if(i in numbers) {
        numbers[i]++;
    } else {
        numbers[i] = 1;
    }
}

var maxKey = -1, maxValue = -1;

for(i in numbers) {
    if(numbers[i] > maxValue) {
        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'
Source Link
Ry-
  • 5.4k
  • 1
  • 24
  • 32
Loading