Snippets tagged math

  • Distance between two 3D segments

    The function segmentSegment takes 2 segments (starting and ending points) and computes the shortest distance between them. The function returns a starting and ending point of the shortest segment between the two segments. The function uses a triple type but can be easily rewritten to work with any other type (vector etc).

    23 people like this
    Posted: 1 years ago by Oldrich Svec

  • Function to get all possible combinations

    Function to get all possible combinations of list items. There are some Euler problems (like 77 & 78) to get total amounts. But e.g. for some card game implementations you will need the real items.

    27 people like this
    Posted: 1 years ago by Tuomas Hietanen

  • Pascal's Triangle

    Returns the pascal triangle in a 2D list . This snippet computes rows translating the 'visual' method taught at school into Lists and the usage of map2 function. It takes almost 5 seconds to compute 5000 rows.

    12 people like this
    Posted: 1 years ago by Horacio Nuñez

  • How to write a financial contract

    Implements the theory from 'How to write a financial contract' by S.L Peyton Jones and J-M Eber

    7 people like this
    Posted: 1 years ago by Ademar Gonzalez

  • Calculating the angle between the hour and minute hand

    This is a response to a Google interview question that someone encountered. A friend of mine was recently hired there and I've heard some thrilling stories of their interview process. So every now and then, I plan to code up a response to one of the hoards of interview questions they have.

    0 people like this
    Posted: 10 months ago by Antwan "A-Dubb" Wimberly

  • Calculating the angle between the hour and minute hand redux

    This snippet introduces a further subtlety into the previous posting, whereby the intra-hour movement of the hour hand is captured.

    0 people like this
    Posted: 10 months ago by HP

  • Prime numbers - Sieve of Eratosthenes

    Basic prime number generator

    1 people like this
    Posted: 8 months ago by d95danb

  • Prime testing

    Simple check if a number is prime. See also http://fssnip.net/2w.

    0 people like this
    Posted: 8 months ago by d95danb

  • RSK algorithm

    Implements a bijective mapping between permutations and pairs of standard Young tableaux, both having the same shape. http://en.wikipedia.org/wiki/Robinson%E2%80%93Schensted_correspondence

    4 people like this
    Posted: 7 months ago by Ademar Gonzalez

  • Compute CC.Net build statistics

    Written against CruiseControl.NET v1.5. Queries a CruiseControl.NET server for a project list and then computes min, max, average, and standard deviation of the build durations based on the statistics.csv CC.NET maintains.

    3 people like this
    Posted: 6 months ago by Matt Wilson

  • XNA's Vector3 with units of measure

    A vector type with units of measure built on top of XNA's Vector3. Not complete, the point is mainly to show how to use generic units of measure to adapt an existing type.

    7 people like this
    Posted: 4 months ago by Johann Deneux

  • Discrete Fréchet Distance

    Compute the Discrete Fréchet Distance between two arrays (which may be of different lengths). Based on the 1994 algorithm by Thomas Eiter and Heikki Mannila. Not extensively tested, so use at your peril! (This version with some small fixes.)

    0 people like this
    Posted: 3 months ago by Kit Eason

  • Monotone Chain Convex Hull Algorithm

    Andrew's Monotone Chain Convex Hull algorithm: given points in 2 dimensions, determine their convex hull by constructing the upper and lower hull.

    3 people like this
    Posted: 1 months ago by Mathias Brandewinder