Skip to content

Instantly share code, notes, and snippets.

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
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
@syafdia
syafdia / Hitung
Last active August 29, 2015 14:16
Menghitung dari 1 - 999
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: DELL
#
# Created: 26/02/2015
# Copyright: (c) DELL 2015
# Licence: <your licence>
#-------------------------------------------------------------------------------
@syafdia
syafdia / utils.js
Created October 30, 2016 15:28
Commonly used function in my JS project
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);
},
// 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;
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)
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> {
// 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())
}
type workerPool struct {
maxWorker int
queuedTaskC chan func()
}
func (wp *workerPool) Run() {
for i := 0; i < wp.maxWorker; i++ {
go func(workerID int) {
for task := range wp.queuedTaskC {
task()
}
}(i + 1)
}
}