Hello friends!
Welcome back! I hope your weekend was nice and relaxing, and even a little productive.
Web links of the week
ES2015+ cheatsheet
Grumbler: A template for writing distributable front-end javascript modules.
An imperative guide to forms in Vue.js
Creating Awesome SPAs With React
Something that interested me this week
This week I watched several awesome woodworking videos. Someday, I really want to work with wood and build furniture and decorations for myself. Watching videos of artists and makers putting things together, whether it be pixel art, paintings, furniture, sculptures... it's satisfying to see, and inspiring. Being in tech, which if you're reading this, you are aware, often makes you think in one mindset for long periods of time. Seeing how others in completely different fields work is so good for just clearing your head or just having something you can learn from playing in the background.
Here's one of the videos I saw this week. It's a long one, but it's amazing to see the effort that went into the project.
Interview question of the week
Last week, I had you write the psuedocode for an algorithm that determines if one of the numbers is present for more than half the list.
I ended up writing code for it because I kept questioning myself. Classic.
function majority(arr) {
var candidate = 0, // doesn't matter what this is initialized to
count = 0,
ret = 'none',
arrSize = arr.length / 2;
arr.forEach((v) => {
if (count === 0) {
candidate = v;
}
if (candidate === v) {
count += 1;
} else {
count = 0;
}
if (count >= arrSize) {
ret = ‘majority is: ‘ + v;
break;
}
});
return ret;
}
I personally think I could do it in a more efficient way (since this is, worst case, O(n)), kind of like they’re mentioning here, but this is what I came up with so far. :)
On to this week’s question!
Given an integer array and two numbers x and y, print x numbers from the array, such that difference between any two pairs is divisible by y. If there are no x numbers, then print -1.
Example:
differencePair([1, 8, 4], 2, 3)
> 1 4
Explanation: the difference between 1 and 4 is divisible by 3
Cool things from around the internet
What bullets do to bodies
The History of the Ampersand
Tony Fadell Gets Back at Silicon Valley - From Paris
DZ60 | EnjoyPBT Hangul
Joke
A funeral service is held for a woman who just passed away.
As the pallbearers carry the casket out, they accidentally bump into a wall, and they hear a faint moan.
They open the casket and find that the woman is actually alive.
She lives for 10 more years and then dies.
They have another funeral for her. At the end of the service, the pallbearers carry out the casket.
As they are walking, the husband cries out, “Watch out for the wall!”
That’s all from me this week friends, have a good one! Be safe, make good choices, and sing some show tunes.
cassidoo