All Questions
Tagged with programming-challengefunctional-programming
111 questions
26votes
3answers
2kviews
Project Euler Problem 2 in Clojure
I am in the process of learning Clojure. I am fairly new to functional programming and would like to know if my code smells or if there are any performance implications with my approach. ...
15votes
4answers
1kviews
Project Euler 6: Difference between sum of squares and square of sum
I've created a (very) simple solution for Project Euler problem 6: Project Euler Problem 6: Sum square difference The sum of the squares of the first ten natural numbers is, $$ 1^2 + 2^2 + ...
11votes
2answers
1kviews
Sum of Even Fibonacci numbers in functional programming
I want to solve this problem in functional programming (fp) way only. Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 ...
10votes
2answers
696views
Array duplicate removal for duplicates exceeding `N`-number
I recently encountered a front-end interview coding challenge question that required one to create a function which returned an array that excluded numbers that occurred more than ...
10votes
3answers
2kviews
Find the majority element, which appears more than half the time
The task: Given a list of elements, find the majority element, which appears more than half the time (> floor(len(lst) / 2.0)). You can assume that such element exists. For example, ...
9votes
1answer
604views
Kattis problem Amanda Lounges
I wrote this solution to Kattis problem Amanda Lounges in Scala. The code is written to solve a graph theory problem where it will read in a list of edges from stdin and try to compute the minimum ...
8votes
4answers
7kviews
Swap even/odd characters
I wrote some code to solve this problem https://www.hackerrank.com/challenges/string-o-permute which basically states: take an even length string and swap all the even indexed characters. For example ...
8votes
1answer
2kviews
Merge Intervals in JavaScript
This is a task taken from Leetcode - Given a collection of intervals, merge all overlapping intervals. Example 1: ...
8votes
1answer
888views
"Curious Numbers" (HackerRank PE 34)
I was inspired by a certain recent question to try my hand at this challenge: Project Euler #34: Digit factorials \$19!\$ is a curious number, as \$1!+9!=1+362880=362881\$ is divisible by \$19\$. ...
7votes
4answers
856views
Finding the sum of all the multiples of 3 or 5 below 1000, using list comprehension
I'm trying to compare my own implementation with another solution of Project Euler problem #1, which uses a list comprehension: ...
7votes
1answer
4kviews
Given a string containing just parentheses, determine if the input string is valid
The task is taken from leetcode Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: ...
6votes
4answers
3kviews
Find all letter Combinations of a Phone Number
The task is taken from LeetCode Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just ...
6votes
3answers
561views
Create an array with the highest values from each array
I am working my way through FreeCodeCamp's Javascript challenges and Return Largest Numbers in Arrays took me a minute. In this one the goal was to create an array with the highest values from each ...
6votes
3answers
298views
Number of Chocolates to Gluttonize in Clojure
I’ve been dabbling in Clojure by solving programming puzzles. This particular puzzle is from HackerRank, with the objective of figuring out how much chocolate one could eat given three parameters: ...
6votes
3answers
752views
Funny string python solution
Problem Statement Suppose you have a string \$S\$ which has length \$N\$ and is indexed from \$0\$ to \$N−1\$. String \$R\$ is the reverse of the string \$S\$. The string \$S\$ is funny if the ...