Y'all are surprising me with your programming opinions

Then again, JavaScript or whatever apparently has a Math.max function, while C doesn't

@wallhackio Are you referring to yourself or to me or to us all?

@vaporeon_ I'm referring to anyone who writes code for money instead of writing code for fun

@vaporeon_ this is not a slight on Holly. i hope that is clear. she does code golf so you know she actually likes coding for the hell of it

@wallhackio @vaporeon_ oh yeah all this goes out the window when you're golfing. sometimes it's fun to let loose and write some horseshit

@monorail @vaporeon_ my worst code practices occur when i hack a solution to a challenging data structures/algorithms problem

@wallhackio How can you have bad code practices when there's no such thing as good Java code, it's all terrible

@vaporeon_ I've done DS&A problems in JavaScript and written some nightmarish oneliners doing that

@vaporeon_ I know how this is gonna go. I will show it to you and then you'll be like, wait this is cool I like it :)

@vaporeon_ look at this beauty:

var change = function(amount, coins) {
for (var i = 0, m = new Array(coins.length); i < coins.length; ++i) m[i] = new Array(amount + 1).fill(0), m[i][0] = 1;

for (var r = coins.length - 1; r >= 0; --r) for (var c = 1; c <= amount; ++c) for (x = r; x < coins.length; ++x) if (c - coins[x] >= 0) m[r][c] += m[x][c - coins[x]];

return m[0][amount];
};

@wallhackio What is an Array and why are we using that instead of just malloc-ing (or calloc-ing, if we want 0-initialization) some space? Also, what's up with the var, does it not have data-types like in C? Or is var like C++ auto?

@aescling @wallhackio Oh

Sorry, I didn't check which thread this was replying to, and thought this was an example of Go...

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.