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

Home > General
Cell Choices (Posted on 2013-03-05) Difficulty: 3 of 5
1	8	15	22	29	36	43
2	9	16	23	30	37	44
3	10	17	24	31	38	45
4	11	18	25	32	39	46
5	12	19	26	33	40	47
6	13	20	27	34	41	48
7	14	21	28	35	42	49
In the 7x7 array given above, select six numbers from six cells simultaneously satisfying the following conditions:
  1. No two numbers chosen should belong to the same row;
  2. No two numbers chosen should belong to the same column;
  3. In the set of numbers chosen, each of the ten digits appears once and only once.
For example, if the numbers selected are 7,9,18,26,30 and 45 then this violates the given conditions as 9 and 30 belong to the same row.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 2 of 4 |

DECLARE SUB doCol (col!)
DECLARE FUNCTION gridNo! (row!, col!)
CLEAR , , 25000
DIM SHARED rowused(7), colnotused, nums(7), numstr$
CLS
FOR colnotused = 1 TO 7
   doCol 1
NEXT colnotused

SUB doCol (col)
  IF col <> colnotused THEN
    FOR row = 1 TO 7
      IF rowused(row) = 0 THEN
        s$ = LTRIM$(STR$(gridNo(row, col)))
        IF LEFT$(s$, 1) <> RIGHT$(s$, 1) OR LEN(s$) = 1 THEN good = 1: ELSE good = 0
        FOR i = 1 TO LEN(s$)
          IF INSTR(numstr$, MID$(s$, i, 1)) > 0 THEN good = 0: EXIT FOR
        NEXT
        IF good THEN
          nums(col) = gridNo(row, col)
          savenumstr$ = numstr$
          numstr$ = numstr$ + "," + s$
          rowused(row) = 1
          IF col = 7 THEN
            PRINT numstr$
          ELSE
            doCol col + 1
          END IF
          numstr$ = savenumstr$
          nums(col) = 0
          rowused(row) = 0
        END IF
      END IF
    NEXT
  ELSE
    IF col = 7 THEN
      PRINT numstr$
    ELSE
      doCol col + 1
    END IF
  END IF
END SUB

FUNCTION gridNo (row, col)
 gridNo = (row - 1) MOD 7 + 1 + 7 * (col - 1)
END FUNCTION

finds

6,8,17,25,30,49


  Posted by Charlie on 2013-03-05 15:42:23
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 (14)
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