[go: up one dir, main page]

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

Hack Athlon 2

The document provides instructions for Hackathon 2 taking place on January 25-27, 2022. It outlines 3 problems to solve involving analyzing input data based on given constraints and formats. The problems involve checking for contiguous subarrays with a given sum, finding integers that satisfy a numerical pattern, and finding occurrences of a pattern string within a main string. Code submissions must follow rules including only using stdio.h and stdlib.h libraries, creating modular functions with comments, avoiding VLAs, and freeing all allocated memory.

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)
40 views2 pages

Hack Athlon 2

The document provides instructions for Hackathon 2 taking place on January 25-27, 2022. It outlines 3 problems to solve involving analyzing input data based on given constraints and formats. The problems involve checking for contiguous subarrays with a given sum, finding integers that satisfy a numerical pattern, and finding occurrences of a pattern string within a main string. Code submissions must follow rules including only using stdio.h and stdlib.h libraries, creating modular functions with comments, avoiding VLAs, and freeing all allocated memory.

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 2 ( Jan 25, 2022)

General Instructions:
Rules:

The allowed libraries are stdio.h and stdlib.h (only for malloc, calloc, free).
Your program should be modular. Do not write your entire program in main. Create suitable
functions.
For each function you create, 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 accept input till EOF. You can detect this by checking if scanf returned
-1.

Deadline: 1800hrs on Thursday 27th Jan,

Problem 1
Input: Each instance will have followed by , and a number .

Format:

\n

\n

\n
Goal: Check if there exists a contiguous subarray that has sum . More precisely, check if
there exists such that .

Output:

If as above exist, then print 1\n


Else print 0\n

Remark: Every 3 lines of the input forms one input instance. Process each input instance as it is
received. Stop at EOF.

See public test cases for examples.

Problem 2
Input:

The starting four elements of a sequence that follows the pattern:

Format: Four numbers each separated by space. Terminated by \n .


Goal: Find integers , , and with and that satisfy the input pattern.

Output: Print the values of , , and , each separated by a space. Terminate the line with a
\n .

Example:
Input: 1 5 7 11 \n
Output: 1 2 3 \n
Remark: Every line of the input forms an input instance. Process each input instance as it is received.
Stop at EOF.

See public test cases for more examples.

Problem 3
Input: followed by a string consisting of characters from the set of
length at most . This is followed by series of "pattern" strings , each of length
at most .

Format:

\n

\n

\n

\n

Goal: For each pattern string given as input, find every occurence of in .
Output: Print the starting position of every occurence in separated by a space. If does
not exist, print . Terminate all output lines with \n

Remark: The first two lines of input define the main string . This does not change for the rest of the
input. The pattern strings are given as input in separate lines. Process each pattern string as it is
received. Stop at EOF.

See public test cases for examples.

You might also like