Skip to content

C solutions initial - #48

Closed
AKJ7 wants to merge 3 commits into
nayuki:masterfrom
AKJ7:master
Closed

AKJ7 wants to merge 3 commits into
nayuki:masterfrom
AKJ7:master

Conversation

@AKJ7

@AKJ7 AKJ7 commented Jul 9, 2020

Copy link
Copy Markdown

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

nayuki commented Jul 12, 2020

Copy link
Copy Markdown
Owner

Rejected - see my policy.

@nayuki

nayuki commented Jul 12, 2020

Copy link
Copy Markdown
Owner

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