Statistics

Problem Statement for "AlienMultiplication"

Problem Statement

Scientists recently received the following transmission from outer space: "000023 * 000011 = 002093". While many rejoiced at this sure sign of intelligent alien life, others pointed out that any such alien life could not be too intelligent since 23 * 11 actually equals 253, not 2093. Not to be put off, the scientists noticed that the equation could easily be corrected by changing the second to last digit in 000011 to a 9. Based on this, they have hypothesized that the message was initially correct, but that it was corrupted during its lengthy transmission to Earth.

Numerous other messages have been received since then, always of the form "a * b = c", where a, b, c are six digit numbers (possibly including leading zeros). Scientists believe the aliens are ignoring overflow, so that c is only intended to represent the last six digits of a * b. Given this, most of the messages have been correct, but a few do have mistakes, and the scientists wonder how well these mistakes can be explained by data corruption. To answer this, they want you to create a class AlienMultiplication that contains the method getCorrections, which takes an int a, an int b, and an int c, representing the quantities described above. The method should return the minimum number of digits that need to be replaced in a, b and c before the last six digits of a * b are given by c. Here, individual digits may be replaced with different digits, but they may not be added or deleted.

Definition

Class:
AlienMultiplication
Method:
getCorrections
Parameters:
int, int, int
Returns:
int
Method signature:
int getCorrections(int a, int b, int c)
(be sure your method is public)

Notes

  • a, b and c should always be interpreted as having precisely six digits, possibly including leading zeros. Thus, there are always a total of eighteen digits that may be changed, six in each of a, b, and c.

Constraints

  • a, b, and c will each be between 0 and 999,999 inclusive.

Examples

  1. 23

    11

    2093

    Returns: 1

    This is the example from the problem statement.

  2. 1538

    951234

    997892

    Returns: 0

    Since c is only required to equal the last six digits of a * b, this equation is already correct.

  3. 153

    7

    71

    Returns: 1

    Since c is always interpreted as a six digit number, this equation can be corrected by changing c from 000071 to 001071.

  4. 421368

    512357

    862812

    Returns: 4

    This can be corrected by changing b to 512312 and c to 882816.

  5. 0

    0

    987654

    Returns: 5

  6. 0

    0

    999979

    Returns: 6

  7. 563585

    193304

    234840

    Returns: 0

  8. 456099

    271879

    301579

    Returns: 4

  9. 650507

    531387

    264116

    Returns: 3

  10. 941068

    286087

    733440

    Returns: 1

  11. 716418

    902697

    38575

    Returns: 5

  12. 188275

    247688

    146200

    Returns: 1

  13. 420674

    801738

    909909

    Returns: 5

  14. 197621

    852842

    872837

    Returns: 4

  15. 72580

    651966

    328178

    Returns: 2

  16. 899014

    206488

    37268

    Returns: 4

  17. 267403

    291970

    653910

    Returns: 0

  18. 292854

    870082

    813164

    Returns: 4

  19. 176013

    14465

    715323

    Returns: 5

  20. 113425

    297921

    396425

    Returns: 2

  21. 158811

    896868

    936054

    Returns: 4

  22. 153233

    557969

    263777

    Returns: 0

  23. 290627

    605822

    933995

    Returns: 4

  24. 411603

    27436

    739908

    Returns: 0

  25. 603961

    200632

    353991

    Returns: 4

  26. 564683

    469069

    290327

    Returns: 1

  27. 384868

    580431

    314308

    Returns: 2

  28. 776606

    83651

    499807

    Returns: 3

  29. 280709

    824976

    187984

    Returns: 0

  30. 107546

    569206

    152296

    Returns: 2

  31. 414410

    764732

    588420

    Returns: 1

  32. 319332

    154221

    142952

    Returns: 4

  33. 481917

    472090

    196590

    Returns: 1

  34. 299539

    822443

    757777

    Returns: 1

  35. 260963

    289529

    356427

    Returns: 0

  36. 914792

    151664

    66743

    Returns: 5

  37. 597729

    192907

    308203

    Returns: 1

  38. 64485

    411297

    214282

    Returns: 4

  39. 659718

    132532

    906258

    Returns: 2

  40. 515610

    187539

    456678

    Returns: 5

  41. 348042

    343753

    577784

    Returns: 4

  42. 532883

    262988

    332234

    Returns: 3

  43. 996459

    995938

    219542

    Returns: 1

  44. 832636

    892666

    847576

    Returns: 0

  45. 112314

    890957

    950641

    Returns: 3

  46. 982693

    2088

    193151

    Returns: 5

  47. 880581

    262855

    118755

    Returns: 0

  48. 239441

    825312

    387471

    Returns: 4

  49. 84376

    557776

    46113

    Returns: 5

  50. 361278

    333833

    39063

    Returns: 5

  51. 766863

    429151

    598214

    Returns: 2

  52. 468082

    929251

    159024

    Returns: 4

  53. 899227

    379516

    642432

    Returns: 3

  54. 815618

    479529

    780008

    Returns: 4

  55. 623666

    468883

    812395

    Returns: 4

  56. 818018

    249452

    26136

    Returns: 1

  57. 200000

    200000

    972578

    Returns: 6

  58. 999999

    999999

    1

    Returns: 0

  59. 23416

    91873

    413457

    Returns: 3

  60. 0

    0

    987654

    Returns: 5


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: