All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
Marbles in boxes (Posted on 2017-08-16) Difficulty: 4 of 5
How many distinct distributions (x,y,z,w) of n identical marbles in 4 boxes labeled A,B,C and D are there, such that
x,y,z,w are positive integers in strictly increasing order?

Verify the validity of your formula (or set of formulas) by manual listing of all such distributions for n=18.

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
a kind of solution | Comment 1 of 5
15 distributions were found (admittedly without brain):

1,2,3,12
1,2,4,11
1,2,5,10
1,2,6,9
1,2,7,8
1,3,4,10
1,3,5,9
1,3,6,8
1,4,5,8
1,4,6,7
2,3,4,9
2,3,5,8
2,3,6,7
2,4,5,7
3,4,5,6


Program in the Prolog language:


box(A,B,C,D) :-
       
        between(1,18,A),
        between(1,18,B),
        between(1,18,C),
        between(1,18,D),

        A < B,
        B < C,
        C < D,

        N is A+B+C+D,
        N is 18.

between(L,U,X) :-
    integer(L),integer(U),
    (   var(X) ->
        L =< U,
        between1(L,U,X)
    ;   integer(X),
        L =< X, X =< U
    ).

between1(L,U,X) :-
    (   X = L
    ;   M is L + 1, M =< U,
        between1(M,U,X)
    ).


Edited on August 16, 2017, 10:31 am
  Posted by ollie on 2017-08-16 10:25:57

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (12)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information