# Streets and houses

• 5
• Locked
A street brawl is going down. The even and odd sides of the street are trying to figure out who's tougher, and absolutely everybody, even little babies, are joining the fray. Let's determine which side has a higher chance of winning (more residents means better chances). We'll create an array of 15 numbers (15 houses, the array index is the house number). Then we'll write the number of residents in each cell and tally up the number of people on the even and odd sides of the street.
You can't complete this task, because you're not signed in.
Level 37 , Tampa, United States
25 August 2021, 18:21
This is a very simple task. Consider which number is the house numbers (the array index) and which number is the people living at each house number (the number at that index). So if you had an array like this: [1, 4, 2, 1, 3, 2, 3, 2, 1, 4, 2, 4, 2, 3, 3] It could be visualized like this:
``````/*at each index the amount to the right of the equals is number of people*/
even side     ↓street↓    odd side
index 0 = 1 |           | index 1 = 4
index 2 = 2 |           | index 3 = 1
index 4 = 3 |           | index 5 = 2
index 6 = 3 |           | index 7 = 2
index 8 = 1 |           | index 9 = 4
index 10= 2 |           | index 11= 4
index 12= 2 |           | index 13= 3
index 14= 3 |           |``````
So if you: - sum up the number living on the even side of the street you get 1+2+3+3+1+2+2+3 for a total 17 - sum up the number living on the odd side you get 4+1+2+2+4+4+3 for a total of 20 Therefore the correct output for this example would be that more people live on the odd side
Usman Full Stack Developer at QA
5 July 2021, 10:07
Enjoyed this one :D
Karas Java Developer
4 September 2020, 22:36
You basically have to sum the number of residents. and the side who has the most then has the most.
28 January 2020, 11:03
2 for's and 3 if's did the trick for me.
Usman Full Stack Developer at QA
5 July 2021, 10:06
interesting, i used three fors and one if/else First for to fill in the array, Second to get the even sum value, Third to get the odd sum value, Lastly do a simple if/else.
Justin Smith
Level 8 , United States
13 November 2019, 06:25
The requirements should state the value of the odd/even index, not the odd/even element. "The program should display "Odd-numbered houses have more residents." if the sum of odd array elements is greater than the sum of even ones." It could be confused for figuring out if the element itself is even or odd, which isn't what the task is looking for.
Level 37 , Tampa, United States
25 August 2021, 18:26
It says "the sum of"... it doesn't say if the element itself is even/odd
Tommy Guinness
Level 15 , Newcastle West, Ireland
10 October 2019, 21:59
/* Comment has been deleted */
Roman
Level 41
11 October 2019, 06:31
Posting the solution in the comments is prohibited.
Tommy Guinness
Level 15 , Newcastle West, Ireland
10 October 2019, 21:45
Getting correct output, still shows not working. What wrong?
Roman
Level 41
11 October 2019, 06:31
If you need help, something isn't right in your code, the server won't accept your solution (even if you are 100% sure that it is correct). Describe your question/issue in the HELP section at codegym.cc/help.
Goff
Level 8 , Berlin, Germany
10 October 2019, 02:47
Just a tip: you may read input in pairs, even house - odd house.