1. Homepage
  2. Programming
  3. CS537 Introduction to Operating Systems - Project 1: Letter Boxed

CS537 Introduction to Operating Systems - Project 1: Letter Boxed

Engage in a Conversation
WISCCS537Introduction to Operating SystemsLetter BoxedCC++

title: CS 537 Project 1 layout: default CourseNana.COM


CS537 Fall 2024, Project 1

Updates

  • TBD

Administrivia

  • A few sample tests are provided in the project repository. To run them, execute run-tests.sh in the tests/ directory. Try run-tests.sh -h to learn more about the testing script. Note these test cases are not complete, and you are encouraged to create more on your own.
  • Handing it in: Copy the whole project, including solution and tests folder, to ~cs537-1/handin/login/p1 where login is your CS login.

Letter Boxed

In this assignment, you will write a program which checks solutions to the word game Letter Boxed. CourseNana.COM

Learning Objectives: CourseNana.COM

  • Re-familiarize yourself with the C programming language
  • Familiarize yourself with a shell / terminal / command-line of Linux
  • Learn about file I/O, string processing, and simple data structures in C

Summary of what gets turned in: CourseNana.COM

  • One .c file: letter-boxed.c
  • It is mandatory to compile your code with following flags -std=c17 -O2 -Wall -Wextra -Werror -pedantic -o letter-boxed.
    • Check man gcc and search for these flags to understand what they do and why you will like them.
    • It is a good idea to create a Makefile so you just type make for the compilation.
    • We are trying to use the most recent version of the C language. However, the compiler (gcc on lab machines) does not support final C23 specification, which is the most recent one. So we are using the second most recent (C17).
  • It should (hopefully) pass the tests we supply.
  • Include a single README.md describing the implementation. This file should include your name, your cs login, you wisc ID and email, and the status of your implementation. If it all works then just say that. If there are things you know doesn't work let me know.

letter-boxed

The program you will build is called letter-boxed. This program plays the New York Times puzzle Letter Boxed. It takes two command line arguments -- a board file and a dictionary file. Then, it reads words from standard input (STDIN) until the board is solved, or until an invalid solution is attempted. CourseNana.COM

Here is what it looks like to run the program: CourseNana.COM

$ ./letter-boxed board1.txt dict.txt

Rules of the game

The rules of letter boxed are simple. Given a letter boxed board, you must use each letter in the board at least once to form words found in the dictionary. You can start on any letter, but the first character of each subsequent word must be the same as the last character of the previous word. Letters on the same side of the board may not be used consecutively. Letters can be used more than once, even in a single word. Letters not present on the board must not be used. If a letter is present on one side of the board, it cannot be present on other sides, i.e. just a single occurrence of a letter on the board. CourseNana.COM

For simplicity, we will only use lower-case ASCII characters a-z. Thus, there are 26 characters in the entire alphabet in use for this project. This is true for the boards, dictionary, and solution inputs. CourseNana.COM

Let us look at an example: CourseNana.COM

    r  o  k
  +---------+
  |         |
 w|         |e
  |         |
 f|         |d
  |         |
 a|         |n
  |         |
  +---------+
    l  c  i

A solution to this board could be CourseNana.COM

flan
now
wreck
kid

However, wrecked would be an invalid word because the e and d are on the same side of the board. The same solution with the words in a different order would also be invalid, because that would break the rule of consecutive words sharing their last/first letters. CourseNana.COM

Since we are writing a programmatic solver, we can be more flexible with the game. Boards might have more than four sides (although never less than three), and sides need not always have three letters. CourseNana.COM

File formats

The picture above is suitable for humans playing the game. Our board files are a little simpler -- a board file has one line of text per side of the board. CourseNana.COM

$ cat board1.txt
rok
edn
lci
wfa

The dictionary file will have one word per line. CourseNana.COM

You can expect the solution to be input through standard input (STDIN) as one word per line. The program should run until an invalid board is detected, an input error is found, the board is solved, or end of file (EOF) is reached. CourseNana.COM

Possible outputs

  • If the board is invalid (less than 3 sides), print Invalid board\n and exit with return code 1.
  • If a board contains a letter more than once, print Invalid board\n and exit with return code 1.
  • If the solution uses a letter not present on the board, print Used a letter not present on the board\n and exit with return code 0.
  • If the solution does not use all the letters on the board, print Not all letters used\n and exit with return code 0.
  • If the solution illegally uses letters on the same side of the board consecutively, print Same-side letter used consecutively\n and exit with return code 0.
  • If the solution uses a word not found in the dictionary, print Word not found in dictionary\n, and exit with return code 0.
  • If the first character of a word in the solution is not the same as the last character in the preceding word, print First letter of word does not match last letter of previous word\n and exit with return code 0.
  • If the solution is correct, print Correct\n, and exit with return code 0.
  • All other errors (wrong number of arguments, open file failed, etc.) should exit with code 1.

Tips

  • When working with any C library functions, check their manual page (man) for a description and proper usage, e.g. man 3 fopen.
  • To work with files, look at man 3 fopen and man 3 fclose.
  • To read data from files and STDIN, consider using getline(3), fgets(3), or maybe scanf(3).
  • Printing to the terminal can be done with printf(3).
  • You don't know the size of boards, words, or the dictionary ahead of time, so you will need to dynamically allocate memory.
  • You will need to compare words against the dictionary. We aren't evaluating your program based on performance, so you could use something as simple as a linked list and linear search, but feel free to explore faster solutions like a dynamically-sized array with binary search, or tries.

Acknowledgments

Assignment written by John Shawger, Letter Boxed may be found at www.nytimes.com CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
WISC代写,CS537代写,Introduction to Operating Systems代写,Letter Boxed代写,C代写,C++代写,WISC代编,CS537代编,Introduction to Operating Systems代编,Letter Boxed代编,C代编,C++代编,WISC代考,CS537代考,Introduction to Operating Systems代考,Letter Boxed代考,C代考,C++代考,WISChelp,CS537help,Introduction to Operating Systemshelp,Letter Boxedhelp,Chelp,C++help,WISC作业代写,CS537作业代写,Introduction to Operating Systems作业代写,Letter Boxed作业代写,C作业代写,C++作业代写,WISC编程代写,CS537编程代写,Introduction to Operating Systems编程代写,Letter Boxed编程代写,C编程代写,C++编程代写,WISCprogramming help,CS537programming help,Introduction to Operating Systemsprogramming help,Letter Boxedprogramming help,Cprogramming help,C++programming help,WISCassignment help,CS537assignment help,Introduction to Operating Systemsassignment help,Letter Boxedassignment help,Cassignment help,C++assignment help,WISCsolution,CS537solution,Introduction to Operating Systemssolution,Letter Boxedsolution,Csolution,C++solution,