Created
July 27, 2019 04:17
-
-
Save JakeKalkman/b4e0787923e477322a8f4438ba465986 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
input <- scan("day1Input.txt") # each line is an integer. | |
sum <- 0 | |
results <- c() | |
flag <- FALSE | |
while(flag == FALSE){ | |
for(line in input){ | |
sum = sum + line | |
if(sum %in% results){ # If we find a duplicate sum print it. | |
print(sum) | |
flag <- TRUE | |
break | |
} | |
results <- c(results,sum) # Keep track of past sums | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment