Coming back to Rust code after a bit of a hiatus with a simple problem… The Two-sum problem. Finding numbers in an array. Yay, fun.
Day 11: Modular Multiplicative Inverse
We build another part of the mystery project by creating a function that calculates the modular multiplicative inverse of a number.
A long time ago, some dude needed to send a letter to his lover but didn’t want the messenger to be reading it. After all, messengers were notorious gossips and if this particular messager knew what was in the letter then the whole of the city would have known by tea time. He couldn’t very […]
Find the first non-repeating character
Today we are given a string of characters, the task is to return the first non-repeating character in the string. For the purposes of repetition upper case and lower case characters are treated as the same character but the returned value must have the correct case. Example If there are no non-repeating characters, then return […]
In mathematics, a determinant is a special number that you can calculate for square matrices. It’s special because it is only nonzero if and only if the matrix is invertible and the linear map represented by the matrix is an isomorphism. That’s a lot of big words don’t you think? For today’s problem, we don’t […]
Today we have a quirky problem that requires knowledge of higher-order functions, recursion, and advanced language features. It’s an add function that returns an adder function. Add Function Problem The problem is to create a function that will add numbers together when called in succession. Example It should chain as many times as we want […]
Ever been to a football match, your team is playing for all their worth and the crowd is enchanted. Then some drunk guys on the other side of the stadium start shouting “WAVE! WAVE”. All of a sudden the a Mexican wave starts from their end, ripples all the way to where you are and […]
Oh boy, this one involved some thinking. The problem is to find the outlier in an array of integers. You are given a list that has a minimum of three elements but can have up to a thousand. The array will always have either all even numbers and exactly one odd number or all odd […]
For today we have a number problem. The idea is to take an integer and return the expanded form. This problem wasn’t particularly difficult or tricky and honestly finding a wrong approach would have been harder than finding two correct approaches. Example Input: 12, Output “10 + 2” Input 42, Output “40 + 2” Expanded […]
The scenario is you are given a string of parentheses and are tasked to check if they are valid. The description from codewars: “Write a function that takes a string of parentheses, and determines if the order of the parentheses is valid. The function should return true if the string is valid, and false if […]