All Questions
Tagged with functional-programming algorithm
81 questions
3
votes
2
answers
185
views
Map coloring algorithm functional implementation in python
I'm an autodidact working on map coloring algorithms with backtracking, see chapter 2 of this book.
I tested this implementation with success but I'm still unsure whether it is tricking me somewhere, ...
2
votes
1
answer
110
views
Move timestamp to the next Monday 10:01 AM [closed]
I've been battling ChatGPT for hours now and can't get satisfied with this simple algorithm in TypeScript. These two (hopefully correct) TypeScript+ReactNative solutions should move the timestamp ...
3
votes
1
answer
135
views
1
vote
2
answers
628
views
Removing Elements from an Array Based on a Second Array
I've written a function that takes two arrays of integers as input and removes all the elements in the first array that are also present in the second array. I would like to share my code with you and ...
1
vote
1
answer
62
views
Optimizing the Dig Pow function
I have written a Python function to solve the Dig Pow problem, where the goal is to find a number k such that the sum of each digit of n raised to a specific and ...
7
votes
5
answers
1k
views
Optimizing a function to find the closest multiple of 10
I have written a Python function called closest_multiple_10() which takes an integer as input and returns the closest multiple of 10. The function works as expected,...
4
votes
7
answers
305
views
Breaking a string expression in operator and operands
Requesting for a code review for a scala implementation.
Problem
Given an expression string made of numbers and operators +,-,/,* , break it in a list of Integer or ...
2
votes
1
answer
143
views
Project Euler 11 Haskell - Largest product in a grid
Intro
I have been learning haskell and functional programming using random Project Euler problems. Currently, I have solved Problem 11.
What is the greatest product of four adjacent numbers in the ...
1
vote
1
answer
832
views
Functional Fibonacci in OCaml
I'm very new to OCaml, and as an exercise I decided to implement the nth Fibonacci algorithm (return a specific Fibonacci number, given an index) in different ways, using what I've learned so far.
I ...
2
votes
3
answers
129
views
Is My Function to Find Triplets in Scala running in O(N^2)
Given the classical problem to find triplets that sum to zero in an array. Is my Scala implementation correct and executed in O(N^2)? If yes, why? Can someone make a running time analysis.
What other ...
4
votes
3
answers
2k
views
Split function using C and dynamic memory allocation
I have programmed a function to split strings, and it gives the expected output.
I am looking forward to write better code and I was told here is a good place to start.
Here's my program:
...
2
votes
1
answer
131
views
Projecteuler.net Problem 2 using collection pipeline Pattern
I solve projecteuler.net Problem 2 deferent way
Generate number from 1 to range ex 100 and get the even number
Get Fibonacci numbers from list
Reduce array
I have one problem with a large set of ...
3
votes
2
answers
5k
views
Hackerrank problem: Climbing the Leaderboard (Java)
I am solving the following Hackerrank problem: Climbing the Leaderboard.
The problem statement:
Alice is playing an arcade game and wants to climb to the top of the leaderboard and wants to track her ...
3
votes
1
answer
228
views
C++ algorithm to implement multiple operators in one
I have a class called IntMatrix which has 2 fields:
...
2
votes
1
answer
91
views
naive bayes sentiment analysis classifier in clojure
attaching my try on implementing simple naive-bayes classifier for sentiment analysis as part of learning clojure and using functional programming on ML algorithms.
I tried to invest more time in ...