I think the problem is Number() cannot handle integer as large as 10^100

checks[0] = Number(num) - checks[1];


fyi. this copy will pass all the tests

/*
 * Marco Lackovic, Apr 2019
 * Google Code Jam, Qualification Round
 * Foregone Solution
 */

declare var require: any;
declare var process: any;
const readline = require("readline");
const rl = readline.createInterface({ input: process.stdin });

let i = 0;
rl.on("line", (num: string) => {
  if (i > 0) {
    const [a, b] = solve(num);
    console.log(`Case #${i}: ${a} ${b}`);
  }
  i++;
});

const solve = (num: string): string[] => {
  const checks = new Array<string>(2);
  const numAsArrayOfDigits = num.split("").map(Number);
  checks[1] = numAsArrayOfDigits
      .map((d: Number) => (d == 4 ? 2 : 0))
      .map(String)
      .join("");
  checks[0] = numAsArrayOfDigits
      .map((d: Number) => (d == 4 ? 2 : d))
      .map(String)
      .join("");
  return checks;
};

在 2019年4月10日星期三 UTC-7下午3:31:04,Marco Lackovic写道:
> Can anyone spot where the problem is?
> 
> https://github.com/lackovic/codejam/blob/master/2019-typescript/src/QualificationRound/ForegoneSolution.ts

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/76e94cce-e7a2-42af-81b2-a261a38465c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to