Skip to content

Instantly share code, notes, and snippets.

@paplorinc
paplorinc / SecretSanta.groovy
Created November 28, 2016 13:42
SecretSanta
def names = ['Agnes', 'Akos', 'Anna', 'Berend', 'Geza', 'Istvan', 'Karel', 'Lorinc', 'Marta', 'Noemi', 'Orsi', 'Zsofi'].sort()
names = names*.padRight(names*.length().max())
def draws = (0..<names.size()).toList().sort() { Math.random() }
draws.eachWithIndex { source, target -> assert source != target }
def linkBase = 'https://www.google.ro/search?q='
def encode = { "%${Integer.toHexString(it).toUpperCase()}" }
def encodedNames = names[draws]*.bytes*.collect(encode)*.join()
/* / \____ _ _ ____ ______ / \ ____ __ _______
* / / \/ \ / \/ \ / /\__\/ // \/ \ // /\__\ JΛVΛSLΛNG
* _/ / /\ \ \/ / /\ \\__\\ \ // /\ \ /\\/ \ /__\ \ Copyright 2014-2016 Javaslang, http://javaslang.io
* /___/\_/ \_/\____/\_/ \_/\__\/__/\__\_/ \_// \__/\_____/ Licensed under the Apache License, Version 2.0
*//* / \____ _ _ ____ ______ / \ ____ __ _______
* / / \/ \ / \/ \ / /\__\/ // \/ \ // /\__\ JΛVΛSLΛNG
* _/ / /\ \ \/ / /\ \\__\\ \ // /\ \ /\\/ \ /__\ \ Copyright 2014-2016 Javaslang, http://javaslang.io
* /___/\_/ \_/\____/\_/ \_/\__\/__/\__\_/ \_// \__/\_____/ Licensed under the Apache License, Version 2.0
*/
package tutorial.webapp
/* / \____ _ _ ____ ______ / \ ____ __ _______
* / / \/ \ / \/ \ / /\__\/ // \/ \ // /\__\ JΛVΛSLΛNG
* _/ / /\ \ \/ / /\ \\__\\ \ // /\ \ /\\/ \ /__\ \ Copyright 2014-2016 Javaslang, http://javaslang.io
* /___/\_/ \_/\____/\_/ \_/\__\/__/\__\_/ \_// \__/\_____/ Licensed under the Apache License, Version 2.0
*//* / \____ _ _ ____ ______ / \ ____ __ _______
* / / \/ \ / \/ \ / /\__\/ // \/ \ // /\__\ JΛVΛSLΛNG
* _/ / /\ \ \/ / /\ \\__\\ \ // /\ \ /\\/ \ /__\ \ Copyright 2014-2016 Javaslang, http://javaslang.io
* /___/\_/ \_/\____/\_/ \_/\__\/__/\__\_/ \_// \__/\_____/ Licensed under the Apache License, Version 2.0
*/
package tutorial.webapp
package com.crossover.trial;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class Node<T extends Comparable<? super T>> {
T value;
Node<T> left, right;
import java.lang.Math.*
data class Point(private val x_: Int, private val y_: Int) {
fun x() = max(0, min(x_, 2))
fun y() = max(0, min(y_, 2))
operator fun plus(p: Point) = Point(x() + p.x_, y() + p.y_)
override fun toString() = "${y() * 3 + x() + 1}"
}
private fun solve(input: String) = input.fold(mutableListOf(Point(1, 1)), { res, c ->
package com.crossover.trial;
import java.time.LocalDateTime;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Solution {
public class TimeParser {
public LocalDateTime parseDuration(String duration, LocalDateTime now) {
for (Matcher m = Pattern.compile("(\\d+) (\\w)s?").matcher(duration);m.find();)
package com.crossover.trial;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.junit.Assert.assertEquals;
public class Solution {
package com.crossover.trial;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.junit.Assert.assertEquals;
public class Solution {
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) => const MaterialApp(home: Scaffold(body: MyStatelessWidget()));
}
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
void main() => runApp(const SticksApp());
class SticksApp extends StatelessWidget {
const SticksApp({super.key});
@override
Widget build(BuildContext context) {