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 io.Source | |
import scala.util.control.Breaks._ | |
/** | |
* Scala TicTacToe game without any side effects | |
* | |
* http://blog.aunndroid.com/2011/11/chewy-code-scala-tictactoe-part-1.html | |
*/ | |
object TicTacToe { | |
val WinCount = 3 |
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
//http://blog.aunndroid.com/2011/11/learning-scala-boyermoore-search-1.html | |
object boyer_more { | |
def main(args : Array[String]) = { | |
if (args.length == 2 && args(0).length >= args(1).length) { | |
val result = boyer_more_search(args(0), args(1)) | |
println("Match found : " + result.length + | |
" Pos : " + result.mkString(" ")) | |
} else { | |
println | |
println("Usage: boyer_more string_body search_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
/* | |
http://blog.aunndroid.com/2011/11/learning-scala-recursion-and-tco-1.html | |
This is the FP implementation of the "Telephone Words" | |
where the program accept 7 digit ph number and spit out | |
all possible word combination e.g. 464-7328 can be | |
"GMGPDAS ... IMGREAT ... IOIRFCU" | |
Per following table, where 1 and 0 does not represent any alphabet | |
------------ | |
| |ABC|DEF| |
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
/* | |
http://blog.aunndroid.com/2011/11/learning-scala-recursion-and-tco-1.html | |
This is the recursion example (p.97) used in "Programming Interviews Exposed" | |
by John Mongan, Noah Suojanen, Eric Giguère | |
The book's imperative style C# code (function combine) has been reimplemented in Scala. | |
Function recursionEx is in pure FP way. | |
Function tailReccursionEx is implemented to get TCO'ed (TCO=Tail Call Optimization) | |
Here is the problem statement: |
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
/* | |
http://blog.aunndroid.com/2011/11/learning-scala-recursion-and-tco-1.html | |
Ackermann is being studied for recursion. It is quite complex to do TCO for Ackermann. | |
However, there have been some implementation of Ackermann in Haskell with TCO | |
http://lambda-the-ultimate.org/node/2673 | |
*/ | |
object Ackermann { | |
def main(args : Array[String]) : Unit = { | |
println(args.toList); |
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
// | |
// MisMisMatch.swift | |
// SwiftNeuralNetworkGame | |
// | |
// Created by Win Myo Htet on 5/21/16. | |
// Copyright © 2016 Win Myo Htet. All rights reserved. | |
// | |
import Foundation |
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 sys | |
import os | |
import re | |
import datetime | |
def get_email_list(name, domain_list, total_left): | |
emails_left = total_left.copy() | |
email_list = [] | |
for email in emails_left: |
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 TreeNode: | |
def __init__(self, val, left=None, right=None): | |
self.val = val | |
self.left = left | |
self.right = right | |
def __repr__(self): | |
return "TreeNode({},{}, {})".format(self.val, self.left, self.right) |
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 collections | |
from helperlc import print_l | |
from helperlc import print_tree | |
from helperlc import TreeNode | |
from helperlc import Node | |
from helperlc import ListNode | |
from helperlc import get_tree_node_levelorder | |
from typing import List | |
import timeit |
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
function FindProxyForURL(url, host) { | |
// List of domains to be proxied | |
var proxyDomains = [ | |
"facebook.com", | |
"wikipedia.org", | |
"ifconfig.me" | |
]; | |
for (var i = 0; i < proxyDomains.length; i++) { | |
if (dnsDomainIs(host, proxyDomains[i]) || shExpMatch(host, "*." + proxyDomains[i])) { |