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

Home > Logic
Ten Items and Two Boxes (Posted on 2013-08-12) Difficulty: 3 of 5
You have two boxes, one is filled with 10 items and the other is empty. You are allowed to transfer items one at a time from one box to the other (transfers may to either way).

There are 2^10=1024 ways to split the items between the two boxes. Can you make all the ways without repetition using only the transfer rule described above?

See The Solution Submitted by Brian Smith    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
program generating the list Comment 2 of 2 |
(In reply to solution by Charlie)

OPEN "10items2.txt" FOR OUTPUT AS #2
FOR i = 0 TO 1023
  s$ = ""
  n = i
  FOR j = 1 TO 10
     s$ = LTRIM$(STR$(n MOD 2)) + s$
     n = n \ 2
  NEXT j
  PRINT s$; " ";   ' binary notation
  FOR p = 10 TO 2 STEP -1
    IF MID$(s$, p - 1, 1) = "1" THEN
      MID$(s$, p, 1) = LTRIM$(STR$(1 - VAL(MID$(s$, p, 1))))
    END IF
  NEXT   ' now it's gray code
  PRINT s$
  FOR j = 1 TO 10
     IF MID$(s$, j, 1) = "1" THEN PRINT #2, MID$("abcdefghij", j, 1);
  NEXT j
  PRINT #2, "   ";
  FOR j = 1 TO 10
     IF MID$(s$, j, 1) = "0" THEN PRINT #2, MID$("abcdefghij", j, 1);
  NEXT j
  PRINT #2,
NEXT
CLOSE

 


  Posted by Charlie on 2013-08-13 01:54:34
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 (6)
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