Statistics

Problem Statement for "EasyPartition"

Problem Statement

Ramanujan loved partitions. And he also loved natural numbers. So, yay! He has a problem for you.

The set S consists of the first 8*N natural numbers: S = { 1, 2, 3, ..., 8*N }. You have to find a subset W of S with the following properties:

  • W contains exactly 2*N numbers.
  • The sum of W is 4*N*N.

If there is a subset W satisfying the mentioned condition, find any one such subset. Return a string of size 8*N, where the ith character (1-indexed) is '1' if i belongs to W, and '0' otherwise. Any valid solution will be accepted.

Return an empty string if it is impossible to construct a valid subset for the given N.

Definition

Class:
EasyPartition
Method:
getPartition
Parameters:
int
Returns:
String
Method signature:
String getPartition(int N)
(be sure your method is public)

Notes

  • W is a subset of S, hence all elements of W must be distinct.

Constraints

  • N will be between 1 and 50, inclusive.

Examples

  1. 1

    Returns: "10100000"

    W = {1,3} satisfies our conditions.

  2. 2

    Returns: "0110110000000000"

    4 * N * N = 16. W={2,3,5,7} Other possible solutions are {1,3,5,7}, {1,2,6,7}, {1,2,5,8} etc.

  3. 3

    Returns: "010110110100000000000000"

    W = {2,4,5,7,8,10} satisfies.

  4. 4

    Returns: "01010110110101000000000000000000"

  5. 5

    Returns: "0101010110110101010000000000000000000000"

  6. 6

    Returns: "010101010110110101010100000000000000000000000000"

  7. 7

    Returns: "01010101010110110101010101000000000000000000000000000000"

  8. 8

    Returns: "0101010101010110110101010101010000000000000000000000000000000000"

  9. 9

    Returns: "010101010101010110110101010101010100000000000000000000000000000000000000"

  10. 10

    Returns: "01010101010101010110110101010101010101000000000000000000000000000000000000000000"

  11. 11

    Returns: "0101010101010101010110110101010101010101010000000000000000000000000000000000000000000000"

  12. 12

    Returns: "010101010101010101010110110101010101010101010100000000000000000000000000000000000000000000000000"

  13. 13

    Returns: "01010101010101010101010110110101010101010101010101000000000000000000000000000000000000000000000000000000"

  14. 14

    Returns: "0101010101010101010101010110110101010101010101010101010000000000000000000000000000000000000000000000000000000000"

  15. 15

    Returns: "010101010101010101010101010110110101010101010101010101010100000000000000000000000000000000000000000000000000000000000000"

  16. 16

    Returns: "01010101010101010101010101010110110101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000"

  17. 17

    Returns: "0101010101010101010101010101010110110101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000"

  18. 18

    Returns: "010101010101010101010101010101010110110101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000"

  19. 19

    Returns: "01010101010101010101010101010101010110110101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000"

  20. 20

    Returns: "0101010101010101010101010101010101010110110101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  21. 21

    Returns: "010101010101010101010101010101010101010110110101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  22. 22

    Returns: "01010101010101010101010101010101010101010110110101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  23. 23

    Returns: "0101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  24. 24

    Returns: "010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  25. 25

    Returns: "01010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  26. 26

    Returns: "0101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  27. 27

    Returns: "010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  28. 28

    Returns: "01010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  29. 29

    Returns: "0101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  30. 30

    Returns: "010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  31. 31

    Returns: "01010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  32. 32

    Returns: "0101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  33. 33

    Returns: "010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  34. 34

    Returns: "01010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  35. 35

    Returns: "0101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  36. 36

    Returns: "010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  37. 37

    Returns: "01010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  38. 38

    Returns: "0101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  39. 39

    Returns: "010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  40. 40

    Returns: "01010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  41. 41

    Returns: "0101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  42. 42

    Returns: "010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  43. 43

    Returns: "01010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  44. 44

    Returns: "0101010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  45. 45

    Returns: "010101010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  46. 46

    Returns: "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  47. 47

    Returns: "0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  48. 48

    Returns: "010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  49. 49

    Returns: "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

  50. 50

    Returns: "0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"


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: