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
3 views

Please help me by reviewing my logic for Tabulate in Runoff Pset3

Let's say 3 candidates were their initially and A and B got 2 votes each while C got 1 hence C should be eliminated then in the next round we need to see the second preference votes right? As the ...
0
votes
0answers
2 views

pset 3 Runoff Where is my code wrong?

I have written the functions but I am not sure which one is wrong as I am not getting any output Here is my code: // Record preference if vote is valid bool vote(int voter, int rank, string name) { ...
0
votes
1answer
12 views

Tabulate in Runoff

Finally took a break for a few days to think about stuff and I am back at doing psets Now I am trying to fix the tabulate function, here's my code - void tabulate(void) { for (int i = 0; i < ...
0
votes
1answer
149 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
7 views

Vote Function in Runoff

Here's my code bool vote(int voter, int rank, string name) { int j = 0; for (int i = 0; i < voter_count; i++) if (strcmp(name, candidates[i].name) == 0) { preferences[i][...
0
votes
1answer
59 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
19 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[...
0
votes
0answers
8 views

Tabulate function in Runoff

Here is my code void tabulate(void) { for (int i = 0; i < candidate_count; i++) if (strcmp(candidates[preferences[i][0]].name, candidates[i].name) == 0) { ...
0
votes
0answers
16 views

PSET3 Tideman Sorting Check50 Error

What's the difference between these two codes? Why does the first return me no error from check50 while the second one does? void sort_pairs(void) { int max; for (int i = 0; i < pair_count; ...
0
votes
0answers
10 views

Is my vote function correct in Runoff?

I have started runoff and just completed step 1 that is to write the vote function can someone tell me if it's correct? It seems to give the correct output but I don't think I used int rank in the ...
0
votes
1answer
14 views

Are we supposed to use Algorithms in pset3?

I know it might sound silly but I've done Plurality and right now I am doing Runoff but I don't feel the need to use any of the algorithms like Bubble Sort etc. specifically. Is this right or should I ...
0
votes
0answers
5 views

pset 3 runoff - problem with tabulate

I am a (very) beginner coder, so pls be gentle!! I have numerous mistakes in my code, but am unsure how to fix them. The code is working for some things, and I have scored 73 % on the problem set, but ...
1
vote
5answers
123 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
50 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
0answers
8 views

cs50 pset3 print winner function

Im strugling with print_winner function in Tideman election program. In my opinion function workes fine. It prints the candidate which has all false values in column under his name (number) in locked ...
0
votes
1answer
28 views

Tideman sort_pairs seems correct but check50 tells me it isn't

Here is the code for my pair sorting algorithm. void sort_pairs(void) { int sorted_pairs_added = 0; for (int i = voter_count; i > 0; i += -1) { for (int j = 0; j < pair_count;...
0
votes
1answer
62 views

PSET3 Runoff — cannot seem to resolve “is_tie detects tie after some candidates have been eliminated”

I have been looking up and down through my code to no avail. Check50 shows that all tests are successful except for "is_tie detects tie after some candidates have been eliminated". I haven't the ...
0
votes
1answer
26 views

Check50 all green but my own tests fail

I completed Runoff with 100% pass in check50 but when i do my own tests i get wrong winners. I checked everything to the best of my abilities but i just can't find the problem and it's driving me ...
1
vote
1answer
832 views

pset3 (runoff) keep getting print_winner error when using check50

I keep getting these errors when running check50 on my runoff program: print_winner prints name when someone has a majority print_winner did not print winner of election print_winner returns ...
0
votes
1answer
45 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
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
12 views

Converting Tideman Cycle test from Python to C

I have written a program in python that (as far as I know) successfully determines whether the locked matrix has a loop in it. However I am having a bit of trouble converting it to C. I am getting an ...
0
votes
1answer
28 views

CS50 Runoff Tabulate

So I have been working on the tabulate function and Check50 says that the function is correct and it does properly work when no candidate is eliminated and when one is eliminated, but not when ...
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
0answers
17 views

help with pset3 tideman lock_pairs function

This function is a recursive function, that lock_pairs is using to understand if a pair will create a cycle: bool create_cycle(int win_idx, int orig_idx) { if (win_idx == orig_idx) // if it's not ...
0
votes
1answer
137 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
49 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
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
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
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
0answers
22 views

cs50 pset3 tideman lock pairs and print winner function are not working rest all are working

in lock pair (lock_pairs skips final pair if it creates cycle is working) rest all lock_pair and print winner is not working. #include <cs50.h> #include <stdio.h> #include <string.h> ...
0
votes
1answer
108 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
0answers
23 views

PSET3 Tideman: Help with lock_pairs function

how's it going? I'm now working on Tideman but I'm now having a hard time why my code does not satisfy all the condition, only the first one: :) lock_pairs locks all pairs when no cycles These two ...
0
votes
1answer
119 views

How to set rank for all preferences?

Any thoughts on that to set rank for all preferences?
0
votes
1answer
26 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
32 views

Problems executing make clang-7 error cs50

Hi, do you know how to solve this error? Thanks!!
0
votes
0answers
30 views

I'm STUCK for a good while in pset3 Tideman last 3 functions :(

I'm mostly concerned about the sort_pairs() function atm, but i'm willing to receive answers regarding the whole code. I can't really see what's wrong with the way i coded it in general, but mostly ...
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
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
37 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
0answers
11 views

My program does **NOT** skip the last pair if it creates cycle. #PSET3 #Tideman

my program has apparently one bug. check50 says my program does NOT skip the last pair if it creates cycle. However, I ran my function through debug and it did skip the last pair and did not write ...
0
votes
1answer
36 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
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
11 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
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
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
18 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
62 views

pset3 Segmentation fault ./generate 1000 50 | ./find 127

the generate.c file compiles and runs well and the find.c also compiles and runs well but i don't know why is i can't test them together

1
2 3 4 5
26