r/dailyprogrammer • u/rya11111 3 1 • May 25 '12
[5/25/2012] Challenge #57 [easy]
Your task is to implement Ackermann Function in the most efficient way possible.
Please refer the wiki page link given for its explanation.
Since many did not like the previous challenge because it was quite unsatisfactory here is a new challenge ...
Input: A sequence of integers either +ve or -ve
Output : a part of the sequence in the list with the maximum sum.
UPDATE: I have given some more info on the [difficult] challenge since it seems to be very tough. you have upto monday to finish all these challenges. pls note it :)
2
u/PenguinKenny May 25 '12
Right, well I gave it a go in VB.NET and it works fine for the smaller results, but I get a StackOverflowException with the larger (such as 4,1)
EDIT: Never mind, the challenge was changed. I'm working on the other one now.
5
u/emcoffey3 0 0 May 25 '12
5
u/ashashwat May 25 '12
Time complexity = O(n), Uses Dynamic programming ( Kadan's algorithm )
4
u/bigronaldo May 25 '12
C#
4
u/SwimmingPastaDevil 0 0 May 25 '12 edited May 26 '12
2
u/MusicalWatermelon May 25 '12
Had to do this in class
http://pastebin.com/bqfsF2LS
2
u/[deleted] May 25 '12
Java 7
package com.dailyprogramming.problems;
import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry;
public class MaxSumSeries {
}
1
u/itstriz May 25 '12
PHP
1
u/brbpizzatime May 25 '12
If Java had a sum()-function like Python, this would've been a cakewalk :(
1
u/bh3 May 26 '12
Hopefully this should work, idea is subsets should only be added together if they are positive, scan left to right; just a hunch. Python:
1
u/xjtian May 26 '12
Here's my first shot at a challenge in this subreddit. I'm new to python, but I've been doing Java in high school for 3 years.
Python:
1
u/Medicalizawhat May 26 '12 edited May 26 '12
C first challenge. Dies on a(4,2):
I don't really understand what that's all about but anyway..
Ruby second challenge:
1
u/[deleted] May 27 '12 edited May 27 '12
First time to try these callenges. too ashamed to post my nooby long code after viewing the solutions presented.
EDIT: ah what the hell..
1
u/leftplusright May 28 '12 edited May 30 '12
Python:
0
u/[deleted] May 25 '12
[deleted] — view deleted comment