Coding Challenge 4!

The Partridge Family were neither partridges nor a family. Discuss.
AverageWhale
Posts: 57
Joined: August 13th, 2018, 2:33 pm

Re: Coding Challenge 4!

Post by AverageWhale » September 25th, 2018, 1:43 pm

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
Last edited by AverageWhale on September 25th, 2018, 1:48 pm, edited 1 time in total.

colencon
Posts: 35
Joined: February 13th, 2014, 2:24 pm

Re: Coding Challenge 4!

Post by colencon » September 25th, 2018, 1:48 pm

AverageWhale 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.
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 solve

AverageWhale
Posts: 57
Joined: August 13th, 2018, 2:33 pm

Re: Coding Challenge 4!

Post by AverageWhale » September 25th, 2018, 2:07 pm

colencon wrote:
AverageWhale 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.
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 solve
when i try release i have this error

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

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Coding Challenge 4!

Post by albinopapa » September 25th, 2018, 6:24 pm

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
Shouldn't the expected result be 44?
( -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

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Coding Challenge 4!

Post by Yumtard » September 25th, 2018, 6:34 pm

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

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Coding Challenge 4!

Post by albinopapa » September 25th, 2018, 6:54 pm

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

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

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Coding Challenge 4!

Post by albinopapa » September 25th, 2018, 6:59 pm

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
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

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Coding Challenge 4!

Post by Yumtard » September 25th, 2018, 7:08 pm

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.

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Coding Challenge 4!

Post by Yumtard » September 25th, 2018, 9:02 pm

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 :D


Image
Last edited by Yumtard on September 25th, 2018, 9:53 pm, edited 1 time in total.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Coding Challenge 4!

Post by albinopapa » September 25th, 2018, 9:02 pm

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

Post Reply