INDAPlus21 / INDAPlus21/carlch-task-7
Pass
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Very well done Carl!
I like how you dereferensed strlen to write your own! It's a great way to maintain readability (given that your overwrite has the same funtion of course).
Here are some notes on your code:
Cyber-Clara och anmälningslistorna
Your last-length-digit-compare optimisation is expensive. You attempt to avoid calling the (most likely [differs between implementations]) linear strcmp to instead call the linear strlen one more time and assign additional memory. Given that most names differs in length, your optimisation has merit. However, strcmp do also compare the first characters, hence there exist a douplication of logic. Additionally, given that names often differs in characters, strcmp is better than strlen. Therefore I'm sceptical to if your optimisation should count as an optimisation. As proof, David's code also run at 0.5 and he doesn't even call gets over scanf:
David's solution:
int main()
{
//get the number of names
unsigned long int size;
char name[42], surname[21];
scanf("%lu", &size);
char names[size][42];
for (int i = 0; i < size; i++)
{
scanf("%s", name);
strcpy(names[i], name);
strcat(names[i], " ");
}
for (int i = 0; i < size; i++)
{
scanf("%s", surname);
strcat(names[i], surname);
}
qsort(names, size, sizeof(names[0]), strcmp);
unsigned long int output = size;
for (int i = 1; i < size; i++)
{
if (strcmp(names[i - 1], names[i]) == 0)
output--;
}
printf("%lu", output);
}
Keep it up!
Programming is like sex:
One mistake and you have to support it for the rest of your life.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue contains feedback and a C code example but names no file, test, entry point, or requested change. No completion condition is provided, so clarify the intended work before starting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 5/100