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
function hashIt(str) | |
{ | |
// just a cyclic rotation | |
var rotateBy = function(s,N) { for (var i = 0; i < N; i++) s.unshift(s.pop()); } | |
// take a random string and convert it to char array | |
var alphabet = "1L,$G=JD'W)7QYC02M#</@B3-AUF*!VT8H(RO;:45&NXZ+PKES>.?I6%9".split(""); | |
// set the initial value of the hash to the first 16 chars of the alphabet | |
var hash = alphabet.slice(0,16); | |
// we go through the string | |
for (var i = 0; i < str.length; i++) |
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
var numbers = readLine.split(" ").map(_.toInt).toList.sorted | |
numbers = numbers.distinct ++ (numbers diff numbers.distinct) | |
def solve(acc: Int, list: List[Int]):Int = list match{ | |
case (h::Nil) => acc | |
case (h::t) => if (h+1 == t.head) solve(acc,t) else solve(acc+1,h+1::t.slice(0,t.size-1)) | |
} | |
println(solve(0,numbers)) |
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
; for i > 2 | |
(defn prime? [i] | |
(not (some | |
#(= 0 (mod i %)) | |
(cons 2 (range 3 (inc (Math/sqrt i)) 2))))) |
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
<html> | |
<body> | |
<div id="box1">1</div> | |
<div id="box2">2</div> | |
<div id="box3">3</div> | |
<div id="box4">4</div> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" | |
type="text/javascript"></script> | |
<script> | |
for (var i = 1; i < 5; i++) { |
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
(defn wlk | |
[nodelist [tag attrs & nodes]] | |
(if (= (:class attrs) "r") | |
(conj nodelist (:href (second (first nodes)))) | |
(reduce wlk nodelist (filter coll? nodes)))) |
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
import java.util.Scanner; | |
import java.util.Arrays; | |
public class Main { | |
public static void main(String... args) { | |
Scanner s = new Scanner(System.in); | |
int t = s.nextInt(); | |
for(; t > 0; --t) { | |
System.out.println(solve(s.next(), s.next())); |
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
import java.util.Arrays; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner s = new Scanner(System.in); | |
int k = s.nextInt(), n; | |
String[] 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
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Scanner; | |
public class Mmass { | |
static Map<Character, Integer> m = new HashMap<Character, Integer>(); | |
public static void main(String[] args) { | |
m.put('H', 1); | |
m.put('C', 12); | |
m.put('O', 16); |
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
import java.util.Scanner; | |
import java.util.Arrays; | |
public class Bsearch1 { | |
public static void main(String... args) { | |
Scanner s = new Scanner(System.in); | |
int N = s.nextInt(), Q = s.nextInt(), n = N, ln = N-1; | |
int[] numbers = new int[N]; | |
while (n --> 0) numbers[ln-n] = s.nextInt(); |
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
import java.util.Scanner; | |
import java.util.Arrays; | |
public class Bsearch1 { | |
public static void main(String... args) { | |
Scanner s = new Scanner(System.in); | |
int N = s.nextInt(), Q = s.nextInt(), n = N, ln = N-1; | |
int[] numbers = new int[N]; | |
while (n --> 0) numbers[ln-n] = s.nextInt(); |
OlderNewer