HackerRank Functional Challenges HR F#: Functions and Fractals: Sierpinski triangles The problem of drawing the Sierpinski triangles is considered to be advanced problem and it really is. The Sierpinski triangle is a fractal, constructed by recursively subdividing equilateral triangles into

HackerRank Functional Challenges HR F#: Pascal's Triangle The second problem from the Recursive subdomain is printing Pascal's Triangle for given n. Pascal's triangle is named after famous French mathematician from XVII century, Blaise Pascal. His findings on

HackerRank Functional Challenges HR F#: Computing the GCD The greatest common divisor (or GCD) of two integers is the largest positive integer that divides two of these integers. The first of the Recursion problems on the Functional track at Hackerrank is computing the GCD using the Euclidean Algorithm. In this algorythm the

HackerRank Functional Challenges HR F#: Compute the Area of a Polygon This is the last from the introductional problems in the Functional Programming domain on Hackerrank. This also might be most complicated among the introductionary problems: You are given the cartesian coordinates of a set of points in a 2D plane. When traversed sequentially, these

HackerRank Functional Challenges HR F#: Compute the Perimeter of a Polygon The problem of computing perimeter of the polygon is one of the easy problems, but it requires a bit more programming. You are given the cartesian coordinates of a set of points in a 2D plane. When traversed sequentially, these points form a Polygon,

HackerRank Functional Challenges HR F#: Functions or Not? The Functions or Not? problem is defined as follows: You are given a set of unique (x, y) ordered pairs constituting a relation. For each of these relations, identify whether they may possibly represent a valid function or not. On a new line for

HackerRank Functional Challenges HR F#: Lambda Calculus - Evaluating Expressions #5 This is even more simple than the previous one. Compute the value of λx.λy.y. The answer is 0. See the same Church numerals table.

HackerRank Functional Challenges HR F#: Lambda Calculus - Evaluating Expressions #4 This problem just checks how well you have got the idea of Church encoding while solving the previous problem. Compute the value of λx.λy.x(xy). Just by looking at the definition of the Church numerals it is easy to see that this

HackerRank Functional Challenges HR F#: Lambda Calculus - Evaluating Expressions #3 Although the Lambda Calculus - Evaluating Expressions #3 is probably the most simple of all the functional problems on Hackerrank (it is quite easy to solve it and even more easy to guess the right answer), it references the precious gem of the functional

HackerRank Functional Challenges HR F#: Lambda Calculus - Evaluating Expressions #2 The first λ-calculus evaluating expression problem was very easy. The second one is similar: Compute the value of (λx.x+1)((λy.y+2)3). Just to make a bit more fun from it, let's solve it by writing the code in F#: (fun

HackerRank Functional Challenges HR F#: Lambda Calculus - Evaluating Expressions #1 The next set of problems are about performing calculations with λ-functions. The first one is to check that the reader is confident with mixing λ-calculus and algebraic operators: Compute the value of (λx.x + 1) 3 Let's use β-reduction on this expression: (λx.x

HackerRank Functional Challenges HR F#: Lambda Calculus - Reductions #4 The last one from reduction problems is following: Reduce the following expression, using the beta-rule, to no more than one term. If the expression cannot be reduced, enter "CAN'T REDUCE". (λg.((λf.((λx.(f(xx)))(λx.(f(xx)))))g)) Well, now I

HackerRank Functional Challenges HR F#: Lambda Calculus - Reductions #3 The third λ-calculus problem is a bit more advanced (although still simple): Reduce the following expression, using the beta-rule, to no more than one term. If the expression cannot be reduced, enter "CAN'T REDUCE". ((λx.(x x)) (λx.(x x))) "beta-reduction&

HackerRank Functional Challenges HR F#: Lambda Calculus - Reductions #2 The second λ-calculus problem is following: Reduce the following to no more than one term. If the expression cannot be reduced, enter "CAN'T REDUCE". ((λx.((λy.(x y)) x)) (λz.w)) Let's reduce the expressions: Framing parentheses are not required: (λx.((λy.

HackerRank Functional Challenges HR F#: Lambda Calculus - Reductions #1 The Lambda Calculus - Reductions #1 is rather unusual. Instead of submitting the code, the required submission is a shortening of the lambda-expression. Reduce the following expression to no more than one term. ... ((λx.(x y))(λz.z)) There is a nice introduction to

HackerRank Functional Challenges HR F#: Area Under Curves and Volume of Revolving a Curve The next problem, Area Under Curves and Volume of Revolving a Curve, in mathematically advance so I introduce some therms and facts first. Numerical integration is the measuring the area between function and axis, which is done by evaluating function in many points closing

F# HR F#: Evaluating eˣ The problem Evaluating e^x: The series expansion of eˣ is given by $$1 + x + \frac{x^2} {2!} + \frac{x^3} {3!} + \frac{x^4} {4!} + ...$$ Evaluate eˣ for given values of x by using the above expansion for the first 10 terms.

F# HR F#: Updating List The problem Updating List requires learning how to generate one list from another. Update the values of a list with their absolute values. In many other programming languages the common approach is to update the array items: a[i] = abs(a[i]);, e.g.

F# HR F#: List Length The problem List Length is interesting because it can be solved using mutable counter but it also can be solved in more functional way. Count the number of elements in an array without using count, size or length operators (or their equivalents). First, let's

F# HR F#: Sum of Odd Elements The problem Sum of Odd Elements: You are given a list. Return the sum of odd elements from the given list. The solusion is basically just an invocation of the List.fold from the standard library: let f arr = arr |> List.fold (fun

F# HR F#: Reverse a List The problem Reverse a List encourages to learn List.rev. You are given a list of elements. Reverse the list without using the reverse function. The simplest implementation is not very efficient one but it works good enough to pass the tests: let rev

F# HR F#: Array Of N Elements The problem Array Of N Elements requires to write the function that returns N items. The string serialisation of the data structure should be very specific and similar to [ 1, 2, 3 ]. In the previous solutions I've generated the items using sequences. If sequences

F# HR F#: Filter Positions in a List The next one is Filter Positions in a List: For a given list with N integers, return a new list removing the elements at odd positions. There are a few methods in the Seq module that looks relevant: iteri and mapi. They both apply

F# HR F#: Filter Array The next HackerRank functional problem is Filter Array. Filter a given array of integers and output only those values that are less than a specified value X. The idea is to create a filtering function, not using the one from the standard library. With

F# HR F#: List Replication This is going to be more interesting than[1] previous[2] three[3]. Given a list, repeat each element in the list n amount of times. The first line of the input is a number specifying how many times repeat every element of the