Announcement

Collapse
No announcement yet.

Let's make a deal!

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

  • #76
    Originally posted by ColdWizard View Post
    Can I claim the person I stole the goats from is my wife?
    filing a false police report is a sersiou crime
    To us, it is the BEAST.

    Comment


    • #77
      Originally posted by Hauldren Collider View Post
      This is trivially solvable through brute force, although I am sure there are more elegant solutions. It just isn't worthwhile to try to find them.

      Am currently writing a short solution in python.
      Enumerate the primes with the sieve of eratosthenes, stick them in a hash table, and test their rotations to see if they're in the hash table. And then eat a goat.
      <p style="font-size:1024px">HTML is disabled in signatures </p>

      Comment


      • #78
        Originally posted by loinburger View Post
        Enumerate the primes with the sieve of eratosthenes, stick them in a hash table, and test their rotations to see if they're in the hash table. And then eat a goat.
        LOL spoilers.

        Damn, now I'm too lazy to finish my solution. I actually didn't know about the sieve of eratosthenes, so I was just doing modulo every number less than x to check primality. Yours is a very good way of doing it though.

        I'll try doing it this way now. Will post results when finished.
        If there is no sound in space, how come you can hear the lasers?
        ){ :|:& };:

        Comment


        • #79
          The sieve of eratosthenes is a good thing to know because for some reason job interviewers absolutely love to ask prime number enumeration questions.
          <p style="font-size:1024px">HTML is disabled in signatures </p>

          Comment


          • #80
            Just like you should always be able to quickly explain quicksort. I can explain how quicksort works very succinctly and answer questions about it but if you actually asked me to write an implementation I'd probably just **** it up because the devil is very much in the details.

            Comment


            • #81
              OK, that took longer than it should have because I took a break to eat, but here's my solution:

              Code:
                1 #simple circular prime solver
                2 def eratosthenes(max):
                3     nums = []
                4     primes = []
                5     for n in range(0, max):
                6         nums.append([n, 0])
                7     #edge cases
                8     nums[0][1] = -1
                9     nums[1][1] = -1
               10     #the sieve
               11     for n in range(2, max):
               12         if nums[n][1]: #status has been assigned
               13             continue
               14         for m in range(n, max, n):
               15             nums[m][1] = -1
               16         nums[n][1] = 1
               17         primes.append(n)
               18     return (nums, primes)
               19
               20 def circulate(x, nums):
               21     #make a list of the digits
               22     y = list(str(x))
               23     for n in range(0, len(y)-1):
               24         #rotate digits
               25         y.insert(0,y.pop())
               26         #convert back to int
               27         z = int("".join(y))
               28         if(nums[z][1] != 1):
               29             return False
               30     return True
               31
               32 (nums, primes) = eratosthenes(1000000)
               33 t=0
               34 a=[]
               35 for p in primes:
               36     if circulate(p, nums):
               37         a.append(p)
               38         t+=1
               39 print "Number of circular primes: " + str(t)
               40 print "Primes: " + str(a)
               41
              And the result:

              Number of circular primes: 55
              Primes: [2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, 97, 113, 131, 197, 199, 311, 337, 373, 719, 733, 919, 971, 991, 1193, 1931, 3119, 3779, 7793, 7937, 9311, 9377, 11939, 19391, 19937, 37199, 39119, 71993, 91193, 93719, 93911, 99371, 193939, 199933, 319993, 331999, 391939, 393919, 919393, 933199, 939193, 939391, 993319, 999331]
              Did I get it right, loinburger?
              If there is no sound in space, how come you can hear the lasers?
              ){ :|:& };:

              Comment


              • #82
                Looks reasonable to me. My usual practice with Project Euler puzzles is to say "I probably could(n't) solve that" and to leave it at that.
                <p style="font-size:1024px">HTML is disabled in signatures </p>

                Comment


                • #83
                  I think that over 90% of the real-life "puzzles" I've seen involve either deadlocks or race conditions or some combination of the two, and those are only really an issue if I can't switch to using optimistic concurrency for some reason (usually because my boss nixes the change because (s)he doesn't understand optimistic concurrency).
                  <p style="font-size:1024px">HTML is disabled in signatures </p>

                  Comment


                  • #84
                    Originally posted by loinburger View Post
                    I think that over 90% of the real-life "puzzles" I've seen involve either deadlocks or race conditions or some combination of the two
                    Why everyone should take Operating Systems or some systems programming course

                    Comment


                    • #85
                      Originally posted by regexcellent View Post
                      Why everyone should take Operating Systems or some systems programming course
                      I'm going to interpret "everyone" as meaning "everyone", and agree, even though you probably mean "everyone in compsci".
                      <Reverend> IRC is just multiplayer notepad.
                      I like your SNOOPY POSTER! - While you Wait quote.

                      Comment


                      • #86
                        I'd rather that compsci students were taught how to program using lock-free concurrency - the code scales better and is ten times easier to maintain.

                        And I'd rather that everybody not have to take an operating systems course - it's already a pain in the ass fixing my relatives' computers without their knowing how to use the fiddly bits in Windows.
                        <p style="font-size:1024px">HTML is disabled in signatures </p>

                        Comment


                        • #87
                          Originally posted by loinburger View Post
                          The sieve of eratosthenes is a good thing to know because for some reason job interviewers absolutely love to ask prime number enumeration questions.
                          Thank you. That was a pleasant accumulation of knowledge.
                          No, I did not steal that from somebody on Something Awful.

                          Comment


                          • #88
                            OS doesn't teach you about the fiddly bits in Windows. It teaches systems programming.

                            xpost
                            If there is no sound in space, how come you can hear the lasers?
                            ){ :|:& };:

                            Comment


                            • #89
                              Originally posted by gribbler View Post
                              What sort of microbrew would Dinner recommend to accompany goat meat?
                              Now that is a worthy question. I shall have to ruminate on it a while. Get it? Ruminate?
                              [/pun]
                              Last edited by Dinner; March 27, 2013, 02:14.
                              Try http://wordforge.net/index.php for discussion and debate.

                              Comment


                              • #90
                                Originally posted by Braindead View Post
                                No. Dinner threadjacked it into a goateating thread. Dinner likes food threads.

                                You should move away from the grazing goats, very dangerous in case of a marine invasion.
                                Oh, and technically Loinburger brought up eating goats before I did.
                                Try http://wordforge.net/index.php for discussion and debate.

                                Comment

                                Working...
                                X