Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save YaroslavShapoval/442dde09db0589ce40f0baad78f1b9f9 to your computer and use it in GitHub Desktop.

Select an option

Save YaroslavShapoval/442dde09db0589ce40f0baad78f1b9f9 to your computer and use it in GitHub Desktop.
const START = 1;
const LENGTH = 990;
const ONE_COUNTS = 261;
let cur_length = 0;
let cur_number = 0;
let one_occurences = 0;
// while (cur_length < LENGTH) {
while (one_occurences < ONE_COUNTS) {
cur_number++;
cur_length += String(cur_number).length;
one_occurences += (String(cur_number).match(/1/g) || []).length;
}
console.log(cur_length);
console.log(cur_number);
console.log(one_occurences);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment