Skip to content

Instantly share code, notes, and snippets.

View mcs's full-sized avatar

Marcus mcs

  • Stromnetz Hamburg GmbH
  • Hamburg, Germany
View GitHub Profile
public boolean test(List<Card> cards) {
if (cards == null || isStraightFlush.test(cards)) {
return false;
}
Map<Suit, Integer> sortedCards = cards.stream()
.map(Card::suit)
.collect(Collectors.toMap(Function.identity(), s -> 1, Integer::sum));
return sortedCards.values().stream()
.anyMatch(count -> count >= 5);
}
public boolean test(List<Card> cards) {
if (cards == null || isStraightFlush.test(cards)) {
return false;
}
List<Card> sortedCards = cards.stream()
.sorted(Comparator.comparing(Card::suit))
.toList();
int suitsInARow = 1;
Suit lastSuit = null;
for (Card card : sortedCards) {
@mcs
mcs / tcec-interest-alert.userscript.js
Created October 4, 2020 16:39
tcec-interest-alert.userscript.js oder so
// ==UserScript==
// @name Alert on interesting events - tcec-chess.com
// @namespace Violentmonkey Scripts
// @match https://tcec-chess.com/
// @grant none
// @version 1.0
// @author M.C.S.
// @description Plays a sound when the boards becomes somewhat interesting, i.e. one engine rates |eval| > 1 or both engines see different positional leaders
// ==/UserScript==
@mcs
mcs / if.java
Last active May 11, 2018 10:18
public static void main(String[] args) {
int a = 10;
if ((a == 10) && (a += 20) == 30) {
System.out.println("a = " + a); // should print 30
}
}
@mcs
mcs / gist:4059304
Created November 12, 2012 13:07
Log wrapper
/**
* Creates a log wrapper for browser console. If console.log is defined, it passed the function arguments to it.
* Using this method prevents problems when using console.log directly in IE (at least in version 8).
*/
var logger = function () {
if (console && console.log) {
console.log.call(console, arguments);
}
}
@mcs
mcs / gist:1385782
Created November 22, 2011 14:29
ParseDate with TimeZone
import static org.junit.Assert.assertEquals;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.TimeZone;
import org.junit.Test;
public class ParseDateTest {
@mcs
mcs / XmlUnitTest.java
Created October 19, 2011 06:48
Using XMLUnit in JUnit4 to test XML
package learning_tests;
import static org.custommonkey.xmlunit.XMLAssert.*;
import org.custommonkey.xmlunit.XMLUnit;
import org.junit.Test;
public class XmlUnitTest {
@Test