We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Search
- Beautiful Quadruples
- Discussions
Beautiful Quadruples
Beautiful Quadruples
Sort by
recency
|
34 Discussions
|
Please Login in order to post a comment
I found a way mathmateically to calculate the number of ALL combinations where order does not matter. I meant to subtract the number of quadruples where each number XOR = 0 from that total, but it turns out it isn't easy to find that.
Here is my solution in java, javascript, python, C, C++, Csharp HackerRank Beautiful Quadruples Problem Solution
Once more, Java "skeleton code" (and I guess the ones for some other languages as well) uses wrong type.
int
is too small to handle all possible values.E.g. for
2997 2998 2999 3000
result is3380890906299
.Here is the solution of Beautiful Quadruples Click Here
for example -> (1,3,4,7) correct subsets accroding to me are -> (1,1,1,2),(1,1,1,3),(1,1,1,4),(1,1,1,5),(1,1,1,6),(1,1,1,7),(1,2,2,2),(1,3,3,3),(1,1,2,3),(1,1,2,4),(1,1,2,5),(1,1,2,6),(1,1,2,7),(1,1,3,4),(1,1,3,5),(1,1,3,6),(1,1,3,7),(1,1,4,5),(1,1,4,6),(1,1,4,7),(1,2,2,3),(1,2,2,4),(1,2,2,5),(1,2,2,6),(1,2,2,7),(1,3,3,4),(1,3,3,5),(1,3,3,6),(1,3,3,6),(1, 3,3,7),(1,2,4,4),(1,3,4,4),(1,2,3,4),(1,2,3,5),(1,2,3,6),(1,2,3,7),(1,3,4,5),(1,3,4,6),(1,3,4,7),(1,2,4,5),(1,2,4,6),(1,2,4,7) =41, but ans is 40 :/ can anyone tell what wrong i'm calculating ??