Questions tagged [pset3]

The problem set for Week 3 asks students to write code for a classic puzzle game in the C programming language.

Filter by
Sorted by
Tagged with
0
votes
0answers
12 views

Need a bit of help in lock_pairs function of tidema(Pset3)

Here's my code for lock pairs- bool check_cycle(int start, int end) { if (end == start) { return false; } for (int i = 0; i < candidate_count; i++) { if (locked[...
0
votes
1answer
494 views

pset3: code failed to compile

Now I am doing tideman and I already test and all are working well and get the expected result.but when I check with Check50,I got this msg :( tideman compiles code failed to compile I just ...
0
votes
1answer
159 views

Pset 3 runoff Randomly Increasing Votecount

I'm close to solving pset 3 runoff but I've run into this interesting problem in my tabulate function. Whenever I run the program with the debugger, my vote counts keep increasing by very large ...
0
votes
1answer
26 views

Passing arrays into function in tideman

I've created a solution to week 3's tideman problem which is entirely logically correct. Unfortunately, I had to dodge the standard solution by commenting out parts of a function and altering its ...
0
votes
1answer
38 views

resize.c write to array

I think i made a breakthrough in this one with the rewrite method but i need to know how to write the triple to the array i tried a couple of things but didn't work out here's my code : int main(int ...
0
votes
1answer
252 views

pset3 (runoff) check50 is giving an error for print_winner

I can't find what's wrong with my code but check50 keeps telling me :( print_winner prints name when someone has a majority print_winner did not print winner of election :( print_winner returns ...
0
votes
2answers
109 views

Why am I running into a segmentation error in PSET 3 plurality?

I've been working on plurality for hours now and I'm stuck with a "segmentaion error." So my approach to this problem was to sort the candidate objects in terms of votes and print the first object (...
0
votes
2answers
33 views

Can't determine the problem with my tideman program - check50 fails at lock_pairs function, says I didn't correctly lock all non-cyclical pairs

My program for the tideman problem in pset3 passes all check50 checks except for :( lock_pairs skips final pair if it creates cycle lock_pairs did not correctly lock all non-cyclical pairs Here ...
1
vote
1answer
21 views

pset3, tideman, cs50 2021

I worked with pset3 and I think there are nothing wrong with my code, but check 50 says it has 2 problems on my code. 1.:( lock_pairs skips final pair if it creates cycle 2.:( lock_pairs skips middle ...
0
votes
1answer
154 views

Plurality - check50 issue

Hoping for some insight on this.. code works perfectly fine, prints correctly when testing in terminal, but for some reason check50 outputs errors once it starts printing winners. Would love to find ...
0
votes
1answer
66 views

pset3 record_prefernces : i have segmentation fault error

i'm trying to implement record_preferences function but when i try to run the program it stops after getting first voter choices sorry for my messy thanks in advance the code :
0
votes
1answer
22 views

what does different return value signifies in this problem of runoff?

#include <cs50.h> #include <stdio.h> // Max voters and candidates #define MAX_VOTERS 100 #define MAX_CANDIDATES 9 // preferences[i][j] is jth preference for voter i int preferences[...
1
vote
5answers
131 views

check50 errors - runoff

I've been trying to resolve these myself for too long - I'm officially stuck These are the check50 errors I get: :( tabulate counts votes when multiple candidates are eliminated :( find_min ignores ...
0
votes
1answer
45 views

resize less help needed

i'm feeling so close to solve it but have some issues with the for loops i tried to debug it and see what's going on but yet there's some things i can't explain specifically with triple variable i'm ...
1
vote
2answers
51 views

My code is swapping “1”, “2” even if i have written code only for swapping “if even.”

This is my init function, please check and suggest: void init(void) { int size= d*d; for (int i=0;i<d;i++) { for (int j=0;j<d;j++) { board[i][j]=size-1; ...
0
votes
1answer
52 views

Back again with runoff problems, tabulate() passes no check50 tests

(I can't get formatting to work properly here so it might look a bit weird) void tabulate(void) { int j = 0; for(int i = 0; i < candidate_count; i++) { for( ; j < voter_count;) { ...
0
votes
1answer
60 views

Recover help - only 2 imgs are getting recovered

#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { if(argc != 2) { fprintf(stderr, "Usage: ./recover <filename>\n"); return 1; } ...
0
votes
0answers
64 views

My tabulate function won't work for multiple eliminated candidates

I dont know what to do. My tabulate function won't work for multiple eliminated candidates and multiple rounds of preferences. The rest is fine, as check50 states: :) tabulate counts votes when all ...
0
votes
1answer
68 views

My game of fifteen doesn't work

void init(void) { // TODO int fill = ((d * d) - 1); int brow = d; //fill entire grid except the bottom for(int i = 1; i <= d; i ++) { for(int j = 1; j <= d; j ++)...
0
votes
1answer
57 views

Pset3 Runoff is_tie

Having issues with Check 50 and the is_tie function: :( is_tie returns false when only some of the candidates are tied is_tie did not return false :( is_tie detects tie after some candidates have ...
0
votes
1answer
27 views

Pset3 Plurality: program runs fine when I check manually, but Check50 disagrees

I wish I could be more specific with my question, but the problem is as the title suggests, check50's results do not seem to comport to mine. When I put it through check50, it fails on print_winner ...
0
votes
1answer
19 views

Plurality error :( vote produces correct counts when all votes are zero

#include <cs50.h> #include <stdio.h> #include <string.h> // Max number of candidates #define MAX 9 // Candidates have name and vote count typedef struct { string name; int ...
0
votes
0answers
22 views

Problem incrementing vote in plurality

EDIT: I FIGURED IT OUT AND IT IS NOW WORKING. My code does not increment the vote. It correctly prints the invalid vote- but its not increment the vote at all. #include <cs50.h> #include <...
0
votes
1answer
96 views

Recovered image does not match pset3

I can't figure out what is wrong with my code. I recovered images from 000.jpg to 050.jpg. This is my code #include <stdio.h> #include <stdlib.h> #include <stdint.h> typedef ...
0
votes
1answer
39 views

Problems executing make clang-7 error cs50

Hi, do you know how to solve this error? Thanks!!
0
votes
1answer
19 views

Breakout / pause(function) slows the paddle

When I add pause(5) to the while loop, pause function makes the ball not zip around, it also seems to slow down the paddle responsiveness. What do I have to do to get around that? I do understand why ...
0
votes
1answer
260 views

PSET3 Runoff - tabulate() function for multiple eliminated candidates

I'm working on the tabulate() function, and to an extent the is_tie() function The tabulate() function passes all the tests of check50 but the last one: :( tabulate counts votes when multiple ...
0
votes
1answer
55 views

Runoff pset 3, arrrays and indexing

I don't understand what's going on with the solutions to the voter preference and tabulate functions. I had set up a similar function to the answer with the exception that I had [voter][i] = rank; ...
0
votes
1answer
144 views

How to set rank for all preferences?

Any thoughts on that to set rank for all preferences?
0
votes
1answer
27 views

pset3 search function declaration must stay the same?

Sorry for asking a probably repeated question, but I wanted to commit to a community! So the search implementation part of pset3 states: "You may not alter the function’s declaration. Its prototype ...
0
votes
1answer
23 views

How to “update” the haystack array not using pointers?

Context: In helpers.c, I can make the sort function actually sort the values[] array. Problem: However, I don't know how to re-inject this sorted array back in main without using pointers. Question: ...
0
votes
1answer
40 views

Fifteen- Pset3: Weird error that is not my fault - help

Well my Fifteen doesn't compile because get_int but I included cs50 library. What I am missing? Check the screen shot please. Thank you!
0
votes
1answer
115 views

Pset3 Helpers.c “timing out while waiting for program to exit”

I have been working on Helpers.c for an extremely long time now, and I have little help with the style of the program due to my doing this totally on my own. When I run check50 from the 2018 pset3 doc,...
0
votes
1answer
18 views

The output is only _

So in this program, the only output I am getting is _. Help would be appreciated. My init: void init(void) { // Initializing the game int square; square = (d*d) - 1; for (int i = 0 ;...
0
votes
1answer
28 views

Move function only moving underscore to the left and not replacing?

My move function is only moving right and also not replacing my tile with the switched tile. The relevant code looks like: bool move(int tile) { for (int row=0; row < d; row++ ) { ...
0
votes
1answer
15 views

Pset3, fifteen.c

In the game of fifteen, I couldn't figure out a way to view the under-score sign "_" , I tried these lines of code: if (board[i][j] == 0) //checking if value is 0 to print a blank tile. ...
0
votes
1answer
32 views

cs50 pset3 runoff tabulate function help

I have been stuck at the tabulate function for quite some time, I'm able to code all the other functions except for this tabulate functions. If possible do help me look to see what wrong with the ...
0
votes
1answer
40 views

pset3 binary search , shows errors in check50

i don't understand acc. to the algorithm it should work correctly , but it doesn't
0
votes
1answer
57 views

CS50 Pset3/less check errors

Hi I am very frustrated since 5 days that I cannot pass check50 that keeps giving me error as: Does anyone have any suggestions? :) helpers.c exists. :) helpers.c compiles. :( sorts {5,4,3,2,1} ...
0
votes
1answer
23 views

Cursor.c week 4 pset3 math question on getX - getWidth

I have watched the video on cursor.c, and I understand that the goal is to put a circle (oval) on top of the mouse cursor, but I don't get the math of the formula used. I see that it's a kindergarten ...
0
votes
1answer
27 views

Plurality print_winner function gives one error

This is my print_winner function void print_winner(void) { int winner_vote; for (int i = 0; i < candidate_count; i++) { for(int j = i + 1; j < candidate_count; j++) {...
0
votes
1answer
31 views

pset3 code not finding any numbers when in helpers.c

// TODO: implement a searching algorithm if(n <= 0) { return false; } int end = n; int start = 0; int middle = (start + end)/2; int found = 0; while(found == 0) { if(value == values[...
0
votes
1answer
29 views

pset 3 tideman print winner does not exist despite being declared

I have such a strange behavior here in pset 3, tideman. I am doing the print_winner function because check50 says everything else is fine, but when i run the program it looks like print_winner does ...
0
votes
1answer
37 views

Help finishing the move function pset3

I've been stuck on this problem for a really long time. I think I'm almost done with the move function, but I need someone to explain what I need to do. Please help me. My code is: bool move(int ...
0
votes
1answer
34 views

pset3: linear search (strange behaviour)

My code is going through check50 okay, but when I try to check it manually it doesn't seem to be able to find the needle in the haystack. I can't figure out why that is happening that's why I'm hoping ...
0
votes
1answer
33 views

pset3/fifteen/issue with board

I have an issue making my board in fifteen, i think im doing well but it shows something i can't explain. Can anyone help me? why my board numbers shudenly do this weird thing: My code: void init(...
0
votes
2answers
30 views

Fifteen.c/PSTE3 MOVE FUNCTION NOT SHOWING EXPECTED OUTPUT

Though my program fifteen.c/pset3 compiles with the int,draw,move function but the tiles are not moving at all. Here's my code as well the output.Kindly check and any suggestions will be appreciated. ...
0
votes
1answer
47 views

Init function in pset 3

I've been working on fifteen, and I started with the init function, and I want to make sure I have it right. Other than the part where you swap 1 and 2, does this look right? void init(void) { ...
0
votes
1answer
12 views

pset3 move function takes illegal moves

Alright, so I've had a go at this for a very long time, and haven't been making much progress. My problems is with this move function. It doesn't accept some illegal moves, however, some illegal moves ...
0
votes
1answer
52 views

cs50 plurality non-void function does not return a value in all control paths error

I'm currently trying to do cs50 pset3 plurality problem and I have unfortunately ran into this error which I do not know how to overcome. The error is "non-void function does not return a value ...

1
2 3 4 5
26