Census

  • 10
People and other citizens of the universe quite often try to find their relatives. Let's take a step towards a program that can search for people. In this task, we need to create a dictionary (Map), add ten (last name, first name) entries, and then check how many people have the same first name or last name.
You can't complete this task, because you're not signed in.
Comments (37)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Anitamalina Level 10, København, Denmark
18 December 2020, 09:46
this task needs some better description. It's really misleading in the way it asks you to "Check how many people have the same first name or last name". But you can't add the same lastName (key) to the HashMap, since the key has to be unique! It's sooo confusing.
Nickolas Johnson Level 8, St. Louis, United States of America
30 November 2020, 16:28
Level of code difficulty for this one: about 2/5 Level of directions readability: 0/5 This one tries to trick you for sure. Anyone reading this should just recognize that given the use of a HashMap and that said hashmap will have Last Name as the KEY, it is not possible to have more than 1 repeat since you cannot repeat keys. I spent half an hour reading comments over and over until someone else finally pointed that out and i started actually coding. It's also worth mentioning that if you "map.put" the same lastname more than once, the hashmap will treat that as a value change and not add another element. So, if you're failing on the third one take a look at your actual hashmap to see if it's actually 10.
Ron R Level 16, Washington, United States
8 December 2020, 17:21
Agreed. Spent more time reading comments than I spent with my code. Before I submitted my solution, I was trying to figure out why the conditions would say write a method to count duplicate last names, last names being the "key", knowing keys are unique.
Vitalina Tkachenko Level 17, Poland
15 October 2020, 11:14
I hate this task. And that is because keys and values:(
ziv fisher Level 9, Petah Tikva, israel
26 September 2020, 20:12
The 3rd condition is wrongly worded: ״Check how many people have the same first name or last name.״ ----- THIS IS MISLEADING! For other students, pay attention to the argument passes in the "getSameFirstNameCount"+"getSameLastNameCount" methods. More specifically: (HashMap<String, String> map, String lastName) And more specifically: (HashMap<String, String> map, String name) What they basically wanted is you to compare the String lastName(in the getSameLastNameCount method) that is passes as an argument in the getSameLastNameCount method(for example) to all of the keys(which are Strings at this example) at the HashMap and count how many Strings(keys) is the same String as the argument(String lastName).
Karas Level 15, Tampa, United States
22 September 2020, 00:32
Okay, this exercise completelly broke my record of 1 to 3 tries. I might be the one to give away the clue but seeing the different number of request and petitions to help, this needs to be addressed. The sequence of the map: LAST NAME will be the KEY. FIRST NAME will be the VALUE. Compare them to the passed parameter accordingly.
andy 6473 Level 9, Bangalore, India
26 July 2020, 14:40
i did not understand the key value pairs. kindly explain
Edddieg Level 15, Providence, United States
27 June 2020, 20:58
this was sweet ..
Daniel Level 8, Vienna, Austria
25 June 2020, 19:27
Wasted more than 1 hour looking for something that I didn't even need because of the way conditions were written. Oh well.
IvanP Level 15, Barcelona, Spain
6 May 2020, 03:45
care with the order haha
16 April 2020, 16:40
Interesting point on this task let's say you give everyone a different last name e.g. Smith1, Smith2, Smith3, Smith4, etc...each key unique as required. BUT you give everyone the exact same first name e.g. all values = John. You will find that your total numbers for last name will be 10 and firstname 100. My code passed with this, I know this isn't correct since there are not 100 "John" in first name, but we do pass "John" into the first name function 10 times.