Skip to content

Instantly share code, notes, and snippets.

@jahunt1
jahunt1 / Prng.kt
Created May 25, 2020 15:30
Generate random integers that follow a normal (Gaussian) distribution
/**
* Copyright 2020 John Hunt
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
@jahunt1
jahunt1 / CsvParser.kt
Last active July 19, 2018 22:02
Parse CSV data in Kotlin
class CsvParser {
fun parseLine(line: String) : List<String> = parseLine(line, ',')
fun parseLine(line: String, separator: Char) : List<String> {
val result = mutableListOf<String>()
val builder = StringBuilder()
var quotes = 0
for (ch in line) {
when {
ch == '\"' -> {