Hot answers tagged

2 votes
Accepted

Week 6: DNA sequence aligning example: Are running times iterative approach and reqursive same?

Recursive with memoization and non-recursive do the same number of computations. The recursive version however is more complex, memoization requires some check whether the value already has been ...
Blauelf's user avatar
  • 20.9k
2 votes
Accepted

Can't get past step 2 in water.c check50 2016.water water.c?

OK, you are pretty close, just some little syntax errors. When I try to compile your source code with clang I get the following errors, so let's solve them step by step: test.c:11:26: error: ...
ChrisG's user avatar
  • 7,366
2 votes
Accepted

Vigenere-Struggling to understand why garbage values are being printed

If you run the code with key = "bbb" and plaintext ABC, the result is ciphertext:BACBDC. This is a mix of the properly coded BCD and the original ABC, printing alternatingly from each string. This ...
Cliff B's user avatar
  • 68.1k
2 votes
Accepted

Why is my ciphertext printing random values?

Apply the %26 to the sum, not the key. Also, don't forget to apply a shift to the plaintext character (like you did in caesar), and shift the result back. And finally, non-alphabetic plaintext ...
Blauelf's user avatar
  • 20.9k
2 votes
Accepted

I am ABSOLUTELY STUCK! (mario less)

I tried running your code in the sandbox, resulting in an additional row without any hashes on top of the pyramid (you can see the space between the pyramid and the height prompt). To solve the ...
Justin Tzuriel's user avatar
2 votes

Using submit50 on VSCode

I noticed this a duplicate question that you have already posted here but I can't flag it as a duplicate, so I'll repost my answer here in case anyone chances upon this one instead: This is due to ...
Melvin Kok's user avatar
2 votes
Accepted

PSET 7 Movies SQL Q9

The issue here was in the syntax of the SQL query. When looking for multiple elements from a subquery, it's necessary to use "IN" in the query. In other words look for all elements A that ...
Cliff B's user avatar
  • 68.1k
2 votes

"cash.c:7:1: error: expected identifier or '('" What do I do?

Get rid of the semicolon on line 6. A semicolon there marks the line as a function signature. You'll learn more about that later.
Cliff B's user avatar
  • 68.1k
2 votes
Accepted

PSET2 Substitution

Did you remember to add one extra char to the length of ciphertext and to insert the end of string marker in that last space? Also, shouldn't the length of ciphertext be based on the length of string ...
Cliff B's user avatar
  • 68.1k
2 votes
Accepted

I need help to fix my selection sort code - Practice Problems (Average High Temperatures)

that's a lot of code for a selection sort. It should be able to be sorted without need for a second array and with only two nested for loops. The setup is pretty straightforward. I'll give a verbal ...
Cliff B's user avatar
  • 68.1k
1 vote
Accepted

One tiny step to completion. Recover recovers all images except the first one. Help!

So let's look at the code that handles the non-signature blocks. else { // if file is open if (ftell(img) >= 0) { fwrite(buffer, 512, 1, img); ...
Cliff B's user avatar
  • 68.1k
1 vote
Accepted

PSet1: Mario - Less Comfortable (Too many periods)

for (space = 0; space <= height - row; space++) runs height - row + 1 times (+1 for having <= instead of <). For the first row, you should have height - 1 spaces, but you have height + 1. Fix ...
Blauelf's user avatar
  • 20.9k
1 vote
Accepted

PSet 3 resize (less)

I'll give you several nudges. Most of the problems arise from the nested for loop structure being off. For example, the current code writes out padding after writing out every pixel. It should only ...
Cliff B's user avatar
  • 68.1k
1 vote
Accepted

Where am I going wrong in Similarities: Substrings?

Check the list extract returns. Its last elements are a bit too short, as there are no len(string) substrings of length num, their number also depends on num itself. You should probably adjust your ...
Blauelf's user avatar
  • 20.9k
1 vote
Accepted

resize : pset3 not all colors are appering after resizing

Let's look at the code that actually processed the image data. (I've refined the style a little to clean it up, but the code is the same.) for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight;...
Cliff B's user avatar
  • 68.1k
1 vote
Accepted

CS50 Week 4 Recover. Generating 50 Blank images

The biggest problem here is that the code is trying to test for a signature before actually reading in the data from the input file. It's doing a "Ready, Fire, Aim." Order of actions is ...
Cliff B's user avatar
  • 68.1k
1 vote
Accepted

PSET3 Runoff Help Please

To check the name of the candidate in the 1st preferred coloumn only Remember, preferences[i][j]; Is simply, preferences[row][coloumn]; So, For first preference only preferences[changing_row][...
Shehroz Ali's user avatar
1 vote

PSET3 Runoff Help Please

vote This function inputs a string a search for the names in the table of candidates, it returns true once the name has been founded or matched i.e == 0 But how? Use for-loop to iterate through the ...
Shehroz Ali's user avatar
1 vote
Accepted

how do i write pesudocode.txt for Mario? (less comfortable)

You make a new file by clicking the green plus sign at the top, next to where it says the name of the file you are currently on. On your keyboard, then do command shift S. It will give you options for ...
mkg15's user avatar
  • 67
1 vote

are we supposed to use the set from hello.c to begin with Mario (less comfortable) or do we need a new terminal and file?

It's a new program. Start with a new file. You're done with hello.c, but feel free to look at it for any ideas on how to do anything you've done in the past. These instructions are guiding you through ...
Cliff B's user avatar
  • 68.1k
1 vote
Accepted

are we supposed to use the set from hello.c to begin with Mario (less comfortable) or do we need a new terminal and file?

You don't have to create a new terminal window, but you should only start mario if you're finished with hello. If you're in the hello directory, on your terminal, execute: cd, cd pset1, mkdir mario, ...
mkg15's user avatar
  • 67
1 vote

Stuck badly in Speller - segmentation fault

node *cursor1 = table[X]; int result = 0; do { result = strcasecmp(word, cursor1->word); // cursor1 is NULL here. The error messsage: Memory access error: dereferencing a ...
stensal's user avatar
  • 450
1 vote

Counter fails to update for DNA

There's a subtle bug in here: for char in range(len(tf)): # ... char += len(str)-1 Let's say range(len(tf) = [0, 1, 2, 3, 4] and len(str) = 3. What happens if we match while char ...
xjcl's user avatar
  • 111
1 vote

I am ABSOLUTELY STUCK! (mario less)

You can check your own style by running style50 mario.c You can see the tests used for grading by clicking the check50 button next to your submission on cs50.me/submissions With both of those ...
curiouskiwi's user avatar
  • 18.6k
1 vote
Accepted

Why isn't my key running cyclically?

The code is using a pair of nested for loops. The outer loop cycles through the plaintext while the inner loop cycles through the key. That means that for EACH char in the plaintext, the inner loop ...
Cliff B's user avatar
  • 68.1k
1 vote

CS50 Understanding Technology Grading?? CS50.me?

Generally, you should be receiving grade feedback via email. Perhaps check your spam folders to make sure your feedback hasn't been directed there? If you can't find it, please send an email to ...
curiouskiwi's user avatar
  • 18.6k
1 vote
Accepted

CS50 - Pset7 - Quote Redirects To Login - 2017

session.clear() clears the session variables, which holds the user id, which makes @login_required think there is not a logged in user. (Notice the comment before session.clear() in the supplied login ...
DinoCoderSaurus's user avatar
1 vote
Accepted

Lecture Week 6: Dynamic programming: rod example, is the recursion approach correct?

Recursion isn't done right. For example, your function meant to return an int might end without returning anything. Essence of recursion is that you define a base case (like for example rod of length ...
Blauelf's user avatar
  • 20.9k
1 vote
Accepted

why can't I even log in now ? pset7

Here you replace the string with a dict: symbol = lookup(symbol) here you use symbol: db.execute("UPDATE log SET price=:price, \ total=:total WHERE id=:id AND symbol=:symbol", \ ...
Blauelf's user avatar
  • 20.9k
1 vote
Accepted

pset2 crack.c Random Characters Follow When Getting Salt

Where's the end of string marker \0? printf will keep printing whatever follows in memory until it sees the EOS marker, even into other areas of memory. If this answers your question, please click ...
Cliff B's user avatar
  • 68.1k

Only top scored, non community-wiki answers of a minimum length are eligible