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 sorting; | |
public class QuickSortWithArray { | |
public static void main(String[] args) { | |
int[] arrs = new int[10]; | |
for (int i = 0; i < 10; i++) { | |
arrs[i] = (int) (Math.random() * 100); | |
} |
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 what_to_have(list, count) | |
result = {} | |
(1..count).each do |n| | |
key = list.sample | |
if result[key] | |
result[key] = result[key] + 1 | |
else | |
result[key] = 1 | |
end | |
end |
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
Transmission Control Protocol | |
Functional Specification | |
+---------+ ---------\ active OPEN | |
| CLOSED | \ ----------- | |
+---------+<---------\ \ create TCB | |
| ^ \ \ snd SYN |
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: bbs | |
Summary: BBS | |
Version: 1.0 | |
Release: 1 | |
URL: example.com | |
Source: %{name}-%{version}-%{release}.tar.gz | |
License: MIT | |
Group: Applications/Internet | |
BuildArch: noarch | |
Requires: java-1.7.0-openjdk, java-1.7.0-openjdk-devel |
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.dcl; | |
import java.math.BigInteger; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class Test { | |
public static Map int2Char = new HashMap<Integer, Character>() {{ | |
put(0, 'a'); |
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 SoccerFixtures = List[(String, String)] | |
def doCombine(teams: List[String], res: SoccerFixtures): SoccerFixtures = teams match { | |
case Nil => res | |
case pick :: others => | |
doCombine(others, others.map(o => (pick, o)) ::: res) | |
} | |
doCombine(List("a", "b", "c", "d"), List()).sorted | |
def combine(teams: List[String]) = doCombine(teams, List()) |
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 Pen { | |
def getInfo = "a pen" | |
} | |
class Chalk extends Pen { | |
override def getInfo = "a pencil that can be erased by eraser" | |
} | |
class WhiteBoardPen extends Pen { | |
override def getInfo = "a white board pen that can write on window wall" |
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 printList(args: TraversableOnce[_]): Unit = { | |
args.foreach(print) | |
println() | |
} | |
def count(ls: List[Int]): Unit = { | |
def doCount(src: List[Int], res: List[Int]): Unit = src match { | |
case Nil => printList(res) | |
case _ => for (element <- src) { | |
doCount(src.diff(List(element)), res :+ element) |
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
// You are not permitted to use these List methods: | |
// * length | |
// * map | |
// * filter | |
// * ::: (and variations such as ++) | |
// * flatten | |
// * flatMap | |
// * reverse (and variations i.e. reverseMap, reverse_:::) | |
// This also means you are not permitted to use for-comprehensions on Lists. | |
// You are permitted to use the functions you write yourself. For example, Exercise 2 may use Exercise 1 or Exercise 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
package recfun | |
import common._ | |
object Main { | |
def main(args: Array[String]) { | |
println("Pascal's Triangle") | |
for (row <- 0 to 10) { | |
for (col <- 0 to row) | |
print(pascal(col, row) + " ") | |
println() |
NewerOlder