Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C solutions initial #48

Closed
wants to merge 3 commits into from
Closed

C solutions initial #48

wants to merge 3 commits into from

Conversation

AKJ7
Copy link

@AKJ7 AKJ7 commented Jul 9, 2020

I just wanted to contribute by providing my C solutions.

AKJ7 and others added 3 commits July 9, 2020 22:54
Better description
Better description
@nayuki
Copy link
Owner

nayuki commented Jul 12, 2020

Rejected - see my policy.

@nayuki
Copy link
Owner

nayuki commented Jul 12, 2020

While well-intentioned, your code is incorrect in these places:

  • You used a variable with type size_t to hold the answer, and the C standard only mandates that size_t is unsigned and at least 16 bits wide. The answer for Problem 1 is 233168. If size_t is indeed the same as uint16_t (max is 65535), then the answer overflows the variable. You were probably hoping that size_t would be the widest integer type available on the platform (like 64 bits), but this is by no means guaranteed.
  • Calling printf() with a size_t value requires the specifier %zu, not %lu as in your code.

@nayuki nayuki closed this Jul 12, 2020
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