Skip to content

Instantly share code, notes, and snippets.

@veiset
veiset / build.gradle.kts
Created March 5, 2021 09:53
Gradle Kotlin Windows Executable
plugins {
kotlin("jvm") version "1.4.31"
id("edu.sc.seis.launch4j") version "2.4.9"
id("de.undercouch.download") version "4.1.1"
}
task("createExecutableWindows") {
val jdkVersion = "15.0.2"
val downloadUrl =
"https://download.java.net/java/GA/jdk15.0.2/0d1cfde4252546c6931946de8db48ee2/7/GPL/openjdk-15.0.2_windows-x64_bin.zip"
package org.veiset.tsar.world
import com.badlogic.gdx.math.Vector2
import org.veiset.tsar.engine2.utils.component1
import org.veiset.tsar.engine2.utils.component2
import org.veiset.tsar.engine2.utils.x
import org.veiset.tsar.world.icon.WorldIcon
import kotlin.math.absoluteValue
import kotlin.math.cos
import kotlin.math.pow
import five from 'johnny-five';
const board = new five.Board();
const SAMPLE_SIZE = 50;
const SAMPLE_FREQ = 1;
const SAMPLE_TIMES = 10;
board.on("ready", function() {
const mic = new five.Sensor({
pin:"A0",
data = data.replace("\n","").lower()
palin = [data[i:j]
for i in xrange(len(data))
for j in xrange(i, len(data)+1)
if data[i:j] == data[i:j][::-1]]
longest = max(map(len, palin))
print filter(lambda x: len(x) == longest, palin)[0]
from collections import Counter
with open('words.txt', 'r') as f:
print Counter(["".join(sorted(w.strip().lower())) for w in f]).most_common(1)
G = {0:[4, 6], 1:[6, 8], 2:[7, 9], 3:[4, 8], 4:[3, 9, 0], 5:[], 6:[1, 7, 0], 7:[2, 6], 8:[1, 3], 9:[2, 4]}
def walk(graph, node, d=1, m=10):
return 1 if d == m else sum([walk(graph, n, d+1, m) for n in graph[node]])
print walk(G, 1)
MOVES = [[-2,-1],[-2,1],[-1,-2],[-1,2],[1,-2],[1,2],[2,-1],[2,1]]
KEYPAD = [[1, 2, 3],[4, 5, 6],[7, 8, 9],[None, 0, None]]
VALID = {(x, y) : key
for x,row in enumerate(KEYPAD)
for y,key in enumerate(row)
if not key == None}
GRAPH = {key : [VALID[(x+x2, y+y2)] for x2, y2 in MOVES if (x+x2, y+y2) in VALID]
for x, row in enumerate(KEYPAD)
from datetime import date, timedelta
start = date(1337,1,1)
delta = date.today() - start
print len([date for date in
[start + timedelta(days=n) for n in range(delta.days)]
if date.day == 13
if date.weekday() == 4])
c, people = 1, range(1, 1501)
while len(people)>1:
people.pop(c)
c += 1
if c == len(people): c = 0
elif c > len(people): c = 1
print people[0]
from itertools import combinations
print min([min(a, b) for (a, b) in combinations(xrange(99, 999), 2)
if a+b>999
if len(set("%s%s%s" % (a,b,a+b)))==10])