Announcement

Collapse
No announcement yet.

I have written a computer program which solves Sudoku puzzles

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Dead brains? It's not like they're going to ****** you.

    OF course it also depends on how you do them. I developed a method, then they got really boring.

    Comment


    • #17
      Sudoku is part of Japan's cultural imperialism.
      DISCLAIMER: the author of the above written texts does not warrant or assume any legal liability or responsibility for any offence and insult; disrespect, arrogance and related forms of demeaning behaviour; discrimination based on race, gender, age, income class, body mass, living area, political voting-record, football fan-ship and musical preference; insensitivity towards material, emotional or spiritual distress; and attempted emotional or financial black-mailing, skirt-chasing or death-threats perceived by the reader of the said written texts.

      Comment


      • #18
        We must pass a law forcing newspapers to equate at least 20% of their puzzle pages to American games
        “I give you a new commandment, that you love one another. Just as I have loved you, you also should love one another. By this everyone will know that you are my disciples, if you have love for one another.”
        - John 13:34-35 (NRSV)

        Comment


        • #19
          We can't have those crazy Japs destroying our heritage.
          DISCLAIMER: the author of the above written texts does not warrant or assume any legal liability or responsibility for any offence and insult; disrespect, arrogance and related forms of demeaning behaviour; discrimination based on race, gender, age, income class, body mass, living area, political voting-record, football fan-ship and musical preference; insensitivity towards material, emotional or spiritual distress; and attempted emotional or financial black-mailing, skirt-chasing or death-threats perceived by the reader of the said written texts.

          Comment


          • #20
            I was going to do something like that, only in another language.
            (\__/) 07/07/1937 - Never forget
            (='.'=) "Claims demand evidence; extraordinary claims demand extraordinary evidence." -- Carl Sagan
            (")_(") "Starting the fire from within."

            Comment


            • #21
              I'm going to write a computer program that creates Sudoku puzzles that contain sublimal messages that program people to KILL!

              KILLKILLKILLKILLKILLKILLKILLKILLKILLKILLKILLKILLKI LLKILL

              To us, it is the BEAST.

              Comment


              • #22
                Hopefully "kill" includes suicide, and you'll test the progrom on yourself first.
                DISCLAIMER: the author of the above written texts does not warrant or assume any legal liability or responsibility for any offence and insult; disrespect, arrogance and related forms of demeaning behaviour; discrimination based on race, gender, age, income class, body mass, living area, political voting-record, football fan-ship and musical preference; insensitivity towards material, emotional or spiritual distress; and attempted emotional or financial black-mailing, skirt-chasing or death-threats perceived by the reader of the said written texts.

                Comment


                • #23
                  Hmmmm, brains.
                  (\__/)
                  (='.'=)
                  (")_(") This is Bunny. Copy and paste bunny into your signature to help him gain world domination.

                  Comment


                  • #24
                    Originally posted by Colon
                    Hopefully "kill" includes suicide, and you'll test the progrom on yourself first.
                    no...

                    the only suiciding I will do is I'll suicide bomb your house while you sleep

                    but after my Sudoku puzzles have caused THE PUBLIC to KILLKILLKILLKILLKILLKILLKILLKILLKILLKILLKILLKILLKI LLKILLKILLKILLKILL

                    that is of course, if you aren't a victim of a CRAZED SUDOKU PROGRAMMED KILLING MACHINE



                    MUHAUHUAHUAHHAUHHAHHAHAH
                    To us, it is the BEAST.

                    Comment


                    • #25
                      Originally posted by Imran Siddiqui
                      Jesus... and I thought I needed a girlfriend
                      I have one
                      12-17-10 Mohamed Bouazizi NEVER FORGET
                      Stadtluft Macht Frei
                      Killing it is the new killing it
                      Ultima Ratio Regum

                      Comment


                      • #26
                        You sure?
                        DISCLAIMER: the author of the above written texts does not warrant or assume any legal liability or responsibility for any offence and insult; disrespect, arrogance and related forms of demeaning behaviour; discrimination based on race, gender, age, income class, body mass, living area, political voting-record, football fan-ship and musical preference; insensitivity towards material, emotional or spiritual distress; and attempted emotional or financial black-mailing, skirt-chasing or death-threats perceived by the reader of the said written texts.

                        Comment


                        • #27
                          Her name is Compiler. Sometime he cheats her with Interpreter

                          Comment


                          • #28
                            Originally posted by Colon
                            You sure?
                            I just put it on her 10 minutes ago, so yes.
                            12-17-10 Mohamed Bouazizi NEVER FORGET
                            Stadtluft Macht Frei
                            Killing it is the new killing it
                            Ultima Ratio Regum

                            Comment


                            • #29
                              Not very pretty code. For shame.

                              Looks like another graph coloring implementation. Go on, be creative!
                              "The issue is there are still many people out there that use religion as a crutch for bigotry and hate. Like Ben."
                              Ben Kenobi: "That means I'm doing something right. "

                              Comment


                              • #30
                                Eh. I'm not a computer scientist or even a computer engineer. It works (in all cases I've tested), and that's what counts.

                                Took out that ugly sequence of inputted values and made it dependent on an external file which has the same format as the puzzle. Blanks (spaces with no preassigned value) should be entered as 0s. The output is now also written to a file, and is in the same intuitive format.

                                Tried to make a standalone but IDL is acting *****y about doing that.

                                Code:
                                function square, r, c
                                s = 3*floor(r/3.0) + floor(c/3.0)
                                return, s
                                end
                                
                                function delta, a, b
                                s = 0
                                if (a EQ b) then begin
                                	s = 1
                                endif
                                return, s
                                end
                                
                                function eliminator, poss
                                a = 0L
                                while a LE 100L do begin
                                	totalposs0 = total(poss)
                                	sumvals = total(poss, 3)
                                	for r = 0, 8 do begin
                                		for c = 0, 8 do begin
                                			if (sumvals[r, c] EQ 0) then begin
                                				poss = fltarr(9, 9, 9)
                                				a = a + 10000L
                                			endif
                                			if (sumvals[r, c] EQ 1) then begin
                                				for j = 0, 8 do begin
                                					if (poss[r, c, j] EQ 1) then begin
                                						for rprime = 0, 8 do begin
                                							poss[rprime, c, j] = delta(r, rprime)
                                						endfor
                                						for cprime = 0, 8 do begin
                                							poss[r, cprime, j] = delta(c, cprime)
                                						endfor
                                						for rprime = 0, 8 do begin
                                							for cprime = 0, 8 do begin
                                								if (square(r, c) EQ square(rprime, cprime)) then begin
                                									poss[rprime, cprime, j] = poss[rprime, cprime, j] * delta(r, rprime) * delta(c, cprime)
                                								endif
                                							endfor
                                						endfor
                                					endif
                                				endfor
                                			endif
                                		endfor
                                	endfor
                                	sumrows = total(poss, 1)
                                	for c = 0, 8 do begin
                                		for j = 0, 8 do begin
                                			if (sumrows[c, j] EQ 0) then begin
                                				poss = fltarr(9, 9, 9)
                                				a = a + 10000L
                                			endif
                                			if (sumrows[c, j] EQ 1) then begin
                                				for r = 0, 8 do begin
                                					if (poss[r, c, j] EQ 1) then begin
                                						for jprime = 0, 8 do begin
                                							poss[r, c, jprime] = delta(j, jprime)
                                						endfor
                                					endif
                                				endfor
                                			endif
                                		endfor
                                	endfor
                                	sumcols = total(poss, 2)
                                	for r = 0, 8 do begin
                                		for j = 0, 8 do begin
                                			if (sumcols[r, j] EQ 0) then begin
                                				poss = fltarr(9, 9, 9)
                                				a = a + 10000L
                                			endif
                                			if (sumcols[r, j] EQ 1) then begin
                                				for c = 0, 8 do begin
                                					if (poss[r, c, j] EQ 1) then begin
                                						for jprime = 0, 8 do begin
                                							poss[r, c, jprime] = delta(j, jprime)
                                						endfor
                                					endif
                                				endfor
                                			endif
                                		endfor
                                	endfor
                                	sumsqrs = fltarr(9, 9)
                                	for j = 0, 8 do begin
                                		for r = 0, 8 do begin
                                			for c = 0, 8 do begin
                                				sqr = square(r, c)
                                				sumsqrs(sqr, j) = sumsqrs(sqr, j) + poss[r, c, j]
                                			endfor
                                		endfor
                                	endfor
                                	for sqr = 0, 8 do begin
                                		for j = 0, 8 do begin
                                			if (sumsqrs[sqr, j] EQ 0) then begin
                                				poss = fltarr(9, 9, 9)
                                				a = a + 10000L
                                			endif
                                			if (sumsqrs[sqr, j] EQ 1) then begin
                                				for r = 0, 8 do begin
                                					for c = 0, 8 do begin
                                						if (square(r, c) EQ sqr) then begin
                                							if (poss[r, c, j] EQ 1) then begin
                                								for jprime = 0, 8 do begin
                                									poss[r, c, jprime] = delta(j, jprime)
                                								endfor
                                							endif
                                						endif
                                					endfor
                                				endfor
                                			endif
                                		endfor
                                	endfor
                                	totalposs1 = total(poss)
                                	if (totalposs1 EQ totalposs0) then begin
                                		a = a + 10000L
                                	endif
                                	a = a + 1
                                endwhile
                                return, poss
                                end
                                
                                pro solver
                                invalues = lonarr(9)
                                openr, lun, 'invalues.txt', /get_lun
                                readf, lun, invalues
                                free_lun, lun
                                gpos = lonarr(81)
                                gvalprime = lonarr(81)
                                for i = 0, 8 do begin
                                	for j = 0, 8 do begin
                                		gvalprime[9*i + j] = (floor(invalues[i] / (10L^(8 - j)))) MOD 10L
                                		if (gvalprime[9*i + j] GE 1) then begin
                                			gpos[9*i + j] = 1
                                		endif
                                	endfor
                                endfor
                                n = total(gpos)
                                ;n is the number of values pre-determined by the person who wrote the puzzle
                                grow = intarr(n)
                                gcol = intarr(n)
                                gval = intarr(n)
                                ;given values for given row and given column
                                ;note that row and column numbering begins at 0, but gval must be an integer from 1 to 9
                                i = 0
                                j = 0
                                while (i LT n) do begin
                                	if (gpos[j] EQ 1) then begin
                                		grow[i] = floor(j / 9.0)
                                		gcol[i] = j MOD 9
                                		gval[i] = gvalprime[j]
                                		i = i + 1
                                	endif
                                	j = j + 1
                                endwhile
                                poss = intarr(9, 9, 9)
                                for r = 0, 8 do begin
                                	for c = 0, 8 do begin
                                		for j = 0, 8 do begin
                                			poss[r, c, j] = 1
                                		endfor
                                	endfor
                                endfor
                                for i = 0, (n - 1) do begin
                                	for j = 0, 8 do begin
                                		if (j NE (gval[i] - 1)) then begin
                                			poss[grow[i], gcol[i], j] = 0
                                		endif
                                	endfor
                                endfor
                                poss = eliminator(poss)
                                if (total(poss) GT 81) then begin
                                	a = 0L
                                	b = 0L
                                	while (a LE 100L) do begin
                                		sumvals = total(poss, 3)
                                		possprime = poss
                                		r = floor(b / 81.0)
                                		c = (floor(b / 9.0)) MOD 9
                                		j = b MOD 9
                                ;		print, r
                                ;		print, c
                                ;		print, j
                                		if ((sumvals[r, c] GE 2) AND (poss[r, c, j] EQ 1)) then begin
                                ;			print, "made it into if loop"
                                ;			print, r
                                ;			print, c
                                ;			print, (j + 1)
                                			for jprime = 0, 8 do begin
                                				possprime[r, c, jprime] = delta(j, jprime)
                                			endfor
                                			possprime = eliminator(possprime)
                                			if (total(possprime) EQ 0) then begin
                                ;				print, "Possibility Eliminated!"
                                				poss[r, c, j] = 0
                                				poss = eliminator(poss)
                                			endif
                                			a = a + 1L
                                		endif
                                		if ((total(poss) EQ 81) OR (b GT 729L)) then begin
                                			a = a + 10000L
                                		endif
                                		b = b + 1L
                                	endwhile
                                endif
                                openw, lun, 'solution.txt', /get_lun
                                if (total(poss) GT 81) then begin
                                	printf, lun, "fail to completely solve; partial solution begins"
                                	for r = 0L, 8L do begin
                                		printf, lun, "beginning of row"
                                		for c = 0L, 8L do begin
                                			count = 0L
                                			p = 0L
                                			for j = 0, 8 do begin
                                				p = p + (j + 1) * poss[r, c, j] * (10L^(count))
                                				count = count + poss[r, c, j]
                                			endfor
                                			printf, lun, p
                                		endfor
                                	endfor
                                endif
                                if (total(poss) LE 81) then begin
                                	p = lonarr(9)
                                	for r = 0, 8 do begin
                                		for c = 0, 8 do begin
                                			for j = 0, 8 do begin
                                				p[r] = p[r] + poss[r, c, j] * (j + 1) * (10L^(8 - c))
                                			endfor
                                		endfor
                                		printf, lun, p[r]
                                	endfor
                                endif
                                free_lun, lun
                                end
                                12-17-10 Mohamed Bouazizi NEVER FORGET
                                Stadtluft Macht Frei
                                Killing it is the new killing it
                                Ultima Ratio Regum

                                Comment

                                Working...
                                X