I don't think I understood this question. Can you please rephrase it / explain to me?
–
Pi Han Goh
·
1 year, 1 month ago

Log in to reply

@Pi Han Goh
–
In file called "AinA.txt", an array is given. The array is described in the following manner:
First, a number is given, and it represents how many elements the array has. That is \( 10^5 \).
The following \( 10^5 \) numbers are elements of that array. Now, it is asked to find how many special sub-arrays exist in the given array. Those special sub-arrays have two properties/characteristics. First one, they have to have at least 2 elements. Second one, the first number and the last one of the sub-array have to be the same number. One more example:

Array has 4 elements: 1 2 2 3

Here we have 4 sub-arrays that have exactly one element {1} , {2}, {2} and {3}, but since they have only one element, they aren't qualified.

Next, we have 3 sub-arrays with exactly 2 elements in it, those are: {1, 2}, {2, 2} and {2, 3}. From these, only {2, 2} satisfies both properties, so: one qualified sub-array for now.

With 3 elements, there are 2 sub-arrays: {1, 2, 2} and {2, 2, 3}. Here, both sub-arrays do not satisfy the second property (first and last the same).

Lastly, there is one sub-array with for elements, and it is the actual starting array {1, 2, 2, 3} and he does not satisfy the second condition either.

Conclusion: There is only one special sub-array (and it is {2, 2}) in the initially given array ( {1, 2, 2, 3} ). So the answer for this example is \( \boxed{1} \). I hope I managed to explain it to some extent and I do apologise for my late response and any other unconviniences, I am in a bit of a haste, and away from home. Good luck :)
–
Milan Milanic
·
1 year, 1 month ago

Can you provide the file APCS.rar through torrent or maybe split the file across different files? Or maybe through some other file-sharing service (i.e., not dropbox) ?

I have a crappy internet connection and Dropbox starts the download in the browser itself and the download fails everytime after about 20 MB of the file is downloaded and the broken download doesn't resume. I have tried downloading it for about 4-5 times by now and it fails every time. :(

Personally, I'd recommend sharing the text file through Pastebin.
–
Prasun Biswas
·
1 year, 4 months ago

Log in to reply

@Prasun Biswas
–
@Prasun Biswas if the file is lesser than 20MB are there any problems with downloading via dropbox? The thing is, dropbox is quite handy, for me at least, and if I can use it for smaller files, I would do so.
–
Milan Milanic
·
1 year, 4 months ago

Log in to reply

@Milan Milanic
–
Never mind, I was able to download it completely later. Nice problem, but I'd like to ask: Does the optimal solution to that problem take 20 secs to run on your PC or on some standard code-testing site? I wrote a code in python that I think takes more or less \(O(n)\) time to execute and its runtime is ~40 secs on my PC.

If the 20 secs is the time to run on your PC, may I know your PC configuration so that I may be able to test the code in such a CPU configuration? Or maybe I can send you my code via email and you can test if it runs in less than 20 secs in your system or not? I'd like to optimize my code as much as possible. Thanks! :)
–
Prasun Biswas
·
1 year, 4 months ago

Log in to reply

@Prasun Biswas
–
I am sorry that I did not post the required file on torrent or some other site. I am having some problems with that.

But, never mind that, I will post the file eventually. I am glad that You solved it correctly, you are the first solver! Congrats :)

What I wanted to tell with this reply, finally, do You want to discuss this via Slack?
–
Milan Milanic
·
1 year, 4 months ago

Log in to reply

@Milan Milanic
–
Sure, what's your username on Slack? I can't seem to find you in the Brilliant-Lounge...
–
Prasun Biswas
·
1 year, 4 months ago

Log in to reply

@Milan Milanic
–
@Milan Milanic you can test out behavior of dropbox on bad connections by using the "network conditioning" feature in the Chrome browser dev tools. See here for quick instructions.
–
Silas Hundt
Staff
·
1 year, 4 months ago

Log in to reply

@Prasun Biswas
–
Oh, I did not know that. The CS committee in my country uses dropbox often, so I figured it is quite good. But hearing this, I will start using Pastebin.

Thanks for the information. I really didn't know. I seek to constantly evolve....
–
Milan Milanic
·
1 year, 4 months ago

@Francis Octavius
–
I am not sure for what "Yt" stands for. So if it is not a problem, I would appreciate the explanation.
–
Milan Milanic
·
1 year, 2 months ago

Log in to reply

I just managed to solve the king's problem. I really liked that problem and would like to thank you for posting it.
–
Levent B
·
8 months, 2 weeks ago

Log in to reply

@Levent B
–
Thank you kindly for the encouragement! I am glad to hear so. I will try to come up with prospectively exciting and fun problem in the future. All the best.
–
Milan Milanic
·
8 months, 2 weeks ago

Log in to reply

For clarification, on this problem (https://brilliant.org/problems/creating-sorted-arrays/?ref_id=1280451), is the array always in the form of {1, 2, 3, ..., m}?
–
Levent B
·
8 months, 1 week ago

Log in to reply

@Levent B
–
Two numbers are given: \( m \) and \( n \). \( n \) says that number of elements of the array in the problem is exactly \( n \), while \( m \) says that elements of the array are positive integers lesser or equal to \( m \). Another important thing is that the array must be strictly increasing. Example (in the case I did not cover everything):

n = 2, m = 3: Array = \( a_1 \), \( a_2 \) ; and the the possible values for elements are from set {1, 2, 3}. For this trivial example, answer is \( \boxed{3} \) and those arrays are:

\( A_1 = 1, 2 \)

\( A_2 = 2, 3 \)

\( A_3 = 1, 3 \)

Do you think that I should perhaps provide example for the problem (within the problem itself)?
–
Milan Milanic
·
8 months, 1 week ago

Log in to reply

@Milan Milanic
–
Thank you that makes much more sense to me now. I think not understanding was just a problem on my part, but you can never go wrong with including an example.
–
Levent B
·
8 months, 1 week ago

Log in to reply

Hello Milan, in your EOTR problem you state that S=5*sqrt(6). I wonder what you mean by this. Best regards, Wim
–
Wim Kerstens
·
1 year, 3 months ago

Log in to reply

@Wim Kerstens
–
I understand. I thought that especially this may represent a problem, but I haven't provided better explanation for some reason. I will add a better explanation what the \( S \) actually is in the problem, but I will explain it here as well.

The standard EOTR has a rectangle \( ABCD \) for its base and points \( P \) and \( Q \) for its "main peak points", so that the \( PQ \) is so called "peak line". It is said that the length of the following segments: AP, DP, BQ and CQ must be the same. That length is labelled as that \( S \). So, it means that \( AP = DP = BQ = CQ = 5\sqrt{6} \). I edited some minor text in the problem, would You mind checking it out and informing me whether it is more understandable now? :)

Thank You for pointing this out. If you have any more questions, use this FAQ note again. :)

@Beakal Tiliksew
–
There are 10 million numbers in that file after all. That number of numbers is somewhat necessary to test the optimization of the solver's code. With the right optimization, I think the run time is about 10 seconds.
–
Milan Milanic
·
1 year, 4 months ago

@Silas Hundt
–
Depends on my mood and the time of the day.

No special reason to be honest. I just pick the one randomly, .in .dat .bin or with no extension. Probably there is some difference between them, but with my knowledge, I cannot tell for sure.
–
Milan Milanic
·
1 year, 4 months ago

Log in to reply

@Milan Milanic
–
The issue is that .dat on many systems (Mac OS X, Ubuntu) is often classified as a video file by the OS which makes it mildly difficult to inspect. I think .txt would be more appropriate.
–
Silas Hundt
Staff
·
1 year, 4 months ago

Log in to reply

@Silas Hundt
–
Ubuntu on my computer did not show that issue. But anyhow, what is your opinion, should I re-upload the same file with textual extension or it is not necessary?
–
Milan Milanic
·
1 year, 4 months ago

Log in to reply

@Milan Milanic
–
I'd re-upload as .txt that has been gzipped so <file-name>.txt.gz.
–
Silas Hundt
Staff
·
1 year, 4 months ago

Log in to reply

@Silas Hundt
–
Now, the document has the textual extension, if my eyes are not deceiving me. I am grateful to You, for notifying and advising me. I look forward to our mutual interacting.
–
Milan Milanic
·
1 year, 4 months ago

## Comments

Sort by:

TopNewestI don't think I understood this question. Can you please rephrase it / explain to me? – Pi Han Goh · 1 year, 1 month ago

Log in to reply

Array has 4 elements: 1 2 2 3

Here we have 4 sub-arrays that have exactly one element {1} , {2}, {2} and {3}, but since they have only one element, they aren't qualified.

Next, we have 3 sub-arrays with exactly 2 elements in it, those are: {1, 2}, {2, 2} and {2, 3}. From these, only {2, 2} satisfies both properties, so: one qualified sub-array for now.

With 3 elements, there are 2 sub-arrays: {1, 2, 2} and {2, 2, 3}. Here, both sub-arrays do not satisfy the second property (first and last the same).

Lastly, there is one sub-array with for elements, and it is the actual starting array {1, 2, 2, 3} and he does not satisfy the second condition either.

Conclusion: There is only one special sub-array (and it is {2, 2}) in the initially given array ( {1, 2, 2, 3} ). So the answer for this example is \( \boxed{1} \). I hope I managed to explain it to some extent and I do apologise for my late response and any other unconviniences, I am in a bit of a haste, and away from home. Good luck :) – Milan Milanic · 1 year, 1 month ago

Log in to reply

– Pi Han Goh · 1 year, 1 month ago

Understoooood!!!! Thank youLog in to reply

Can you provide the file

`APCS.rar`

through torrent or maybe split the file across different files? Or maybe through some other file-sharing service (i.e., not dropbox) ?I have a crappy internet connection and Dropbox starts the download in the browser itself and the download fails everytime after about 20 MB of the file is downloaded and the broken download doesn't resume. I have tried downloading it for about 4-5 times by now and it fails every time. :(

Personally, I'd recommend sharing the text file through Pastebin. – Prasun Biswas · 1 year, 4 months ago

Log in to reply

– Milan Milanic · 1 year, 4 months ago

@Prasun Biswas if the file is lesser than 20MB are there any problems with downloading via dropbox? The thing is, dropbox is quite handy, for me at least, and if I can use it for smaller files, I would do so.Log in to reply

If the 20 secs is the time to run on your PC, may I know your PC configuration so that I may be able to test the code in such a CPU configuration? Or maybe I can send you my code via email and you can test if it runs in less than 20 secs in your system or not? I'd like to optimize my code as much as possible. Thanks! :) – Prasun Biswas · 1 year, 4 months ago

Log in to reply

But, never mind that, I will post the file eventually. I am glad that You solved it correctly, you are the first solver! Congrats :)

What I wanted to tell with this reply, finally, do You want to discuss this via Slack? – Milan Milanic · 1 year, 4 months ago

Log in to reply

– Prasun Biswas · 1 year, 4 months ago

Sure, what's your username on Slack? I can't seem to find you in the Brilliant-Lounge...Log in to reply

@Milan Milanic you can test out behavior of dropbox on bad connections by using the "network conditioning" feature in the Chrome browser dev tools. See here for quick instructions. – Silas Hundt Staff · 1 year, 4 months ago

Log in to reply

Thanks for the information. I really didn't know. I seek to constantly evolve.... – Milan Milanic · 1 year, 4 months ago

Log in to reply

– Francis Octavius · 1 year, 2 months ago

Yt?Log in to reply

– Milan Milanic · 1 year, 2 months ago

I am not sure for what "Yt" stands for. So if it is not a problem, I would appreciate the explanation.Log in to reply

I just managed to solve the king's problem. I really liked that problem and would like to thank you for posting it. – Levent B · 8 months, 2 weeks ago

Log in to reply

– Milan Milanic · 8 months, 2 weeks ago

Thank you kindly for the encouragement! I am glad to hear so. I will try to come up with prospectively exciting and fun problem in the future. All the best.Log in to reply

For clarification, on this problem (https://brilliant.org/problems/creating-sorted-arrays/?ref_id=1280451), is the array always in the form of {1, 2, 3, ..., m}? – Levent B · 8 months, 1 week ago

Log in to reply

strictly increasing. Example (in the case I did not cover everything):n = 2, m = 3: Array = \( a_1 \), \( a_2 \) ; and the the possible values for elements are from set {1, 2, 3}. For this trivial example, answer is \( \boxed{3} \) and those arrays are:

Do you think that I should perhaps provide example for the problem (within the problem itself)? – Milan Milanic · 8 months, 1 week ago

Log in to reply

– Levent B · 8 months, 1 week ago

Thank you that makes much more sense to me now. I think not understanding was just a problem on my part, but you can never go wrong with including an example.Log in to reply

Hello Milan, in your EOTR problem you state that S=5*sqrt(6). I wonder what you mean by this. Best regards, Wim – Wim Kerstens · 1 year, 3 months ago

Log in to reply

The standard

EOTRhas a rectangle \( ABCD \) for its base and points \( P \) and \( Q \) for its "main peak points", so that the \( PQ \) is so called "peak line". It is said that the length of the following segments: AP, DP, BQ and CQ must be the same. That length is labelled as that \( S \). So, it means that \( AP = DP = BQ = CQ = 5\sqrt{6} \). I edited some minor text in the problem, would You mind checking it out and informing me whether it is more understandable now? :)Thank You for pointing this out. If you have any more questions, use this FAQ note again. :)

Best regards – Milan Milanic · 1 year, 3 months ago

Log in to reply

Why did you provide input data as a

`.dat`

file? – Silas Hundt Staff · 1 year, 4 months agoLog in to reply

– Beakal Tiliksew · 1 year, 4 months ago

Yeah I agree, and 29MB is a bit too much!!Log in to reply

– Milan Milanic · 1 year, 4 months ago

There are 10 million numbers in that file after all. That number of numbers is somewhat necessary to test the optimization of the solver's code. With the right optimization, I think the run time is about 10 seconds.Log in to reply

– Beakal Tiliksew · 1 year, 4 months ago

I see, better get to downloading then :(Log in to reply

No special reason to be honest. I just pick the one randomly, .in .dat .bin or with no extension. Probably there is some difference between them, but with my knowledge, I cannot tell for sure. – Milan Milanic · 1 year, 4 months ago

Log in to reply

`.dat`

on many systems (Mac OS X, Ubuntu) is often classified as a video file by the OS which makes it mildly difficult to inspect. I think`.txt`

would be more appropriate. – Silas Hundt Staff · 1 year, 4 months agoLog in to reply

– Milan Milanic · 1 year, 4 months ago

Ubuntu on my computer did not show that issue. But anyhow, what is your opinion, should I re-upload the same file with textual extension or it is not necessary?Log in to reply

`.txt`

that has been gzipped so`<file-name>.txt.gz`

. – Silas Hundt Staff · 1 year, 4 months agoLog in to reply

– Milan Milanic · 1 year, 4 months ago

Now, the document has the textual extension, if my eyes are not deceiving me. I am grateful to You, for notifying and advising me. I look forward to our mutual interacting.Log in to reply