Code Golf: All +-*/ Combinations for 3 integers

Perl 130 chars So long as external libraries are permitted: use Algorithm::Permute”permute”; permute{for$x(@a=qw(+ – / *)){for$y(@a){$_=”@ARGV”;s/ /$x/;s/ /$y/;printf” $_ = %.0f”,eval}}}@ARGV 2nd newline is significant. Without a module, and assuming that all three inputs are distinct, here’s another solution: @n=& ARGV; @o=( q[+], “-“, q{/}, ‘*’ );; for$ {a}(@ n){ for $b(@n){for$c(@ {n}){ for $x( … Read more

Do cryptographic hash functions reach each possible values, i.e., are they surjective?

First, let’s point out that SHA-256 does not accept all possible binary strings as input. As defined by FIPS 180-3, SHA-256 accepts as input any sequence of bits of length lower than 2^64 bits (i.e. no more than 18446744073709551615 bits). This is very common; all hash functions are somehow limited in formal input length. One … Read more

Compute the ‘elbow’ for a curve automatically and mathematically

I created a Python package that attempts to implement the Kneedle algorithm. To recreate the function above and detect the point of maximum curvature: x = range(1,21) y = [0.065, 0.039, 0.030, 0.024, 0.023, 0.022, 0.019, 0.0185, 0.0187, 0.016, 0.015, 0.016, 0.0135, 0.0130, 0.0125, 0.0120, 0.0117, 0.0115, 0.0112, 0.013] kn = KneeLocator( x, y, curve=”convex”, … Read more

Direction of two points

Answer 1: it is Vector(x2-x1,y2-y1) Answer 2: Normalizing means to scale the vector so that its length is 1. It is a useful operation in many computations, for example, normal vectors should be specified normalized for lighting calculations in computer graphics. The normalized vector of v(x,y) is vn(x/Length(v), y/length(v)). HTH

Why do programming languages round down until .6?

First off, in most languages an undecorated constant like “1.55” is treated as a double precision value. However, 1.55 is not exactly representable as double precision value, because it doesn’t have a terminating representation in binary. This causes many curious behaviors, but one effect is that when you type 1.55, you don’t actually get the … Read more

Prerequisites Needed to Read Books on Neural Networks (and understand them)

If you want a list of college courses that you’ll need to understand the book, here it is: Calculus (I, II and III) Differential Equations Linear Algebra Statistics (or a good covering of Bayes) However, I did just fine in my NN classes without Diff. Eq. and just had to look up concepts I hadn’t … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)