Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 52 additions & 9 deletions assignment1/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const std::string COURSES_NOT_OFFERED_PATH = "student_output/courses_not_offered
* Hint: Remember what types C++ streams work with?!
*/
struct Course {
/* STUDENT TODO */ title;
/* STUDENT TODO */ number_of_units;
/* STUDENT TODO */ quarter;
std::string title;
std::string number_of_units;
std::string quarter;
};

/**
Expand Down Expand Up @@ -58,8 +58,22 @@ struct Course {
* @param filename The name of the file to parse.
* @param courses A vector of courses to populate.
*/
void parse_csv(std::string filename, std::vector<Course> courses) {
/* (STUDENT TODO) Your code goes here... */
void parse_csv(std::string filename, std::vector<Course> &courses) {
std::ifstream file(filename);
if (file.is_open()) {
std::string line;
std::getline(file, line);
while (std::getline(file, line)) {
auto parts = split(line, ',');
Course course;
course.title = parts[0];
course.number_of_units = parts[1];
course.quarter = parts[2];
courses.push_back(course);
}

file.close();
}
}

/**
Expand All @@ -80,8 +94,25 @@ void parse_csv(std::string filename, std::vector<Course> courses) {
* @param all_courses A vector of all courses gotten by calling `parse_csv`.
* This vector will be modified by removing all offered courses.
*/
void write_courses_offered(std::vector<Course> all_courses) {
/* (STUDENT TODO) Your code goes here... */
void write_courses_offered(std::vector<Course> &all_courses) {
std::string file_name = "./student_output/courses_offered.csv";
std::ofstream file(file_name);
if (file.is_open()) {
file << "Title,Number of Units,Quarter" << std::endl;
std::vector<Course> courses_to_delete;
for (const auto & course : all_courses) {
if (course.quarter != "null") {
file << course << std::endl;
courses_to_delete.push_back(course);
}
}

file.close();

for (const auto & course : courses_to_delete) {
delete_elem_from_vector(all_courses, course);
}
}
}

/**
Expand All @@ -98,7 +129,20 @@ void write_courses_offered(std::vector<Course> all_courses) {
* @param unlisted_courses A vector of courses that are not offered.
*/
void write_courses_not_offered(std::vector<Course> unlisted_courses) {
/* (STUDENT TODO) Your code goes here... */
std::string file_name = "./student_output/courses_not_offered.csv";
std::ofstream file(file_name);
if (file.is_open()) {
file << "Title,Number of Units,Quarter" << std::endl;
std::vector<Course> courses_to_delete;
for (const auto & course : unlisted_courses) {
if (course.quarter == "null") {
file << course << std::endl;
courses_to_delete.push_back(course);
}
}

file.close();
}
}

int main() {
Expand All @@ -113,6 +157,5 @@ int main() {

write_courses_offered(courses);
write_courses_not_offered(courses);

return run_autograder();
}
149 changes: 149 additions & 0 deletions assignment1/student_output/courses_not_offered.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
Title,Number of Units,Quarter
Introduction to Computing at Stanford (VPTL 1),1,null
Practical Unix,1,null
Problem-Solving for the CS Technical Interview,1,null
Introduction to Version Control with Git,1,null
Beyond NLP: CS & Language through Text Input & Design,1,null
Hap.py Code: The Python Programming Language,2,null
Functional Programming Abstractions,2,null
Software Tools Every Programmer Should Know,2,null
Working with Data: Delights and Doubts,3,null
Cross-Platform Mobile Development,2,null
Using Tech for Good,2,null
Great Discoveries and Inventions in Computing,3,null
Randomness: Computational and Philosophical Approaches (PHIL 3N),3,null
You Say You Want a Revolution (Blockchain Edition),2,null
The Blockchain Revolution Will Not Be Televised,3,null
Quantum Computing: Open-Source Project Experience,2,null
Computation for Puzzles and Games,1,null
Race and Gender in Silicon Valley (AFRICAAM 80Q),3,null
AI Interpretability and Fairness,1,null
Wellness in Tech: Designing an Intentional Lifestyle in a Tech-Driven World,1,null
Emotional Intelligence,2,null
Digital Canvas: An Introduction to UI/UX Design,2,null
Digital Canvas: An Introduction to UI/UX Design,2,null
Teaching AI,1,null
Introduction to Computing Principles,5,null
Working with Data - Tools and Techniques,4,null
Programming Abstractions (Accelerated),5,null
Principles of Computer Systems,5,null
Problem Solving Lab for CS110,1,null
Safety in Systems Programming,2,null
Selected Reading of Computer Science Research,3,null
Human Centered NLP (CS 329X),4,null
Human-Centered AI,3,null
Operating Systems and Systems Programming,5,null
Web Applications,3,null
Introduction to Game Design and Development,4,null
The Practice of Theory Research,3,null
Data Structures,4,null
Effective Leadership in High-Tech,1,null
Bridging Policy and Tech Through Design (PUBLPOL 170),4,null
Design for Advocacy,4,null
Android Programming,3,null
iOS Application Development,3,null
Video Game Development in C++ and Unreal Engine,3,null
Web Programming Fundamentals,3,null
Android Programming Workshop,1,null
Computer Consulting (VPTL 196),2,null
Computational Law,3,null
Antidiscrimination Law and Algorithmic Bias,3,null
Great Ideas in Computer Science,3,null
Creating Great VR: From Ideation to Monetization,1,null
Selected Reading of Computer Science Research,3,null
Hardware Accelerators for Machine Learning,4,null
The Future of Mechanical Engineering (ME 228),1,null
Computer Vision and Image Analysis of Art,3,null
Digital Image Processing (EE 368),3,null
Generative Adversarial Networks,3,null
Principles of Data-Intensive Systems,4,null
Mining Massive Data Sets Hadoop Lab,1,null
Design for Understanding,4,null
Algebraic Error Correcting Codes (EE 387),3,null
Analysis of Boolean Functions,3,null
Web Security,3,null
Geometry of Polynomials in Algorithm Design,3,null
Geometric Algorithms,3,null
Almost Linear Time Graph Algorithms (MS&E 313),3,null
Introduction to Optimization Theory (MS&E 213),3,null
Elements of Quantum Computer Programming,3,null
Information Retrieval and Web Search (LINGUIST 286),3,null
Research Project in Artificial Intelligence,3,null
Research Project in Software Systems and Security,3,null
Writing Intensive Research Project in Computer Science,3,null
Industrial Lectureships in Computer Science,1,null
Parallel Computing Research Project,3,null
Advanced Multi-Core Systems,3,null
Topics in Digital Systems,3,null
Value of Data and AI,3,null
The AI Awakening: Implications for the Economy and Society,4,null
The AI Awakening: Implications for the Economy and Society,3,null
Advances in Foundation Models,3,null
Topics in Artificial Intelligence,3,null
Machine Learning Under Distributional Shifts,3,null
Machine Learning on Embedded Systems (EE 292D),3,null
Practical Machine Learning,4,null
Machine Learning Systems Design,4,null
Human Centered NLP (CS 129X),4,null
Interactive Simulation for Robot Learning,3,null
Advanced Survey of Reinforcement Learning,3,null
Algorithms for Interactive Robotics,4,null
Physical Human Robot Interaction,3,null
Human-Computer Interaction and AI/ML,3,null
Topics in Computer Systems,4,null
Advanced Operating System Lab: Accelerated (II),2,null
Project in Mining Massive Data Sets,3,null
Topics in Computer Networks,3,null
Data-intensive Systems for the Next 1000x,4,null
Computer Graphics: Geometric Modeling & Processing,3,null
Computer Graphics: Image Synthesis Techniques,4,null
Neural Models for 3D Geometry,3,null
Topics in Programming Systems,3,null
Technology for Financial Systems,2,null
Selected Reading of Ph.D. Dissertations,3,null
Machine Learning for Software Engineering,4,null
Project Lab: Video and Audio Technology for Live Theater in the Age of COVID (EE 192T),3,null
Secure Compilation,3,null
Open Problems in Coding Theory,3,null
Blockchain Governance,3,null
Topics in Intractability: Unfulfilled Algorithmic Fantasies,3,null
Advanced Topics in Formal Methods,3,null
Formal Methods for Computer Systems,3,null
Topics in Programming Language Theory,3,null
Programming Language Foundations,3,null
Topics in the Theory of Computation,3,null
Research Seminar in Complexity Theory,3,null
Quantum Complexity Theory,3,null
Simplicity and Complexity in Economic Theory (ECON 284),5,null
Research in AI Alignment,3,null
Algorithmic Techniques for Big Data,3,null
Topics in Analysis of Algorithms,3,null
Algorithmic Perspective on Machine Learning,3,null
Metric Embeddings and Algorithmic Applications,3,null
Dynamic Data Structures for Graphs,3,null
Topics in Human-Computer Interaction,3,null
Designing Solutions to Global Grand Challenges (DESIGN 297),4,null
Introduction to the Design of Smart Products (ME 216M),4,null
Topics in Human-Computer Interaction: Teaching Studio Classes,3,null
Computational Models of the Neocortex,3,null
Sensorimotor Learning for Embodied Agents (EE 381),3,null
Seminar on Ethical and Social Issues in Natural Language Processing (LINGUIST 287),4,null
Computational Education,4,null
Designing AI to Cultivate Human Well-Being,2,null
Probabilistic models of cognition: Reasoning and Learning (PSYCH 220A),3,null
High-level Vision: From Neurons to Deep Neural Networks (PSYCH 250),3,null
Topics in Computer Graphics,4,null
Topics in Computer Graphics: Agile Hardware Design,3,null
Making Making Machines for Makers,4,null
Hacking the Pandemic,3,null
Topics in Computer Graphics: Computational Video Manipulation,3,null
Physically Based Animation and Sound,4,null
Topics in Geometric Algorithms: Non-Euclidean Methods in Machine Learning,3,null
Digital Technology and Law: Foundations,3,null
Knowledge Graphs,1,null
Seminar on AI Safety,1,null
Research Seminar in Computer Vision + X,2,null
Research Seminar in Computer Vision and Healthcare,1,null
Human-Computer Interaction in the Real World,1,null
Surgical Robotics Seminar (ME 571),1,null
Media Innovation,1,null
Loading