Author | Message |
---|---|
Arnav98
Posts: 48
|
Posted 21:23 Apr 22, 2017 |
Did anyone finish the 4th problem ? I'm not able to figure it out. Any hint would be great. Last edited by Arnav98 at
21:23 Apr 22, 2017.
|
jzunig20
Posts: 38
|
Posted 01:14 Apr 23, 2017 |
I'm sure there are plenty of ways but i used inline if else statements using the ternary operator from ch3 the logic in this problem took forever to figure out but hopefully that helps or if anyone else has different hints |
kknaur
Posts: 540
|
Posted 17:24 Apr 23, 2017 |
For this problem, you need to look one value ahead in the array. Depending on the value that comes next you will need to print an open "(" assuming you didn't already have an open "(" ), or print the close ")", or don't print any " ( ) ". |
jgarc629
Posts: 76
|
Posted 17:14 Apr 26, 2017 |
Can someone please rephrase the problem? I'm kinda confused on what it's asking |
kknaur
Posts: 540
|
Posted 18:56 Apr 26, 2017 |
The problem is to generate an array of random numbers in the required range. Then you display the array. The trick is that you want to display groups of repeated values wrapped in parenthesis ( ). Example if your array is 1 2 3 4 4 4 4 1 2 1 1 1 2 2 3 3 3 3 4 3 4 4, the result would be: 1 2 3 (4 4 4 4) 1 2 (1 1 1) (2 2) (3 3 3 3) 4 3 (4 4) |
jgarc629
Posts: 76
|
Posted 19:01 Apr 26, 2017 |
Oh okay I get it now, thanks |
jgarc629
Posts: 76
|
Posted 20:52 Apr 26, 2017 |
Should we do this as the array is being made? Or should we make the array first? I don't know how to look at one value ahead if it's not even produced yet. |