Skip to content

Instantly share code, notes, and snippets.

View mishadoff's full-sized avatar
🐼

Misha Kozik mishadoff

🐼
View GitHub Profile
(ns cups.darkus)
;; data
(def sentences (seq (.split (slurp "res/FPC_May2012_tsk.txt") "\r\n")))
(def priority {:add 0.0001 :sub 0.0 :mul 0.0002 :div 0.0003})
(def features {"поровну" {:add 0 :sub 0 :mul 0 :div 1}
"всего\\?" {:add 1 :sub 0 :mul 1 :div 0}
" (П|п)о \\d+" {:add 0 :sub 0 :mul 0.9 :div 0.9}
// Assume all following objects have id-constructor
// Book (int id) { this.bookId = id; }
// first book with 1 page and 8 words
Book book1 = new Book(1);
ArrayList<Page> pages = new ArrayList<Page>(); // create holder for pages
Page page1 = new Page(1); // create page
pages.add(page1); // bind page to pages
ArrayList<Word> words = new ArrayList<Word>(); // create holder for words
// filling words list
module: beautiful-strings
define function string-beauty (s :: <string>) => (n :: <integer>)
let repetitions = make(<simple-vector>, size: 26, fill: 0);
for (c in choose(alphabetic?, s))
let i = as(<integer>, as-uppercase(c)) - as(<integer>, 'A');
repetitions[i] := repetitions[i] + 1;
end for;
reduce1(\+, map(\*, sort(repetitions), range(from: 1, to: 26)))
end function string-beauty;
@mishadoff
mishadoff / gist:5284903
Last active December 15, 2015 15:49
Piskomerka
package com.stackoverflow;
import java.util.Random;
public class ZeroOneSorting {
static Random random = new Random();
public static void main(String[] args) {
int LENGTH = 1_00_000_000; long before, after;
package com.stackoverflow;
import java.util.Arrays;
import java.util.Comparator;
public class ContSubArray {
public static void main(String[] args) {
int[] array =
//{10, 5, 3, 1, 4, 2, 8, 7};
var fs=require('fs');
var hljs=require('highlight.js');
fs.readFile('D:/temp/code/345.txt','utf-8',function(err, content){
if (err) throw err;
langEntry = hljs.highlightAuto(content);
console.log(langEntry.language);
});
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
(defn solve [r t]
"r - initial radius, t - mls of paint"
(letfn [(nrings [n]
(+' (*' 2 n n)
(-' n)
(*' 2 r n)))
(binary [[a b]]
(cond (or (= a b) (= (inc a) b)) a
:else (let [avg (quot (+' a b) 2)
pnt (nrings avg)]
@mishadoff
mishadoff / gist:919ab09841e81005d6a2
Created June 16, 2014 11:23
jopbox usage example
(:require [jopbox.client :as dbx])
(def *APP-KEY* "YOUR_APP_KEY")
(def *APP-SECRET* "YOUR_APP_SECRET")
;; make consumer and request token
(def consumer (dbx/make-consumer *APP-KEY* *APP-SECRET*))
(def request-token (dbx/fetch-request-token consumer nil))
;; generate authorization url
# Using STM
Create a custom implementation of some data structure. Data structure
should work according to its definition,
follow the Big-O limitations,
be completely thread-safe in concurrent environment and use only STM
primitives in implementation.
You are free to use any Java STM library, but we recommend
[Multiverse STM](http://multiverse.codehaus.org/overview.html)