2
votes
Accepted
Infinite looping in hacker 1 - water
I like that you don't want to use CS50's tools and use tools that you are going to have available everywhere outside of CS50.
I was reviewing your code. I tried to solve it with a fflush(stdin) line, ...
1
vote
Accepted
Understanding infinite loop with while loop
while() will run as long as the condition inside is true. In your code, an integer >2 will make it an infinite loop because the condition will be forever true.
Alternatively, if you use if() ...
1
vote
PSET6 DNA Think I'm getting an infinite loop which is apparent when testing with every txt file after 4.txt
The proximate cause of the infinite loop is this while in the repeatss function:
while dna_str[j : j + len_str] in str_csv[i]:
curr_str += 1
j += len_str
In ...
1
vote
Accepted
won function does not seem to return true (even though it should)
Why do you loop till j < d - 1 not j < d? For board 3*3, you miss board[0][2] so should return false for board[1][0].
However, I do not understand why you are stack in an infinite loop. You ...
1
vote
Accepted
PSET3 Binary Search Function Infinite Loop
Seems you just misprinted.
Change
end = middle + 1
to
start = middle + 1
and it will work just fine.
1
vote
Accepted
pset5 compile but it's thinking too long so it must be wrong
Written based on the second code:
You are allocating multiple times, overwriting the pointer each time? valgrind won't like that:
for(int i = 0; i < ALPHABETS; i++)
{
root = NULL;
...
Only top scored, non community-wiki answers of a minimum length are eligible