Recently Added TSSOJ Problemshttps://tssoj.ca/The latest problems added on the Thornhill Secondary School Online Judge websiteen-caFri, 10 Feb 2023 17:18:32 +0000CCC '07 J3 - Deal or No Deal Calculatorhttps://tssoj.ca/problem/ccc07j3<p>Deal or No Deal™ is a game show on NBC.</p>
<p>In the CCC version of the game, there are \(10\) possible dollar amounts. \($100, $500, $1\) \(000, $5\) \(000, $10\) \(000, $25\) \(000, $50\) \(000, $100\) \(000, $500\) \(000, $1\) \(000\) \(000\) sealed in imaginary briefcases. These dollar amounts are numbered \(1 - 10\) (i.e. \(1 \rightarrow $100, 2 \rightarrow $500, 3 \rightarrow $1 000,..., 10 \rightarrow $1 000 000\)). Before the game starts the contestant will have chosen one of the bri...Fri, 10 Feb 2023 17:18:32 +0000https://tssoj.ca/problem/ccc07j3School Triphttps://tssoj.ca/problem/schooltrip<p>Problem taken from <a href="http://dmoj.ca/problem/ecoo17r1p1" rel="nofollow">DMOJ</a>.</p>
<p>BOSS is planning a year-end trip for the graduating class. However, they need to find a way to raise money to fund the trip, as it costs \(C\) dollars. They eventually settle on organizing a school lunch, where students can buy a lunch in the cafeteria for some amount of money.</p>
<p>The members of BOSS decide that the price of the lunch depends on how many years a student has been at the school. F...Wed, 04 Jan 2023 22:25:55 +0000https://tssoj.ca/problem/schooltripCount Codehttps://tssoj.ca/problem/countcode<p>Print the number of times that the string <code>code</code> appears anywhere in the given string, but there's a twist. Any letter except for 'd' in code will also count, so <code>cope</code> and <code>cooe</code> will also satisfy the conditions.</p>
<h4>Input Specification</h4>
<p>The only line of input will be a single string.</p>
<h4>Output Specification</h4>
<p>Print the number of times <code>code</code> or any other variation of the word appears in the string.</p>
<h4>Sample Input</h4>
...Fri, 23 Dec 2022 15:19:02 +0000https://tssoj.ca/problem/countcodeTSS '22 CC P4 - Ancient Castle Ruinshttps://tssoj.ca/problem/tss22ccp4<p>You stumble across the ruins of an ancient castle...</p>
<p>The ruins of the castle have left a strange pillar formation behind. In particular, there are \(N\) adjacent pillars each with height \(h_i\). Let \(x\) represent your exhaustion. It initally starts at \(1\), and increases by \(1\) after each time you jump to a <strong>taller</strong> pillar. It takes \(x\) seconds to travel from pillar \(i\) to pillar \(i+1\) if \(h_i \ge h_{i+1}\). However, there are \(2\) different ways to travel ...Tue, 01 Nov 2022 14:51:45 +0000https://tssoj.ca/problem/tss22ccp4TSS '22 CC P3 - Treasure Hunt in the Junglehttps://tssoj.ca/problem/tss22ccp3<p>You stumble across a jungle rumored to have ancient treasures in it. Luckily, you have a map of the jungle with the locations of the treasure chests.</p>
<p>Your map contains the following legend:</p>
<table class="table" style="width: fit-content; margin: 0">
<tr>
<th>Symbol</th>
<th>Description</th>
</tr>
<tr>
<td><code>.</code></td>
<td>Terrain you may walk through</td>
</tr>
<tr>
<td><code>X</code></td>
<td>A t...Tue, 01 Nov 2022 14:51:22 +0000https://tssoj.ca/problem/tss22ccp3TSS '22 CC P2 - River Crossinghttps://tssoj.ca/problem/tss22ccp2<p>You find yourself in front of a long river and decide to cross it safely...</p>
<p>There are \(N\) stones scattered throughout the river that you can jump on in order to make it to the other side. You start at position \(0\) and the river ends at position \(M\).</p>
<p>From any given point, you can jump up to \(K\) units forward, as long you don't land in the water. More specifically, you can jump on a stone at position \(a_i\) if \(|a_i - x| \le K\), where \(x\) represents your current posit...Tue, 01 Nov 2022 14:50:21 +0000https://tssoj.ca/problem/tss22ccp2TSS '22 CC P1 - Mud Puddleshttps://tssoj.ca/problem/tss22ccp1<p>You have decided to go hiking on a trail consisting of \(N\) characters.</p>
<p>Each character will be one of the following:</p>
<ul>
<li><code>-</code> representing dry ground</li>
<li><code>*</code> representing wet mud</li>
</ul>
<p>Before your trip, you decide to count the number of mud puddles to make sure you're not getting too dirty. Any contiguous sequence of <code>*</code> is considered one mud puddle.</p>
<p>Given \(N\) and a string representing the trail, output the total number of...Tue, 01 Nov 2022 14:49:42 +0000https://tssoj.ca/problem/tss22ccp1Simple Valid Bracketshttps://tssoj.ca/problem/simplevalidbrackets<p>For an extra challenge, check out <a href="https://tssoj.ca/problem/validbrackets" rel="nofollow">Valid Brackets</a>!</p>
<p>Determine if the given sequence of round brackets is valid. A sequence of brackets is considered valid if each opening bracket is paired with a closing bracket. The closing bracket can be anywhere in the sequence, as long as it comes after (to the right of) its corresponding pair. For example: <code>()()()</code>, <code>((()))</code>, <code>(())()</code>, <code>(()())</...Fri, 21 Oct 2022 17:04:35 +0000https://tssoj.ca/problem/simplevalidbracketsHow's the Weatherhttps://tssoj.ca/problem/howstheweather<p>You've had quite enough of confusing conversations with Americans who assume you're using Fahrenheit when Celsius is clearly the way to go. Rather than argue with them, you've settled for writing a program to conveniently convert temperatures measured in degrees Celsius to Fahrenheit instead.</p>
<p>You came across the following formula, which holds true given that \(F\) is a temperature in degrees Fahrenheit while \(C\) is that same temperature in degrees Celsius:</p>
<p>\[C=5/9*(F-32)\]</p>...Tue, 23 Aug 2022 17:07:19 +0000https://tssoj.ca/problem/howstheweatherAn Honest Day's Workhttps://tssoj.ca/problem/anhonestdayswork<p>Jessie, James, and Meowth, members of the honourable Team Rocket, have unfortunately fallen on hard times. With their funds necessarily allocated to constructing all manner of giant robots and other devices, they've been having difficulty affording any food lately. But that's nothing that an honest day's work can't fix!</p>
<p>James has a can of leftover paint, containing \(P(1 \le P \le 100)\) litres of the stuff. When combined with his boundless collection of bottlecaps, this can result in ...Tue, 09 Aug 2022 23:35:27 +0000https://tssoj.ca/problem/anhonestdaysworkNext in Linehttps://tssoj.ca/problem/nextinline<p>You know a family with three children. Their ages form an arithmetic sequence: the difference in ages between the middle child and youngest child is the same as the difference in ages between the oldest child and the middle child. For example, their ages could be 5, 10 and 15, since both adjacent pairs have a difference of 5 years.</p>
<p>Given the ages of the youngest and middle children, what is the age of the oldest child?</p>
<h4>Input Specification</h4>
<p>The input consists of two integ...Mon, 08 Aug 2022 17:49:14 +0000https://tssoj.ca/problem/nextinlineA New Hopehttps://tssoj.ca/problem/anewhope<p><em>Problem taken from <a href="https://dmoj.ca/problem/wc15c2j1" rel="nofollow">DMOJ</a></em></p>
<p>You might be aware that the events of the Star Wars saga took place a long time ago, in a galaxy that was rather far away. But just how far away was it? We can try to describe it by repeating the word <code>far</code> a certain number of times in the following sentence format:</p>
<p>\[\texttt{A long time ago in a galaxy far, far away...}\]</p>
<p>In the above example, the word <code>far</cod...Mon, 08 Aug 2022 17:36:23 +0000https://tssoj.ca/problem/anewhopeA Spooky Seasonhttps://tssoj.ca/problem/aspookyseason<p><em>Problem taken from <a href="https://dmoj.ca/problem/wc16c1j1" rel="nofollow">DMOJ</a></em></p>
<p>Late October can be a rather frightening time of year. Night begins to fall ever earlier, ancient Pagan rituals make demons stir, and at the end of the month, hordes of small creatures can even be seen roaming the streets! It's a spooky sight if there ever was one.</p>
<p>But just how spooky is this demonic festival? Its spookiness level can, in fact, be measured and represented as a single i...Mon, 08 Aug 2022 17:32:23 +0000https://tssoj.ca/problem/aspookyseasonCore Drillhttps://tssoj.ca/problem/coredrill<p><em>Problem taken from <a href="https://dmoj.ca/problem/dmopc14c5p1" rel="nofollow">DMOJ</a></em></p>
<p>Simon got a new drill recently. Everyone knows that a drill is shaped like a right circular cone. Simon knows his drill has radius \(r\) and height \(h\), But now he wants to calculate the volume. Write a program to help Simon!</p>
<p><strong>Note:</strong> The formula for the volume of a cone is \(V=\frac{\pi r^2h}{3}\)</p>
<h4>Input Specification</h4>
<p>The first line of input will have...Mon, 08 Aug 2022 17:24:17 +0000https://tssoj.ca/problem/coredrillNot a Wall of Texthttps://tssoj.ca/problem/notawalloftext<p><em>Problem was taken from <a href="https://dmoj.ca/problem/dmopc15c7p2" rel="nofollow">DMOJ</a>.</em></p>
<p>Count the number of words in a text.</p>
<h4>Input Specification</h4>
<p>The input will be a text with only lowercase letters and spaces (ASCII code 32). The only constraint is that the length of the entire text will not exceed 80 characters. Also, there won't be anything tricky like double whitespace in a row, leading whitespace, or trailing whitespace.</p>
<h4>Output Specification<...Mon, 08 Aug 2022 17:05:10 +0000https://tssoj.ca/problem/notawalloftextVolleyball Gamehttps://tssoj.ca/problem/volleyballgame<p>Two teams, Team \(A\) and Team \(B\), are playing a volleyball game. In volleyball, the first team to reach at least 25 points with a 2 point difference or more wins the game. A team gets a point when the ball lands on the opponent's side of the court or when the opponent hits the ball out of bounds. Create a program that determines which team won.</p>
<h4>Input Specification</h4>
<p>The only line of input will be a string which is made solely from the characters <code>A</code> and <code>B</c...Wed, 27 Jul 2022 16:44:44 +0000https://tssoj.ca/problem/volleyballgameElevator Doorshttps://tssoj.ca/problem/elevatordoors<p>When a person presses the button to go into an elevator, the elevator on the nearest floor will travel to the user's floor and open its doors. You are tasked to determine which elevator out of two will open its doors for the person that presses the button.</p>
<h4>Input Specification</h4>
<p>There are three types of floors in the building: The main floors, the ground floor, and the parking floor. There will be three lines of input, all of them being a character that denotes the floors. The ma...Tue, 26 Jul 2022 17:20:56 +0000https://tssoj.ca/problem/elevatordoorsAge Demographichttps://tssoj.ca/problem/demographic<p>You have just uploaded your first video as a content creator.</p>
<p>Curious about which audiences you should be targeting, you have gathered data about \(N\:(1 \le N \le 3 \cdot 10^5)\) different viewers. Specifically, you know the ages \(x_i\:(1 \le x_i \le 10^9)\) of every single person that has watched your video.</p>
<p>Given \(Q\:(1 \le Q \le 3 \cdot 10^5)\) different queries, how many people between the ages of \(a\) and \(b\) inclusive \((1 \le a, b \le 10^9)\) have watched your video...Thu, 26 May 2022 21:04:47 +0000https://tssoj.ca/problem/demographicWC '17 Contest 3 J3 - Uncrackablehttps://tssoj.ca/problem/wc17c3j3<h4>Woburn Challenge 2017-18 Round 3 - Junior Division</h4>
<p>You'd like to register an account on an extremely entertaining website. You've already selected a username, but it seems that the requirements for choosing a password are quite strict, in order to completely protect your account from being hacked into. The password must be a string between \(8\) and \(12\) characters long (inclusive), such that every character is either a lowercase letter (<code>a</code> … <code>z</code>), uppercase ...Fri, 20 May 2022 17:21:16 +0000https://tssoj.ca/problem/wc17c3j3COCI '18 Contest 3 #1 Magnushttps://tssoj.ca/problem/coci18c3p1<p>Magnus lost a game of chess to Kile so he found comfort in competitive programming. Very soon, he heard of the iconic COCI competition and decided to try his luck there.</p>
<p>He wrote a mail to Kile: "<em>Dear Kile, please, prepare me for COCI. Magnus</em>".</p>
<p>Kile replied: "<em>You want to participate in COCI? All right, here's your warm-up task. A series of four consecutive letters of some word that make up the subword <code>HONI</code> (Croatian acronym for COCI) is called the HONI-...Fri, 20 May 2022 16:35:05 +0000https://tssoj.ca/problem/coci18c3p1Three Cupshttps://tssoj.ca/problem/coci06c5p1<h4>COCI '06 Contest 5 #1 Trik</h4>
<p>Jealous of Mirko's position as head of the village, Borko stormed into his tent and tried to demonstrate Mirko's incompetence for leadership with a trick.</p>
<p>Borko puts three opaque cups onto the table next to each other (opening facing down) and a small ball under the leftmost cup. He then swaps two cups in one of three possible ways a number of times. Mirko has to tell which cup the ball ends up under.</p>
<p><img src="https://static.dmoj.ca/texoid/0e...Wed, 18 May 2022 02:25:46 +0000https://tssoj.ca/problem/coci06c5p1CCC '18 J1 - Telemarketer or not?https://tssoj.ca/problem/ccc18j1<h4>Canadian Computing Competition: 2018 Stage 1, Junior #1</h4>
<p>Here at the Concerned Citizens of Commerce (CCC), we have noted that telemarketers like to use seven-digit phone numbers where the last four digits have three properties. Looking just at the last four digits, these properties are:</p>
<ul>
<li>the first of these four digits is an <strong>8</strong> or <strong>9</strong>;</li>
<li>the last digit is an <strong>8</strong> or <strong>9</strong>;</li>
<li>the second and third digits ...Wed, 11 May 2022 01:41:11 +0000https://tssoj.ca/problem/ccc18j1CCC '19 J1 - Winning Scorehttps://tssoj.ca/problem/ccc19j1<h4>Problem Description</h4>
<p>You record all of the scoring activity at a basketball game. Points are scored by a 3-point shot, a
2-point field goal, or a 1-point free throw.
You know the number of each of these types of scoring for the two teams: the Apples and the
Bananas. Your job is to determine which team won, or if the game ended in a tie.</p>
<h4>Input Specification</h4>
<p>The first three lines of input describe the scoring of the Apples, and the next three lines of input
describe the ...Tue, 10 May 2022 20:35:05 +0000https://tssoj.ca/problem/ccc19j1Problem J1: Who is in the middle?https://tssoj.ca/problem/ccc07j1<h4>Problem Description</h4>
<p>In the story Goldilocks and the Three Bears, each bear had a bowl of porridge to eat while sitting
at his/her favourite chair. What the story didn’t tell us is that Goldilocks moved the bowls around
on the table, so the bowls were not at the right seats anymore. The bowls can be sorted by weight
with the lightest bowl being the Baby Bear’s bowl, the medium bowl being the Mama Bear’s bowl
and the heaviest bowl being the Papa Bear’s bowl. Write a program that reads ...Tue, 10 May 2022 17:00:57 +0000https://tssoj.ca/problem/ccc07j1CCC '15 J2 - Happy or Sadhttps://tssoj.ca/problem/ccc15j2<h4>Problem Description</h4>
<p>We often include emoticons in our text messages to indicate how we are feeling. The three consecutive characters <code>:-)</code> indicate a happy face and the three consecutive characters <code>:-(</code> indicate a sad face. Write a program to determine the overall mood of a message.</p>
<h4>Input Specification</h4>
<p>There will be one line of input that contains between <strong>1</strong> and <strong><em>255</em></strong> characters.
Output Specification
The o...Tue, 10 May 2022 02:14:05 +0000https://tssoj.ca/problem/ccc15j2