From 019ede191a362b93cf0d99a776ab5d6081843417 Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 17 May 2023 14:14:37 -0700 Subject: [PATCH] Cleaned up problem library --- Problems/all.tex | 70 ++++++++++++++----- Problems/{problem.tex => problemlib.sty} | 51 ++++++-------- Problems/problems/misc.tex | 85 +++++++++++++++--------- Problems/problems/pidgeonhole.tex | 28 +++++++- 4 files changed, 154 insertions(+), 80 deletions(-) rename Problems/{problem.tex => problemlib.sty} (66%) diff --git a/Problems/all.tex b/Problems/all.tex index 59806fa..d76bac8 100755 --- a/Problems/all.tex +++ b/Problems/all.tex @@ -4,34 +4,74 @@ ]{../resources/ormc_handout} +\def\stars#1{ + \count255=1 + \ifnum #1 > 0 + \loop + {\color{cyan!50!gray} \bigstar}% + \ifnum\count255 < #1 + \advance\count255 by 1 + \repeat + \else% + {\color{cyan!50!gray} \bigstar}% + \fi% + % + \ifnum \count255 < 5 + \loop + {\color{gray} \bigstar}% + \ifnum\count255 < 4 + \advance\count255 by 1 + \repeat + \fi +} + + \NewDocumentCommand{\p}{ m m }{ - \textbf{#1 #2:} \par - {\color{gray}Difficulty:} {\color{cyan!50!gray} \bigstar \bigstar \bigstar}{\color{gray} \bigstar \bigstar} + \begin{minipage}{\textwidth} + \textbf{#1 #2:} \par - \vspace{3mm} + \ifdifficulty{#1}{#2}{{\color{gray}Difficulty:} \stars{\getdifficulty{#1}{#2}}} - \getproblem{#1}{#2} + \vspace{2mm} - \vspace{2mm} + \getproblem{#1}{#2} + \ifsolution{#1}{#2}{}[ + \ifanswer{#1}{#2}{% + \vspace{2mm}% + {\color{red}\textbf{Solution:}} \getanswer{#1}{#2} + } + ] + \end{minipage} \ifsolution{#1}{#2}{ \begin{solution} \getsolution{#1}{#2} \end{solution} - }[ - \ifanswer{#1}{#2}{% - \vspace{2mm}% - {\color{red}\textbf{Solution:}} \getanswer{#1}{#2} - } - ] + } - \vspace{20mm} + \penalty-500 + + \vspace{15mm} \vfill } -\input{problem} +\newcommand{\postproblem}[2]{ + \ifcsname#1:all\endcsname + \expandafter\edef\csname#1:all\endcsname{\csname#1:all\endcsname \p{#1}{#2}} + \else + \expandafter\gdef\csname#1:all\endcsname{\p{#1}{#2}} + \fi +} + +\usepackage{problemlib} + +\input{problems/numbertheory} +\input{problems/algebra} +\input{problems/combinatorics} +\input{problems/pidgeonhole} +\input{problems/misc} %\makeatletter %\newcommand{\shoppinglist}[1]{Shopping list: #1\checknextarg} @@ -40,7 +80,6 @@ %\makeatother \newcommand{\q}[1]{ - \section{#1} \csname#1:all\endcsname @@ -53,7 +92,7 @@ {Mark's Problem Library} { This document lists all problems in this library. \\ - Use it to find problems or debug \LaTeX{}. + Use it to find problems or debug the source. } @@ -61,4 +100,5 @@ \q{Combinatorics} \q{NumberTheory} \q{Pidgeonhole} + \q{Misc} \end{document} \ No newline at end of file diff --git a/Problems/problem.tex b/Problems/problemlib.sty similarity index 66% rename from Problems/problem.tex rename to Problems/problemlib.sty index a583983..42c4fda 100755 --- a/Problems/problem.tex +++ b/Problems/problemlib.sty @@ -1,8 +1,12 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{problemlib}[2023/05/17 ORMC Problem Library] + + % Defines a new problem. % See problem definition files for usage examples. \long\def\problemdef#1#2#3{ \ifcsname#1:problem:#2\endcsname - \PackageError{Problem Sets}{Problem #1:#2 is already defined}{} + \PackageError{problemlib}{Problem #1:#2 is already defined}{} \fi % Use a group to limit scope of special commands. @@ -32,12 +36,10 @@ \endgroup - \ifcsname#1:all\endcsname - \expandafter\edef\csname#1:all\endcsname{\csname#1:all\endcsname \p{#1}{#2}} - \else - \expandafter\gdef\csname#1:all\endcsname{ - \p{#1}{#2} - } + % Optional hook to run after each problem definition. + % Must be defined BEFORE problems are included. + \ifdefined\postproblem + \postproblem{#1}{#2} \fi } @@ -50,7 +52,7 @@ \ifcsname#1:#3:#2\endcsname% \csname#1:#3:#2\endcsname% \else% - \PackageError{Problem Sets}{Problem #1:#2 is not defined}{} + \PackageError{problemlib}{Problem #1:#2 is not defined}{} \fi% } \NewDocumentCommand{\getdifficulty}{ m m }{\get{#1}{#2}{difficulty}} @@ -59,34 +61,25 @@ % #1: Category % #2: Problem id -% #3: Show if this problem has an answer -% #4: Show if this problem doesn't have an answer -\NewDocumentCommand{\ifanswer}{ m m m d[] }{% - \ifcsname#1:answer:#2\endcsname% - #3% +% #3: attribute to check +% #4: Show if true +% #5: Show if false +\NewDocumentCommand{\ifattribute}{ m m m m d[] }{% + \ifcsname#1:#3:#2\endcsname#4% \else% - \IfNoValueF{#4}{#4}% - \fi% -} -\NewDocumentCommand{\ifsolution}{ m m m d[] }{ - \ifcsname#1:solution:#2\endcsname% - #3% - \else% - \IfNoValueF{#4}{#4}% + \IfNoValueF{#5}{#5}% \fi% } +\NewDocumentCommand{\ifanswer}{ m m m d[] }{\ifattribute{#1}{#2}{answer}{#3}[#4]} +\NewDocumentCommand{\ifsolution}{ m m m d[] }{\ifattribute{#1}{#2}{solution}{#3}[#4]} +\NewDocumentCommand{\ifdifficulty}{ m m m d[] }{\ifattribute{#1}{#2}{difficulty}{#3}[#4]} \NewDocumentCommand{\getanswer}{ m m }{% \ifanswer{#1}{#2}{\get{#1}{#2}{answer}}% - [\PackageError{Problem Sets}{Problem #1:#2 has no answer}{}]% + [\PackageError{problemlib}{Problem #1:#2 has no answer}{}]% } \NewDocumentCommand{\getsolution}{ m m }{ \ifsolution{#1}{#2}{\get{#1}{#2}{solution}}% - [\PackageError{Problem Sets}{Problem #1:#2 has no solution}{}]% -} - -\input{problems/numbertheory} -\input{problems/algebra} -\input{problems/combinatorics} -\input{problems/pidgeonhole} \ No newline at end of file + [\PackageError{problemlib}{Problem #1:#2 has no solution}{}]% +} \ No newline at end of file diff --git a/Problems/problems/misc.tex b/Problems/problems/misc.tex index e0f2db3..4a816cc 100755 --- a/Problems/problems/misc.tex +++ b/Problems/problems/misc.tex @@ -1,43 +1,62 @@ -\problem{} -A carpenter cut a chessboard into $1 \times 1$ squares in 70 minutes. \\ -How long will it take him to cut it into $2 \times 2$ squares? \\ +\problemdef{Misc}{1}{ + \difficulty{1} -\begin{solution} - 30 -\end{solution} + \statement{ + A carpenter cut a chessboard into $1 \times 1$ squares in 70 minutes. \par + How long will it take him to cut it into $2 \times 2$ squares? + } -\problem{} -There are two kinds of books on a shelf: those on permissible magic and those on black magic. Two books on permissible magic cannot be set between exactly three other books, and two books on black magic may not stand next to each other. \\ -What is the maximal amount of books that may be placed on the shelf? - -\begin{solution} - 8 -\end{solution} + \answer{30} +} -\problem{} -The numbers $1 ... 9$ are arranged in a $3 \times 3$ grid. \\ -The sum of each row and column is then computed. \\ -What is the maximum number of consecutive integers one may find in the set of these sums? - -\begin{solution} - 5 -\end{solution} +\problemdef{Misc}{2}{ + \difficulty{2} -\problem{} -16 rugby teams participate in a regional championship. Each pair of teams plays against each other twice. The 8 teams with the most wins will proceed to the national championship. If there is a tie in this ranking, the tied teams will draw lots. \\ -Assume a rugby game can never tie. What is the minimum number of wins a team needs to guarantee a spot in the nationals? + \statement{ + There are two kinds of books on a shelf: those on permissible magic and those on black magic. Two books on permissible magic cannot be set between exactly three other books, and two books on black magic may not stand next to each other. \par + What is the maximal amount of books that may be placed on the shelf? + } -\begin{solution} - 23 -\end{solution} + \answer{8} +} -\problem{} -Five boxes are filled with pastries. We know that box C contains a third of the pastries in E, and that B contains two times more than C and E combined. A contains half the number of pastries in E, and a tenth of those in D. Box B contains four times more pastries than D. \\ -What is the minimal possible positive number of pastries in all the boxes put together? +\problemdef{Misc}{3}{ + \difficulty{3} -\begin{solution} - 310 -\end{solution} \ No newline at end of file + \statement{ + The numbers $1 ... 9$ are arranged in a $3 \times 3$ grid. \par + The sum of each row and column is then computed. \par + What is the maximum number of consecutive integers one may find in the set of these sums? + } + + \answer{5} +} + + +\problemdef{Misc}{4}{ + \difficulty{4} + + \statement{ + 16 rugby teams participate in a regional championship. Each pair of teams plays against each other twice. The 8 teams with the most wins will proceed to the national championship. If there is a tie in this ranking, the tied teams will draw lots. \par + Assume a rugby game can never tie. What is the minimum number of wins a team needs to guarantee a spot in the nationals? + } + + \answer{23} +} + + + + +\problemdef{Misc}{5}{ + \difficulty{5} + + \statement{ + Five boxes are filled with pastries. We know that box C contains a third of the pastries in E, and that B contains two times more than C and E combined. A contains half the number of pastries in E, and a tenth of those in D. Box B contains four times more pastries than D. \par + What is the minimal possible positive number of pastries in all the boxes put together? + } + + \answer{310} +} \ No newline at end of file diff --git a/Problems/problems/pidgeonhole.tex b/Problems/problems/pidgeonhole.tex index 1d9de80..028b068 100755 --- a/Problems/problems/pidgeonhole.tex +++ b/Problems/problems/pidgeonhole.tex @@ -1,4 +1,5 @@ \problemdef{Pidgeonhole}{1}{ + \difficulty{1} \statement{ Is it possible to cover an equilateral triangle with two smaller equilateral triangles? Why or why not? @@ -15,13 +16,13 @@ \problemdef{Pidgeonhole}{2}{ + \difficulty{3} \statement{ You are given $n + 1$ integers. \par Prove that at least two of them have a difference divisible by $n$. } - \answer{} \solution{ $n~|~(a-b) \iff a \equiv b \pmod{n}$ \par @@ -37,6 +38,7 @@ \problemdef{Pidgeonhole}{3}{ + \difficulty{1} \statement{ You have an $8 \times 8$ chess board with two opposing corner squares cut off. You also have a set of dominoes, each of which is the size of two squares. Is it possible to completely cover the the board with dominos, so that none overlap nor stick out? @@ -52,6 +54,7 @@ } \problemdef{Pidgeonhole}{4}{ + \difficulty{2} \statement{ The ocean covers more than a half of the Earth's surface. Prove that the ocean has at least one pair of antipodal points. @@ -66,6 +69,7 @@ \problemdef{Pidgeonhole}{5}{ + \difficulty{2} \statement{ There are $n > 1$ people at a party. Prove that among them there are at least two people who have the same number of acquaintances at the gathering. (We assume that if A knows B, then B also knows A) @@ -81,6 +85,7 @@ \problemdef{Pidgeonhole}{6}{ + \difficulty{3} \statement{ Pick five points in $\mathbb{R}^2$ with integral coordinates. Show that two of these form a line segment that has an integral midpoint. @@ -99,6 +104,7 @@ \problemdef{Pidgeonhole}{7}{ + \difficulty{2} \statement{ Every point on a line is painted black or white. Show that there exist three points of the same color where one is the midpoint of the line segment formed by the other two. @@ -169,6 +175,7 @@ } \problemdef{Pidgeonhole}{8}{ + \difficulty{1} \statement{ Every point on a plane is painted black or white. Show that there exist two points in the plane that have the same color and are located exactly one foot away from each other. @@ -178,17 +185,18 @@ } \problemdef{Pidgeonhole}{9}{ + \difficulty{2} \statement{ Each point on a circle is colored either black or white. Prove that there exist three equally spaced points of the same color. - } - \solution{This problem is exactly the same as linethreecolor} + \solution{This problem is exactly the same as Pidgeonhole 7} } \problemdef{Pidgeonhole}{10}{ + \difficulty{4} \statement{ Let n be an integer not divisible by $2$ and $5$. Show that n has a multiple consisting entirely of ones. @@ -201,6 +209,8 @@ \problemdef{Pidgeonhole}{11}{ + \difficulty{5} + \statement{ Prove that for any $n > 1$, there exists an integer made of only sevens and zeros that is divisible by $n$. } @@ -211,6 +221,8 @@ \problemdef{Pidgeonhole}{12}{ + \difficulty{4} + \statement{ Choose $n + 1$ integers between $1$ and $2n$. Show that at least two of these are co-prime. } @@ -221,6 +233,7 @@ \problemdef{Pidgeonhole}{13}{ + \difficulty{3} \statement{ Choose $n + 1$ integers between $1$ and $2n$. Show that you must select two numbers $a$ and $b$ such that $a$ divides $b$. @@ -242,6 +255,7 @@ \problemdef{Pidgeonhole}{14}{ + \difficulty{4} \statement{ Show that it is always possible to choose a subset of the set of integers $a_1, a_2, ... , a_n$ so that the sum of the numbers in the subset is divisible by $n$. @@ -254,6 +268,8 @@ \problemdef{Pidgeonhole}{15}{ + \difficulty{4} + \statement{ Show that there exists a positive integer divisible by $2013$ that has $2014$ as its last four digits. } @@ -263,6 +279,7 @@ \problemdef{Pidgeonhole}{16}{ + \difficulty{3} \statement{ Let $n$ be an odd number. Let $a_1, a_2, ... , a_n$ be a permutation of the numbers $1, 2, ... , n$. \par @@ -280,6 +297,7 @@ \problemdef{Pidgeonhole}{17}{ + \difficulty{4} \statement{ A stressed-out student consumes at least one espresso every day of a particular year, drinking $500$ overall. Show the student drinks exactly $100$ espressos on some consecutive sequence of days. @@ -347,6 +365,8 @@ \problemdef{Pidgeonhole}{18}{ + \difficulty{1} + \statement{ Show that there are either three mutual acquaintances or four mutual strangers at a party with ten or more people. } @@ -357,6 +377,8 @@ \problemdef{Pidgeonhole}{19}{ + \difficulty{5} + \statement{ Given a table with a marked point, $O$, and with $2013$ properly working watches put down on the table, prove that there exists a moment in time when the sum of the distances from $O$ to the watches' centers is less than the sum of the distances from $O$ to the tips of the watches' minute hands. }