Statistics

Problem Statement for "ParallelepipedUnion"

Problem Statement

You are given 2 rectangular parallelepipeds (rectangular solids) in space, edges parallel to coordinate axes. Compute the volume of their union.

For example, consider the two following parallelepipeds (they are divided into unit cubes for clarity):
and
When combined in the following manner, their union is a figure of volume 12 (it consists of 12 unit blocks: ten on the bottom level, and two on the top level):

You are given a String[] parallelepipeds containing exactly two elements. Each element represents a single parallelepiped, and is formatted as "x1 y1 z1 x2 y2 z2" (quotes for clarity only), where (x1, y1, z1) and (x2, y2, z2) are the coordinates of opposing corners of the parallelepiped.

Definition

Class:
ParallelepipedUnion
Method:
getVolume
Parameters:
String[]
Returns:
int
Method signature:
int getVolume(String[] parallelepipeds)
(be sure your method is public)

Constraints

  • parallelepipeds will contain exactly 2 elements.
  • Each element of parallelepipeds will be formatted as "x1 y1 z1 x2 y2 z2" (quotes for clarity only).
  • In each element of parallelepipeds, x1 < x2, y1 < y2, z1 < z2.
  • All coordinates will be integers between 1 and 100, inclusive, without extra leading zeroes.

Examples

  1. {"1 1 1 4 4 2", "3 2 1 5 3 3"}

    Returns: 12

    The example from the problem statement.

  2. {"1 1 1 2 2 2", "3 3 3 4 4 4"}

    Returns: 2

    Two unit cubes that do not intersect.

  3. {"1 10 20 5 15 23", "2 12 22 3 14 23"}

    Returns: 60

    One parallelepiped inside another.

  4. {"28 31 21 67 60 81","60 1 21 67 50 81"}

    Returns: 80460

  5. {"34 3 50 37 6 53","36 1 51 38 4 55"}

    Returns: 49

  6. {"32 35 15 57 49 70","73 10 82 86 16 90"}

    Returns: 19874

  7. {"43 31 21 65 48 78","16 28 2 43 30 11"}

    Returns: 21804

  8. {"72 53 3 90 70 5","33 20 5 72 49 8"}

    Returns: 4005

  9. {"40 45 76 42 69 98","42 14 40 76 45 76"}

    Returns: 39000

  10. {"14 38 8 30 42 15","41 40 23 69 43 65"}

    Returns: 3976

  11. {"54 92 49 57 95 59","53 96 58 54 97 68"}

    Returns: 100

  12. {"52 26 24 54 51 31","54 28 31 57 68 61"}

    Returns: 3950

  13. {"66 13 5 90 14 54","53 15 42 75 18 66"}

    Returns: 2760

  14. {"72 21 60 75 47 69","71 47 41 74 82 61"}

    Returns: 2802

  15. {"38 3 40 41 4 62","56 5 51 88 8 62"}

    Returns: 1122

  16. {"4 41 10 79 42 14","27 38 30 79 41 78"}

    Returns: 7788

  17. {"19 29 32 46 68 83","19 22 4 77 29 32"}

    Returns: 65071

  18. {"20 11 64 24 14 65","21 12 66 24 15 69"}

    Returns: 39

  19. {"71 34 70 72 73 93","68 29 70 71 68 78"}

    Returns: 1833

  20. {"59 22 42 78 80 62","31 46 53 60 80 86"}

    Returns: 54272

  21. {"32 53 49 62 87 76","83 53 11 92 95 76"}

    Returns: 52110

  22. {"20 70 3 59 74 74","25 21 25 59 70 74"}

    Returns: 92710

  23. {"40 61 22 64 76 74","6 61 10 64 82 55"}

    Returns: 61650

  24. {"33 29 26 76 62 60","11 29 26 76 87 74"}

    Returns: 180960

  25. {"83 5 7 93 14 86","31 21 34 58 67 84"}

    Returns: 69210

  26. {"40 45 18 56 86 48","10 86 13 14 89 52"}

    Returns: 20148

  27. {"19 6 17 22 41 58","22 2 4 24 63 17"}

    Returns: 5891

  28. {"44 20 44 64 74 60","13 5 25 84 17 53"}

    Returns: 41136

  29. {"48 13 64 73 16 89","43 14 11 48 17 91"}

    Returns: 3075

  30. {"14 42 44 58 96 47","55 19 43 81 97 45"}

    Returns: 11022

  31. {"41 90 27 57 93 30","13 89 25 64 93 26"}

    Returns: 348

  32. {"27 6 6 32 49 74","32 23 36 41 49 71"}

    Returns: 22810

  33. {"36 47 21 54 64 44","5 39 10 62 55 44"}

    Returns: 34734

  34. {"22 47 61 25 50 64","21 46 59 25 50 65"}

    Returns: 96

  35. {"21 46 18 47 71 75","3 32 5 55 88 12"}

    Returns: 57434

  36. {"17 14 88 92 94 90","43 44 85 83 78 88"}

    Returns: 16080

  37. {"33 46 51 53 68 83","3 40 44 49 87 100"}

    Returns: 123888

  38. {"29 55 28 51 70 69","5 19 5 93 82 69"}

    Returns: 354816

  39. {"32 37 55 68 52 68","1 5 30 73 89 82"}

    Returns: 314496

  40. {"21 31 27 61 79 30","40 16 25 61 27 26"}

    Returns: 5991

  41. {"47 36 24 90 70 81","47 6 11 84 36 22"}

    Returns: 95544

  42. {"10 60 35 14 83 37","14 34 35 42 60 42"}

    Returns: 5280

  43. {"79 58 42 83 59 43","81 60 40 84 63 43"}

    Returns: 31

  44. {"18 25 43 43 28 78","23 28 65 43 29 89"}

    Returns: 3105

  45. {"29 71 42 35 84 86","29 21 24 45 75 63"}

    Returns: 36624

  46. {"42 91 31 52 96 81","42 37 31 68 84 62"}

    Returns: 40382

  47. {"11 59 16 14 80 50","11 9 50 12 80 52"}

    Returns: 2284

  48. {"28 66 37 58 75 56","27 70 39 58 92 56"}

    Returns: 14174

  49. {"20 57 93 59 93 98","20 57 93 86 80 96"}

    Returns: 8883

  50. {"19 37 37 22 40 40","17 39 36 18 40 42"}

    Returns: 33

  51. {"35 63 41 45 66 98","45 38 45 78 66 90"}

    Returns: 43290

  52. {"12 5 10 27 36 95","12 7 18 52 52 55"}

    Returns: 90030

  53. {"7 42 52 86 77 53","8 42 52 65 76 55"}

    Returns: 6641

  54. {"6 5 26 67 98 91","18 28 17 58 74 91"}

    Returns: 385305

  55. {"56 19 20 59 79 68","56 12 21 58 18 68"}

    Returns: 9204

  56. {"10 28 12 49 55 15","12 44 10 49 55 12"}

    Returns: 3973

  57. {"24 42 50 60 70 84","5 42 74 40 52 84"}

    Returns: 36172

  58. {"83 85 54 86 88 88","83 87 54 85 88 97"}

    Returns: 324

  59. {"6 70 49 91 76 72","32 54 33 41 76 72"}

    Returns: 18210

  60. {"45 23 6 80 84 9","60 24 6 80 84 8"}

    Returns: 6405

  61. {"3 95 50 27 96 87","29 91 50 82 94 87"}

    Returns: 6771

  62. {"43 42 38 62 81 68","5 42 30 43 81 35"}

    Returns: 29640

  63. {"25 19 52 28 39 67","25 10 33 28 19 52"}

    Returns: 1413

  64. {"12 24 16 40 59 27","19 24 42 50 59 95"}

    Returns: 68285

  65. {"83 7 57 86 38 60","83 2 56 86 7 59"}

    Returns: 324

  66. {"11 14 45 59 49 48","29 33 45 78 55 48"}

    Returns: 6834

  67. {"21 26 27 71 66 79","86 15 27 93 66 79"}

    Returns: 122564

  68. {"65 10 10 90 36 45","65 10 45 90 28 80"}

    Returns: 38500

  69. {"30 54 21 33 75 44","29 54 21 32 75 45"}

    Returns: 1995

  70. {"28 40 37 89 97 89","28 40 37 83 82 89"}

    Returns: 180804

  71. {"35 19 17 92 59 53","27 19 98 94 59 99"}

    Returns: 84760

  72. {"32 18 11 35 60 14","32 12 14 35 76 15"}

    Returns: 570

  73. {"32 22 11 72 74 48","32 21 5 72 77 12"}

    Returns: 90560

  74. {"18 15 33 36 18 79","13 13 33 97 18 79"}

    Returns: 19320

  75. {"29 45 93 32 48 96","29 43 91 32 50 98"}

    Returns: 147

  76. {"57 65 53 60 90 59","57 20 36 60 50 59"}

    Returns: 2520

  77. {"31 29 15 96 44 53","23 29 15 31 87 53"}

    Returns: 54682

  78. {"26 54 42 77 65 62","26 54 42 78 65 49"}

    Returns: 11297

  79. {"32 42 24 86 60 71","32 5 52 86 66 71"}

    Returns: 89802

  80. {"58 59 57 72 60 73","58 28 38 72 60 73"}

    Returns: 15680

  81. {"35 50 18 83 86 45","35 50 5 83 86 13"}

    Returns: 60480

  82. {"23 37 20 41 54 72","23 54 20 41 75 72"}

    Returns: 35568

  83. {"20 35 27 63 63 65","20 35 21 63 63 36"}

    Returns: 52976

  84. {"93 46 12 98 89 61","93 46 12 96 89 61"}

    Returns: 10535

  85. {"15 28 42 18 74 58","15 16 42 18 75 58"}

    Returns: 2832

  86. {"95 94 40 98 97 43","95 94 42 98 97 43"}

    Returns: 27

  87. {"22 27 64 42 52 69","22 27 64 42 52 69"}

    Returns: 2500

  88. {"54 26 10 68 33 17","34 41 31 82 72 74"}

    Returns: 64670

  89. {"27 91 71 60 94 74","29 95 74 46 96 76"}

    Returns: 331

  90. {"56 73 11 62 78 28","19 42 28 63 73 84"}

    Returns: 76894

  91. {"93 34 31 96 74 60","92 37 1 94 39 8"}

    Returns: 3508

  92. {"5 46 47 29 49 55","29 48 30 49 51 63"}

    Returns: 2556

  93. {"93 83 81 96 86 84","91 81 82 95 85 83"}

    Returns: 39

  94. {"12 20 50 13 21 55","11 22 52 14 25 55"}

    Returns: 32

  95. {"44 24 25 59 85 62","14 85 42 59 95 52"}

    Returns: 38355

  96. {"31 11 42 47 44 51","29 12 50 59 44 62"}

    Returns: 15760

  97. {"21 83 92 77 88 93","40 85 91 77 88 94"}

    Returns: 502

  98. {"41 6 29 54 21 73","39 28 38 78 69 66"}

    Returns: 53352

  99. {"15 48 7 76 84 10","76 64 5 89 71 12"}

    Returns: 7225

  100. {"12 31 71 73 42 96","48 30 55 69 55 83"}

    Returns: 28703

  101. {"51 41 30 80 81 65","46 60 35 89 81 47"}

    Returns: 44128

  102. {"45 37 36 50 42 37","46 38 35 49 41 38"}

    Returns: 43

  103. {"85 32 33 88 96 48","86 8 33 87 11 36"}

    Returns: 2889

  104. {"49 16 17 81 75 20","49 75 18 78 94 19"}

    Returns: 6215

  105. {"19 13 81 22 16 84","21 14 83 24 15 84"}

    Returns: 29

  106. {"58 41 21 61 44 24","57 42 21 61 43 22"}

    Returns: 28

  107. {"64 18 72 70 55 75","65 12 26 68 61 75"}

    Returns: 7536

  108. {"24 77 17 26 78 18","23 75 16 26 78 19"}

    Returns: 27

  109. {"27 60 61 30 89 74","27 62 15 30 63 39"}

    Returns: 1203

  110. {"27 35 43 50 47 81","27 39 12 50 45 43"}

    Returns: 14766

  111. {"35 30 63 63 85 65","39 30 30 64 85 70"}

    Returns: 55440

  112. {"45 31 21 51 51 66","25 33 21 53 51 66"}

    Returns: 23220

  113. {"22 3 26 57 88 27","22 28 25 57 73 28"}

    Returns: 6125

  114. {"48 40 58 79 81 72","71 40 59 79 81 60"}

    Returns: 17794

  115. {"52 19 17 87 66 20","52 19 18 87 66 19"}

    Returns: 4935

  116. {"21 65 53 57 71 80","12 22 13 61 61 81"}

    Returns: 135780

  117. {"19 56 32 40 84 37","18 14 26 52 56 44"}

    Returns: 28644

  118. {"29 15 29 30 16 31","28 14 27 31 17 30"}

    Returns: 28

  119. {"45 12 16 59 24 84","40 8 16 64 41 60"}

    Returns: 38880

  120. {"28 36 21 39 40 77","27 33 41 77 46 71"}

    Returns: 20644

  121. {"56 48 95 65 55 97","53 32 94 81 81 97"}

    Returns: 4116

  122. {"70 26 40 91 43 69","74 36 40 75 41 69"}

    Returns: 10353

  123. {"52 26 26 82 60 58","55 27 30 75 41 52"}

    Returns: 32640

  124. {"1 1 1 99 99 99", "2 2 2 100 100 100"}

    Returns: 969711

  125. {"1 1 1 10 10 10", "20 20 1 30 30 10" }

    Returns: 1629

  126. {"1 1 1 2 2 11", "9 9 2 10 10 10" }

    Returns: 18

  127. {"99 99 99 100 100 100", "99 99 99 100 100 100" }

    Returns: 1

  128. {"28 31 21 67 60 81", "60 1 21 67 50 81" }

    Returns: 80460

  129. {"13 22 44 100 100 100", "1 1 4 83 99 88" }

    Returns: 817880

  130. {"11 22 33 44 55 66", "2 33 44 55 66 77" }

    Returns: 77682

  131. {"34 3 50 37 6 53", "36 1 51 38 4 55" }

    Returns: 49

  132. {"1 2 3 4 5 6", "1 2 3 4 8 8" }

    Returns: 90

  133. {"1 1 1 4 4 2", "3 2 1 5 3 6" }

    Returns: 18

  134. {"1 2 1 3 4 2", "2 1 1 4 3 2" }

    Returns: 7

  135. {"3 2 1 5 3 3", "1 1 1 4 4 2" }

    Returns: 12

  136. {"1 1 1 100 100 100", "1 1 1 100 100 100" }

    Returns: 970299

  137. {"1 1 1 3 3 5", "6 6 3 8 8 7" }

    Returns: 32

  138. {"1 1 1 4 4 2", "5 5 1 6 6 2" }

    Returns: 10

  139. {"1 1 1 10 10 10", "20 20 5 30 30 50" }

    Returns: 5229

  140. {"34 3 50 37 6 53", "36 1 5 99 4 55" }

    Returns: 9474

  141. {"1 1 1 4 4 2", "3 2 1 5 3 3" }

    Returns: 12

  142. {"2 2 2 3 3 3", "1 1 1 4 4 4" }

    Returns: 27

  143. {"39 49 59 99 59 99", "1 2 3 99 99 99" }

    Returns: 912576

  144. {"60 1 21 67 100 81", "60 1 21 67 50 81" }

    Returns: 41580

  145. {"1 1 1 5 5 5", "50 50 1 100 100 5" }

    Returns: 10064

  146. {"1 1 1 5 5 5", "50 50 50 100 100 100" }

    Returns: 125064

  147. {"1 1 1 2 2 2", "3 3 1 4 4 2" }

    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: