Statistics

Problem Statement for "CopyingHomework"

Problem Statement

  • "Dude, can I copy your homework?"
  • "Sure, but change it a little, so it doesn't look like we cheated."

You are given the int[] friendsHomework containing the five values your friend measured for their Physics homework. Construct and return a int[] yourHomework with the following properties:

  • yourHomework must have exactly 5 elements.
  • For each i, yourHomework[i] must differ from friendsHomework[i] (so it doesn't look like you cheated).
  • For each i, the difference between yourHomework[i] and friendsHomework[i] must be at most 10 (so that the values are similar).
  • The sum of yourHomework must be the same as the sum of friendsHomework (so that you both get the same final result).

Definition

Class:
CopyingHomework
Method:
copy
Parameters:
int[]
Returns:
int[]
Method signature:
int[] copy(int[] friendsHomework)
(be sure your method is public)

Notes

  • Any valid solution will be accepted.

Constraints

  • friendsHomework will contain exactly 5 elements.
  • Each element of friendsHomework will be between 0 and 1000, inclusive.

Examples

  1. {10, 20, 30, 40, 50}

    Returns: {9, 19, 29, 39, 54 }

  2. {0, 0, 0, 0, 0}

    Returns: {-1, -1, -1, -1, 4 }

    Note that the values in yourHomework may lie outside the range [0,1000]. As long as they satisfy the constraints from the problem statement, you have a valid answer.

  3. {400,399,400,399,400}

    Returns: {399, 398, 399, 398, 404 }

  4. {1000,1000,1000,1000,1000}

    Returns: {999, 999, 999, 999, 1004 }

  5. {360,64,440,566,464}

    Returns: {359, 63, 439, 565, 468 }

  6. {584,351,263,524,395}

    Returns: {583, 350, 262, 523, 399 }

  7. {401,630,41,814,428}

    Returns: {400, 629, 40, 813, 432 }

  8. {674,24,980,104,0}

    Returns: {673, 23, 979, 103, 4 }

  9. {270,965,988,811,493}

    Returns: {269, 964, 987, 810, 497 }

  10. {741,559,9,939,835}

    Returns: {740, 558, 8, 938, 839 }

  11. {920,323,581,437,235}

    Returns: {919, 322, 580, 436, 239 }

  12. {243,535,526,367,452}

    Returns: {242, 534, 525, 366, 456 }

  13. {980,247,34,574,383}

    Returns: {979, 246, 33, 573, 387 }

  14. {733,704,361,615,350}

    Returns: {732, 703, 360, 614, 354 }

  15. {571,588,780,200,244}

    Returns: {570, 587, 779, 199, 248 }

  16. {807,860,746,936,957}

    Returns: {806, 859, 745, 935, 961 }

  17. {36,128,341,100,371}

    Returns: {35, 127, 340, 99, 375 }

  18. {592,392,520,553,832}

    Returns: {591, 391, 519, 552, 836 }

  19. {258,99,664,892,902}

    Returns: {257, 98, 663, 891, 906 }

  20. {232,949,715,865,342}

    Returns: {231, 948, 714, 864, 346 }

  21. {223,482,762,112,791}

    Returns: {222, 481, 761, 111, 795 }

  22. {426,619,361,691,893}

    Returns: {425, 618, 360, 690, 897 }

  23. {293,900,791,829,244}

    Returns: {292, 899, 790, 828, 248 }

  24. {828,568,944,267,365}

    Returns: {827, 567, 943, 266, 369 }

  25. {545,578,41,495,319}

    Returns: {544, 577, 40, 494, 323 }

  26. {576,798,404,266,967}

    Returns: {575, 797, 403, 265, 971 }

  27. {747,531,818,226,620}

    Returns: {746, 530, 817, 225, 624 }

  28. {116,642,861,212,388}

    Returns: {115, 641, 860, 211, 392 }

  29. {497,259,985,618,947}

    Returns: {496, 258, 984, 617, 951 }

  30. {571,152,454,15,174}

    Returns: {570, 151, 453, 14, 178 }

  31. {560,642,823,779,84}

    Returns: {559, 641, 822, 778, 88 }

  32. {76,272,523,832,637}

    Returns: {75, 271, 522, 831, 641 }

  33. {559,487,801,821,446}

    Returns: {558, 486, 800, 820, 450 }

  34. {374,940,777,33,622}

    Returns: {373, 939, 776, 32, 626 }

  35. {271,920,659,623,529}

    Returns: {270, 919, 658, 622, 533 }

  36. {966,690,931,483,936}

    Returns: {965, 689, 930, 482, 940 }

  37. {725,653,817,974,322}

    Returns: {724, 652, 816, 973, 326 }

  38. {849,22,590,248,216}

    Returns: {848, 21, 589, 247, 220 }

  39. {354,441,981,887,708}

    Returns: {353, 440, 980, 886, 712 }

  40. {188,180,481,943,203}

    Returns: {187, 179, 480, 942, 207 }

  41. {130,100,139,747,803}

    Returns: {129, 99, 138, 746, 807 }

  42. {583,352,540,401,110}

    Returns: {582, 351, 539, 400, 114 }

  43. {273,454,0,668,125}

    Returns: {272, 453, -1, 667, 129 }

  44. {424,68,378,21,270}

    Returns: {423, 67, 377, 20, 274 }

  45. {42,143,185,756,523}

    Returns: {41, 142, 184, 755, 527 }

  46. {855,502,205,801,791}

    Returns: {854, 501, 204, 800, 795 }

  47. {831,506,540,464,577}

    Returns: {830, 505, 539, 463, 581 }

  48. {580,10,711,75,179}

    Returns: {579, 9, 710, 74, 183 }

  49. {855,154,943,556,346}

    Returns: {854, 153, 942, 555, 350 }

  50. {650,887,47,898,636}

    Returns: {649, 886, 46, 897, 640 }

  51. {240,729,62,387,126}

    Returns: {239, 728, 61, 386, 130 }

  52. {22,90,309,55,900}

    Returns: {21, 89, 308, 54, 904 }

  53. {561,315,244,627,917}

    Returns: {560, 314, 243, 626, 921 }

  54. {751,547,154,563,593}

    Returns: {750, 546, 153, 562, 597 }

  55. {400, 399, 400, 399, 400 }

    Returns: {399, 398, 399, 398, 404 }


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: