Code Monkey home page Code Monkey logo

Comments (8)

obiwankennedy avatar obiwankennedy commented on May 28, 2024

It is dedicated to build groups.
this command works for me but I made a fix perhaps it will fix your issue.

5d10g10

The group operator bring together die values to reach the group value (10 in previous example).
And the final result is the group count. In some games it is your success count.

result: 3 9 6 10 2
This sum of the result is 30. So you may think there is 3 group but in fact you can only build 2.
Number can only be part of one group.

10 => 1 group
+
9+6 => 1 group ( lost 5)
or
9+2 => 1 group ( lost 1)
or
6+3+2 => 1 group (lost 1)
or
9+3 => 1 group ( lost 2)

from diceparser.

robinmoussu avatar robinmoussu commented on May 28, 2024

Isn't that just integer division?

10g3 => 3 group (lost 1)

from diceparser.

obiwankennedy avatar obiwankennedy commented on May 28, 2024

No it is more complex than that.
For example:
3d10g10 => 9, 9, 2

In this result, the integer division (9+9+2)/10 is 2
But in that case, g operator must return 1.
Because:
9+9 => 1 group (lost 8)
or
9+2 => 1 group (lost 1)
or
2+9 => 1 group (lost 1)
or
9+9 => 1 group (lost 8)

When you use a number, you lost it.
So if I use one 9 and the 2. I overcome 10. So I get one success. But one 9 remains and I can't reach 10 with 9.

Same if I use both 9, 18 > 10, So I get one success. But the 2 remains and I can't reach 10 with 2.

from diceparser.

robinmoussu avatar robinmoussu commented on May 28, 2024

Ok, thanks for the precision. I think you should add this example to the documentation.

from diceparser.

robinmoussu avatar robinmoussu commented on May 28, 2024

Btw, I'm happily surprise that he is able to correctly solve the backpack problem for case like 4d2g3 with the possible corner cases {2,2,1,1} and {1,1,2,2} who both need re-ordering. I just tested it, it effectively answers 2 in both cases.

from diceparser.

obiwankennedy avatar obiwankennedy commented on May 28, 2024

I'm not quiet sure my algorithm works every time and I can't prove it is right.
but as far I had tested, it never gives me a wrong result.

It was really funny to implement, but it is a bit dirty. Perhaps there are ways to make it cleaner and more optimized

from diceparser.

robinmoussu avatar robinmoussu commented on May 28, 2024

I found a corner case (see commit 1b00f06 in the PR #15). I'm sad because this mean that I can't just copie your code in my re-write draft.

from diceparser.

obiwankennedy avatar obiwankennedy commented on May 28, 2024

I set many unit test on rolisteam code and I fix an issue about g operator. It was en endless loop in some case.

from diceparser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.