Statistics

Problem Statement for "BunnyPuzzle"

Problem Statement

NOTE: This problem statement contains images that may not display properly if viewed outside of the applet.

Taro and Hanako are playing Bunny Puzzle. There are several bunnies standing on a line. You are given a int[] bunnies, where each element is the initial position of a single bunny.

They must perform the following routine exactly once:
  1. Choose two different bunnies A and B, located at points a and b, respectively.
  2. A jumps over B and lands at point 2*b-a.




The jump is not allowed if another bunny is already at point 2*b-a.



The jump is also not allowed if A jumps over more than one bunny.





Return the number of different ways in which Taro and Hanako can choose the pair of bunnies A and B. "A jumps over B" and "B jumps over A" are considered to be different.

Definition

Class:
BunnyPuzzle
Method:
theCount
Parameters:
int[]
Returns:
int
Method signature:
int theCount(int[] bunnies)
(be sure your method is public)

Constraints

  • bunnies will contain between 2 and 50 elements, inclusive.
  • Each element of bunnies will be between -10^6 and 10^6, inclusive.
  • bunnies will be sorted in strictly ascending order.

Examples

  1. {5, 8}

    Returns: 2

    There are two possible moves: A bunny jumps from 5 to 11 A bunny jumps from 8 to 2

  2. {-1, 0, 1}

    Returns: 2

    There are two possible moves: A bunny jumps from 0 to -2 A bunny jumps from 0 to 2

  3. {0, 1, 3}

    Returns: 3

    There are three possible moves: A bunny jumps from 0 to 2 A bunny jumps from 1 to -1 A bunny jumps from 1 to 5

  4. {-677, -45, -2, 3, 8, 29, 384, 867}

    Returns: 7

  5. {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

    Returns: 2

  6. {841607, 851764}

    Returns: 2

  7. {-70850, 188438, 656310}

    Returns: 3

  8. {-750339, -737904, -682537, -610306}

    Returns: 4

  9. {-317956, -176306, 187111, 281088, 660579}

    Returns: 5

  10. {-24305, -14673, 146059, 149877, 183615, 200167}

    Returns: 6

  11. {949866, 950667, 953100, 953143, 953640, 955282, 963935, 964012, 967429, 967921, 971596}

    Returns: 11

  12. {-200859, -185170, -81018, -52857, 8700, 97902, 135154, 187790, 188240, 196079, 197381, 208924, 276467, 321365, 370936, 408981, 460774, 569889, 578619, 594680, 660988, 854272, 879181}

    Returns: 23

  13. {337609, 343274, 345079, 349169, 350275, 353468, 357389, 357570, 358340, 361155, 361648, 362709, 363946, 365113, 365834, 366617, 367719, 369680, 369841, 370407, 370936, 371151, 373949, 374184, 374635, 375922, 376785}

    Returns: 27

  14. {839952, 842122, 842793, 843662, 843814, 849167, 851156, 854249, 856117, 856189, 856546, 857488, 858725, 858820, 860950, 862018, 862083, 864254, 865753, 866439, 866712, 870701, 872000, 876645, 876776, 878117, 878656, 880256, 881111, 882088, 883030, 885690, 887865, 887988, 888126, 889380, 890731, 891268, 891352, 892166, 894581, 899573, 900912}

    Returns: 43

  15. {-235867, -233450, -227304, -198135, -197547, -179286, -165885, -126935, -125018, -122980, -106429, -98373, -75139, -72768, -59807, -47846, -38453, 18065, 39354, 65920, 85279, 88317, 97103, 99332, 140374, 188915, 214534, 225909, 232990, 269305, 272628, 287309, 307143, 314606, 325946, 333573, 388953, 435585, 444178, 448727}

    Returns: 40

  16. {143091, 196864, 205578, 207594, 227677, 278039, 303640, 312155}

    Returns: 8

  17. {-293987, -232876, -216009, -207133, -204053, -203360, -183096, -180112, -176281, -147648, -130982, -100028, -84884, -76749, -66404, -51043, -21988, -8683, -5724, 9558, 27093, 136613, 138118, 145874, 161108, 168774, 259812, 270556, 310713, 386013, 395836, 423195, 494683, 519940, 527591, 562734, 644820, 698375, 729841, 743733, 797596, 799067, 804485, 806942, 817059, 821539, 850149, 876080}

    Returns: 48

  18. {748959, 750220, 751622, 760002, 761044, 769888, 770670, 779131, 784747, 786499, 792405, 796645, 800343, 800675, 827245, 829353, 831100, 831651, 834233, 839940, 841569, 841994, 848302, 865843, 866367, 866908, 876039, 895953, 903235, 925929, 935244, 945744, 952213, 954455, 959290, 960613, 968437, 979521, 982592, 983256, 984884}

    Returns: 41

  19. {11839, 24469, 27075, 33293, 52047, 109664, 135259, 135668, 144076, 196191, 251108, 271066, 271561, 296891, 306186, 320417, 328679, 342927, 353226, 389251, 396145, 397764, 463314, 488050, 489710, 511344, 528425, 560838, 578805, 597695, 616144, 706256, 731623, 733769, 745564, 750742, 854557, 858032, 861349, 881675, 934200}

    Returns: 41

  20. {326406, 366616, 404143, 425400, 473294, 478476, 483925, 501382, 515511, 519301, 526712}

    Returns: 11

  21. {-509508, -509507}

    Returns: 2

  22. {212750, 212751, 212752}

    Returns: 2

  23. {-943839, -943835, -943832, -943831}

    Returns: 4

  24. {112894, 112895, 112896, 112897, 112898}

    Returns: 2

  25. {488941, 488942, 488958, 488963, 488969, 488971}

    Returns: 6

  26. {815379, 815386, 815392, 815394, 815398, 815405, 815411, 815425, 815439, 815455}

    Returns: 9

  27. {104294, 104295, 104296, 104297, 104298, 104299, 104300, 104301, 104302, 104303, 104304, 104305, 104306, 104307, 104308, 104309, 104310, 104311, 104312, 104313, 104314, 104315, 104316, 104317, 104318, 104320, 104321, 104322, 104323, 104324, 104326, 104327, 104328, 104329, 104330}

    Returns: 6

  28. {312979, 312980, 312981, 312982, 312983, 312984, 312985, 312986, 312987, 312988, 312989, 312990, 312991, 312992, 312993, 312994, 312995, 312996, 312997, 312998, 312999, 313000}

    Returns: 2

  29. {411759, 411760, 411761, 411765, 411767, 411773, 411778, 411787, 411790, 411794, 411798, 411803, 411811, 411817, 411818, 411822, 411826, 411829, 411834, 411840, 411846, 411857, 411868, 411870, 411874, 411879, 411882, 411885, 411902, 411910, 411913, 411915, 411917, 411922, 411924, 411926, 411929, 411937, 411938, 411945, 411948, 411949, 411955, 411959, 411962, 411965, 411968, 411971, 411972}

    Returns: 38

  30. {-239199, -239198, -239197, -239196, -239195, -239194, -239193, -239192, -239191, -239190, -239189, -239188, -239187, -239186, -239185, -239184, -239183, -239182, -239181, -239180, -239179, -239178, -239177, -239176, -239175, -239174, -239173}

    Returns: 2

  31. {-25928, -25927, -25926, -25925, -25924, -25923, -25922, -25921, -25920, -25919, -25918, -25917, -25916, -25915, -25914, -25913, -25912, -25911, -25910, -25909, -25908}

    Returns: 2

  32. {-308874, -308873, -308872, -308871, -308870, -308869, -308868, -308867, -308866, -308865, -308864, -308863, -308862, -308861, -308860, -308859, -308858, -308857, -308856, -308855, -308854, -308853, -308852, -308851, -308850, -308849, -308848, -308847, -308846, -308845, -308844, -308843, -308842, -308841, -308840, -308839, -308838, -308837, -308836, -308835, -308834, -308833, -308832, -308831, -308830, -308829, -308828, -308827, -308826}

    Returns: 2

  33. {748556, 748559, 748560, 748565, 748566, 748567, 748568, 748569, 748570, 748572, 748573}

    Returns: 7

  34. {-587403, -587402, -587401, -587400, -587399, -587398, -587397, -587396, -587395, -587394, -587393, -587392, -587391, -587390, -587389, -587388, -587387, -587386, -587385, -587384, -587383, -587382, -587380, -587379, -587378, -587377, -587376, -587375, -587374, -587373, -587372, -587371, -587370, -587369, -587368, -587367, -587366, -587365, -587364, -587363, -587362, -587361, -587360, -587359}

    Returns: 4

  35. {-323903, -323902, -323901, -323900, -323899, -323895, -323893, -323891, -323890, -323889, -323886, -323884, -323883, -323882, -323878, -323877, -323876, -323875, -323874, -323873, -323871, -323869, -323866, -323860, -323859, -323858, -323857, -323856, -323854}

    Returns: 15

  36. {-677, -45, -2, 3, 8, 29, 384, 867 }

    Returns: 7

  37. {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }

    Returns: 2

  38. {0, 1, 3 }

    Returns: 3

  39. {-1000000, 1000000 }

    Returns: 2

  40. {3, 4, 7 }

    Returns: 3

  41. {2, 3, 5, 6, 7 }

    Returns: 4

  42. {5, 8 }

    Returns: 2

  43. {1, 4, 6 }

    Returns: 3

  44. {1, 2 }

    Returns: 2

  45. {3, 4, 5, 6, 7, 8 }

    Returns: 2


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: