Manipulative Numbers
Manipulative Numbers
+ 0 comments Why the second test case answer is 25 ?
May be I understood something worng .. Here is the steps of my solution: 1. I got the array of numbers A 2. I Xor first element with the rest of elements starting from element two, and then the second element with the rest of the elements starting element three, and so on. 3. Now I have a list with all numbers xored, I sort them and get the first element in xored list and applied this equation to it :- int k = (int) log (xoredList[0]) / log (2);
and in the second test case it gives me 9 not 25
I think, I miss understand something .. can anyone help me ?!
+ 0 comments who can i find optimal permutation
+ 0 comments Is there anyway to solve this without finding all the permutations of the array, because when the number of elements increase it leads to timeout.
+ 0 comments I am attemping to complete one of the Erlang sample test exercises. When I try to run my code, I get an odd Erlang error:
{"init terminating in do_boot",{badarg,[{array,size,1,[{file,"array.erl"},{line,324}]},{solution,main,0,[{file,"/run-CIU10ESE6BCJICS6R3yc/solution.erl"},{line,47}]},{init,start_em,1,[]},{init,do_boot,3,[]}]}}
This looks like an Erlang configuration problem to me. I'm pretty confident that my code is correct since it runs as expected in my local environment.
The exercise that I am attempting is "Odd Numbers" and my code is:
even(X) when X >= 0 -> (X band 1) == 0. odd(X) when X > 0 -> not even(X). oddNumbers(L, L) -> Odd = odd(L), if Odd -> [L]; true -> [] end; oddNumbers(L, R) -> Odd = odd(L), if Odd -> [L | oddNumbers(L + 1, R)]; true -> oddNumbers(L + 1, R) end.
Can someone check to see what might be going wrong?
Thanks
Sort 17 Discussions, By:
Please Login in order to post a comment