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 urllib.request | |
import json | |
import os | |
import datetime | |
dumps_dir = 'github dumps {}'.format(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")) | |
os.makedirs(dumps_dir, exist_ok=True) | |
response = urllib.request.urlopen("https://api.github.com/users/qwert2603/repos?per_page=9000") | |
response_string = response.read().decode("utf-8") |
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
fun getString(): String { | |
null?.let { return "fish" } | |
} | |
fun main() { | |
println(getString().length) | |
} |
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 requests | |
ids = [1, 2, 3, 4, 5, 6] | |
frs = {} | |
for id in ids: | |
r = requests.get('https://api.vk.com/method/friends.get', {'user_id': id}) | |
frs.update({id: r.json()['response']}) | |
print(r) |
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 java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.util.*; | |
public class Main { | |
public static final class Point implements Comparable<Point> { | |
final int x; | |
final int y; | |
private final int pos; |
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 java.util.* | |
import java.util.concurrent.atomic.AtomicInteger | |
import kotlin.concurrent.thread | |
private val numbers = (0..9999) | |
.map { listOf(it / 1000, it % 1000 / 100, it % 100 / 10, it % 10) } | |
.filter { it.distinct().size == 4 } | |
private fun newNumber(): List<Int> = numbers[Random().nextInt(numbers.size)] |
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 okhttp3.OkHttpClient | |
import okhttp3.Request | |
fun main(args: Array<String>) { | |
val urls = listOf( | |
"http://cmit22.ru/", | |
"http://eljur.ru/elektronnyi-klassnyi-zhurnal", | |
"https://salesap.ru/crm_sistemy_chto_eto", | |
"http://prostoysoft.ru/College.htm", | |
"http://tallanto.com/ru/programma-dlya-ucheta-uchenikov", |
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 java.math.BigInteger | |
import java.util.* | |
private fun powMod(n: BigInteger, p: BigInteger, mod: BigInteger): BigInteger { | |
var res = BigInteger.ONE | |
var cp = BigInteger.ZERO | |
while (cp < p) { | |
res = res * n % mod | |
cp += BigInteger.ONE |
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 java.util.* | |
fun nod(i: Int, j: Int): Int { | |
if (i == j) return i | |
val max = maxOf(i, j) | |
val min = minOf(i, j) | |
return nod(max - min, min) | |
} | |
fun powMod(n: Long, p: Long, mod: Long): Long { |
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
private val P2: List<Int> = (0..20).map { 1 shl it } | |
fun Boolean.toInt() = if (this) 1 else 0 | |
fun String.toBooleanList() = this | |
.map { it.toInt() } | |
.map { it.toBooleanList(8) } | |
.flatten() | |
fun List<Boolean>.anthToString() = divide(8).map { it.toInt().toChar().toString() }.reduce { c1, c2 -> "$c1$c2" } |
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
fun sqrtI(l: Long): Long { | |
val sqrt = Math.sqrt(l.toDouble()).toLong() | |
if (isFullSqr(l)) return sqrt | |
return sqrt + 1 | |
} | |
fun isFullSqr(l: Long) = l == Math.sqrt(l.toDouble()).toLong().let { it * it } | |
fun main(args: Array<String>) { | |
val N = 229_637L |