Challenges

  • Ryerson letter grade
    Created: Sep 08, 2024
    Difficulty: Easy
    Type: Text
    Tags: Algorithms Math Parsing

    Before the name change in the year 2022, Toronto Metropolitan University was known as Ryerson University. Given the percentage grade, calculate and return the letter grade that would appear in the Ryerson grades transcript. This letter grade should...

    Read more
  • Ascending list
    Created: Sep 08, 2024
    Difficulty: Easy
    Type: Text
    Tags: Data Structures Algorithms Sequences

    Determine whether the sequence of items is strictly ascending so that each element is strictly larger (not just merely equal to) than the element that precedes it. Return True if the elements in the list of items are strictly ascending,...

    Read more
  • Riffle shuffle kerfuffle
    Created: Sep 08, 2024
    Difficulty: Hard
    Type: Text
    Tags: Algorithms Simulation Sequences

    Given a list of items whose length is guaranteed to be even (note that “oddly” enough, zero is an even number), create and return a list produced by performing a perfect riffle to the items by interleaving the items of the two halves of the list...

    Read more
  • Even the odds
    Created: Sep 08, 2024
    Difficulty: Easy
    Type: Text
    Tags: Algorithms Math Number Theory Pattern Matching

    Check that the given positive integer n contains only odd digits (1, 3, 5, 7 and 9) when it is written out. Return True if this is the case, and False otherwise. Note that this question is not asking whether the number n itself is odd or even. Yo...

    Read more
  • Cyclops numbers
    Created: Sep 08, 2024
    Difficulty: Easy
    Type: Text
    Tags: Algorithms Math Number Theory Pattern Matching

    A nonnegative integer is said to be a cyclops number if it consists of an odd number of digits so that the middle (more poetically, the “eye”) digit is a zero, and all the other digits of that number are non zero. This function should determine wheth...

    Read more
  • Domino cycle
    Created: Sep 08, 2024
    Difficulty: Easy
    Type: Text
    Tags: Data Structures Algorithms Combinatorics Simulation

    A single domino tile is represented as a two-tuple of its pip values, such as (2,5) or (6,6). This function should determine whether the given list of tiles forms a cycle so that each tile in the list ends with the exact same pip value that its succe...

    Read more
  • Colour trio
    Created: Sep 08, 2024
    Difficulty: Medium
    Type: Text
    Tags: Algorithms Math Combinatorics Simulation

    This problem was inspired by the Mathologer video “Secret of Row 10”. To start, assume the existence of three values called “red”, “yellow” and “blue”. These names serve as colourful (heh) mnemonics and could as well have been 0, 1, and 2, or “foo”...

    Read more
  • Count dominators
    Created: Sep 08, 2024
    Difficulty: Medium
    Type: Text
    Tags: Data Structures Algorithms Optimization Loops

    An element in a list of items is a dominator if every element to its right (not just the one element immediately to its right, but all of them) is strictly smaller than that element. Note how according to this definition, the last item of the lis...

    Read more
  • Beat the previous
    Created: Sep 08, 2024
    Difficulty: Easy
    Type: Text
    Tags: Data Structures Algorithms Sequences Optimization

    Given a string of digits guaranteed to only contain ordinary integer digit characters 0 to 9, create and return the list of increasing integers acquired from reading these digits in order from left to right. The first integer in the result list is ma...

    Read more
  • Identify Parameter Type
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes a parameter and returns the type of the variable as a string. The function should accept one parameter and return a string indicating whether the variable is of type int, float or str.

    Constraints:

    • The input will...
    Read more
  • Variable Casting
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Math Basics

    Write a function that takes two parameters: a value and a type to cast to. The function should cast the input value to the specified type and return the result. This problem is designed to help you practice variable casting and type conversion betw...

    Read more
  • Even or Odd Number
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Math Basics

    Write a function that takes an integer and returns "Even" if the number is even, or "Odd" if the number is odd. This problem is designed to help you practice using if statements and modulo operations. The function should accept one parameter an...

    Read more
  • Compare Two Numbers
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Math Basics

    Write a function that takes two numbers and returns a string indicating their comparison result. The function should accept two parameters and return:

    • "Greater" if the first number is greater than the second.
    • "Less" if the first number is le...
    Read more
  • Get Nth Character of a String
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: String Manipulation Basics

    Write a function that takes a string and a position (index) and returns the character at that position in the string. This problem is designed to help you practice string indexing. The function should accept two parameters and return the character...

    Read more
  • Reverse a String
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: String Manipulation Basics

    Write a function that takes a string and returns the string reversed. This problem is designed to help you practice string manipulation and slicing. The function should accept one parameter and return the reversed string.

    Constraints:

    • The input...
    Read more
  • Check Substring in String
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: String Manipulation Basics

    Write a function that takes two strings and returns True if the second string is a substring of the first string, or False otherwise. This problem is designed to help you practice string searching. The function should accept two parameters and...

    Read more
  • String Concatenation
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: String Manipulation Basics

    Write a function that takes two strings and returns a new string that is the concatenation of the two input strings. This problem is designed to help you practice string concatenation. The function should accept two parameters and return the concat...

    Read more
  • Formatted String
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: String Manipulation Basics

    Write a function that takes a context string and a value, and returns a formatted string combining both. This problem is designed to help you practice string formatting. The function should accept two parameters and return the formatted string.

    Co...

    Read more
  • Sum of Elements in a List
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Data Structures Basics

    Write a function that takes a list of numbers and returns the sum of all the elements. This problem is designed to help you practice working with lists and basic iteration. The function should accept one parameter and return the sum of the elements...

    Read more
  • Find the Largest Element in a List
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Data Structures Basics

    Write a function that takes a list of numbers and returns the largest element. This problem is designed to help you practice working with lists and finding maximum values. The function should accept one parameter and return the largest element.

    Co...

    Read more
  • Reverse a List
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Data Structures Basics

    Write a function that takes a list and returns a new list with the elements in reverse order. This problem is designed to help you practice working with lists and reversing sequences. The function should accept one parameter and return the reversed...

    Read more
  • Sort a List
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Data Structures

    Write a function that takes a list of numbers and returns a new list with the elements sorted in ascending order. This problem is designed to help you practice using built-in sorting methods. The function should accept one parameter and return the...

    Read more
  • Remove Specified Item
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Data Structures Basics

    Write a function that takes a list and a value, and returns a new list with all occurrences of the specified value removed. This problem is designed to help you practice removing items from lists. The function should accept two parameters and retur...

    Read more
  • Join Two Lists
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Data Structures Basics

    Write a function that takes two lists and returns a new list that is the concatenation of the two input lists. This problem is designed to help you practice joining lists. The function should accept two parameters and return the combined list.

    Con...

    Read more
  • Find Item in List
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Data Structures Basics

    Write a function that takes a list and a value, and returns True if the value is in the list, or False otherwise. This problem is designed to help you practice searching for items in lists. The function should accept two parameters and return a...

    Read more
  • Access Dictionary Item
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes a dictionary and a key, and returns the value associated with the key. This problem is designed to help you practice accessing values in dictionaries. The function should accept two parameters and return the value corres...

    Read more
  • Add Item to Dictionary
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes a dictionary, a key, and a value, and returns a new dictionary with the key-value pair added. This problem is designed to help you practice adding items to dictionaries. The function should accept three parameters and re...

    Read more
  • Remove Item from Dictionary
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes a dictionary and a key, and returns a new dictionary with the specified key removed. This problem is designed to help you practice removing items from dictionaries. The function should accept two parameters and return th...

    Read more
  • Find Numbers from N to 1
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Loops Basics

    Write a function that takes a positive integer N and returns a list of numbers from N down to 1. This problem is designed to help you practice looping backwards using a for loop. The function should accept one parameter and return the list of numbe...

    Read more
  • Custom Step In For Loop
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Loops Basics

    Write a function that takes a start number, an end number, and a step size, and returns a list of numbers starting from the start number up to but not including the end number, incremented by the step size. This problem is `designed to help you pract...

    Read more
  • Find Even Numbers
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Loops Basics

    Write a function that takes two integers, start and end, and returns a list of all even numbers between start and end (inclusive). This problem is designed to help you practice using for loops and conditionals. The function should accept two parame...

    Read more
  • Factorial
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Loops Basics

    Write a function that takes a positive integer N and returns its factorial calculated using a for loop. This problem is designed to help you practice using for loops for calculations. The function should accept one parameter and return the factoria...

    Read more
  • Sum of Numbers
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes a positive integer N and returns the sum of all numbers from 1 to N using a while loop. This problem is designed to help you practice using while loops. The function should accept one parameter and return the sum.

    Const...

    Read more
  • Reverse a Number
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes a positive integer N and returns its reverse using a while loop. This problem is designed to help you practice using while loops and working with numbers. The function should accept one parameter and return the reversed...

    Read more
  • Fibonacci Sequence
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes a positive integer N and returns a list containing the Fibonacci sequence up to N terms using a while loop. This problem is designed to help you practice using while loops and generating sequences. The function should ac...

    Read more
  • Count Digits in a Number
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes a positive integer N and returns the number of digits it contains using a while loop. This problem is designed to help you practice using while loops and working with numbers. The function should accept one parameter and...

    Read more
  • Find All Prime Numbers
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes two integers: start and an end (interval definition, exclusive) and returns all identified prime numbers in a list. You should create a helper function to perform the primality check. This problem is `designed to h...

    Read more
  • Find Powers
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes two parameters: a list of integers and an integer exponent. The objective is to return a list of integers where each of the provided numbers have been raised to the power of the exponent. You should use the provided...

    Read more
  • A Primitive Calculator
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Math Basics

    Implement a primitive calculator that accepts some operation code with two parameters operand1 and operand2 . This problem is designed to help you practice using and calling custom functions. The helper functions should accept two parameters...

    Read more
  • Find Palindromes
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes a list of words and identifies which words are palindromes. This problem is designed to help you practice creating and calling custom functions. The helper function should accept one word and return a boolean value.

    Con...

    Read more
  • Calculate Age from Birthdate
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes a birthdate as a string in the format "YYYY-MM-DD" and returns the age in years as an integer. This problem is designed to help you practice working with dates and calculating time differences. The function should accept...

    Read more
  • Add Days to Date
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes a date string in the format "YYYY-MM-DD" and an integer number of days to add. The function should return a new date string in the same format after adding the specified number of days. This problem is `designed to help yo...

    Read more
  • Days Between Dates
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes two date strings in the format "YYYY-MM-DD" and returns the number of days between them as an integer. This problem is designed to help you practice calculating the difference between dates. The function should accept tw...

    Read more
  • Format Time
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes a time string in the format "HH:MM:SS" and returns it in 12-hour format with AM/PM. This problem is designed to help you practice time formatting. The function should accept one parameter and return the formatted time as...

    Read more
  • Is Leap Year
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes a year as an integer and returns True if it is a leap year, or False otherwise. This problem is designed to help you practice working with dates and leap year calculations. The function should accept one parameter an...

    Read more
  • Find Minimum of Two Numbers
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes two numbers and returns the minimum of the two using built-in functions. This problem is designed to help you practice using built-in functions for finding minimum values. The function should accept two parameters and re...

    Read more
  • Find Maximum of Two Numbers
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes two numbers and returns the maximum of the two using built-in functions. This problem is designed to help you practice using built-in functions for finding maximum values. The function should accept two parameters and re...

    Read more
  • Calculate Power of a Number
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes two numbers, base and exponent, and returns the result of raising the base to the power of the exponent using built-in functions. This problem is designed to help you practice using built-in functions for exponentiation....

    Read more
  • Calculate Absolute Value
    Created: Sep 14, 2024
    Difficulty: Beginner
    Type: Text
    Tags: Basics

    Write a function that takes a number and returns its absolute value using built-in functions. This problem is designed to help you practice using built-in functions for calculating absolute values. The function should accept one parameter and retur...

    Read more