From a95baf583cc589b327a14fcbf3e045c8e0c1541d Mon Sep 17 00:00:00 2001 From: sonder037 Date: Mon, 24 Nov 2025 17:28:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=AE=8C=E6=88=90assignment1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assignment1/main.cpp | 61 +++++- .../student_output/courses_not_offered.csv | 149 ++++++++++++++ .../student_output/courses_offered.csv | 189 ++++++++++++++++++ assignment1/utils.cpp | 2 +- 4 files changed, 391 insertions(+), 10 deletions(-) diff --git a/assignment1/main.cpp b/assignment1/main.cpp index 9b372fc..8316584 100644 --- a/assignment1/main.cpp +++ b/assignment1/main.cpp @@ -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; }; /** @@ -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 courses) { - /* (STUDENT TODO) Your code goes here... */ +void parse_csv(std::string filename, std::vector &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(); + } } /** @@ -80,8 +94,25 @@ void parse_csv(std::string filename, std::vector 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 all_courses) { - /* (STUDENT TODO) Your code goes here... */ +void write_courses_offered(std::vector &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 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); + } + } } /** @@ -98,7 +129,20 @@ void write_courses_offered(std::vector all_courses) { * @param unlisted_courses A vector of courses that are not offered. */ void write_courses_not_offered(std::vector 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 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() { @@ -113,6 +157,5 @@ int main() { write_courses_offered(courses); write_courses_not_offered(courses); - return run_autograder(); } \ No newline at end of file diff --git a/assignment1/student_output/courses_not_offered.csv b/assignment1/student_output/courses_not_offered.csv index e69de29..3fa9909 100644 --- a/assignment1/student_output/courses_not_offered.csv +++ b/assignment1/student_output/courses_not_offered.csv @@ -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 diff --git a/assignment1/student_output/courses_offered.csv b/assignment1/student_output/courses_offered.csv index e69de29..a468a18 100644 --- a/assignment1/student_output/courses_offered.csv +++ b/assignment1/student_output/courses_offered.csv @@ -0,0 +1,189 @@ +Title,Number of Units,Quarter +Personal Finance for Engineers,1,2023-2024 Autumn +How to Make VR: Introduction to Virtual Reality Design and Development,2,2023-2024 Autumn +Introduction to Mobile Augmented Reality Design and Development,1,2023-2024 Spring +AI for Social Good,2,2023-2024 Spring +Transformers United V3,1,2023-2024 Autumn +Computational Decision Making,3,2023-2024 Winter +Counterfactuals: The Science of What Ifs?,3,2023-2024 Summer +Cloud Infrastructure and Scalable Application Deployment,3,2023-2024 Winter +Great Ideas in Graphics,3,2023-2024 Autumn +Using Bits to Control Atoms,3,2023-2024 Summer +CS + Social Good Studio: Designing Social Impact Projects,2,2023-2024 Winter +CS + Social Good Studio: Implementing Social Good Projects,2,2023-2024 Spring +How Can Generative AI Help Us Learn?,3,2023-2024 Spring +Dissecting The Modern Computer,2,2023-2024 Autumn +Playback Theater,3,2023-2024 Winter +Problem-solving Lab for CS106A,1,2023-2024 Autumn +Problem-solving Lab for CS106B,1,2023-2024 Winter +Mathematical Foundations of Computing,5,2023-2024 Winter +Mathematical Problem-solving Strategies,1,2023-2024 Autumn +Introduction to Essential Software Systems and Tools,3,2023-2024 Winter +Introduction to Computers,5,2023-2024 Autumn +Programming Methodology,5,2023-2024 Winter +Programming Methodologies in JavaScript and Python (Accelerated),5,2023-2024 Autumn +Programming Abstractions,5,2023-2024 Spring +Exploration of Computing,3,2023-2024 Spring +Standard C++ Programming Laboratory,1,2023-2024 Autumn +Enrichment Adventures in Programming Abstractions,1,2023-2024 Autumn +Coding for Social Good,1,2023-2024 Autumn +Computer Organization and Systems,5,2023-2024 Autumn +Problem-solving Lab for CS107,1,2023-2024 Spring +Computer Systems from the Ground Up,5,2023-2024 Winter +Object-Oriented Systems Design,4,2023-2024 Winter +Introduction to Probability for Computer Scientists,5,2023-2024 Winter +Problem-solving Lab for CS109,1,2023-2024 Winter +Operating Systems Principles,5,2023-2024 Autumn +Problem Solving Lab for CS111,1,2023-2024 Winter +Operating systems kernel implementation project,3,2023-2024 Winter +A Hands-On Introduction to Building AI-Enabled Robots,3,2023-2024 Autumn +Applied Machine Learning,4,2023-2024 Winter +Computer Vision: Foundations and Applications,4,2023-2024 Winter +Operating systems design and implementation,4,2023-2024 Winter +Compilers,4,2023-2024 Spring +Introduction to Computer Networking,4,2023-2024 Winter +Data Management and Data Systems,4,2023-2024 Autumn +Introduction to Human-Computer Interaction Design,5,2023-2024 Autumn +Cross-platform Mobile App Development,3,2023-2024 Autumn +Introduction to Computer Graphics and Imaging,4,2023-2024 Summer +Parallel Computing,4,2023-2024 Autumn +Logic Programming,3,2023-2024 Spring +Trust and Safety Engineering (COMM 122),3,2023-2024 Spring +Applied Security at Scale,3,2023-2024 Winter +Introduction to the Theory of Computation,4,2023-2024 Autumn +Computer and Network Security,3,2023-2024 Spring +Computational Logic,3,2023-2024 Autumn +Design and Analysis of Algorithms,5,2023-2024 Winter +Problem-Solving Lab for CS161,1,2023-2024 Winter +The Modern Algorithmic Toolbox,4,2023-2024 Spring +Human Centered Product Management,4,2023-2024 Autumn +Coding with LLM Assistants,2,2023-2024 Autumn +Software Design Studio,4,2023-2024 Winter +Senior Project,6,2023-2024 Summer +Writing Intensive Senior Research Project,6,2023-2024 Spring +Programming Service Project,4,2023-2024 Summer +Client-Side Internet Technologies,3,2023-2024 Summer +Introduction to Python Programming,1,2023-2024 Autumn +Software Project,3,2023-2024 Winter +User Interface Design Project,4,2023-2024 Winter +Software Project (WIM),3,2023-2024 Spring +Supervised Undergraduate Research,4,2023-2024 Autumn +Computer Science Research,4,2023-2024 Winter +Computer Science Research: CURIS Internship Onramp,3,2023-2024 Spring +Teaching Computer Science,4,2023-2024 Spring +Additional Topics in Teaching Computer Science,1,2023-2024 Autumn +Independent Work,6,2023-2024 Autumn +Independent Work,6,2023-2024 Winter +Law for Computer Science Professionals,1,2023-2024 Spring +Continuous Mathematical Methods with an Emphasis on Machine Learning,3,2023-2024 Winter +Exploring Computational Journalism (COMM 281),3,2023-2024 Winter +Software Project Experience with Corporate Partners,4,2023-2024 Winter +Software Project Experience with Corporate Partners,4,2023-2024 Spring +Operating Systems and Systems Programming,5,2023-2024 Winter +Artificial Intelligence: Principles and Techniques,4,2023-2024 Spring +Introduction to Robotics (ME 320),3,2023-2024 Winter +NLP for Computational Social Science,3,2023-2024 Spring +Apps With LLMs Inside,3,2023-2024 Winter +Deep Reinforcement Learning,3,2023-2024 Spring +Spoken Language Processing (LINGUIST 285),4,2023-2024 Spring +Conversational Virtual Assistants with Deep Learning,4,2023-2024 Autumn +Machine Learning with Graphs,4,2023-2024 Autumn +Machine Learning for Discrete Optimization (MS&E 236),3,2023-2024 Spring +Experimental Robotics,3,2023-2024 Spring +General Game Playing,3,2023-2024 Spring +Probabilistic Graphical Models: Principles and Techniques,4,2023-2024 Winter +Machine Learning (STATS 229),4,2023-2024 Winter +Machine Learning for Sequence Modeling (STATS 232),4,2023-2024 Autumn +Machine Learning Theory (STATS 214),3,2023-2024 Autumn +Systems for Machine Learning,3,2023-2024 Autumn +Deep Learning,4,2023-2024 Spring +Computer Vision: From 3D Reconstruction to Recognition,4,2023-2024 Spring +Deep Learning for Computer Vision,4,2023-2024 Spring +Geometric and Topological Data Analysis (CME 251),3,2023-2024 Winter +Reinforcement Learning,3,2023-2024 Spring +Deep Generative Models,3,2023-2024 Autumn +Decision Making under Uncertainty (AA 228),4,2023-2024 Autumn +Advanced Topics in Sequential Decision Making (AA 229),4,2023-2024 Winter +Advanced Topics in Operating Systems,3,2023-2024 Spring +Embedded Systems Workshop (EE 285),3,2023-2024 Winter +Programming Languages,4,2023-2024 Autumn +Program Analysis and Optimizations,4,2023-2024 Winter +Advanced Topics in Networking,4,2023-2024 Spring +Distributed Systems,3,2023-2024 Spring +Mining Massive Data Sets,4,2023-2024 Winter +Design for Artificial Intelligence (SYMSYS 195A),4,2023-2024 Autumn +Design for Behavior Change (SYMSYS 195B),4,2023-2024 Winter +Design for Play (SYMSYS 195G),4,2023-2024 Spring +Service Design (SYMSYS 195S),4,2023-2024 Winter +Fundamentals of Computer Graphics: Animation and Simulation,3,2023-2024 Autumn +The Modern Internet,3,2023-2024 Winter +Cryptocurrencies and blockchain technologies,3,2023-2024 Autumn +Computational Complexity,3,2023-2024 Winter +Computational Complexity II,3,2023-2024 Spring +Introduction to Cryptography,3,2023-2024 Winter +Algorithmic Fairness,3,2023-2024 Winter +Introduction to Automated Reasoning,3,2023-2024 Autumn +Quantum Computing,3,2023-2024 Autumn +Optimization and Algorithmic Paradigms,3,2023-2024 Autumn +Counting and Sampling,3,2023-2024 Autumn +Randomized Algorithms and Probabilistic Analysis (CME 309),3,2023-2024 Autumn +Incentives in Computer Science,3,2023-2024 Spring +Modeling Biomedical Systems (BIOMEDIN 210),3,2023-2024 Winter +Symbolic Musical Information (MUSIC 253),4,2023-2024 Winter +Computational Music Analysis (MUSIC 254),4,2023-2024 Spring +Foundation Models for Healthcare (BIODS 271),3,2023-2024 Winter +Ethics of Artificial Intelligence,4,2023-2024 Spring +Applied Causal Inference with Machine Learning and AI (MS&E 228),3,2023-2024 Winter +Empowering Educators via Language Technology (EDUC 473),4,2023-2024 Autumn +Software Engineering,3,2023-2024 Winter +Seminar on Teaching Introductory Computer Science (EDUC 298),1,2023-2024 Autumn +Departmental Lecture Series,1,2023-2024 Autumn +Cloud Computing Seminar,1,2023-2024 Autumn +History of Natural Language Processing,4,2023-2024 Winter +Topics in Advanced Robotic Manipulation,4,2023-2024 Autumn +Advanced Robotic Manipulation (ME 323),3,2023-2024 Spring +Foundations of Causal Machine Learning,3,2023-2024 Autumn +Machine Learning from Human Preferences,3,2023-2024 Autumn +Machine Programming,4,2023-2024 Autumn +Trustworthy Machine Learning,3,2023-2024 Autumn +Deep Multi-task and Meta Learning,3,2023-2024 Autumn +Language Modeling from Scratch,3,2023-2024 Spring +AI-Assisted Care (MED 277),4,2023-2024 Autumn +Collaborative Robotics (ME 326),3,2023-2024 Winter +Rusty Systems,3,2023-2024 Spring +Building for Digital Health (MED 253),4,2023-2024 Winter +Domain-Specific Programming Models and Compilers,3,2023-2024 Winter +Human-Computer Interaction: Foundations and Frontiers,4,2023-2024 Spring +Computer Graphics: Animation and Simulation,3,2023-2024 Winter +Computer Graphics in the Era of AI,4,2023-2024 Winter +Visual Computing Systems,4,2023-2024 Spring +Cloud Computing Technology,3,2023-2024 Spring +Software Techniques for Emerging Hardware Platforms (EE 292Y),3,2023-2024 Autumn +Seminar on Logic & Formal Philosophy (PHIL 391),4,2023-2024 Winter +Advanced Topics in Cryptography,3,2023-2024 Spring +Topics in Computer and Network Security,3,2023-2024 Autumn +Engineering Design Optimization (AA 222),4,2023-2024 Spring +Computational Social Choice (MS&E 336),3,2023-2024 Winter +Artificial Intelligence for Precision Medicine and Psychiatric Disorders,3,2023-2024 Spring +Large-Scale Neural Network Modeling for Neuroscience (PSYCH 249),3,2023-2024 Winter +Designing Serious Games,4,2023-2024 Autumn +Designing for Accessibility (ME 214),4,2023-2024 Spring +Understanding Users,4,2023-2024 Spring +Curricular Practical Training,1,2023-2024 Winter +Curricular Practical Training,1,2023-2024 Winter +Curricular Practical Training,1,2023-2024 Spring +Part-time Curricular Practical Training,1,2023-2024 Summer +Independent Project,9,2023-2024 Spring +Independent Project,9,2023-2024 Autumn +Interactive and Embodied Learning (EDUC 234A),3,2023-2024 Winter +Computer Vision for Education and Social Science Research (EDUC 463),3,2023-2024 Winter +Computational Imaging (EE 367),3,2023-2024 Winter +Music and AI (MUSIC 356),4,2023-2024 Winter +Introduction to CSCL: Computer-Supported Collaborative Learning (EDUC 315A),3,2023-2024 Winter +Advanced Reading and Research,15,2023-2024 Summer +Advanced Reading and Research,15,2023-2024 Summer +Seminar in Artificial Intelligence in Healthcare,1,2023-2024 Autumn +Machine Learning Systems Seminar,1,2023-2024 Winter +Robotics and Autonomous Systems Seminar (AA 289),1,2023-2024 Spring +Human-Computer Interaction Seminar,1,2023-2024 Autumn +TGR Dissertation,0,2023-2024 Summer diff --git a/assignment1/utils.cpp b/assignment1/utils.cpp index 5edf34d..41cccd6 100644 --- a/assignment1/utils.cpp +++ b/assignment1/utils.cpp @@ -63,7 +63,7 @@ bool operator==(const Course& lhs, const Course& rhs) { } std::ostream& operator<<(std::ostream& os, const Course& course) { - os << course.title << ", " << course.number_of_units << ", " << course.quarter; + os << course.title << "," << course.number_of_units << "," << course.quarter; return os; }