Ad
  • Custom User Avatar

    Yeah, I didn't like that either, though I guess it is a valid challenge to have slightly strange specifications, as that happens sometimes in programming.

  • Custom User Avatar

    This would be interesting with arbitrary amounts (like 300, 12, and 6). null could be returned if it was impossible (like with 3, 18, and 4).

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Here's a challenging one:

    Magical loops

    Channels

    A wizard can open a mana channel to send mana to another wizard. Rules for channels:

    1. In order to open a channel, you must send at least a certain amount of mana over it.
    2. If not enough mana is sent to open the channel, all mana sent into it is lost.
    3. If enough mana is sent to open the channel, there's no mana cost for opening the channel.
    4. The channel from Jim to Sally is not the same as the channel from Sally to Jim.
    5. The channel from Jim to Sally is not the same as the channel from Jim to Stan.
    6. The channel from Jim to Sally is not the same as the channel from Stan to Sally.

    Prisms

    Each channel has zero or more ethereal prisms which transmit and multiply mana until they're used up. Rules for prisms:

    1. Each prism in a channel has a different multiplier from all other prisms in that channel.
    2. Each prism is used up after a certain amount of mana is sent through it.
    3. Without a prism, any mana sent through the channel is lost.

    Loops

    A wizard can increase their mana by relaying mana through a sequence of wizards until it gets back to the starting wizard. Rules for loops:

    1. Regardless of how many wizards are in the loop, it takes one hour to send mana through a loop.
    2. The starting wizard must be the same as the ending wizard.
    3. The starting wizard can only appear at the start or end of the loop.
    4. Wizards other than the starting wizard can only appear once in a loop, though they can appear in multiple separate loops.
    5. Multiple loops that use the same channel combine to open the channel (their mana is summed for that purpose).
    6. Multiple loops that use the same channel combine to use up that channel's prisms faster (their mana is summed for that purpose).

    Your task

    Wizards are allowed to hire assistants a little over one hour before solo battles, which is only time enough to start off zero or more loops simultaneously, but not time enough to feed the mana gained from one loop into a second round of loops.

    You've been hired! Find a set of loops that maximizes the amount of mana your wizard will have for their upcoming battle.

    Inputs

    You'll be given:

    1. Name of hiring wizard.
    2. Amount of starting mana.
    3. Channel information table:
      • channels['Jim']['Sally'].opening gives the minimum amount of mana needed to open the channel from Jim to Sally.
      • channels['Jim']['Sally'][0].multiplier gives the multiplier of the best prism in the channel from Jim to Sally (the prisms in a channel are sorted from highest multiplier at index zero to lowest multiplier at the last index).
      • channels['Jim']['Sally'][0].capacity gives the amount of mana that can enter the best prism from Jim to Sally before that prism is used up.

    Output

    Return the total mana sent through each channel.

    To send 2.5 mana from Jim to Sally to Stan to Jim and 3.5 mana from Jim to Stan to Sally to Jim, you might, with the right set of channel values, return (the format for each element is [mana, from, to]):

    [
        [2.5, 'Jim', 'Sally'],
        [1.5, 'Sally', 'Stan'],
        [4.5, 'Stan', 'Jim'],
        [3.5, 'Jim', 'Stan'],
        [8.5, 'Stan', 'Sally'],
        [4.0, 'Sally', 'Jim']
    ]
    

    If there is more than one way to get the maximum resulting mana, any maximized solution is fine. Your solution will be checked for two qualities:

    1. Is the resulting total mana the highest possible?
    2. Can the wizard actually carry out this plan without violating any rules?
  • Custom User Avatar

    Not putting a comma in front of 'and' is the work of SATAN!

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution