Interesting task for programmers

tommy-gung
Site user since 22.11.2006
Offline
274
#51
Danforth:
tommy-gung, a working solution, but it is possible to optimize) the first implementation I have also worked well, this is the first that comes to mind.

so I'm not a programmer) just remembered institute years

all wanted to be rewritten to use only one array, but was too lazy)

---------- Posted 18.06.2020 at 12:46 ----------

Gerga, you have to throw out all that great $ target? as well as the same amount with a negative number?

Здесь не могла быть ваша реклама
Gerga
Site user since 02.08.2015
Offline
94
#52
tommy-gung:
Gerga, you have to throw out all that great $ target? as well as the same amount with a negative number?

you can add a check for a negative number and filter in the opposite direction, but it is still clearly faster than without such a filter.

danforth
Site user since 18.12.2015
Offline
153
#53
tommy-gung:
Gerga, you have to throw out all that great $ target? as well as the same amount with a negative number?
Gerga:
you can add a check for a negative number and filter in the opposite direction, but it is still clearly faster than without such a filter.

Your implementation has not passed the test with [0,4,3,0] and Target 0, return was [0, 3], and returned empty array. If Fixed, run a test, look at how much faster option, but your implementation seems to me to be as long in pyhe no tail recursion optimization.

The idea with the exception of numbers more than $ target, I also implemented, but I zafeylili test with the amount which a single number is negative, as stated above tommy-gung.

Junior Web Developer
Gerga
Site user since 02.08.2015
Offline
94
#54

Danforth, took into account the 0 and a negative number https://pastebin.com/JDPYysWF .

danforth
Site user since 18.12.2015
Offline
153
#55

Gerga,

[-3,4,3,90]

0

Output: []

Expected: [0,2]

Gerga
Site user since 02.08.2015
Offline
94
#56

Danforth, yes, if so, then this filter will not help ...

danforth
Site user since 18.12.2015
Offline
153
#57

Gerga, a little problem here , there is an opportunity to throw the code in the test and see the result of execution speed and memory consumption. There is also a hint for those who did not think himself. I recommend to all before the climb to the tips to think about how you can speed up, the solution is very simple.

For example, my last realization in Rust.



Sly32
Site user since 29.03.2012
Offline
252
#58
Danforth:
In your function has no arguments, it takes them out of the object. Here's the code that I threw for python, you need to write code in a function, without self

🍾 Well ok, changed

https://pastebin.com/3zZ45mts

danforth
Site user since 18.12.2015
Offline
153
#59

Sly32,

Input: [3,2,4]

6

Output: []

Expected: [1,2]

Above there is a link where you can get rid of the tests

Sly32
Site user since 29.03.2012
Offline
252
#60

Danforth, I put the wrong flag and eventually was generally non-working code that is executed only one time)

I corrected, but now the test fails Output Limit Exceeded

To post a new comment, please log in or register