This file contains 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
def atm(): | |
CHARGE = 0.5 | |
temp = input() | |
temp = temp.split() | |
withdrawal = int(temp[0]) | |
balance = float(temp[1]) | |
if ((withdrawal <= balance) and (withdrawal%5 == 0)): | |
balance -= withdrawal+CHARGE | |
This file contains 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 java.util.Scanner; | |
public class TesFactorial | |
{ | |
public static void main(String[] args) | |
{ | |
Scanner scan = new Scanner(System.in); | |
int []tot = new int[100]; | |
int num, max, i; | |
//Input T |
This file contains 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
#------------------------------------------------------------------------------- | |
# Name: module1 | |
# Purpose: | |
# | |
# Author: DELL | |
# | |
# Created: 26/02/2015 | |
# Copyright: (c) DELL 2015 | |
# Licence: <your licence> | |
#------------------------------------------------------------------------------- |
This file contains 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
var utils = { | |
is: function (instanceOf, data) { | |
var dataType = Object.prototype.toString.call(data); | |
var expectedType = '[object ' + instanceOf + ']'; | |
return dataType === expectedType; | |
}, | |
isNot: function (instanceOf, data) { | |
return !this.is(instanceOf, data); | |
}, |
This file contains 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
// Utils | |
const data = [0, 1, 2, 3, 4, 5]; | |
const reduce = (fn) => (a) => (b) => b.reduce(fn, a); | |
const compose = (fns) => (a) => fns.reduceRight((acc, fn) => fn(acc), a); | |
// Transducer | |
const mapping = (transformerFn) => (combinerFn) => (acc, v) => combinerFn(acc, transformerFn(v)); | |
const filtering = (testFn) => (combinerFn) => (acc, v) => testFn(v) ? combinerFn(acc, v) : acc; | |
const dropping = (totDrop) => (combinerFn) => (acc, v) => --totDrop >= 0 ? acc : combinerFn(acc, v); | |
const taking = (totTake) => (combinerFn) => (acc, v) => --totTake >= 0 ? combinerFn(acc, v) : acc; |
This file contains 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
package com.syafdia.github.dummykotlin.datastructure | |
sealed class LinkedList<out T> { | |
fun filter(f: (v: T) -> Boolean): LinkedList<T> { | |
return when (this) { | |
is Nil -> Nil | |
is Node<T> -> when (f(head)) { | |
true -> Node(head, tail.filter(f)) | |
false -> tail.filter(f) |
This file contains 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
class AppSignatureHelper(context: Context) : ContextWrapper(context) { | |
/** | |
* Get all the app signatures for the current package | |
* @return | |
*/ | |
// Get all package signatures for the current package | |
// For each signature create a compatible hash | |
fun getAppSignatures(): ArrayList<String> { |
This file contains 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
// T is a type alias to accept any type. | |
type T = interface{} | |
// WorkerPool is a contract for Worker Pool implementation | |
type WorkerPool interface { | |
Run() | |
AddTask(task func()) | |
} |
This file contains 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
type workerPool struct { | |
maxWorker int | |
queuedTaskC chan func() | |
} |
This file contains 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
func (wp *workerPool) Run() { | |
for i := 0; i < wp.maxWorker; i++ { | |
go func(workerID int) { | |
for task := range wp.queuedTaskC { | |
task() | |
} | |
}(i + 1) | |
} | |
} |
OlderNewer