Skip to content

Instantly share code, notes, and snippets.

@romabelka
romabelka / taskt-example.md
Created October 1, 2019 08:41
Kickstart testing example

You have a long piece of text, and you want to send it to your friend as a series of SMS messages. Your text consists of English letters (uppercase and lowercase) and spaces. The text doesn't contain any leading spaces at the beginning or trailing spaces at the end. There are no two consecutive spaces in the text.

One proper SMS can contain at most K characters. If the text is longer, it needs to be split into parts. Each part should be sent in a separate message that fulfills the maximum length requirement. Text may not be split within words. The order of the words and the messages can't change, so that we can later concatenate the resulting messages to retrieve the original text. Spaces at the start and end of all messages are removed, and thus are not accounted for in the overall message length.

The goal is to count the number of SMS messages needed to accommodate the whole text, keeping the length of each message less than or equal to K. The total number of SMS messages must be kept to a minimum, ho

@romabelka
romabelka / gist:642dd8a68c58c008bbc6
Last active August 29, 2015 14:17
Private object attributes using ES6 WeakMap
var My = (function() {
var privates = new WeakMap;
return function(a) {
privates.set(this, a);
this.setter = function(a) {
privates.set(this, a)
};
this.getter = function() {
return privates.get(this)
};
//---------Promise----------
var Promise = function() {
this.__successCallbacks = [];
this.__errorCallbacks = [];
this.__value = undefined;
this.__state = 'pending';
//state = pending, success, error
this.then = function(successHandler, errorHandler) {
this.done(successHandler);