Skip to content

Tallyer Assignment TW#8

Open
timmyd4 wants to merge 2 commits intogrc-cohort-21:mainfrom
timmyd4:main
Open

Tallyer Assignment TW#8
timmyd4 wants to merge 2 commits intogrc-cohort-21:mainfrom
timmyd4:main

Conversation

@timmyd4
Copy link
Copy Markdown

@timmyd4 timmyd4 commented Jan 11, 2025

No description provided.

Copy link
Copy Markdown

@auberonedu auberonedu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job with wave 1! I think the algorithm you have for wave 2 doesn't quite work though, see comments below.

Comment thread src/Tallyer.java
Comment on lines 56 to +69
// TODO: Implement this method
Map<String, Integer> count = new HashMap<>();
for(String item: topics)
{
if(!count.containsKey(item))
{
count.put(item, 1);
}
else
{
int currentCount = count.get(item);
int newCount = currentCount + 1;
count.put(item, newCount);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice logic!

Comment thread src/Tallyer.java
Comment on lines +91 to +103
Map<String, Integer> count = new HashMap<>();
for(String item: topics)
{
if(!count.containsKey(item))
{
count.put(item, 1);
}
else
{
int currentCount = count.remove(item);
count.put(item, currentCount);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this algorithm quite works. As described in the README, the expected output for the sample file is
{maps=1, loops=1, arrays=2}

but yours actually gives
{maps=1, lists=1, loops=1, arrays=1, compound=1}

Make sure to always check your code to see whether it's giving the result you expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants