Announcement

Collapse
No announcement yet.

I have written a computer program which solves Sudoku puzzles

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

  • #31
    Originally posted by KrazyHorse
    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.
    That's the attitude of the engineer. It's the easiest way to tell apart a computer scientist and a software engineer.
    "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


    • #32
      I'm a scientist when it comes to physics. I'm an engineer when it comes to cranking out code to do my bidding (in order to further physics)
      12-17-10 Mohamed Bouazizi NEVER FORGET
      Stadtluft Macht Frei
      Killing it is the new killing it
      Ultima Ratio Regum

      Comment


      • #33
        I also notice the use of debug-print statements -- do you know how to use a debugger? There's a bit of a learning curve to using it effectively (especially with archaic debuggers like gdb), but they're far more effective than debug-print statements.
        "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


        • #34
          Originally posted by KrazyHorse
          I'm a scientist when it comes to physics. I'm an engineer when it comes to cranking out code to do my bidding (in order to further physics)
          That's how things have to be done in the real world. Hardcore computer scientists are more like theoretical academics than anything else.

          I still don't think they've decided on what the optimal algorithm is for solving problems like this.

          They're also the people who cringe when you mention using FFT -- "why would you use FFT knowing it is not completely accurate?? use a DFT with high precision!"

          Anyway, that's almost a rant, but too pathetic to qualify for it, so it's just ramblings.
          "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


          • #35
            I debug using print statements. I have no clue as to the existence of any sort of utility to do that for me, nor do I know if such a utility exists in IDL. I certainly know that I have no such utility on my parents' home computer.

            This code was written in notepad, was ftped to my workstation in Baltimore (1000 km away), and was compiled and run from the IDL command-line interface in an ssh shell.
            12-17-10 Mohamed Bouazizi NEVER FORGET
            Stadtluft Macht Frei
            Killing it is the new killing it
            Ultima Ratio Regum

            Comment


            • #36
              Everybody uses FFT.

              Exact DFTs can suck my balls.
              12-17-10 Mohamed Bouazizi NEVER FORGET
              Stadtluft Macht Frei
              Killing it is the new killing it
              Ultima Ratio Regum

              Comment


              • #37
                I take it this was mostly an exercise to make yourself more familiar with IDL,which I presume is a language you use a lot in physics land?
                "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


                • #38
                  This was an exercise in reducing boredom when my fiancée and family are away at work, and I have nothing to do (for Christmas holidays). It did not make me any more familiar with IDL (which is used mainly by astrophysicists and cosmologists) since I use IDL every day. I managed to bang this code out in under 4 hours start to finish, which I'm pretty proud of.

                  Now that it is completed I will probably attempt to do some real work in my spare time, although it's a bit annoying to write code at a location remote from your compiler and the GUI IDL has.
                  12-17-10 Mohamed Bouazizi NEVER FORGET
                  Stadtluft Macht Frei
                  Killing it is the new killing it
                  Ultima Ratio Regum

                  Comment


                  • #39
                    Have to find the roots of a function which depends on 7 variables (that's what I've reduced a problem down to after a week of paperwork)
                    12-17-10 Mohamed Bouazizi NEVER FORGET
                    Stadtluft Macht Frei
                    Killing it is the new killing it
                    Ultima Ratio Regum

                    Comment


                    • #40
                      Anyhow, what's so ugly about my code?

                      I was going to reduce some of those nested loops through the use of clever functions, but when I tried that something ****ed up and I didn't have the heart to debug properly. It's not exactly computationally intense, so I bit the bullet and built those beautiful staircase structures you see...
                      12-17-10 Mohamed Bouazizi NEVER FORGET
                      Stadtluft Macht Frei
                      Killing it is the new killing it
                      Ultima Ratio Regum

                      Comment


                      • #41
                        Since we're showing weird code in ugly languages, I must share this.

                        Way back when I wa in Jr. High, I wrote an economy system for a science-fiction text-based game. It was written in "MUSHcode", which is an interpreted in-game scripting language used in a variant of MUDs (dating back to the 70s).

                        It was a huge project, took me 2 years to complete. It's still used today in modified forms in many games.

                        Here's an example: it's the skeleton code for implementing a command in the Factory objects to allocate power to producing a certain widget.

                        The full "Factory" source is here, for old times sake: http://www.oompa-loompa.net/mush/softcode/F/FACTORY.TXT

                        Code:
                        $alloc *=*:th [switch({[u(iscommod,[secure(%0)])][cand([lte(%1,[add([v(free_power)],[v(%0_alloc)])])],[gte(%1,0)])]},11,[u(fun_alloc_power,[secure(%0)],[secure(%1)])],10,[pemit(%#,Not enough power to do that.)],01,[pemit(%#,That is not a valid commodity.)],00,[pemit(%#,That is not a valid commodity.)])]
                        debugging this wants to make you point your eyes out.
                        "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


                        • #42
                          Beat this for useless: another silly IDL routine to simulate bowling scores based on several variables (e.g. strike percentage etc.)

                          Code:
                          pro scoring
                          pins = fltarr(24)
                          strike = 0.0
                          spare = 0.0
                          leftover = 0.7
                          logleft = alog(leftover)
                          number = 100000
                          score = fltarr(number)
                          for j = 0L, (number - 1) do begin
                          	ranpins = randomu(s, 24)
                          	for i = 0, 9 do begin
                          		if (ranpins[2*i] LE strike) then begin
                          			pins[2*i] = 0.0
                          			pins[2*i + 1] = 0.0
                          		endif
                          		if (ranpins[2*i] GT strike) then begin
                          			rescale = (ranpins[2*i] - strike)/(1.0 - strike)
                          			pins[2*i] = 10.0 < ceil(alog(rescale)/logleft)
                          			if (ranpins[2*i + 1] LE spare) then begin
                          				pins[2*i + 1] = 0.0
                          			endif
                          			if (ranpins[2*i + 1] GT spare) then begin
                          				rescale = (ranpins[2*i + 1] - spare)/(1.0 - spare)
                          				pins[2*i + 1] = pins[2*i] < ceil(alog(rescale)/logleft)
                          			endif
                          		endif
                          	endfor
                          	for i = 0, 9 do begin
                          		if (pins[2*i + 1] GT 0.0) then begin
                          			score[j] = score[j] + 10.0 - pins[2*i + 1]
                          		endif
                          		if (pins[2*i] GT 0.0) and (pins[2*i + 1] EQ 0.0) then begin
                          			score[j] = score[j] + 20.0 - pins[2*i + 2]
                          		endif
                          		if (pins[2*i] EQ 0.0) and (pins[2*i + 2] EQ 0.0) then begin
                          		score[j] = score[j] + 30.0 - pins[2*i + 4]
                          		endif
                          		if (pins[2*i] EQ 0.0) and (pins[2*i + 2] GT 0.0) then begin
                          			score[j] = score[j] + 20.0 - pins[2*i + 3]
                          		endif
                          	endfor
                          endfor
                          sum = total(score)
                          sumsquares = total(score*score)
                          stddev = sqrt((sumsquares - sum*sum/number)/(number - 1.0))
                          print, sum / number
                          print, stddev
                          end
                          Written during a lunch hour a few months ago
                          12-17-10 Mohamed Bouazizi NEVER FORGET
                          Stadtluft Macht Frei
                          Killing it is the new killing it
                          Ultima Ratio Regum

                          Comment


                          • #43
                            Originally posted by Asher
                            Looks like another graph coloring implementation.
                            Sudoku does't look anything like that at all.
                            (\__/) 07/07/1937 - Never forget
                            (='.'=) "Claims demand evidence; extraordinary claims demand extraordinary evidence." -- Carl Sagan
                            (")_(") "Starting the fire from within."

                            Comment


                            • #44
                              People actually do these things, you know. It's incomprehensible.
                              The genesis of the "evil Finn" concept- Evil, evil Finland

                              Comment


                              • #45
                                Ye gods. This thread is geek Mecca.
                                The genesis of the "evil Finn" concept- Evil, evil Finland

                                Comment

                                Working...
                                X