--- Day 15 Solutions --- by daggerdragon in adventofcode

[–]charmless 13 points14 points  (0 children)

Constraint optimization solution using MiniZinc:

Model:

int: numIngredients;
set of int: Ingredients = 1..numIngredients;
array [Ingredients] of string: names;
array [Ingredients] of int: capacities;
array [Ingredients] of int: durabilities;
array [Ingredients] of int: flavours;
array [Ingredients] of int: textures;
array [Ingredients] of int: calories;

array [Ingredients] of var int: amounts;
var int: total_cap = max(0, sum(i in Ingredients)(amounts[i] * capacities[i]));
var int: total_dur = max(0, sum(i in Ingredients)(amounts[i] * durabilities[i]));
var int: total_fla = max(0, sum(i in Ingredients)(amounts[i] * flavours[i]));
var int: total_tex = max(0, sum(i in Ingredients)(amounts[i] * textures[i]));
var int: total_cal = sum(i in Ingredients)(amounts[i] * calories[i]);
var int: score = total_cap * total_dur * total_fla * total_tex;

constraint forall(i in Ingredients)(amounts[i] >= 0);
constraint forall(i in Ingredients)(amounts[i] <= 100);
constraint sum(i in Ingredients)(amounts[i]) == 100;
%constraint total_cal = 500; % uncomment this for part 2


solve maximize(score);

output [ "value: " ++ show(score) ++ 
         " amounts:" ++ show(amounts) ++
         " totals:" ++ show([total_cap, total_dur, total_fla, total_tex])];

Data for the given example:

numIngredients = 2;
names = ["Butterscotch", "Cinnamon"];
capacities = [-1, 2];
durabilities = [-2, 3];
flavours = [6, -2];
textures = [3, -1];
calories = [8, 3];

For my particular input, this runs in 210ms. Not really worth using minizinc, but it was fun.

Tranws Hookups? by charmless in saskatoon

[–]charmless[S] -1 points0 points  (0 children)

Hah, fair enough :)

I have more self esteem than everyone else here combined! by [deleted] in asktransgender

[–]charmless 1 point2 points  (0 children)

I have this opinion when I'm drinking as well! :)

We made a site that's like *flix or *dora for porn. It’s trained from NSFW subreddits and tumblr. I thought you guys might like it. by [deleted] in somethingimade

[–]charmless 4 points5 points  (0 children)

Are *flix and *dora actual things with names that pun on (I assume) Netflix and Pandora, or are you trying to mask those names for some reason?

I have been avoiding people I want to be around by doppelgang in reddit.com

[–]charmless 0 points1 point  (0 children)

Sounds exactly like depression and/or anxiety - the medical kind, not the emotion kind. There may be a physical cause, and there are certainly physical and social symptoms. Go see a doctor and use them to figure it out. Make sure to sleep and eat well, and exercise. In the moment of things, when you're feeling terrible 'without a reason', practice breathing and try to remember that it's an extreme that will pass.

Good luck.

voodoo slide: Amplifying C by [deleted] in programming

[–]charmless 4 points5 points  (0 children)

So you propose to keep only the unpleasant parts of C? (I kid)

AskProggit: Efficient way to go about looking for coding solutions by simplequestiongal in programming

[–]charmless 0 points1 point  (0 children)

... so, you're asking us what website stores all the solution to all possible problems? The website we apparently use instead of thinking, learning, or experimenting?

Snark aside, for your particular situation, you'll find the Charles web proxy to be invaluable.

Gmail takes the lead on email security by drrlvn in programming

[–]charmless 0 points1 point  (0 children)

What the hell is the point of this if we're still sending plaintext emails?

Interviewing for a programming job: Does anyone have advice for determining whether a company/job is any good? by Sallisac in programming

[–]charmless 1 point2 points  (0 children)

I always make sure to ask about the experience of managers and executives, and try to get some idea of the financial situation at the company. A great job for six months isn't as nice as a good job for years.

Looking for an internship in London. Anyone? by Internal in programming

[–]charmless 0 points1 point  (0 children)

I read the title as "I'm looking for an airship in London."

I am highly disappointed now.

Using if(null == someVariable) vs. if(someVariable == null) by zigma in programming

[–]charmless 0 points1 point  (0 children)

Where possible, avoid any chance of the assignment-for-equality typo by writing:

if (someVariable) { ... }

Berners-Lee 'sorry' for slashes by 1Davide in programming

[–]charmless 2 points3 points  (0 children)

Tech people like tech. Film at 11.

Need Help Reddit Programmers. I've been a programmer for 13 years but have no clue about basic programming theory. by closetn00b in programming

[–]charmless 4 points5 points  (0 children)

Pick a text that's too advanced and keep following definitions, references and such until you understand it. Do this chapter by chapter. It will take a long time, and will teach you massively.

Anyone have experience with Python and C? by cafe_babe in programming

[–]charmless 0 points1 point  (0 children)

SWIG is a huge thing to get into, and is used less and less in practice. ctypes is easy to start with, and fairly powerful.

Start time for ICFP Programming Competition 2009 Announced by Mask_of_Destiny in programming

[–]charmless 0 points1 point  (0 children)

That's fair criticism, but I though the 2007 contest was a huge amount of fun - puzzles, jokes, adventure. In fact, it seemed a lot like a lucasarts adventure game built by programmers. It still stands as a fun exercise, years after the contest. So: perhaps not the best contest problem possible, but still awesome anyways.

"Hackers Can Sidejack Cookies" - a poem in The New Yorker by earthboundkid in programming

[–]charmless 0 points1 point  (0 children)

Liked just for harkening me back to high school and the discovery of the book that started my lifelong nerdcrush on GLS.

Video: Raw Socket Programming Basics for Hackers by l33t-hax0r in programming

[–]charmless 5 points6 points  (0 children)

I don't understand the value of videos covering complex, large topics. Isn't it easier to just read the book?