0% found this document useful (0 votes)
33 views2 pages

Hack Athlon 4

The document provides instructions for Hackathon 4 taking place on February 25-27, 2022. It describes 3 problems related to reading input files, implementing a grep-like command, and creating a queue data structure in C. Participants must submit their solutions by 1800hrs on February 27th with limitations on the number of submissions allowed for each problem.

Uploaded by

Aryam Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views2 pages

Hack Athlon 4

The document provides instructions for Hackathon 4 taking place on February 25-27, 2022. It describes 3 problems related to reading input files, implementing a grep-like command, and creating a queue data structure in C. Participants must submit their solutions by 1800hrs on February 27th with limitations on the number of submissions allowed for each problem.

Uploaded by

Aryam Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Hackathon 4 ( Feb 25, 2022)

General Instructions:
Rules:

The allowed libraries are stdio.h and stdlib.h (only for malloc, calloc, realloc, free).
Your program should be modular. Do not write your entire program in main. Create suitable
functions.
For each function, leave a short comment above it describing what the function does.
You are not allowed to use variable length arrays (VLA). All dynamic memory allocation must
be on the heap.
Your program should not have memory leaks. Free all heap memory used.
Your program should take input till EOF. You can detect this by checking if scanf returned -1.

Deadline: 1800hrs on Sunday 27th Feb.

Submission: On Autojudge. Limit of 3, 3, and 4 submissions for problems 1,2, and 3 respectively.
Autojudge will not evaluate problem 1.

Problem 1
(20 marks)

Input:

A number and a string "inputFileName" as command line arguments.


Zero or more \n characters given as input via stdin .

Output:

Let inputFile denote the file with filename "inputFileName".

First, output the first lines of the inputFile.


Then for each \n given as input, output another line of the file.

Termination: Your program should terminate when either the end of inputFile has been reached,
or the input read is EOF.

Assumption: You can assume that will fit inside int on the machine that we will use to run
your program.

Problem 2
(40 marks)

See the attached file for the description of a command provided in "man page" style. Implement
the command in C.

Remark: The command is a simpler version of grep -n . You can play with grep -n and optional
arguments -v and -i to understand exactly what we want you to implement.
Problem 3
(40 marks)

Queues:

A queue is a "first in first out" data structure. Inserting elements is called 'enqueuing'.
Removing/deleting elements from a queue is called 'dequeueing'.

If you enqueue (insert) elements in this order, then when you call dequeue, the
first element removed is . The second element would be and so on.

Input:

Each input line will look like one of the following:

E \n
D \n

where is a number that will fit inside int on the server.

Goal:

Maintain a queue of elements. Enqueue elements when input starts with "E". Dequeue when
the input line is "D".

Output:

If the input line said "E ", then enqueue (insert) the number into . No output!
If the input line said "D", then dequeue from and print the number that was dequeued.
If a dequeue was requested on an empty queue, print "Empty".

Terminate all your output lines with \n .

Implementation Rules:

You must use a struct to maintain your queue.


Use convenient typedef(s).
Create supporting functions.

Although in practice, you would create separate header file(s), we require you to put everything
into just one .c file so that our evaluation server can be used.

You might also like