Practice Problems
Test your Sloplang skills. Each problem provides variables and validates your output against test cases.
Given a list of numbers and a target, find the two numbers that add up to the target. Print them as a list [a, b] where a appears before b in the original list.
For each number from 1 to n, print "Fizz" if it's divisible by 3, "Buzz" if divisible by 5, "FizzBuzz" if divisible by both, or the number itself otherwise. Print each result on its own line.
Given a string containing only the characters (, ), {, }, [, and ], determine if the input string is valid. A string is valid if open brackets are closed by the same type in the correct order. Print true or false.
Given a string, determine if it is a palindrome (reads the same forwards and backwards). Print true or false.
Given a string, find the character that appears most often. Print the character and its count separated by a colon and space, like "a: 5". If there's a tie, any of the most common is fine.
Given a list of numbers, solve two parts:
Elves carry food items, each with a calorie count. Each elf's inventory is a group of numbers separated by blank lines.
Parse a log file where each line has a timestamp, level, and message separated by | characters.
Given a list of numbers and a window size k, compute the running average over each window of k consecutive elements. Print the results as a list of integers (use integer division).
Given a list of words, group the anagrams together. Print each group as a list on its own line, with groups sorted by their first element, and words within each group sorted alphabetically.