Posts

Sorted by New

Wiki Contributions

Comments

Sorted by
yernab42

First time poster/D&D Sci player - thanks so much for making this! I'm a complete novice at data science/stats, mostly just the usual sort of intuitions you get from the occasional Excel munging at $corporate_job. I just discovered D&D Sci a day or two ago, and picked this one for my first puzzle from the index because it was marked as high-quality and middle-of-the-road difficulty.

While I may not have much DSci experience, I do have a lot of experience solving programming puzzles in a programming language called APL - think of it like NumPy (so array/tensor oriented) with a longer/weirder heritage that you primarily interact with by typing (vaguely runic?) symbols. It's REPL-based, so it's quick to try different ideas, and it has a long-standing reputation as being good for "data exploration". I'll also say that if you want to match the aesthetics of casting data-analysis spells for an archmage, typing inscrutable wizard-ish symbols into a REPL feels on-point. :)

As an example, assume we've already defined a vector of strings r that contains the unique result names, and a vector of boolean matrices rpt ("result partitioned table", naming things is hard) where each matrix consists of the rows in the input filtered to the corresponding result. The following line

  • AND-reduces each matrix in rpt to a boolean vector where 1 means an ingredient was used in every row (call these "required ingredient pairs") and catenates these into a single matrix.
  • Constructs a larger boolean matrix where each row is a possible combination of required ingredient pairs.
  • For each matrix in rpt, analyzes each row and determines whether it contains a required ingredient pair combination.
  • Calculates the percentage of rows that contain a required ingredient pair combination, and renders this info as a 2-column matrix where the left column consists of the unique result names.

     r,⍪100×rpt{(+/÷≢)∨/4=+/⍺∧⍤1⍤1 2⊢⍵}¨⊂x⌿⍨4=+/x←,[1 2]∨⍤1⍤1 2⍨↑∧⌿¨rpt 

    As might be expected, this gives 100% for "Mutagenic Ooze" and 0% for "Acidic Slurry".

APL is also quite fast (especially on large boolean matrices!), and the above line returns in 47ms on my machine. Nice to be able to try a bunch of random analyses quickly.

I recorded my live solution of this and posted it on my APL-focused Youtube channel here in case you want to see a DSci novice flail around for ~2 hours in this weird language. If there's some rule against links or self-promotion or something (especially for a fresh account), let me know and I'll remove the link. Actually, I'll take feedback on any part of this post. :)

Anyway, on to the data analysis journey:

A simple first thing to do seemed to be partitioning the rows by result, allowing me to do a bunch of result-specific analyses. Looking at the average ingredient count for each result, I noticed that "Mutagenic Ooze" and "Magical Explosion" had the highest avg ingredient counts, and "Inert Glop" and "Acidic Slurry" had the lowest. Hrmm... 

Also, partitioning the "Success?" column and looking at unique results for each partition reveals that, indeed, the wizard has 4 unique failure modes, and a bunch of potions that constitute a successful attempt. 

Next, I looked at at the percentages for occurrences of each ingredient for each result, sorted from most-common to least-common. This showed that each potion had 2 ingredients that occurred 100% of the time, so from this point forward we have the concept of "required ingredients". 

Also, no failure had an ingredient that occurs 100% of the time, meaning that adding an ingredient in and of itself doesn't automatically trigger any failure. 

Scrolling through the data, I noticed that the most common ingredients for "Magical Explosion" were all "fantasy ingredients", while the most common ingredients for "Inert Glop" were all "real ingredients". I got a bit lucky here (or maybe the data was constructed this way?) that the sorted occurence percentages exactly partition the ingredient list into fantasy/real - if there had been any overlap, I might not have noticed this. Going in blind, I was kind of thinking whether there was some subset of ingredients that would always (or at least strongly correlate) with some failure, but... uh... 

+/!∘24¨⍳24 

With 167,77,215 possible subsets this would have taken a while to analyze. So, lucky that I noticed this! 

With the hint of fantasy items, I was able to look at the rows for each result and see the percentage occurence of each result for each count of included fantasy items. This laid out the rules for avoiding "Magical Explosion" and "Inert Glop", so from this point I knew I wanted 3 fantasy ingredients in addition to the 2 required ingredients for Barkskin Potion. 

Still don't know what causes "Mutagenic Ooze" or "Acidic Slurry", so next I looked at percentages of occurrences of pairs of ingredients for each result (being reluctantly ready to look at 3-sets, 4-sets etc.). Looking at the big matrix of data, the number "0" stood out to me, and focusing only on those we see there are a bunch of pairs that never occur for "Acidic Slurry". Noting that the required ingredients for Barkskin Potion were in that list, I was able to match it to the list of required ingredients overall. So, now we know that to avoid "Acidic Slurry", you just need to include some required ingredient pair. 

Seeing as how "Magical Explosion" and "Inert Glop" are kind of opposites, I wondered if "Mutagenic Ooze" was the opposite of "Acidic Slurry" in some way. I messed up the analysis here - idea was to check occurrences of all possible pairs of required potion ingredients (basically my sample line above), but I did it wrong in the heat of the moment. Still, I was able to see that each pair of required potion ingredients occurred at least once for "Mutagenic Ooze", and this didn't happen for any other result except for "Magical Explosion", so I figured it was close enough to being an opposite of "Acidic Slurry" and I was just missing something. 

So, time to formulate a guess! Take the 2 required ingredients for Barkskin Potion, add 3 fantasy items that the mage has available, and avoid including required ingredients for any other potion. Checked the solution page and... success!

Thanks again for putting this together, it was fun! I may do some other puzzles in the series, it's probably good to build this type of skillset in any case. :)