Statistics

Problem Statement for "Conglutination"

Problem Statement

You are developing a new software calculator. Some people use the calculator to check the sums of several numbers, but they sometimes get unexpected results because they forget to press the 'plus' button. You have almost solved this problem, but a small method is still required.

You will be given a String conglutination and an int expectation. Your method should split conglutination into two numbers A and B so that A + B = expectation. Return the result as a String in the form "A+B" (quotes for clarity only). A and B must contain at least one digit each. Leading zeros are allowed and they must be preserved in the result. If there are several possible splits, choose the one with the smallest value of A. Return an empty String if there are no possible splits.

Definition

Class:
Conglutination
Method:
split
Parameters:
String, int
Returns:
String
Method signature:
String split(String conglutination, int expectation)
(be sure your method is public)

Constraints

  • conglutination will contain between 2 and 20 characters, inclusive.
  • conglutination will contain only digits ('0'-'9').
  • The first character of conglutination will not be zero.
  • expectation will be between 1 and 1000000000, inclusive.

Examples

  1. "22"

    4

    Returns: "2+2"

  2. "536"

    41

    Returns: "5+36"

  3. "123456000789"

    1235349

    Returns: "1234560+00789"

    Be careful with leading zeros.

  4. "123456789"

    4245

    Returns: ""

  5. "112"

    13

    Returns: "1+12"

    The value of A should be as small as possible.

  6. "11"

    1

    Returns: ""

  7. "11"

    11

    Returns: ""

  8. "111"

    12

    Returns: "1+11"

  9. "10000000000"

    1000000000

    Returns: "1000000000+0"

  10. "112"

    112

    Returns: ""

  11. "1111111113"

    111111113

    Returns: ""

  12. "99999999900000000000"

    999999999

    Returns: "999999999+00000000000"

  13. "999999999"

    999999999

    Returns: ""

  14. "10000000000000000000"

    1

    Returns: "1+0000000000000000000"

  15. "10000000000000000000"

    1000000000

    Returns: "1000000000+0000000000"

  16. "99999999900000000001"

    1000000000

    Returns: "999999999+00000000001"

  17. "99999999000000000001"

    999999991

    Returns: "999999990+00000000001"

  18. "99990000000000000001"

    9999001

    Returns: "9999000+0000000000001"

  19. "1111111113"

    111111114

    Returns: "1+111111113"

  20. "99999999900000000000"

    99999999

    Returns: ""

  21. "999999999"

    9999999

    Returns: ""

  22. "10000000000000000001"

    111

    Returns: ""

  23. "50000000000500000000"

    1000000000

    Returns: "500000000+00500000000"

  24. "50000000000000000500"

    1000000000

    Returns: ""

  25. "111111111111111111"

    222222222

    Returns: "111111111+111111111"

  26. "11111111111111111"

    122222222

    Returns: "11111111+111111111"

  27. "44614087100466127532"

    365749560

    Returns: ""

  28. "77956790500099935109"

    819229001

    Returns: ""

  29. "77956790500099935109"

    812239001

    Returns: ""

  30. "96648973000037879133"

    320324268

    Returns: ""

  31. "43006128100327664862"

    639682960

    Returns: ""

  32. "143660"

    803

    Returns: "143+660"

  33. "155486"

    641

    Returns: "155+486"

  34. "625244"

    869

    Returns: "625+244"

  35. "625244"

    869

    Returns: "625+244"

  36. "359479"

    838

    Returns: "359+479"

  37. "140011323230"

    463241

    Returns: "140011+323230"

  38. "52015718268"

    538425

    Returns: "520157+18268"

  39. "328912612662"

    941574

    Returns: "328912+612662"

  40. "55303648060"

    601096

    Returns: "553036+48060"

  41. "813070122112"

    935182

    Returns: "813070+122112"

  42. "809136541110669776"

    919806317

    Returns: "809136541+110669776"

  43. "177099653377515920"

    554615573

    Returns: "177099653+377515920"

  44. "48570398889656317"

    575360305

    Returns: "485703988+89656317"

  45. "794400476173674100"

    968074576

    Returns: "794400476+173674100"

  46. "1621418292876068"

    165017897

    Returns: "162141829+2876068"

  47. "61677414500104718744"

    721492889

    Returns: "616774145+00104718744"

  48. "60190369900390969790"

    992873489

    Returns: "601903699+00390969790"

  49. "91202121100055186283"

    967207494

    Returns: "912021211+00055186283"

  50. "27689270300394925682"

    671818385

    Returns: "276892703+00394925682"

  51. "58702279300070728386"

    657751179

    Returns: "587022793+00070728386"

  52. "21705640000003073463"

    5244027

    Returns: "2170564+0000003073463"

  53. "56475700000009276613"

    9841370

    Returns: "564757+00000009276613"

  54. "98015950000000094916"

    9896511

    Returns: "9801595+0000000094916"

  55. "50258590000001619067"

    6644926

    Returns: "5025859+0000001619067"

  56. "16009400000005635813"

    7236753

    Returns: "1600940+0000005635813"

  57. "66539540000003177588"

    9831542

    Returns: "6653954+0000003177588"

  58. "19637860000001070810"

    3034596

    Returns: "1963786+0000001070810"

  59. "21899000000001192720"

    1214619

    Returns: "21899+000000001192720"

  60. "55123070000000726749"

    6239056

    Returns: "5512307+0000000726749"

  61. "64236550000001396182"

    7819837

    Returns: "6423655+0000001396182"

  62. "42949672982"

    4

    Returns: ""

  63. "24294967298"

    4

    Returns: ""

  64. "18446744073709551618"

    2

    Returns: ""

  65. "19999999999999999999"

    1

    Returns: ""

  66. "99990000000000009999"

    19998

    Returns: "9999+0000000000009999"

  67. "123456000789"

    1235349

    Returns: "1234560+00789"

  68. "22"

    22

    Returns: ""

  69. "112"

    112

    Returns: ""

  70. "32"

    5

    Returns: "3+2"

  71. "99999999999999999999"

    1000000

    Returns: ""

  72. "99999999999999999999"

    999999999

    Returns: ""

  73. "12"

    4

    Returns: ""

  74. "10000000000000000001"

    2

    Returns: "1+0000000000000000001"

  75. "99999999999999999999"

    277447230

    Returns: ""

  76. "12345678900123456789"

    246913578

    Returns: "123456789+00123456789"

  77. "123456789"

    4245

    Returns: ""

  78. "99999999999999999999"

    109998

    Returns: ""

  79. "12"

    12

    Returns: ""

  80. "18121568157777777777"

    1000000000

    Returns: ""

  81. "99999999999999999999"

    1235349

    Returns: ""

  82. "99999999999999999999"

    10

    Returns: ""

  83. "112"

    13

    Returns: "1+12"

  84. "123"

    123

    Returns: ""

  85. "99999999999999999999"

    99

    Returns: ""

  86. "12345"

    12345

    Returns: ""

  87. "22000000002200000000"

    105032704

    Returns: ""


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: