Assignment due on Paperless on Sunday, Jan 23 at 11:59 PM
It's undeniable: human beings are obsessed with finding patterns. Whether it's in the mysteries of language, the beauties of art, or the depths of strategic games, finding patterns is built into our DNA. In fact, some biologists believe that finding patterns is what sets us apart as a species.
One interesting place to find interesting patterns is Wikipedia. For example, we can play a game called WikiRacer, where we try to move from one article to another with the fewest number of clicks. Try a round online before you move on!
In Assignments 1 and 2, we will be building a standard C++ program that plays WikiRacer! Specifically, it will find a path between two given Wikipedia articles in the fewest number of links. Throughout this and next assignment, we'll refer to this path as a "ladder." In the process of completing Assignments 1 and 2, you will get practice working with iterators, algorithms, templates, and special containers like a priority queue. We expect that this assignment will take you less than 30 minutes.
To simplify the implementation and allow for some testing, we will do this in two parts (A1 and A2). For Assignment 1, you will be writing the user-facing side of the program.
You will have access to a function findWikiLadder that finds ladders between Wikipedia topics for you (you'll implement the core of this interesting search algorithm that finds the ladder in A2).
You're in charge with writing parts of a main() function that will take a user-inputted file name, read in the file,
find Wiki ladders between the start and end destinations in the file, and print out the ladder. Let's get started!
If you haven't already, please follow the instructions on this page before proceeding. Please do both the one-time instructions and the instructions for editing each assignment. Since we're working on assignment1, you can follow the instructions exactly. If you have any questions at all, please don't hesitate to send us an email!
If you've already completed the Assignment Setup and downloaded, and set up Assignment 1, you are all set to start coding! In this assignment, you'll only be editing main.cpp.
The assignment comes with sample files you can test your programs on in the "res" folder. We'd recommend exploring them, as well as adding your own test cases in random.txt.
std::ifstream),
and then process the file data appropriately for the given program as follows.
input-small.txt or input-big.txt
for an example. You can assume files will be formatted correctly.findWikiLadder and append its result to the outputLadders vector. To see its function signature (and thus what parameters the findWikiLadder function takes), check out wikiscraper.h!
outputLadders, however you may like!Implementation tips:
cin and getline!stoi(line) function, which takes in a string line and returns the integer it represents.findWikiLinks. The starter code already prints out filenames upon which to test your code.That's it! We've made this assignment a bit shorter than usual, to accommodate for setting up your environment,
the surely hectic return to campus, and to give you capacity to explore the assignment code. We recommend adding your own Wiki ladders to
random.txt, as well as checking out wikiscraper.h and setup.sh. This assignment (and class) is one that will reward
you for putting more effort into learning from the materials we provide you!. Lastly, you can expect future assignments to take around as long as this one took you.