add test files
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* This example implements the famous "99 Bottles of Beer" program
|
||||
* See http://99-bottles-of-beer.net/
|
||||
*
|
||||
* The point is to print out a song with the following lyrics:
|
||||
*
|
||||
* The "99 bottles of beer" song
|
||||
*
|
||||
* 99 bottles of beer on the wall, 99 bottles of beer.
|
||||
* Take one down, pass it around, 98 bottles of beer on the wall.
|
||||
*
|
||||
* 98 bottles of beer on the wall, 98 bottles of beer.
|
||||
* Take one down, pass it around, 97 bottles of beer on the wall.
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* 2 bottles of beer on the wall, 2 bottles of beer.
|
||||
* Take one down, pass it around, 1 bottle of beer on the wall.
|
||||
*
|
||||
* 1 bottle of beer on the wall, 1 bottle of beer.
|
||||
* Take one down, pass it around, no more bottles of beer on the wall.
|
||||
*
|
||||
* No more bottles of beer on the wall, no more bottles of beer.
|
||||
* Go to the store and buy some more, 99 bottles of beer on the wall.
|
||||
*
|
||||
* Additionally, you can pass the desired initial number of bottles to use (rather than 99)
|
||||
* as a command-line argument
|
||||
*/
|
||||
import js.*
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
if (args.isEmpty()) {
|
||||
printBottles(99)
|
||||
}
|
||||
else {
|
||||
val bottles = parseInt(args[0]);
|
||||
if (bottles != null) {
|
||||
printBottles(bottles);
|
||||
} else {
|
||||
println("You have passed '${args[0]}' as a number of bottles, " +
|
||||
"but it is not a valid integral number")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun printBottles(bottleCount : Int) {
|
||||
if (bottleCount <= 0) {
|
||||
println("No bottles - no song")
|
||||
return
|
||||
}
|
||||
|
||||
println("The \"${bottlesOfBeer(bottleCount)}\" song\n")
|
||||
|
||||
var bottles = bottleCount
|
||||
while (bottles > 0) {
|
||||
val bottlesOfBeer = bottlesOfBeer(bottles)
|
||||
print("$bottlesOfBeer on the wall, $bottlesOfBeer.\nTake one down, pass it around, ")
|
||||
bottles--
|
||||
println("${bottlesOfBeer(bottles)} on the wall.\n")
|
||||
}
|
||||
println("No more bottles of beer on the wall, no more bottles of beer.\n" +
|
||||
"Go to the store and buy some more, ${bottlesOfBeer(bottleCount)} on the wall.")
|
||||
}
|
||||
|
||||
fun bottlesOfBeer(count : Int) : String =
|
||||
when (count) {
|
||||
0 -> "no more bottles"
|
||||
1 -> "1 bottle"
|
||||
else -> "$count bottles"
|
||||
} + " of beer"
|
||||
|
||||
// From the std package
|
||||
// This is an extension property, i.e. a property that is defined for the
|
||||
// type Array<T>, but does not sit inside the class Array
|
||||
fun <T> Array<T>.isEmpty() = size == 0
|
||||
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
* This is an example of a Type-Safe Groovy-style Builder
|
||||
*
|
||||
* Builders are good for declaratively describing data in your code.
|
||||
* In this example we show how to describe an HTML page in Kotlin.
|
||||
*
|
||||
* See this page for details:
|
||||
* http://confluence.jetbrains.net/display/Kotlin/Type-safe+Groovy-style+builders
|
||||
*/
|
||||
import js.*
|
||||
import java.util.*
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
val result =
|
||||
html {
|
||||
head {
|
||||
title {+"XML encoding with Kotlin"}
|
||||
}
|
||||
body {
|
||||
h1 {+"XML encoding with Kotlin"}
|
||||
p {+"this format can be used as an alternative markup to XML"}
|
||||
|
||||
// an element with attributes and text content
|
||||
a(href = "http://jetbrains.com/kotlin") {+"Kotlin"}
|
||||
|
||||
// mixed content
|
||||
p {
|
||||
+"This is some"
|
||||
b {+"mixed"}
|
||||
+"text. For more see the"
|
||||
a(href = "http://jetbrains.com/kotlin") {+"Kotlin"}
|
||||
+"project"
|
||||
}
|
||||
p {+"some text"}
|
||||
|
||||
// content generated from command-line arguments
|
||||
p {
|
||||
+"Command line arguments were:"
|
||||
ul {
|
||||
for (arg in args)
|
||||
li {+arg}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
println(result)
|
||||
}
|
||||
|
||||
trait Element {
|
||||
fun render(builder : StringBuilder, indent : String)
|
||||
|
||||
fun toString() : String? {
|
||||
val builder = StringBuilder()
|
||||
render(builder, "")
|
||||
return builder.toString()
|
||||
}
|
||||
}
|
||||
|
||||
class TextElement(val text : String) : Element {
|
||||
override fun render(builder : StringBuilder, indent : String) {
|
||||
builder.append("$indent$text\n")
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Tag(val name : String) : Element {
|
||||
val children = ArrayList<Element>()
|
||||
val attributes = HashMap<String, String>()
|
||||
|
||||
protected fun initTag<T : Element>(tag : T, init : T.() -> Unit) : T {
|
||||
tag.init()
|
||||
children.add(tag)
|
||||
return tag
|
||||
}
|
||||
|
||||
override fun render(builder : StringBuilder, indent : String) {
|
||||
builder.append("$indent<$name${renderAttributes()}>\n")
|
||||
for (c in children) {
|
||||
c.render(builder, indent + " ")
|
||||
}
|
||||
builder.append("$indent</$name>\n")
|
||||
}
|
||||
|
||||
private fun renderAttributes() : String? {
|
||||
val builder = StringBuilder()
|
||||
for (a in attributes.keySet()) {
|
||||
builder.append(" $a=\"${attributes[a]}\"")
|
||||
}
|
||||
return builder.toString()
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TagWithText(name : String) : Tag(name) {
|
||||
fun String.plus() {
|
||||
children.add(TextElement(this))
|
||||
}
|
||||
}
|
||||
|
||||
class HTML() : TagWithText("html") {
|
||||
fun head(init : Head.() -> Unit) = initTag(Head(), init)
|
||||
|
||||
fun body(init : Body.() -> Unit) = initTag(Body(), init)
|
||||
}
|
||||
|
||||
class Head() : TagWithText("head") {
|
||||
fun title(init : Title.() -> Unit) = initTag(Title(), init)
|
||||
}
|
||||
|
||||
class Title() : TagWithText("title")
|
||||
|
||||
abstract class BodyTag(name : String) : TagWithText(name) {
|
||||
fun b(init : B.() -> Unit) = initTag(B(), init)
|
||||
fun p(init : P.() -> Unit) = initTag(P(), init)
|
||||
fun h1(init : H1.() -> Unit) = initTag(H1(), init)
|
||||
fun ul(init : UL.() -> Unit) = initTag(UL(), init)
|
||||
fun a(href : String, init : A.() -> Unit) {
|
||||
val a = initTag(A(), init)
|
||||
a.href = href
|
||||
}
|
||||
}
|
||||
|
||||
class Body() : BodyTag("body")
|
||||
class UL() : BodyTag("ul") {
|
||||
fun li(init : LI.() -> Unit) = initTag(LI(), init)
|
||||
}
|
||||
|
||||
class B() : BodyTag("b")
|
||||
class LI() : BodyTag("li")
|
||||
class P() : BodyTag("p")
|
||||
class H1() : BodyTag("h1")
|
||||
class A() : BodyTag("a") {
|
||||
public var href : String
|
||||
get() = attributes["href"]
|
||||
set(value) {
|
||||
attributes["href"] = value
|
||||
}
|
||||
}
|
||||
|
||||
fun html(init : HTML.() -> Unit) : HTML {
|
||||
val html = HTML()
|
||||
html.init()
|
||||
return html
|
||||
}
|
||||
|
||||
// An excerpt from the Standard Library
|
||||
fun <K, V> Map<K, V>.set(key : K, value : V) = this.put(key, value)
|
||||
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
* This is a straightforward implementation of The Game of Life
|
||||
* See http://en.wikipedia.org/wiki/Conway's_Game_of_Life
|
||||
*/
|
||||
|
||||
import java.util.*
|
||||
import java.lang.split;
|
||||
import js.*;
|
||||
|
||||
/*
|
||||
* A field where cells live. Effectively immutable
|
||||
*/
|
||||
class Field(
|
||||
val width : Int,
|
||||
val height : Int,
|
||||
// This function tells the constructor which cells are alive
|
||||
// if init(i, j) is true, the cell (i, j) is alive
|
||||
init : (Int, Int) -> Boolean
|
||||
) {
|
||||
private val live : Array<Array<Boolean>> = Array(height) {i -> Array(width) {j -> init(i, j)}}
|
||||
|
||||
private fun liveCount(i : Int, j : Int)
|
||||
= if (i in 0..height-1 &&
|
||||
j in 0..width-1 &&
|
||||
live[i][j]) 1 else 0
|
||||
|
||||
// How many neighbors of (i, j) are alive?
|
||||
fun liveNeighbors(i : Int, j : Int) =
|
||||
liveCount(i - 1, j - 1) +
|
||||
liveCount(i - 1, j) +
|
||||
liveCount(i - 1, j + 1) +
|
||||
liveCount(i, j - 1) +
|
||||
liveCount(i, j + 1) +
|
||||
liveCount(i + 1, j - 1) +
|
||||
liveCount(i + 1, j) +
|
||||
liveCount(i + 1, j + 1)
|
||||
|
||||
// You can say field[i, j], and this function gets called
|
||||
fun get(i : Int, j : Int) = live[i][j]
|
||||
}
|
||||
|
||||
/**
|
||||
* This function takes the present state of the field
|
||||
* and return a new field representing the next moment of time
|
||||
*/
|
||||
fun next(field : Field) : Field {
|
||||
return Field(field.width, field.height) {i, j ->
|
||||
val n = field.liveNeighbors(i, j)
|
||||
if (field[i, j])
|
||||
// (i, j) is alive
|
||||
n in 2..3 // It remains alive iff it has 2 or 3 neighbors
|
||||
else
|
||||
// (i, j) is dead
|
||||
n == 3 // A new cell is born if there are 3 neighbors alive
|
||||
}
|
||||
}
|
||||
|
||||
/** A few colony examples here */
|
||||
fun main(args : Array<String>) {
|
||||
// Simplistic demo
|
||||
printField("***", 3)
|
||||
// "Star burst"
|
||||
printField("""
|
||||
__*__
|
||||
_***_
|
||||
__*__
|
||||
""", 10)
|
||||
// Stable colony
|
||||
printField("""
|
||||
__*__
|
||||
_*_*_
|
||||
__*__
|
||||
""", 3)
|
||||
// Stable from the step 2
|
||||
printField("""
|
||||
__**__
|
||||
__**__
|
||||
__**__
|
||||
""", 3)
|
||||
// Oscillating colony
|
||||
printField("""
|
||||
__**__
|
||||
__**__
|
||||
__**__
|
||||
__**__
|
||||
""", 6)
|
||||
// A fancier oscillating colony
|
||||
printField("""
|
||||
---------------
|
||||
---***---***---
|
||||
---------------
|
||||
-*----*-*----*-
|
||||
-*----*-*----*-
|
||||
-*----*-*----*-
|
||||
---***---***---
|
||||
---------------
|
||||
---***---***---
|
||||
-*----*-*----*-
|
||||
-*----*-*----*-
|
||||
-*----*-*----*-
|
||||
---------------
|
||||
---***---***---
|
||||
---------------
|
||||
""", 10)
|
||||
}
|
||||
|
||||
// UTILITIES
|
||||
|
||||
fun printField(s : String, steps : Int) {
|
||||
var field = makeField(s)
|
||||
for (step in 1..steps) {
|
||||
println("Step: $step")
|
||||
for (i in 0..field.height-1) {
|
||||
for (j in 0..field.width-1) {
|
||||
print(if (field[i, j]) "*" else " ")
|
||||
}
|
||||
println("")
|
||||
}
|
||||
field = next(field)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun <T> Array<T>.toList() : List<T> = this.to(ArrayList<T>())
|
||||
|
||||
val String?.size : Int
|
||||
get() = if (this != null) this.length else 0;
|
||||
|
||||
fun <T, C: Collection<T>> Array<T>.to(result: C) : C {
|
||||
for (elem in this)
|
||||
result.add(elem)
|
||||
return result
|
||||
}
|
||||
|
||||
fun makeField(s : String) : Field {
|
||||
val lines : Array<String> = s.split("\n")
|
||||
|
||||
val w = max<String>(lines.toList(), comparator<String> {o1, o2 ->
|
||||
val l1 : Int = o1.size
|
||||
val l2 = o2.size
|
||||
l1 - l2
|
||||
}).sure()
|
||||
val data = Array(lines.size) {Array(w.size) {false}}
|
||||
|
||||
// workaround
|
||||
for (i in data.indices) {
|
||||
data[i] = Array(w.size) {false}
|
||||
for (j in data[i].indices)
|
||||
data[i][j] = false
|
||||
}
|
||||
|
||||
for (line in lines.indices) {
|
||||
for (x in lines[line].indices) {
|
||||
val c = lines[line][x]
|
||||
data[line][x] = c == '*'
|
||||
}
|
||||
}
|
||||
|
||||
return Field(w.size, lines.size) {i, j -> data[i][j]}
|
||||
}
|
||||
|
||||
// An excerpt from the Standard Library
|
||||
val String?.indices : IntRange get() = IntRange(0, this.sure().size)
|
||||
|
||||
fun <K, V> Map<K, V>.set(k : K, v : V) { put(k, v) }
|
||||
|
||||
val <T> Array<T>.isEmpty : Boolean get() = size == 0
|
||||
@@ -0,0 +1,223 @@
|
||||
/**
|
||||
* Let's Walk Through a Maze.
|
||||
*
|
||||
* Imagine there is a maze whose walls are the big 'O' letters.
|
||||
* Now, I stand where a big 'I' stands and some cool prize lies
|
||||
* somewhere marked with a '$' sign. Like this:
|
||||
*
|
||||
* OOOOOOOOOOOOOOOOO
|
||||
* O O
|
||||
* O$ O O
|
||||
* OOOOO O
|
||||
* O O
|
||||
* O OOOOOOOOOOOOOO
|
||||
* O O I O
|
||||
* O O
|
||||
* OOOOOOOOOOOOOOOOO
|
||||
*
|
||||
* I want to get the prize, and this program helps me do so as soon
|
||||
* as I possibly can by finding a shortest path through the maze.
|
||||
*/
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* This function looks for a path from max.start to maze.end through
|
||||
* free space (a path does not go through walls). One can move only
|
||||
* straightly up, down, left or right, no diagonal moves allowed.
|
||||
*/
|
||||
fun findPath(maze : Maze) : List<#(Int, Int)>? {
|
||||
val previous = HashMap<#(Int, Int), #(Int, Int)>
|
||||
|
||||
val queue = LinkedList<#(Int, Int)>
|
||||
val visited = HashSet<#(Int, Int)>
|
||||
|
||||
queue.offer(maze.start)
|
||||
visited.add(maze.start)
|
||||
while (!queue.isEmpty()) {
|
||||
val cell = queue.poll()
|
||||
if (cell == maze.end) break
|
||||
|
||||
for (newCell in maze.neighbors(cell._1, cell._2)) {
|
||||
if (newCell in visited) continue
|
||||
previous[newCell] = cell
|
||||
queue.offer(newCell)
|
||||
visited.add(cell)
|
||||
}
|
||||
}
|
||||
|
||||
if (previous[maze.end] == null) return null
|
||||
|
||||
val path = ArrayList<#(Int, Int)>()
|
||||
var current = previous[maze.end]
|
||||
while (current != maze.start) {
|
||||
path.add(0, current)
|
||||
current = previous[current]
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
/**
|
||||
* Find neighbors of the (i, j) cell that are not walls
|
||||
*/
|
||||
fun Maze.neighbors(i : Int, j : Int) : List<#(Int, Int)> {
|
||||
val result = ArrayList<#(Int, Int)>
|
||||
addIfFree(i - 1, j, result)
|
||||
addIfFree(i, j - 1, result)
|
||||
addIfFree(i + 1, j, result)
|
||||
addIfFree(i, j + 1, result)
|
||||
return result
|
||||
}
|
||||
|
||||
fun Maze.addIfFree(i : Int, j : Int, result : List<#(Int, Int)>) {
|
||||
if (i !in 0..height-1) return
|
||||
if (j !in 0..width-1) return
|
||||
if (walls[i][j]) return
|
||||
|
||||
result.add(#(i, j))
|
||||
}
|
||||
|
||||
/**
|
||||
* A data class that represents a maze
|
||||
*/
|
||||
class Maze(
|
||||
// Number or columns
|
||||
val width : Int,
|
||||
// Number of rows
|
||||
val height : Int,
|
||||
// true for a wall, false for free space
|
||||
val walls : Array<out Array<out Boolean>>,
|
||||
// The starting point (must not be a wall)
|
||||
val start : #(Int, Int),
|
||||
// The target point (must not be a wall)
|
||||
val end : #(Int, Int)
|
||||
) {
|
||||
}
|
||||
|
||||
/** A few maze examples here */
|
||||
fun main(args : Array<String>) {
|
||||
printMaze("I $")
|
||||
printMaze("I O $")
|
||||
printMaze("""
|
||||
O $
|
||||
O
|
||||
O
|
||||
O
|
||||
O I
|
||||
""")
|
||||
printMaze("""
|
||||
OOOOOOOOOOO
|
||||
O $ O
|
||||
OOOOOOO OOO
|
||||
O O
|
||||
OOOOO OOOOO
|
||||
O O
|
||||
O OOOOOOOOO
|
||||
O OO
|
||||
OOOOOO IO
|
||||
""")
|
||||
printMaze("""
|
||||
OOOOOOOOOOOOOOOOO
|
||||
O O
|
||||
O$ O O
|
||||
OOOOO O
|
||||
O O
|
||||
O OOOOOOOOOOOOOO
|
||||
O O I O
|
||||
O O
|
||||
OOOOOOOOOOOOOOOOO
|
||||
""")
|
||||
}
|
||||
|
||||
// UTILITIES
|
||||
|
||||
fun printMaze(str : String) {
|
||||
val maze = makeMaze(str)
|
||||
|
||||
println("Maze:")
|
||||
val path = findPath(maze)
|
||||
for (i in 0..maze.height - 1) {
|
||||
for (j in 0..maze.width - 1) {
|
||||
val cell = #(i, j)
|
||||
print(
|
||||
if (maze.walls[i][j]) "O"
|
||||
else if (cell == maze.start) "I"
|
||||
else if (cell == maze.end) "$"
|
||||
else if (path != null && path.contains(cell)) "~"
|
||||
else " "
|
||||
)
|
||||
}
|
||||
println("")
|
||||
}
|
||||
println("Result: " + if (path == null) "No path" else "Path found")
|
||||
println("")
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A maze is encoded in the string s: the big 'O' letters are walls.
|
||||
* I stand where a big 'I' stands and the prize is marked with
|
||||
* a '$' sign.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* OOOOOOOOOOOOOOOOO
|
||||
* O O
|
||||
* O$ O O
|
||||
* OOOOO O
|
||||
* O O
|
||||
* O OOOOOOOOOOOOOO
|
||||
* O O I O
|
||||
* O O
|
||||
* OOOOOOOOOOOOOOOOO
|
||||
*/
|
||||
fun makeMaze(s : String) : Maze {
|
||||
val lines = s.split("\n").sure()
|
||||
val w = max<String?>(lines.toList(), comparator<String?> {o1, o2 ->
|
||||
val l1 : Int = o1?.size ?: 0
|
||||
val l2 = o2?.size ?: 0
|
||||
l1 - l2
|
||||
}).sure()
|
||||
val data = Array<Array<Boolean>>(lines.size) {Array<Boolean>(w.size) {false}}
|
||||
|
||||
var start : #(Int, Int)? = null
|
||||
var end : #(Int, Int)? = null
|
||||
|
||||
for (line in lines.indices) {
|
||||
for (x in lines[line].indices) {
|
||||
val c = lines[line].sure()[x]
|
||||
data[line][x] = c == 'O'
|
||||
when (c) {
|
||||
'I' -> start = #(line, x)
|
||||
'$' -> end = #(line, x)
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (start == null) {
|
||||
throw IllegalArgumentException("No starting point in the maze (should be indicated with 'I')")
|
||||
}
|
||||
|
||||
if (end == null) {
|
||||
throw IllegalArgumentException("No goal point in the maze (should be indicated with a '$' sign)")
|
||||
}
|
||||
|
||||
return Maze(w.size, lines.size, data, start.sure(), end.sure())
|
||||
}
|
||||
|
||||
|
||||
// An excerpt from the Standard Library
|
||||
val String?.indices : IntRange get() = IntRange(0, this.sure().size)
|
||||
|
||||
fun <K, V> Map<K, V>.set(k : K, v : V) { put(k, v) }
|
||||
|
||||
fun comparator<T> (f : (T, T) -> Int) : Comparator<T> = object : Comparator<T> {
|
||||
override fun compare(o1 : T, o2 : T) : Int = f(o1, o2)
|
||||
override fun equals(p : Any?) : Boolean = false
|
||||
}
|
||||
|
||||
fun <T, C: Collection<T>> Array<T>.to(result: C) : C {
|
||||
for (elem in this)
|
||||
result.add(elem)
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
The "99 bottles of beer" song
|
||||
|
||||
99 bottles of beer on the wall, 99 bottles of beer.
|
||||
Take one down, pass it around, 98 bottles of beer on the wall.
|
||||
|
||||
98 bottles of beer on the wall, 98 bottles of beer.
|
||||
Take one down, pass it around, 97 bottles of beer on the wall.
|
||||
|
||||
97 bottles of beer on the wall, 97 bottles of beer.
|
||||
Take one down, pass it around, 96 bottles of beer on the wall.
|
||||
|
||||
96 bottles of beer on the wall, 96 bottles of beer.
|
||||
Take one down, pass it around, 95 bottles of beer on the wall.
|
||||
|
||||
95 bottles of beer on the wall, 95 bottles of beer.
|
||||
Take one down, pass it around, 94 bottles of beer on the wall.
|
||||
|
||||
94 bottles of beer on the wall, 94 bottles of beer.
|
||||
Take one down, pass it around, 93 bottles of beer on the wall.
|
||||
|
||||
93 bottles of beer on the wall, 93 bottles of beer.
|
||||
Take one down, pass it around, 92 bottles of beer on the wall.
|
||||
|
||||
92 bottles of beer on the wall, 92 bottles of beer.
|
||||
Take one down, pass it around, 91 bottles of beer on the wall.
|
||||
|
||||
91 bottles of beer on the wall, 91 bottles of beer.
|
||||
Take one down, pass it around, 90 bottles of beer on the wall.
|
||||
|
||||
90 bottles of beer on the wall, 90 bottles of beer.
|
||||
Take one down, pass it around, 89 bottles of beer on the wall.
|
||||
|
||||
89 bottles of beer on the wall, 89 bottles of beer.
|
||||
Take one down, pass it around, 88 bottles of beer on the wall.
|
||||
|
||||
88 bottles of beer on the wall, 88 bottles of beer.
|
||||
Take one down, pass it around, 87 bottles of beer on the wall.
|
||||
|
||||
87 bottles of beer on the wall, 87 bottles of beer.
|
||||
Take one down, pass it around, 86 bottles of beer on the wall.
|
||||
|
||||
86 bottles of beer on the wall, 86 bottles of beer.
|
||||
Take one down, pass it around, 85 bottles of beer on the wall.
|
||||
|
||||
85 bottles of beer on the wall, 85 bottles of beer.
|
||||
Take one down, pass it around, 84 bottles of beer on the wall.
|
||||
|
||||
84 bottles of beer on the wall, 84 bottles of beer.
|
||||
Take one down, pass it around, 83 bottles of beer on the wall.
|
||||
|
||||
83 bottles of beer on the wall, 83 bottles of beer.
|
||||
Take one down, pass it around, 82 bottles of beer on the wall.
|
||||
|
||||
82 bottles of beer on the wall, 82 bottles of beer.
|
||||
Take one down, pass it around, 81 bottles of beer on the wall.
|
||||
|
||||
81 bottles of beer on the wall, 81 bottles of beer.
|
||||
Take one down, pass it around, 80 bottles of beer on the wall.
|
||||
|
||||
80 bottles of beer on the wall, 80 bottles of beer.
|
||||
Take one down, pass it around, 79 bottles of beer on the wall.
|
||||
|
||||
79 bottles of beer on the wall, 79 bottles of beer.
|
||||
Take one down, pass it around, 78 bottles of beer on the wall.
|
||||
|
||||
78 bottles of beer on the wall, 78 bottles of beer.
|
||||
Take one down, pass it around, 77 bottles of beer on the wall.
|
||||
|
||||
77 bottles of beer on the wall, 77 bottles of beer.
|
||||
Take one down, pass it around, 76 bottles of beer on the wall.
|
||||
|
||||
76 bottles of beer on the wall, 76 bottles of beer.
|
||||
Take one down, pass it around, 75 bottles of beer on the wall.
|
||||
|
||||
75 bottles of beer on the wall, 75 bottles of beer.
|
||||
Take one down, pass it around, 74 bottles of beer on the wall.
|
||||
|
||||
74 bottles of beer on the wall, 74 bottles of beer.
|
||||
Take one down, pass it around, 73 bottles of beer on the wall.
|
||||
|
||||
73 bottles of beer on the wall, 73 bottles of beer.
|
||||
Take one down, pass it around, 72 bottles of beer on the wall.
|
||||
|
||||
72 bottles of beer on the wall, 72 bottles of beer.
|
||||
Take one down, pass it around, 71 bottles of beer on the wall.
|
||||
|
||||
71 bottles of beer on the wall, 71 bottles of beer.
|
||||
Take one down, pass it around, 70 bottles of beer on the wall.
|
||||
|
||||
70 bottles of beer on the wall, 70 bottles of beer.
|
||||
Take one down, pass it around, 69 bottles of beer on the wall.
|
||||
|
||||
69 bottles of beer on the wall, 69 bottles of beer.
|
||||
Take one down, pass it around, 68 bottles of beer on the wall.
|
||||
|
||||
68 bottles of beer on the wall, 68 bottles of beer.
|
||||
Take one down, pass it around, 67 bottles of beer on the wall.
|
||||
|
||||
67 bottles of beer on the wall, 67 bottles of beer.
|
||||
Take one down, pass it around, 66 bottles of beer on the wall.
|
||||
|
||||
66 bottles of beer on the wall, 66 bottles of beer.
|
||||
Take one down, pass it around, 65 bottles of beer on the wall.
|
||||
|
||||
65 bottles of beer on the wall, 65 bottles of beer.
|
||||
Take one down, pass it around, 64 bottles of beer on the wall.
|
||||
|
||||
64 bottles of beer on the wall, 64 bottles of beer.
|
||||
Take one down, pass it around, 63 bottles of beer on the wall.
|
||||
|
||||
63 bottles of beer on the wall, 63 bottles of beer.
|
||||
Take one down, pass it around, 62 bottles of beer on the wall.
|
||||
|
||||
62 bottles of beer on the wall, 62 bottles of beer.
|
||||
Take one down, pass it around, 61 bottles of beer on the wall.
|
||||
|
||||
61 bottles of beer on the wall, 61 bottles of beer.
|
||||
Take one down, pass it around, 60 bottles of beer on the wall.
|
||||
|
||||
60 bottles of beer on the wall, 60 bottles of beer.
|
||||
Take one down, pass it around, 59 bottles of beer on the wall.
|
||||
|
||||
59 bottles of beer on the wall, 59 bottles of beer.
|
||||
Take one down, pass it around, 58 bottles of beer on the wall.
|
||||
|
||||
58 bottles of beer on the wall, 58 bottles of beer.
|
||||
Take one down, pass it around, 57 bottles of beer on the wall.
|
||||
|
||||
57 bottles of beer on the wall, 57 bottles of beer.
|
||||
Take one down, pass it around, 56 bottles of beer on the wall.
|
||||
|
||||
56 bottles of beer on the wall, 56 bottles of beer.
|
||||
Take one down, pass it around, 55 bottles of beer on the wall.
|
||||
|
||||
55 bottles of beer on the wall, 55 bottles of beer.
|
||||
Take one down, pass it around, 54 bottles of beer on the wall.
|
||||
|
||||
54 bottles of beer on the wall, 54 bottles of beer.
|
||||
Take one down, pass it around, 53 bottles of beer on the wall.
|
||||
|
||||
53 bottles of beer on the wall, 53 bottles of beer.
|
||||
Take one down, pass it around, 52 bottles of beer on the wall.
|
||||
|
||||
52 bottles of beer on the wall, 52 bottles of beer.
|
||||
Take one down, pass it around, 51 bottles of beer on the wall.
|
||||
|
||||
51 bottles of beer on the wall, 51 bottles of beer.
|
||||
Take one down, pass it around, 50 bottles of beer on the wall.
|
||||
|
||||
50 bottles of beer on the wall, 50 bottles of beer.
|
||||
Take one down, pass it around, 49 bottles of beer on the wall.
|
||||
|
||||
49 bottles of beer on the wall, 49 bottles of beer.
|
||||
Take one down, pass it around, 48 bottles of beer on the wall.
|
||||
|
||||
48 bottles of beer on the wall, 48 bottles of beer.
|
||||
Take one down, pass it around, 47 bottles of beer on the wall.
|
||||
|
||||
47 bottles of beer on the wall, 47 bottles of beer.
|
||||
Take one down, pass it around, 46 bottles of beer on the wall.
|
||||
|
||||
46 bottles of beer on the wall, 46 bottles of beer.
|
||||
Take one down, pass it around, 45 bottles of beer on the wall.
|
||||
|
||||
45 bottles of beer on the wall, 45 bottles of beer.
|
||||
Take one down, pass it around, 44 bottles of beer on the wall.
|
||||
|
||||
44 bottles of beer on the wall, 44 bottles of beer.
|
||||
Take one down, pass it around, 43 bottles of beer on the wall.
|
||||
|
||||
43 bottles of beer on the wall, 43 bottles of beer.
|
||||
Take one down, pass it around, 42 bottles of beer on the wall.
|
||||
|
||||
42 bottles of beer on the wall, 42 bottles of beer.
|
||||
Take one down, pass it around, 41 bottles of beer on the wall.
|
||||
|
||||
41 bottles of beer on the wall, 41 bottles of beer.
|
||||
Take one down, pass it around, 40 bottles of beer on the wall.
|
||||
|
||||
40 bottles of beer on the wall, 40 bottles of beer.
|
||||
Take one down, pass it around, 39 bottles of beer on the wall.
|
||||
|
||||
39 bottles of beer on the wall, 39 bottles of beer.
|
||||
Take one down, pass it around, 38 bottles of beer on the wall.
|
||||
|
||||
38 bottles of beer on the wall, 38 bottles of beer.
|
||||
Take one down, pass it around, 37 bottles of beer on the wall.
|
||||
|
||||
37 bottles of beer on the wall, 37 bottles of beer.
|
||||
Take one down, pass it around, 36 bottles of beer on the wall.
|
||||
|
||||
36 bottles of beer on the wall, 36 bottles of beer.
|
||||
Take one down, pass it around, 35 bottles of beer on the wall.
|
||||
|
||||
35 bottles of beer on the wall, 35 bottles of beer.
|
||||
Take one down, pass it around, 34 bottles of beer on the wall.
|
||||
|
||||
34 bottles of beer on the wall, 34 bottles of beer.
|
||||
Take one down, pass it around, 33 bottles of beer on the wall.
|
||||
|
||||
33 bottles of beer on the wall, 33 bottles of beer.
|
||||
Take one down, pass it around, 32 bottles of beer on the wall.
|
||||
|
||||
32 bottles of beer on the wall, 32 bottles of beer.
|
||||
Take one down, pass it around, 31 bottles of beer on the wall.
|
||||
|
||||
31 bottles of beer on the wall, 31 bottles of beer.
|
||||
Take one down, pass it around, 30 bottles of beer on the wall.
|
||||
|
||||
30 bottles of beer on the wall, 30 bottles of beer.
|
||||
Take one down, pass it around, 29 bottles of beer on the wall.
|
||||
|
||||
29 bottles of beer on the wall, 29 bottles of beer.
|
||||
Take one down, pass it around, 28 bottles of beer on the wall.
|
||||
|
||||
28 bottles of beer on the wall, 28 bottles of beer.
|
||||
Take one down, pass it around, 27 bottles of beer on the wall.
|
||||
|
||||
27 bottles of beer on the wall, 27 bottles of beer.
|
||||
Take one down, pass it around, 26 bottles of beer on the wall.
|
||||
|
||||
26 bottles of beer on the wall, 26 bottles of beer.
|
||||
Take one down, pass it around, 25 bottles of beer on the wall.
|
||||
|
||||
25 bottles of beer on the wall, 25 bottles of beer.
|
||||
Take one down, pass it around, 24 bottles of beer on the wall.
|
||||
|
||||
24 bottles of beer on the wall, 24 bottles of beer.
|
||||
Take one down, pass it around, 23 bottles of beer on the wall.
|
||||
|
||||
23 bottles of beer on the wall, 23 bottles of beer.
|
||||
Take one down, pass it around, 22 bottles of beer on the wall.
|
||||
|
||||
22 bottles of beer on the wall, 22 bottles of beer.
|
||||
Take one down, pass it around, 21 bottles of beer on the wall.
|
||||
|
||||
21 bottles of beer on the wall, 21 bottles of beer.
|
||||
Take one down, pass it around, 20 bottles of beer on the wall.
|
||||
|
||||
20 bottles of beer on the wall, 20 bottles of beer.
|
||||
Take one down, pass it around, 19 bottles of beer on the wall.
|
||||
|
||||
19 bottles of beer on the wall, 19 bottles of beer.
|
||||
Take one down, pass it around, 18 bottles of beer on the wall.
|
||||
|
||||
18 bottles of beer on the wall, 18 bottles of beer.
|
||||
Take one down, pass it around, 17 bottles of beer on the wall.
|
||||
|
||||
17 bottles of beer on the wall, 17 bottles of beer.
|
||||
Take one down, pass it around, 16 bottles of beer on the wall.
|
||||
|
||||
16 bottles of beer on the wall, 16 bottles of beer.
|
||||
Take one down, pass it around, 15 bottles of beer on the wall.
|
||||
|
||||
15 bottles of beer on the wall, 15 bottles of beer.
|
||||
Take one down, pass it around, 14 bottles of beer on the wall.
|
||||
|
||||
14 bottles of beer on the wall, 14 bottles of beer.
|
||||
Take one down, pass it around, 13 bottles of beer on the wall.
|
||||
|
||||
13 bottles of beer on the wall, 13 bottles of beer.
|
||||
Take one down, pass it around, 12 bottles of beer on the wall.
|
||||
|
||||
12 bottles of beer on the wall, 12 bottles of beer.
|
||||
Take one down, pass it around, 11 bottles of beer on the wall.
|
||||
|
||||
11 bottles of beer on the wall, 11 bottles of beer.
|
||||
Take one down, pass it around, 10 bottles of beer on the wall.
|
||||
|
||||
10 bottles of beer on the wall, 10 bottles of beer.
|
||||
Take one down, pass it around, 9 bottles of beer on the wall.
|
||||
|
||||
9 bottles of beer on the wall, 9 bottles of beer.
|
||||
Take one down, pass it around, 8 bottles of beer on the wall.
|
||||
|
||||
8 bottles of beer on the wall, 8 bottles of beer.
|
||||
Take one down, pass it around, 7 bottles of beer on the wall.
|
||||
|
||||
7 bottles of beer on the wall, 7 bottles of beer.
|
||||
Take one down, pass it around, 6 bottles of beer on the wall.
|
||||
|
||||
6 bottles of beer on the wall, 6 bottles of beer.
|
||||
Take one down, pass it around, 5 bottles of beer on the wall.
|
||||
|
||||
5 bottles of beer on the wall, 5 bottles of beer.
|
||||
Take one down, pass it around, 4 bottles of beer on the wall.
|
||||
|
||||
4 bottles of beer on the wall, 4 bottles of beer.
|
||||
Take one down, pass it around, 3 bottles of beer on the wall.
|
||||
|
||||
3 bottles of beer on the wall, 3 bottles of beer.
|
||||
Take one down, pass it around, 2 bottles of beer on the wall.
|
||||
|
||||
2 bottles of beer on the wall, 2 bottles of beer.
|
||||
Take one down, pass it around, 1 bottle of beer on the wall.
|
||||
|
||||
1 bottle of beer on the wall, 1 bottle of beer.
|
||||
Take one down, pass it around, no more bottles of beer on the wall.
|
||||
|
||||
No more bottles of beer on the wall, no more bottles of beer.
|
||||
Go to the store and buy some more, 99 bottles of beer on the wall.
|
||||
@@ -0,0 +1,12 @@
|
||||
The "2 bottles of beer" song
|
||||
|
||||
2 bottles of beer on the wall, 2 bottles of beer.
|
||||
Take one down, pass it around, 1 bottle of beer on the wall.
|
||||
|
||||
1 bottle of beer on the wall, 1 bottle of beer.
|
||||
Take one down, pass it around, no more bottles of beer on the wall.
|
||||
|
||||
No more bottles of beer on the wall, no more bottles of beer.
|
||||
Go to the store and buy some more, 2 bottles of beer on the wall.
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
XML encoding with Kotlin
|
||||
</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>
|
||||
XML encoding with Kotlin
|
||||
</h1>
|
||||
<p>
|
||||
this format can be used as an alternative markup to XML
|
||||
</p>
|
||||
<a href="http://jetbrains.com/kotlin">
|
||||
Kotlin
|
||||
</a>
|
||||
<p>
|
||||
This is some
|
||||
<b>
|
||||
mixed
|
||||
</b>
|
||||
text. For more see the
|
||||
<a href="http://jetbrains.com/kotlin">
|
||||
Kotlin
|
||||
</a>
|
||||
project
|
||||
</p>
|
||||
<p>
|
||||
some text
|
||||
</p>
|
||||
<p>
|
||||
Command line arguments were:
|
||||
<ul>
|
||||
</ul>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,40 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
XML encoding with Kotlin
|
||||
</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>
|
||||
XML encoding with Kotlin
|
||||
</h1>
|
||||
<p>
|
||||
this format can be used as an alternative markup to XML
|
||||
</p>
|
||||
<a href="http://jetbrains.com/kotlin">
|
||||
Kotlin
|
||||
</a>
|
||||
<p>
|
||||
This is some
|
||||
<b>
|
||||
mixed
|
||||
</b>
|
||||
text. For more see the
|
||||
<a href="http://jetbrains.com/kotlin">
|
||||
Kotlin
|
||||
</a>
|
||||
project
|
||||
</p>
|
||||
<p>
|
||||
some text
|
||||
</p>
|
||||
<p>
|
||||
Command line arguments were:
|
||||
<ul>
|
||||
<li>
|
||||
over9000
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,323 @@
|
||||
Step: 1
|
||||
***
|
||||
Step: 2
|
||||
*
|
||||
Step: 3
|
||||
|
||||
Step: 1
|
||||
|
||||
*
|
||||
***
|
||||
*
|
||||
|
||||
Step: 2
|
||||
|
||||
***
|
||||
* *
|
||||
***
|
||||
|
||||
Step: 3
|
||||
*
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*
|
||||
Step: 4
|
||||
*
|
||||
***
|
||||
** **
|
||||
***
|
||||
*
|
||||
Step: 5
|
||||
***
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
***
|
||||
Step: 6
|
||||
***
|
||||
* * *
|
||||
*** **
|
||||
* * *
|
||||
***
|
||||
Step: 7
|
||||
***
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
***
|
||||
Step: 8
|
||||
**
|
||||
* * *
|
||||
*** **
|
||||
* * *
|
||||
**
|
||||
Step: 9
|
||||
***
|
||||
* * *
|
||||
* * *
|
||||
* * *
|
||||
***
|
||||
Step: 10
|
||||
***
|
||||
* *
|
||||
** * *
|
||||
* *
|
||||
***
|
||||
Step: 1
|
||||
|
||||
*
|
||||
* *
|
||||
*
|
||||
|
||||
Step: 2
|
||||
|
||||
*
|
||||
* *
|
||||
*
|
||||
|
||||
Step: 3
|
||||
|
||||
*
|
||||
* *
|
||||
*
|
||||
|
||||
Step: 1
|
||||
|
||||
**
|
||||
**
|
||||
**
|
||||
|
||||
Step: 2
|
||||
|
||||
**
|
||||
* *
|
||||
**
|
||||
|
||||
Step: 3
|
||||
|
||||
**
|
||||
* *
|
||||
**
|
||||
|
||||
Step: 1
|
||||
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
|
||||
Step: 2
|
||||
|
||||
**
|
||||
*
|
||||
*
|
||||
**
|
||||
|
||||
Step: 3
|
||||
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
|
||||
Step: 4
|
||||
|
||||
**
|
||||
*
|
||||
*
|
||||
**
|
||||
|
||||
Step: 5
|
||||
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
|
||||
Step: 6
|
||||
|
||||
**
|
||||
*
|
||||
*
|
||||
**
|
||||
|
||||
Step: 1
|
||||
|
||||
|
||||
*** ***
|
||||
|
||||
* * * *
|
||||
* * * *
|
||||
* * * *
|
||||
*** ***
|
||||
|
||||
*** ***
|
||||
* * * *
|
||||
* * * *
|
||||
* * * *
|
||||
|
||||
*** ***
|
||||
|
||||
|
||||
Step: 2
|
||||
|
||||
* *
|
||||
* *
|
||||
** **
|
||||
|
||||
*** ** ** ***
|
||||
* * * * * *
|
||||
** **
|
||||
|
||||
** **
|
||||
* * * * * *
|
||||
*** ** ** ***
|
||||
|
||||
** **
|
||||
* *
|
||||
* *
|
||||
|
||||
Step: 3
|
||||
|
||||
|
||||
** **
|
||||
** **
|
||||
* * * * * *
|
||||
*** ** ** ***
|
||||
* * * * * *
|
||||
*** ***
|
||||
|
||||
*** ***
|
||||
* * * * * *
|
||||
*** ** ** ***
|
||||
* * * * * *
|
||||
** **
|
||||
** **
|
||||
|
||||
|
||||
Step: 4
|
||||
|
||||
|
||||
*** ***
|
||||
|
||||
* * * *
|
||||
* * * *
|
||||
* * * *
|
||||
*** ***
|
||||
|
||||
*** ***
|
||||
* * * *
|
||||
* * * *
|
||||
* * * *
|
||||
|
||||
*** ***
|
||||
|
||||
|
||||
Step: 5
|
||||
|
||||
* *
|
||||
* *
|
||||
** **
|
||||
|
||||
*** ** ** ***
|
||||
* * * * * *
|
||||
** **
|
||||
|
||||
** **
|
||||
* * * * * *
|
||||
*** ** ** ***
|
||||
|
||||
** **
|
||||
* *
|
||||
* *
|
||||
|
||||
Step: 6
|
||||
|
||||
|
||||
** **
|
||||
** **
|
||||
* * * * * *
|
||||
*** ** ** ***
|
||||
* * * * * *
|
||||
*** ***
|
||||
|
||||
*** ***
|
||||
* * * * * *
|
||||
*** ** ** ***
|
||||
* * * * * *
|
||||
** **
|
||||
** **
|
||||
|
||||
|
||||
Step: 7
|
||||
|
||||
|
||||
*** ***
|
||||
|
||||
* * * *
|
||||
* * * *
|
||||
* * * *
|
||||
*** ***
|
||||
|
||||
*** ***
|
||||
* * * *
|
||||
* * * *
|
||||
* * * *
|
||||
|
||||
*** ***
|
||||
|
||||
|
||||
Step: 8
|
||||
|
||||
* *
|
||||
* *
|
||||
** **
|
||||
|
||||
*** ** ** ***
|
||||
* * * * * *
|
||||
** **
|
||||
|
||||
** **
|
||||
* * * * * *
|
||||
*** ** ** ***
|
||||
|
||||
** **
|
||||
* *
|
||||
* *
|
||||
|
||||
Step: 9
|
||||
|
||||
|
||||
** **
|
||||
** **
|
||||
* * * * * *
|
||||
*** ** ** ***
|
||||
* * * * * *
|
||||
*** ***
|
||||
|
||||
*** ***
|
||||
* * * * * *
|
||||
*** ** ** ***
|
||||
* * * * * *
|
||||
** **
|
||||
** **
|
||||
|
||||
|
||||
Step: 10
|
||||
|
||||
|
||||
*** ***
|
||||
|
||||
* * * *
|
||||
* * * *
|
||||
* * * *
|
||||
*** ***
|
||||
|
||||
*** ***
|
||||
* * * *
|
||||
* * * *
|
||||
* * * *
|
||||
|
||||
*** ***
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
Maze:
|
||||
I~~$
|
||||
Result: Path found
|
||||
|
||||
Maze:
|
||||
I O $
|
||||
Result: No path
|
||||
|
||||
Maze:
|
||||
|
||||
O $
|
||||
O ~
|
||||
O ~
|
||||
O ~
|
||||
O ~~~~~~~~~I
|
||||
|
||||
Result: Path found
|
||||
|
||||
Maze:
|
||||
|
||||
OOOOOOOOOOO
|
||||
O $~~~~~ O
|
||||
OOOOOOO~OOO
|
||||
O ~~~ O
|
||||
OOOOO~OOOOO
|
||||
O~~~~~ O
|
||||
O~OOOOOOOOO
|
||||
O~~~~~~ OO
|
||||
OOOOOO~~~IO
|
||||
|
||||
Result: Path found
|
||||
|
||||
Maze:
|
||||
|
||||
OOOOOOOOOOOOOOOOO
|
||||
O ~~~ O
|
||||
O$~~O~ O
|
||||
OOOOO~ O
|
||||
O ~~~~ O
|
||||
O ~OOOOOOOOOOOOOO
|
||||
O ~ O I O
|
||||
O ~~~~~~~~~~~~~ O
|
||||
OOOOOOOOOOOOOOOOO
|
||||
|
||||
Result: Path found
|
||||
Reference in New Issue
Block a user