-
Expanded Numbers
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…
-
Brace Validation
Yesterday I did the valid parentheses problem and came up with two solutions, that worked. One was overthought while the other was simplicity defined. The next logical question one can ask though is what if we now want to do brace validation? I.e. there are more than just brackets? What if we include curly braces{},…
-
Valid Parentheses
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…
-
Word Reversal Code Challenge
Here’s the scenario, you are given a string s that contains a sentence and your task is to write a word reversal function to reverse the order of all words that are longer than n characters. Example: s = The quick brown fox n = 4 Then the result should be “The kciuq nworb fox”…
-
A story about Storybook
Storybook is a fascinating piece of software that allows pain-free React development. We started using it at djangsters, and I wrote our thoughts about it here. This is a brief summary, and I will be writing a more detailed post both on Medium and here so follow me on Twitter @phoexer or @djangsters not to…
-
is DOMRect not serializing for you?
Today I was writing a playwright test that needed to do some calculations on an element’s coordinates. No problem right? Just get the DOMRect object from getBoundingClientRect and go about your day. Easy, expect that rect was an empty object. It took me a second to figure out, but it appears that DOMRect is not…
-
Code Corner: Triangles
For the last two weeks, I’ve had a bunch of interviews and code challenge tasks I was taking which took up a lot of my time. Add that to #DadLife and the result is two weeks with no content. The pressure is off for the moment so I’m picking it up again. So for today:…
-
Code Corner: Nested Squares
Problem Draw three nested squares in html and css. My Solution Simple, you need three divs nested inside each other with a unique way of referencing them, the rest is done in CSS. I set the body to gray because reasons, there is really no need to do this. The first part is that all…
-
Code Corner: Counting Multiples
Problem We are given 3 numbers, a starting number A, an ending number B and an integer K, find the number of multiples of K there is between A and B inclusive. Source Example a = 6 b = 9 k = 2 Should return 2 My solution The ranges are irrelevant because this is…
-
Code Corner: Bracket Matching
Problem Given a string with brackets check to see if the brackets are properly nested. Source Example [] = return 1 () => 1 )( => 0 ({)} => 0 ” => 1 My Solution Classic stack problem. Didn’t need to brute first. The idea is you create a stack and loop through each character…