--- /dev/null
+#!/usr/bin/perl -w
+
+use v5.16;
+use strict;
+
+my %prop;
+while (<>) {
+ my ($name) = /\A(\w+):/;
+ my @vals = /(-?\d+)/g;
+ $prop{$name} = \@vals;
+}
+
+my $max;
+
+sub addprop {
+ my ($amounts, $rem, $rest) = @_;
+
+ if (!@$rest) {
+ for my $p (keys %prop) {
+ print "$p=$amounts->{$p}, ";
+ }
+ print "\n";
+ my $mul = 1;
+ for my $t (0 ..3) {
+ my $sum = 0;
+ for my $p (keys %prop) {
+ $sum += $prop{$p}->[$t] * $amounts->{$p};
+ }
+ $sum = 0 if $sum < 0;
+ $mul *= $sum;
+ }
+ $max = $mul if !$max || $mul > $max;
+ } else {
+ for my $i (0 .. $#$rest) {
+ my @nr = @$rest;
+ my ($ing) = splice @nr, $i, 1;
+ my $min = @nr ? 0 : $rem;
+ for my $a ($min .. $rem) {
+ my %na = %$amounts;
+ $na{$ing} = $a;
+ addprop(\%na, $rem-$a, \@nr);
+ }
+ }
+ }
+}
+
+addprop({}, 100, [ keys %prop ]);
+
+say $max;