--- /dev/null
+#!/usr/bin/env nit
+#
+# This file is part of NIT ( http://www.nitlanguage.org ).
+# This program is public domain
+
+# Task: Ethiopian Multiplication
+# SEE: <http://rosettacode.org/wiki/ethiopian_multiplication>
+#
+# Generic non-robust version.
+module ethiopian_multiplication
+
+fun ethiopian(x, y: Int): Int
+do
+ print "{x}; {0}"
+ var sum: Int
+ if x.is_even then
+ sum = 0
+ else
+ sum = y
+ end
+
+ while x>1 do
+ x /= 2
+ y *= 2
+ print "{x}; {y}"
+ if not x.is_even then sum += y
+ end
+
+ return sum
+end
+
+var words = gets.split(" ")
+print ethiopian(words[0].to_i, words[1].to_i)
--- /dev/null
+#!/usr/bin/env nit
+#
+# This file is part of NIT ( http://www.nitlanguage.org ).
+# This program is public domain
+
+# Task: One-dimensional_cellular_automata
+# SEE: <http://rosettacode.org/wiki/One-dimensional_cellular_automata>
+module one_dimensional_cellular_automata
+
+fun evolve(cells: SequenceRead[Char]): SequenceRead[Char]
+do
+ var res = new Array[Char]
+ for i in [0..cells.length[ do
+ var n = neighboors(i, cells)
+ if cells[i] == '#' then
+ res.add(b_to_char(n == 1))
+ else
+ res.add(b_to_char(n == 2))
+ end
+ end
+ return res
+end
+
+fun b_to_char(b: Bool): Char do if b then return '#' else return '_'
+
+fun neighboors(i: Int, cells: SequenceRead[Char]): Int
+do
+ var res = 0
+ if i > 0 and cells[i-1] == '#' then res += 1
+ if i < cells.length - 1 and cells[i+1] == '#' then res += 1
+ return res
+end
+
+var ary = "_###_##_#_#_#_#__#__".chars
+loop
+ print ary.join("")
+ var nxt = evolve(ary)
+ if ary == nxt then break
+ ary = nxt
+end
--- /dev/null
+#!/usr/bin/env nit
+#
+# This file is part of NIT ( http://www.nitlanguage.org ).
+# This program is public domain
+
+# Task: Pig the dice game
+# SEE: http://rosettacode.org/wiki/Pig_the_dice_game
+
+var player = 0
+var score = [0, 0]
+var turnscore = 0
+var max_score = 100
+loop
+ if (score[player] + turnscore) >= max_score then
+ print "Congratulation Player {player + 1}! You won with {score[player]} points! "
+ return
+ end
+ print "Player {player +1}"
+ print "Total score : {score[player]}"
+ print "What do you want to do? (\"1\" to roll, \"0\" to hold)"
+ if stdin.eof then break
+ var input = gets
+ if input == "1" then
+ var roll = 6.rand + 1
+ if roll == 1 then
+ turnscore = 0
+ print "You rolled 1! all points lost for this turn"
+ print ""
+ player = 1 - player
+ else
+ turnscore += roll
+ print "rolled: {roll}"
+ print "score this turn: {turnscore}"
+ print ""
+ end
+ else if input == "0" then
+ score[player] += turnscore
+ print "Scored: {turnscore}"
+ print "New Score: {score[player]}"
+ print ""
+ player = 1 - player
+ turnscore = 0
+ end
+end
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+# This program is public domain
+
+# Task: Vigenère cipher
+#
+# See: <http://rosettacode.org/wiki/Vigenère_cipher>
+module vignere_cipher
+
+fun encrypt(src, key: String): String do
+ var out = new Buffer
+ var j = 0
+
+ for i in [0..src.length - 1] do
+ var c = src[i]
+
+ if c >= 'a' and c <= 'z' then
+ c = c.to_upper
+ else if c < 'A' or c > 'Z' then
+ continue
+ end
+
+ out.add(((c.ascii + key[j].ascii - 2 * 'A'.ascii) % 26 + 'A'.ascii).ascii)
+ j = (j + 1) % key.length
+ end
+
+ return out.to_s
+end
+
+fun decrypt(src, key: String): String do
+ var out = new Buffer
+ var j = 0
+
+ for i in [0..src.length - 1] do
+ var c = src[i]
+
+ if c >= 'a' and c <= 'z' then
+ c = c.to_upper
+ else if c < 'A' or c > 'Z' then
+ continue
+ end
+
+ out.add(((c.ascii - key[j].ascii + 26) % 26 + 'A'.ascii).ascii)
+ j = (j + 1) % key.length
+ end
+
+ return out.write_to_string
+end
+
+# Main part
+var str = "All your base are belong to us"
+var key = "CRYPTONIT"
+var code = encrypt(str, key)
+var decode = decrypt(code, key)
+
+print "Text: " + str
+print "Key : " + key
+print "Code: " + code
+print "Back: " + decode
--- /dev/null
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+0
+1
+1
+1
+0
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
--- /dev/null
+8; 0
+4; 12
+2; 24
+1; 48
+48
--- /dev/null
+_###_##_#_#_#_#__#__
+_#_#####_#_#_#______
+__##___##_#_#_______
+__##___###_#________
+__##___#_##_________
+__##____###_________
+__##____#_#_________
+__##_____#__________
+__##________________
--- /dev/null
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 6
+score this turn: 6
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 3
+score this turn: 9
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 5
+score this turn: 14
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 5
+score this turn: 19
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 6
+score this turn: 25
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 2
+score this turn: 27
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 3
+score this turn: 30
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 5
+score this turn: 35
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 2
+score this turn: 37
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 4
+score this turn: 41
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 3
+score this turn: 44
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 4
+score this turn: 48
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 3
+score this turn: 51
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 4
+score this turn: 55
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 6
+score this turn: 61
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 6
+score this turn: 67
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 4
+score this turn: 71
+
+Player 1
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+Scored: 71
+New Score: 71
+
+Player 2
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 5
+score this turn: 5
+
+Player 2
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+You rolled 1! all points lost for this turn
+
+Player 1
+Total score : 71
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 4
+score this turn: 4
+
+Player 1
+Total score : 71
+What do you want to do? ("1" to roll, "0" to hold)
+Scored: 4
+New Score: 75
+
+Player 2
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+You rolled 1! all points lost for this turn
+
+Player 1
+Total score : 75
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 2
+score this turn: 2
+
+Player 1
+Total score : 75
+What do you want to do? ("1" to roll, "0" to hold)
+You rolled 1! all points lost for this turn
+
+Player 2
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 5
+score this turn: 5
+
+Player 2
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+You rolled 1! all points lost for this turn
+
+Player 1
+Total score : 75
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 3
+score this turn: 3
+
+Player 1
+Total score : 75
+What do you want to do? ("1" to roll, "0" to hold)
+You rolled 1! all points lost for this turn
+
+Player 2
+Total score : 0
+What do you want to do? ("1" to roll, "0" to hold)
+You rolled 1! all points lost for this turn
+
+Player 1
+Total score : 75
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 6
+score this turn: 6
+
+Player 1
+Total score : 75
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 2
+score this turn: 8
+
+Player 1
+Total score : 75
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 4
+score this turn: 12
+
+Player 1
+Total score : 75
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 6
+score this turn: 18
+
+Player 1
+Total score : 75
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 4
+score this turn: 22
+
+Player 1
+Total score : 75
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 2
+score this turn: 24
+
+Player 1
+Total score : 75
+What do you want to do? ("1" to roll, "0" to hold)
+rolled: 4
+score this turn: 28
+
+Congratulation Player 1! You won with 75 points!
--- /dev/null
+Text: All your base are belong to us
+Key : CRYPTONIT
+Code: CCJNHIEJTUVYGXPRTHPXRDNG
+Back: ALLYOURBASEAREBELONGTOUS