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
-- Write a function that given a list of non negative integers, | |
-- arranges them such that they form the largest possible number. | |
-- For example, given [50, 2, 1, 9], the largest formed number is 95021. | |
-- Source: https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour | |
import Data.List | |
intCombinations :: [Int] -> [Int] | |
intCombinations xs = map (read.concat.(map show)) (permutations xs) | |
-- usage: solve [50, 2, 1, 9] |
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
-- Write a program that outputs all possibilities to put + or - or nothing between the numbers 1, 2, ..., 9 (in this order) such that the result is always 100. For example: 1 + 2 + 34 – 5 + 67 – 8 + 9 = 100. | |
-- Source: https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour | |
data Join = Plus | Minus | Concat deriving Show | |
compute :: Integer -> (Integer, Join) -> Integer | |
compute x (y, Plus) = x+y | |
compute x (y, Minus) = x-y | |
compute x (y, Concat) = read(show(x)++show(y)) |
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 asyncLoop(index, callback) { | |
if(index+1) { | |
setTimeout(function() { | |
callback(index); | |
asyncLoop(index-1, callback); | |
}, 10); | |
} | |
} | |
// sync |
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
@ECHO OFF | |
REM Source: http://svnbook.red-bean.com/en/1.7/svn.advanced.externaldifftools.html | |
SET DIFF="bcomp.exe" | |
SET LEFT=%6 | |
SET RIGHT=%7 | |
%DIFF% %LEFT% %RIGHT% |
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
/** | |
* fs.watch wrapper that checks file SHA1 | |
* and prevents multiple callback calls. | |
* | |
* Related: http://stackoverflow.com/q/12978924/1637178 | |
* | |
* Usage is the same as fs.watch | |
* | |
* var onFileChange = require("./onFileChange.js"); | |
* |
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
class FizzBuzz | |
{ | |
public static void main(String[] args) | |
{ | |
for(int i = 1; i <= 100; i++) | |
{ | |
String str = ""; | |
if(i%3 == 0) str += "Fizz"; | |
if(i%5 == 0) str += "Buzz"; |
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
@echo off | |
REM put this file in C:/Windows | |
REM then if you are in `d:/abc/cdf` and type `go e:/xxx` in cmd.exe, you will go there :) | |
cd %~f1 | |
%~d1 |
NewerOlder