Searching for the longest word that can be written with left hand touch typing I used the following code, that uses the English words list found in https://github.com/dwyl/english-words. That gave the word ‘aftercataract’ as a result. Aftercataract does not come up as a result to this question though it’s in both Merriem-Webster and wictionary. Another… Continue reading Stewardesses, sweaterdresses and aftercataract
How can we see if stewardesses is a word that can be written with only the left hand. The string with the left hand letters is ‘QWERTASDFGZXCV’, so how can we check if all the letters of an input word are in this string? A straightforward solution is: But stackoverflow has a much better suggestion… Continue reading Stewardesses
Yesterday Cassidy Williams (@cassidoo) sent the following problem through her newsletter (do subscribe): Assume you are given an unsorted list of numbers where everything is duplicated twice except for one number. Find and return that one number! How many solutions can you think of? Example input: [1,2,3,6,4,9,9,2,1,4,6] Example output: 3 My first solution was the… Continue reading Space-time tradeoff
Yesterday I wanted to print a tic-tac-toe. I wrote this: to get the grid: |—|—|—| |—|—|—| |—|—|—| And then I thought that I could compute the positions for Xs and Os. I even thought of a dict to hold them like: But Python had its own mind on the subject, when I tried: it gave:… Continue reading The immutable string
For a small project that hopefully will reach some level eventually. At some point after many efforts I tried the following code: This code affects only the last image (div id ttt9), the reason may be that theImg is overwritten after every each(). So the solution was: It will take me a while to get… Continue reading Last image standing
Remember when I was trying to have a code for “Give a number or give ‘end’ to exit:” “Give a number or give ‘end’ to exit:” Proceeding to the amazing course I am taking our teacher gave the following solution:
The following code transforms a string of zeros and ones in a form of consecutive zeros and ones. E.g., “00001110000111” will be 4,3,4,3. Without importing I had written the following code for the same task: For a minute I thought that the original code was more readable than the groupby one but I was wrong.