// Usage Example: const result = permutations('abc')
for (let value of result) { console.log(value) }
A Pen by Vlad Bezden on CodePen.
'use strcit' | |
/* | |
* Calculate if number is power of two. For instance 1, 2, 4, 8, 16, 32, 64, 128, ... | |
* | |
* @param {Number} n - number > 0 | |
* @returns {Bool} - true if number is power of two false otherwise | |
*/ | |
function isPowerOfTwo(n) { | |
if (n < 0) { |
// Usage Example: const result = permutations('abc')
for (let value of result) { console.log(value) }
A Pen by Vlad Bezden on CodePen.
<h1 id="result"></h1> |
source $VIMRUNTIME/vimrc_example.vim | |
source $VIMRUNTIME/mswin.vim | |
behave mswin | |
set diffexpr=MyDiff() | |
function MyDiff() | |
let opt = '-a --binary ' | |
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif | |
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif | |
let arg1 = v:fname_in |
'''Example of how to simulate sensor data''' | |
import datetime | |
import itertools | |
import random | |
import time | |
class Sensor: | |
'''Sensor simulator |
'''Calculating number of words and number of times they occurred in sentences | |
Example of how to use map, reduce, and sorting dictionary by value | |
Available functions: | |
- count_words: counts how many times each word occurred in the sentence | |
- combine_counts: combines two dictionaries. In other word sums up number of | |
times word occurred in each sentence | |
''' |
'use strict' | |
console.clear() | |
const array1 = [1, 2, 3] | |
const array2 = [2, 3, 4] | |
const union = [...new Set([...array1, ...array2])] | |
const intersection = [...new Set(array1.filter(a1 => array2.find(a2 => a1 === a2)))] | |
const differences = [...new Set(array1.filter(a1 => !array2.find(a2 => a1 === a2)))] |
Performance calculator based on Proxy ES6/ES2015 feature
A Pen by Vlad Bezden on CodePen.
Analog clocks display time with an analog clock face, which consists of a round dial with the numbers 1 through 12, the hours in the day, around the outside. The hours are indicated with an hour hand, which makes two revolutions in a day, while the minutes are indicated by a minute hand, which makes one revolution per hour. In this mission we will use a clock without second hand. The hour hand moves smoothly and the minute hand moves step by step. You are given a time in 24-hour format and you should calculate a lesser angle between the hour and minute hands in degrees. Don't forget that clock has numbers from 1 to 12, so 23 == 11. The time is given as a string with the follow format "HH:MM", where HH is hours and MM is minutes. Hours and minutes are given in two digits format, so "1" will be written as "01". The result should be given in degrees with precision ±0.1.
For example, on the given image we see "02:30" or "14:30" at the left part and "01:42" or "13:42" at the right part. We
<div id="mocha"></div> |