Skip to content

Instantly share code, notes, and snippets.

View uzilan's full-sized avatar

Uzi Landsmann uzilan

View GitHub Profile
@uzilan
uzilan / exercism-pipeline.groovy
Last active June 17, 2019 11:46
A Jenkins pipeline script to test Exercism solutions in Java and Kotlin
import groovy.io.FileType
def path = ""
def uuid = ""
properties([[$class: "ParametersDefinitionProperty",
parameterDefinitions: [
[$class: "StringParameterDefinition",
description : "Exercise UUID",
name : "UUID"]]]])
@uzilan
uzilan / benchmarks.go
Last active October 21, 2019 07:03
gosoup
func GetANumber() int {
rand.Seed(time.Now().UnixNano()) // different seed every time
return rand.Intn(100) // generate a random number
}
func BenchmarkGetANumber(b *testing.B) {
for i := 0; i < b.N; i++ {
GetANumber()
}
}
package gosoup
func mySecretLittleFunction() {}
func UseMeImExported() {}
uzilan Oct 2nd at 11:21 PM
Hamming 2.3.0 allows both strands to be empty, but if only the left or the right strands are empty then an exception should be thrown with different error messages for each case. This means one should check for many different situation. And this is only the third exercise. Isn’t it a bit of an overkill?
12 replies
uzilan 1 month ago
https://raw.githubusercontent.com/exercism/problem-specifications/master/exercises/hamming/canonical-data.json
uzilan 1 month ago
Specifically, for Kotlin, that means you can’t use the idiomatic require because the condition (not empty) is only required if only one strand is empty
interface TrollNumber {
val value: Int
}
package zer.ubba.bel;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import static java.lang.ClassLoader.getSystemResource;
import static java.util.Arrays.stream;
package zer.ubba.bel
import java.io.File
import java.lang.ClassLoader.getSystemResource
import java.util.Locale
private val boringWords = ("the,and,of,to,that,for,in,i,his,a,with,it,be,is,not,they,thou")
.split(",")
fun readTheBible(): Map<String, Int> {
package zer.ubba.bel
import scala.io.Source.fromResource
class ScalaBible {
private val boringWords = ("the,and,of,to,that,for,in,i,his,a,with,it,be,is,not,they,thou")
.split(",")
def readTheBible(): Map[String, Int] = {
val source = fromResource("bible.txt")
package zer.ubba.bel
class GroovyBible {
private final def boringWords = "the,and,of,to,that,for,in,i,his,a,with,it,be,is,not,they,thou"
.split(",");
def readTheBible() {
def resource = ClassLoader.getSystemResource("bible.txt")
return resource
(ns zer.ubba.bel.clojure_bible
(:require [clojure.java.io :as io])
(:require [clojure.string :as str])
(:gen-class))
(def data-file (io/resource "bible.txt"))
(def boringWords
(str/split "the,and,of,to,that,for,in,i,his,a,with,it,be,is,not,they,thou" #","))