#Mac OS X
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import sys | |
dict = { | |
0: "часов", | |
1: "час", | |
2: "часа", |
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
filename = "dict.csv" | |
lookup = {} | |
with open(filename,"r") as file: | |
for line in file: | |
(key, value) = line.split(" ")[0:2] |
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
/* | |
You have given n numbers from 1 to n. You have to sort numbers with increasing number of set bits. | |
Example: n = 5 => Output: 1,2,4,3,5 | |
*/ | |
def numberOfBitsSet(i: Int) = { | |
// http://en.wikipedia.org/wiki/Hamming_weight implementation | |
val j = i - ((i >> 1) & 0x55555555); |
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
object Main extends App { | |
println(isBalanced("(.)(.)".toList)) | |
def isBalanced(list: List[Char]) = { | |
@annotation.tailrec | |
def countBracets(string: List[Char], count: Int = 0): Int = { | |
string match { | |
case '('::tail => countBracets(tail, count+1) | |
case ')'::tail => countBracets(tail, count-1) |
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
trait Base { | |
protected def contribute : List[String] = List("Beginning") | |
val list = contribute.reverse | |
} | |
trait TrA extends Base { | |
override protected def contribute = "A" :: super.contribute | |
} | |
trait TrB extends TrA { |
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
"FooO bar baZ bow".split(" ").filter(word => word.last >= 'a').map(_.reverse) |
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
import javax.swing.*; | |
import javax.swing.event.ListSelectionEvent; | |
import javax.swing.event.ListSelectionListener; | |
import java.awt.*; | |
import java.awt.event.ActionEvent; | |
public class Foo { | |
static final JFrame MainWindow = new JFrame(); | |
static final JPanel content = new JPanel(new BorderLayout()); | |
static final JLabel resultFromDialog = new JLabel("SomeText"); |
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
.DS_STORE |
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
#!/usr/bin/python | |
import os | |
import sys | |
import re | |
import subprocess | |
devnull = open(os.devnull, 'w') |