This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Multiplies two n-length integers using recursively the Karatsuba altorithm | |
class Karatsuba | |
def initialize | |
end | |
def self.karatsuba(x, y) | |
return x * y if (x < 10) || (y < 10) | |
n = [x.to_s.size, y.to_s.size].max |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (exports) { | |
'use strict'; | |
var sum, operation; | |
var add = function(number){ | |
sum += number; | |
} | |
var substract = function(number){ | |
sum -= number; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assumption: '1' is not a number, but a String, so it shouldn't be added. | |
// [‘a’, 2, 4, [‘1’, 5, ‘b’, [2,3, [‘a’, 4, [1,’b’,[5,’a’]]]]]] | |
(function (exports) { | |
'use strict'; | |
var sum; | |
var getValue = function(element){ | |
var value = 0; | |
if(typeof element === "number"){ | |
value = element; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Positive addition: both operands are positive | |
*/ | |
function sum(s0, s1) { | |
'use strict'; | |
let result = ''; | |
let carryOver = 0; | |
for(let i = 0, l = Math.max(s0.length, s1.length); i < l; i++) { | |
let sum = carryOver + parseInt(s0.charAt(s0.length - 1 - i ) || 0) + parseInt(s1.charAt(s1.length - 1 - i ) || 0); | |
carryOver = sum > 9 ? 1 : 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Edy Twiddle', | |
stepStatus: [ | |
Ember.Object.create({isValid: false}), | |
Ember.Object.create({isValid: false}), | |
Ember.Object.create({isValid: false}), | |
Ember.Object.create({isValid: false}), | |
Ember.Object.create({isValid: false}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
bool1: true, | |
bool2: Ember.computed.alias('bool1'), | |
actions: { | |
toggleBool2() { | |
this.toggleProperty('bool2'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
sortAscending: true, | |
notSortAscending: Ember.computed.not('sortAscending'), | |
_items: Em.A([1, 2, 3]), | |
items: Ember.computed('sortAscending', function() { | |
if (this.get('sortAscending')) { | |
return this.get('ascending'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
i: 1, | |
iEven: Ember.computed(function() { | |
return this.get('i') % 2 === 0; | |
}), | |
actions: { | |
incrementI() { | |
this.incrementProperty('i'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['class-0'], | |
init() { | |
this._super(); | |
// this.classNames = this.classNames.slice(); | |
this.classNames.pushObjects(['WOLOLO']); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
arr: [{isBot: true, id: 'bot'}, {isBot: false, id: 'not bot'}], | |
rejects: Ember.computed('arr.[]', function() { | |
return this.get('arr').rejectBy('isBot'); | |
}), | |
filters: Ember.computed('arr.[]', function() { | |
return this.get('arr').filterBy('isBot', false); |
OlderNewer