Skip to content

Instantly share code, notes, and snippets.

Yannick Grenzinger ygrenzinger

Block or report user

Report or block ygrenzinger

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View FiniteGrid.scala
package gameoflife
import scala.collection.immutable.Seq
case class FiniteGrid(override val size: Int, override val rows: Seq[Row]) extends Grid[FiniteGrid](size: Int, rows: Seq[Row]) {
override def changeCellAt(position: (Int, Int), state: CellState): FiniteGrid =
FiniteGrid(size, changeRowsAt(rows, position, state))
}
object FiniteGrid {
View BowlingScoreCalculator.hs
module ScoreCalculator ( bowlingScore ) where
import Data.Char
data Roll = Strike | Spare | PinHit Int deriving Eq
parseRawRolls :: String -> [Roll] -> [Roll]
parseRawRolls [] rolls = reverse rolls
parseRawRolls (' ' : rest) rolls = parseRawRolls rest rolls
parseRawRolls ('-':rest) rolls = parseRawRolls rest ((PinHit 0) : rolls)
View bolwing_kata.dart
import 'package:cli/cli.dart';
import 'package:test/test.dart';
// https://learnxinyminutes.com/docs/dart/
// http://codingdojo.org/kata/Bowling/
int parseRoll(String roll) {
if (roll == 'X') {
return 10;
}
View BoardImpl.kt
package board
import board.Direction.*
class SquareBoardImpl(private val size: Int, private val cells: List<Cell>) : SquareBoard {
constructor(width: Int) : this(width, createCells(width))
override val width: Int
get() = size
View MockkSlowness.kt
package com.kata.tetris
import io.mockk.every
import io.mockk.mockk
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
/*
<dependency>
View README.md

Tetris Kata

This kata is intended to simulate a game of Tetris.

The point of this kata to to provide a larger than trivial exercise that can be used to practice TDD. A significant portion of the effort will be in determining what tests should be written and, more importantly, written next.

Considerations:

  • Multi-threading should not be a consideration. This should be done in a single thread.
  • Drawing the board is a bonus feature, and is not required in order to solve the problem.
  • For the purpose of the kata we do not need a true "game loop". We simply need to implement the rules in such a way as to advance the game state.
View FooBarQix.java
package com.course.polytech;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class FooBarQix {
private static Map<Integer, String> NUMBER_2_STRING = new HashMap<>();
@ygrenzinger
ygrenzinger / Cell.kt
Created Mar 18, 2019
Kotlin Game of Life with JC Melikian
View Cell.kt
enum class Cell {
ALIVE {
override fun nextGeneration(neighbors: Int): Cell {
if (neighbors == 2 || neighbors == 3) return this
return DEAD
}
}, DEAD {
override fun nextGeneration(neighbors: Int): Cell {
if (neighbors == 3) return ALIVE
return this
@ygrenzinger
ygrenzinger / Day6.kt
Last active Dec 26, 2018
Advent of Code
View Day6.kt
import java.io.File
import java.util.*
import java.util.concurrent.atomic.AtomicInteger
data class Coordinate(val x: Int, val y: Int)
data class Point(val label: Int, val coordinate: Coordinate)
data class area(val associatedToPoint: Point, val size: Int = 0)
var seqId = AtomicInteger(1)
View Latencies.md

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns  = 250 µs
You can’t perform that action at this time.