Coding Challenge 4!
-
- Posts: 57
- Joined: August 13th, 2018, 2:33 pm
Re: Coding Challenge 4!
guys when i try to open 80m version test data while running my code it does not even calls solution function it stops i dont know what to do? does reading take a long time like 5 minutes?
and guys i have one more question. what is the optimal amount of threads to use for 80m numbers? for ex 1 thread per million numbers. i dont know. i am currently using 1 thread to find max difference between 1 million numbers
and guys i have one more question. what is the optimal amount of threads to use for 80m numbers? for ex 1 thread per million numbers. i dont know. i am currently using 1 thread to find max difference between 1 million numbers
Last edited by AverageWhale on September 25th, 2018, 1:48 pm, edited 1 time in total.
Re: Coding Challenge 4!
make sure you run 80m num in release mode, or you will wait forever, my code is single theard and it take about 322ms to solveAverageWhale wrote:guys when i try to open 80m version test data while running my code it does not even calls solution function it stops i dont know what to do? does reading take a long time like 5 minutes?
and guys i have one more question. what is the optimal amount of threads to use for 80m numbers? for ex 1 thread per million numbers. i dont know.
-
- Posts: 57
- Joined: August 13th, 2018, 2:33 pm
Re: Coding Challenge 4!
when i try release i have this errorcolencon wrote:make sure you run 80m num in release mode, or you will wait forever, my code is single theard and it take about 322ms to solveAverageWhale wrote:guys when i try to open 80m version test data while running my code it does not even calls solution function it stops i dont know what to do? does reading take a long time like 5 minutes?
and guys i have one more question. what is the optimal amount of threads to use for 80m numbers? for ex 1 thread per million numbers. i dont know.
edit* i understand now i have to change from debug to release. i will try thanks
- Attachments
-
- Capture.PNG
- (33.46 KiB) Not downloaded yet
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Coding Challenge 4!
Code: Select all
Buck Futter's Sexy Test 5
99
22 43 1 33 1 1 1 1 24 22 1 45 1 1 100 1
( -22 + 43 ), (-1 + 33 ), ( -1 + 1 ), ( -1 + 1 ), ( -24 + 22 ), ( -1 + 45 ), ( -1 + 1 ), ( -100 + 1 )
results:
( 21 ), ( 32 ), ( 0 ), ( 0 ), ( -2 ), ( 44 ), ( 0 ), ( -99 )
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: Coding Challenge 4!
I think you're confused about the problem
" Return the maximum value of v[j] - v where j > i and v[j] > v."
So the biggest difference in test 5 would be 100 - 1 = 99
" Return the maximum value of v[j] - v where j > i and v[j] > v."
So the biggest difference in test 5 would be 100 - 1 = 99
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Coding Challenge 4!
That doesn't work though, since 100 would be i and 1 would be j in the order the values are given.
If we can decide which two values is J and which is I, then
The expected result would be ( 34 - 23 = 11 ) not -1.
If we can decide which two values is J and which is I, then
Code: Select all
Buck Futter's Sexy Test 2
-1
34 23 12 3 3 3 0 0
The expected result would be ( 34 - 23 = 11 ) not -1.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Coding Challenge 4!
Or, is it suppose to be done like this?
43 - 22 = 11
1 - 43 = -42
33 - 1 = 32
1 - 33 = -32
1 - 1 = 0
1 - 1 = 0
1 - 1 = 0
24 -1 = 23
22 -24 = -2
1 -22 = -21
45 - 22 = 23
1 - 45 = -44
1 -1 = 0
100 -1 = 99
1 - 100 = -99
43 - 22 = 11
1 - 43 = -42
33 - 1 = 32
1 - 33 = -32
1 - 1 = 0
1 - 1 = 0
1 - 1 = 0
24 -1 = 23
22 -24 = -2
1 -22 = -21
45 - 22 = 23
1 - 45 = -44
1 -1 = 0
100 -1 = 99
1 - 100 = -99
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: Coding Challenge 4!
i is an index in the array
j is another index in the array
the condition is that j must be bigger than i
there's a 1 at index 2 and there's a 100 at index 14
14 > 2 so we're allowed to count 100 - 1 as the difference
in test 2 we're not allowed to do 34 - 23 as 0 < 1
The expected result is -1 because we return -1 when we can't find a value that fits the conditions.
j is another index in the array
the condition is that j must be bigger than i
there's a 1 at index 2 and there's a 100 at index 14
14 > 2 so we're allowed to count 100 - 1 as the difference
in test 2 we're not allowed to do 34 - 23 as 0 < 1
The expected result is -1 because we return -1 when we can't find a value that fits the conditions.
Re: Coding Challenge 4!
Finally managed to do some optimizing
Went from ~110ms to ~24ms for my 80 million test. No multi threading.
And the code went from neat to a mess
Went from ~110ms to ~24ms for my 80 million test. No multi threading.
And the code went from neat to a mess
Last edited by Yumtard on September 25th, 2018, 9:53 pm, edited 1 time in total.
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Coding Challenge 4!
Yeah, after getting some insight from someone else, they suggested that a nested for loop is probably what chili meant.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com