Last active
December 7, 2015 11:07
-
-
Save EvelynSubarrow/4f26ed97f8ae06cf01f0 to your computer and use it in GitHub Desktop.
Project Euler, problem 8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <string.h> | |
uint64_t solve(char* input) | |
{ | |
size_t moo_len = strlen(input); | |
uint8_t *moo = malloc(moo_len); | |
int i = 0, o = 0; | |
for(i=0; i<moo_len; i++) moo[i] = (uint8_t)*(input++) - 060; | |
uint64_t value = 0; | |
for(i=0; i<moo_len-12; i++) | |
{ | |
uint64_t check = 1; | |
for (o=0; o<13; o++) check = check * moo[i+o]; | |
if(check > value) value = check; | |
} | |
return value; | |
} | |
int main(void) | |
{ | |
printf("%ld\n", solve( | |
"7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843" | |
"8586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557" | |
"6689664895044524452316173185640309871112172238311362229893423380308135336276614282806444486645238749" | |
"3035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776" | |
"6572733300105336788122023542180975125454059475224352584907711670556013604839586446706324415722155397" | |
"5369781797784617406495514929086256932197846862248283972241375657056057490261407972968652414535100474" | |
"8216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586" | |
"1786645835912456652947654568284891288314260769004224219022671055626321111109370544217506941658960408" | |
"0719840385096245544436298123098787992724428490918884580156166097919133875499200524063689912560717606" | |
"0588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450" | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment