Bobinas P4G
  • Login
  • Public

    • Public
    • Groups
    • Popular
    • People

Conversation

Notices

  1. La FÊe Verte (absinthe@qoto.org)'s status on Sunday, 22-Sep-2019 14:43:10 UTC La Fée Verte La FÊe Verte

    #toyprogrammingchallenge #python #lisp #c #c++ #cpp #coding #programming

    Ready for the next challenge?

    "5 Guys and a Bunch of Coconuts"

    Here is a link to the text description of the problem.

    https://git.qoto.org/Absinthe/coconuts/blob/master/coconuts.txt

    That link is to the repo, and my solution is in it as well.

    In conversation Sunday, 22-Sep-2019 14:43:10 UTC from qoto.org permalink

    Attachments


    • 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą repeated this.
    • 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą (freemo@qoto.org)'s status on Sunday, 22-Sep-2019 17:32:36 UTC 🎓 Dr. Freemo :jpf: 🇳🇱 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą
      in reply to

      @Absinthe

      I decided to take a stand at finding this solution mathematically without the brute Force approach applied in the source. I want to solve for the answer (the most efficient answer).

      So far I framed the question mathematically and reduced. All I need to do is find the smallest value of T_R that produces Integer solutions for the following 5 equations and I will have a solution... I'll be finished soon hopefully.

      In conversation Sunday, 22-Sep-2019 17:32:36 UTC permalink

      Attachments


      1. https://storage.gra5.cloud.ovh.net/v1/AUTH_011f6e315d3744d498d93f6fa0d9b5ee/qotoorg/media_attachments/files/005/480/481/original/98fcacf26dc9e002.png
    • 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą (freemo@qoto.org)'s status on Monday, 23-Sep-2019 08:19:26 UTC 🎓 Dr. Freemo :jpf: 🇳🇱 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą
      in reply to

      @Absinthe
      This was a lot of fun decided to do the problem by hand using non brute Force techniques. Attached are all the steps unused to solve the problem including the final solution on the last page.

      Total number of coconuts is 3,121 at the start. The number of coconuts they ended up with was the following: 828, 703, 603, 523, 459

      If your following the pages I attached the order in which you follow them is "knowns" then "reduce" then "final solution"

      In conversation Monday, 23-Sep-2019 08:19:26 UTC permalink

      Attachments


      1. https://storage.gra5.cloud.ovh.net/v1/AUTH_011f6e315d3744d498d93f6fa0d9b5ee/qotoorg/media_attachments/files/005/486/119/original/9809260b74550d2c.png

      2. https://storage.gra5.cloud.ovh.net/v1/AUTH_011f6e315d3744d498d93f6fa0d9b5ee/qotoorg/media_attachments/files/005/486/122/original/c7e02bea0e34d7c7.png

      3. https://storage.gra5.cloud.ovh.net/v1/AUTH_011f6e315d3744d498d93f6fa0d9b5ee/qotoorg/media_attachments/files/005/486/124/original/3eeb05a8912e0797.png
      🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą repeated this.
    • 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą (freemo@qoto.org)'s status on Monday, 23-Sep-2019 08:26:29 UTC 🎓 Dr. Freemo :jpf: 🇳🇱 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą
      • Wetrix

      @Wetrix

      Its the modulo math most people dont know. Once you understand how to solve for mosulo equations then the rest is actually kinda simple.

      @Absinthe

      In conversation Monday, 23-Sep-2019 08:26:29 UTC permalink
    • 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą (freemo@qoto.org)'s status on Monday, 23-Sep-2019 08:26:42 UTC 🎓 Dr. Freemo :jpf: 🇳🇱 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą
      • Wetrix

      @Wetrix

      Its the modulo math most people dont know. Once you understand how to solve for modulo equations then the rest is actually kinda simple.

      @Absinthe

      In conversation Monday, 23-Sep-2019 08:26:42 UTC permalink
    • 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą (freemo@qoto.org)'s status on Monday, 23-Sep-2019 08:31:48 UTC 🎓 Dr. Freemo :jpf: 🇳🇱 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą
      in reply to

      @Absinthe
      This was a lot of fun decided to do the problem by hand using non brute Force techniques. Attached are all the steps I used to solve the problem including the final solution on the last page.

      Total number of coconuts is 3,121 at the start. The number of coconuts they ended up with was the following: 828, 703, 603, 523, 459

      If your following the pages I attached the order in which you follow them is "knowns/reduce" then "All valid values" then "final solution"

      In conversation Monday, 23-Sep-2019 08:31:48 UTC permalink

      Attachments


      1. https://storage.gra5.cloud.ovh.net/v1/AUTH_011f6e315d3744d498d93f6fa0d9b5ee/qotoorg/media_attachments/files/005/486/119/original/9809260b74550d2c.png

      2. https://storage.gra5.cloud.ovh.net/v1/AUTH_011f6e315d3744d498d93f6fa0d9b5ee/qotoorg/media_attachments/files/005/486/122/original/c7e02bea0e34d7c7.png

      3. https://storage.gra5.cloud.ovh.net/v1/AUTH_011f6e315d3744d498d93f6fa0d9b5ee/qotoorg/media_attachments/files/005/486/124/original/3eeb05a8912e0797.png
      🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą, 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą, 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą and 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą repeated this.
    • 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą (freemo@qoto.org)'s status on Monday, 23-Sep-2019 10:34:21 UTC 🎓 Dr. Freemo :jpf: 🇳🇱 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą
      • Wetrix

      @Wetrix

      I used to think the same, now im not so sure.

      @Absinthe

      In conversation Monday, 23-Sep-2019 10:34:21 UTC permalink
    • 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą (freemo@qoto.org)'s status on Monday, 23-Sep-2019 10:53:03 UTC 🎓 Dr. Freemo :jpf: 🇳🇱 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą

      @Absinthe They are readable here, should be good. Let me know if you have any questions on the math

      In conversation Monday, 23-Sep-2019 10:53:03 UTC permalink
    • zingbretsen (zingbretsen@qoto.org)'s status on Monday, 23-Sep-2019 16:47:20 UTC zingbretsen zingbretsen
      • 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą

      @Absinthe @freemo I forked the repo and added my solution here: https://git.qoto.org/zingbretsen/coconuts/blob/master/coco.py

      It should solve the 5 person problem when run as-is, but it could be run for any number of people. I should probably have added that as a command line argument.

      It works backwards from possible ending amounts, but is somewhat selective in the numbers it tries. e.g., for the 5 person case, we know that the ending pile must be divisible by both 4 and 5, so the final pile will be a multiple of 20. In addition to that, we know that 5/4 + 1 of the ending pile must be divisible by 5, so 60 is the lowest number that would work for the first round of stepping backwards.

      There is a regular pattern that seems to work for all of the numbers of people I tested, not just 5, so we can reduce the search space pretty significantly. For the 5 person problem, I only have to test 13 numbers before finding the answer.

      In conversation Monday, 23-Sep-2019 16:47:20 UTC permalink

      Attachments


      🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą repeated this.
    • 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą (freemo@qoto.org)'s status on Monday, 23-Sep-2019 16:49:36 UTC 🎓 Dr. Freemo :jpf: 🇳🇱 🎓 Dr. Freemo :jpf: đŸ‡ŗđŸ‡ą
      in reply to
      • zingbretsen

      @zingbretsen

      very cool, I like how you try to limit the problem space for efficiency. Reminds me of common examples of primality checkers that use a sort of smart-brute force to reduce the problem space :)

      @Absinthe

      In conversation Monday, 23-Sep-2019 16:49:36 UTC permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • Privacy
  • Source
  • Version
  • Contact

Bobinas P4G is a social network. It runs on GNU social, version 2.0.1-beta0, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All Bobinas P4G content and data are available under the Creative Commons Attribution 3.0 license.