Re: [gcj] Re: Square Dance - WA for Test Set 2

2020-04-15 Thread Edward Lockhart
The suggestion is that you avoid using float at all (because floating point arithmetic is hard), and instead use integer arithmetic. In this case, you can do that by not computing the average. On Wed, 15 Apr 2020 at 16:42, Matt Fenlon wrote: > That fixed it! Thank you so much. Out of curiosity,

Re: [gcj] Re: Parenting Partnering Returns

2020-04-13 Thread Edward Lockhart
Did you look at the example I posted? On Mon, 13 Apr 2020, 17:09 AC, wrote: > Hi Matt, > > Thanks for the response > So I revisited the problem after reading the many posts. > Solution below is working and tested. > For each case: > 1. take input > 2. sort the input , but keep the original

Re: [gcj] Re: Parenting Partnering Returns

2020-04-10 Thread Edward Lockhart
The greedy approach you're using doesn't handle all cases, eg 0 1 5 6 0 2 1 6 On Fri, 10 Apr 2020, 16:55 rajeswara reddy, wrote: > > Can anyone find what's wrong in my program for parenting partners returns > problem > > z=int(input()) > for zz in range(1,z+1): > n=int(input()) > l=[]

Re: [gcj] Find maximum sum in an array provided that no elements in a combination can have common digits

2019-05-29 Thread Edward Lockhart
You can do it with a single pass through the list, maintaining the maximum sum with every possible set of permitted digits (1024 values). On Wed, 29 May 2019, 00:03 akshit bhatia, wrote: > Hello, > > I know this is not the right community to ask this coding problem, but > please if possible,

Re: [gcj] 1C 2016 Problem A

2016-05-08 Thread Edward Lockhart
The analysis covers this case. When there's AABB, you have to take 2 out. On Sunday, 8 May 2016, Eric Mordezki wrote: > Could I get some help as to why my algorithm couldn't solve this exercise? > > The problem was to figure a way to let people out without having a party >

Re: [gcj] I found solution but I can't prove correctness.

2016-03-26 Thread Edward Lockhart
Correct. This is proved in the contest analysis. https://code.google.com/codejam/contest/32016/dashboard#s=a=0 > On 26 Mar 2016, at 11:33, Seung Youp Oh wrote: > > https://code.google.com/codejam/contest/32016/dashboard#s=p0 > > I'm solving this problem and found a solution

Re: [gcj] a Linear Programming approach to problem B of round 2

2015-06-09 Thread Edward Lockhart
Yes - see for example linguo's solution. He solved bilingual as an integer linear programming problem too. Edward On 9 Jun 2015, at 21:09, bigOnion haibren...@gmail.com wrote: During round 2 I recognized that problem B can be described as a Linear Programming problem. There are two

Re: [gcj] Round 1A Problem C Logging: The size of eps

2015-04-19 Thread Edward Lockhart
For any pair of trees, drawing the line connecting them and then clearing all trees on one side of the line will put both of them on the boundary. Checking all ways to do that is n^3 naively but can be made n^2 log n by sorting the trees clockwise around the tree being considered. Edward On

Re: [gcj] Please help me with the Small B. Getting wrong.

2015-04-12 Thread Edward Lockhart
Try a single stack of 9 pancakes. Edward On 12 Apr 2015, at 09:10, utkarsh gupta guptautkarsh2...@gmail.com wrote: For small B, what I did was to first divide all the maximum sized pancakes to half giving the extra half to empty plates.Now it will be take special minutes equal to the

Re: [gcj] Problem A solution has a bug? Please correct me where I was wrong. Thank you.

2014-10-13 Thread Edward Lockhart
Perhaps you could list the 4 moves which you believe solve the particular case? Edward On 13 Oct 2014, at 18:46, Shenghua Song songsheng...@gmail.com wrote: I'm new to Google Code Jam. I am very excited and thank you for providing me this opportunity to learn coding from world top

Re: [gcj] Any hint to solve this easy problem

2013-11-15 Thread Edward Lockhart
This general approach will work if you are careful about defining what your variables mean. You may find writing explicit loop invariants helpful. To progress though, you'll need to switch from direct simulation of this sort to analysing the problem with pencil and paper, finding a simpler way