Contents tagged with .Net
-
Solving SPOJ 97. Party Schedule with Dynamic Programing and F#
The Party Schedule problem, published in SPOJ website, is about deriving an optimal set of parties that maximizes fun value, given a party budget: and parties: where each party have an entrance cost , and is associated with a fun value . In this post, we discuss how to solve this problem by first outlining an algorithm, and afterwards, by implementing that using F#. This problem is a special case of Knapsack problem. Main objective of this problem is to select a subset of parties that maximizes fun value, subject to the restriction that the budget must not exceed . More formally, we are given a budget as the bound. All parties have costs and values . We have to select a subset such that is as large as possible, and subject to the following restriction-- (read more)
-
Levenshtein Distance with F#
Definition. Edit Distance—a.k.a “Lavenshtein Distance”--is the minimum number of edit operations required to transform one word into another. The allowable edit operations are letter insertion, letter deletion and letter substitution ...(read more)
-
Collatz Problem a.k.a. 3n+1 Problem
This post focuses on Collatz problem, which is also known as, among others, the 3n+1 problem, and the Syracuse problem. Outline. We begin by introducing Collatz conjecture; afterwards, we presents an algorithm to solve the problem (UVa 100 or SPOJ 4073) published in both UVa and SPOJ. The primary advantage of having it in SPOJ is that we can use F# to derive a simple and elegant solution; at the same time, we can verify it via SPOJ's online judge... continue reading.
-
F#: Computing Length of a List (Tail Recursive)
The code snippets listed below defines a function to compute the length of a give list using F#. Note that these functions are also known polymorphic function, as they work with any type of list (as shown in the output).