Byte Heist Home Leaderboard
Join the Heist (with Github)
Solve View

Square pandigital numbers

Print every 10-digit square number that contains every digit from 0-9 exactly once, separated by newlines, in any order.

Judge

(async function*(context: Context): Challenge {
  let out = (await context.run(undefined)).text.split('\n').filter(l => l != '');
  const nums = [1026753849,1042385796,1098524736,1237069584,1248703569,1278563049,1285437609,1382054976,1436789025,1503267984,1532487609,1547320896,1643897025,1827049536,1927385604,1937408256,2076351489,2081549376,2170348569,2386517904,2431870596,2435718609,2571098436,2913408576,3015986724,3074258916,3082914576,3089247561,3094251876,3195867024,3285697041,3412078569,3416987025,3428570916,3528716409,3719048256,3791480625,3827401956,3928657041,3964087521,3975428601,3985270641,4307821956,4308215769,4369871025,4392508176,4580176329,4728350169,4730825961,4832057169,5102673489,5273809641,5739426081,5783146209,5803697124,5982403716,6095237184,6154873209,6457890321,6471398025,6597013284,6714983025,7042398561,7165283904,7285134609,7351862049,7362154809,7408561329,7680594321,7854036129,7935068241,7946831025,7984316025,8014367529,8125940736,8127563409,8135679204,8326197504,8391476025,8503421796,8967143025,9054283716,9351276804,9560732841,9614783025,9761835204,9814072356]
  let nonNumber = out.find(l => !/^\d+$/.test(l))
  if (nonNumber) {
    let t = new TestCase('Not a number', 'Fail', {"Text": "non-number printed: " + nonNumber })
    yield context.registerTestCase(t);
    return context.noFailures();
  }

  let res = out.map(Number);

  if (nums.some(n => !res.includes(n))) {
    let t = new TestCase('Missing numbers', 'Fail', {"Text": "missing numbers: " + nums.filter(n => !res.includes(n)).join(',') })
    yield context.registerTestCase(t);
    return context.noFailures();
  }

  if (res.some(n => !nums.includes(n))) {
    let t =  new TestCase('Extra numbers', 'Fail', {"Text": "extra numbers: " + res.filter(n => !nums.includes(n)).join(',') })
    yield context.registerTestCase(t);
    return context.noFailures();
  }
  
  yield new TestCase('Check', 'Pass', {"Text": ""})
  return context.noFailures();
})

Example Code

for(l of[1026753849,1042385796,1098524736,1237069584,1248703569,1278563049,1285437609,1382054976,1436789025,1503267984,1532487609,1547320896,1643897025,1827049536,1927385604,1937408256,2076351489,2081549376,2170348569,2386517904,2431870596,2435718609,2571098436,2913408576,3015986724,3074258916,3082914576,3089247561,3094251876,3195867024,3285697041,3412078569,3416987025,3428570916,3528716409,3719048256,3791480625,3827401956,3928657041,3964087521,3975428601,3985270641,4307821956,4308215769,4369871025,4392508176,4580176329,4728350169,4730825961,4832057169,5102673489,5273809641,5739426081,5783146209,5803697124,5982403716,6095237184,6154873209,6457890321,6471398025,6597013284,6714983025,7042398561,7165283904,7285134609,7351862049,7362154809,7408561329,7680594321,7854036129,7935068241,7946831025,7984316025,8014367529,8125940736,8127563409,8135679204,8326197504,8391476025,8503421796,8967143025,9054283716,9351276804,9560732841,9614783025,9761835204,9814072356]) console.log(l)