Update exam/packet.tex
This commit is contained in:
117
exam/packet.tex
117
exam/packet.tex
@@ -145,15 +145,16 @@ Output:
|
|||||||
% ========================= Problem 6 =========================
|
% ========================= Problem 6 =========================
|
||||||
\problem{Problem 6(.7): Sequencing}
|
\problem{Problem 6(.7): Sequencing}
|
||||||
\textit{Difficulty: Easy}
|
\textit{Difficulty: Easy}
|
||||||
\begin{itemize}
|
|
||||||
You are given a string S composed of only the characters ‘6', ‘7’, ‘A', ‘B', and ‘\#' (without the quotation marks). This string is processed from left to right, and you must maintain a sequence of chracters that changes according to these rules:
|
|
||||||
|
|
||||||
|
You are given a string S composed of only the characters 6, 7, A, B, and \# (without the quotation marks). This string is processed from left to right, and you must maintain a sequence of chracters that changes according to these rules:
|
||||||
|
\begin{itemize}
|
||||||
\item 6 - add a 6 to the end of the sequence
|
\item 6 - add a 6 to the end of the sequence
|
||||||
\item 7 - if the sequence is non-empty and its last chracter is ‘6', remove that last ‘6', otherwise, add ‘7' to the end of the sequence
|
\item 7 - if the sequence's last chracter is 6, remove that last 6, otherwise, add 7 to the end of the sequence
|
||||||
\item A - reverse the sequence
|
\item A - reverse the sequence
|
||||||
\item B - add a duplicate of the current sequence to the end of it
|
\item B - add a duplicate of the current sequence to the end of it
|
||||||
\item \# - clear the sequence
|
\item \# - clear the sequence
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
\inputformat
|
\inputformat
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item The first line consists of the string S. The string consists only of the characters 6, 7, A, B, and \#.
|
\item The first line consists of the string S. The string consists only of the characters 6, 7, A, B, and \#.
|
||||||
@@ -166,23 +167,23 @@ You are given a string S composed of only the characters ‘6', ‘7’, ‘A',
|
|||||||
|
|
||||||
\examples
|
\examples
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
Input 1:
|
Input 1:
|
||||||
67A6
|
67A6
|
||||||
|
|
||||||
Output 1:
|
Output 1:
|
||||||
6
|
6
|
||||||
|
|
||||||
Input 2:
|
Input 2:
|
||||||
66B7
|
66B7
|
||||||
|
|
||||||
Output 2:
|
Output 2:
|
||||||
666
|
666
|
||||||
|
|
||||||
Input 3:
|
Input 3:
|
||||||
7A7#
|
7A7#
|
||||||
|
|
||||||
Output 3:
|
Output 3:
|
||||||
EMPTY
|
EMPTY
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
% ========================= Problem 7 =========================
|
% ========================= Problem 7 =========================
|
||||||
@@ -212,30 +213,30 @@ Your task is to determine if there exists any valid path from (1,1) to (N,M) obe
|
|||||||
|
|
||||||
\examples
|
\examples
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
Input 1:
|
Input 1:
|
||||||
2 2
|
2 2
|
||||||
66
|
66
|
||||||
67
|
67
|
||||||
|
|
||||||
Output 1:
|
Output 1:
|
||||||
Sixxx sevennn
|
Sixxx sevennn
|
||||||
|
|
||||||
Input 2:
|
Input 2:
|
||||||
2 2
|
2 2
|
||||||
77
|
77
|
||||||
77
|
77
|
||||||
|
|
||||||
Output 2:
|
Output 2:
|
||||||
Six was afraid of seven after all
|
Six was afraid of seven after all
|
||||||
|
|
||||||
Input 3:
|
Input 3:
|
||||||
3 3
|
3 3
|
||||||
666
|
666
|
||||||
676
|
676
|
||||||
666
|
666
|
||||||
|
|
||||||
Output 3:
|
Output 3:
|
||||||
Sixxx sevennn
|
Sixxx sevennn
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
% ========================= Problem 8 =========================
|
% ========================= Problem 8 =========================
|
||||||
@@ -258,38 +259,38 @@ There is a staircase with N steps. Each step is labelled with a 6 or a 7. Simon
|
|||||||
|
|
||||||
\examples
|
\examples
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
Input 1:
|
Input 1:
|
||||||
5
|
5
|
||||||
66766
|
66766
|
||||||
|
|
||||||
Output 1:
|
Output 1:
|
||||||
3
|
3
|
||||||
|
|
||||||
Explanation 1:
|
Explanation 1:
|
||||||
Case 1: Step 1->2->3->4->5
|
Case 1: Step 1->2->3->4->5
|
||||||
Case 2: Step 1->2->4->5
|
Case 2: Step 1->2->4->5
|
||||||
Case 3: Step 1->3->4->5
|
Case 3: Step 1->3->4->5
|
||||||
|
|
||||||
Input 2:
|
Input 2:
|
||||||
3
|
3
|
||||||
677
|
677
|
||||||
|
|
||||||
Output 2:
|
Output 2:
|
||||||
2
|
2
|
||||||
|
|
||||||
Explanation 2:
|
Explanation 2:
|
||||||
Case 1: 1->2->3
|
Case 1: 1->2->3
|
||||||
Case 2: 1->3
|
Case 2: 1->3
|
||||||
|
|
||||||
Input 3:
|
Input 3:
|
||||||
1
|
1
|
||||||
6
|
6
|
||||||
|
|
||||||
Output 3:
|
Output 3:
|
||||||
1
|
1
|
||||||
|
|
||||||
Explanation 3:
|
Explanation 3:
|
||||||
There is only one way to get to the top (which Simon is already at).
|
There is only one way to get to the top (which Simon is already at).
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
\end{document}
|
\end{document}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user