Skip to content

Instantly share code, notes, and snippets.

View alebaffa's full-sized avatar
🗼
Focusing

Alessandro alebaffa

🗼
Focusing
View GitHub Profile
@alebaffa
alebaffa / romannumeral2.java
Created July 4, 2016 22:09
Roman Numeral Kata - TPP 8
public class RomanNumbers {
private static Map<Integer, String> dictionary = new HashMap<>();
static {
dictionary.put(1, "I");
dictionary.put(2, "II");
dictionary.put(3, "III");
dictionary.put(4, "IV");
};
@alebaffa
alebaffa / romannumerals.java
Created July 4, 2016 21:57
Roman Numeral Kata
public class RomanNumbers {
private static String[] dictionary = {"I", "II", "III"};
public String convertToRoman(int number) {
return dictionary[number - 1];
}
}
@alebaffa
alebaffa / fizzbuzz.go
Created June 19, 2016 17:45
FizzBuzz kata in Go
package fizzbuzz
import (
"bytes"
"strconv"
)
func FizzBuzz(max int) string {
var result bytes.Buffer
@alebaffa
alebaffa / concurrency.go
Created June 19, 2016 12:14
Personaly testing of concurrency in Go
func Frequency(s string) map[rune]int {
//DO SOMETHING
}
func ConcurrentFrequency(words []string) map[rune]int {
// (buffered)channel if type map[run]int with capacity of the lenght of the input (3)
channel := make(chan map[rune]int, len(words))
for _, value := range words {
// anonymous function that calls Frequency() 3 times in parallel
// and puts the three different results in the channel of capacity 3
go func(v string){
channel <- Frequency(v)
}(value)
@alebaffa
alebaffa / frequency.go
Created May 16, 2016 19:11
Parallel Letter Frequency in Go
package letter
type FreqMap map[rune]int
func Frequency(s string) FreqMap {
m := FreqMap{}
for _, r := range s {
m[r]++
}
return m
@alebaffa
alebaffa / bowling.go
Created May 16, 2016 10:16
Bowling kata in Go
package bowling
type Game struct {
throws [21]int
currentThrow int
}
const maxFrames = 10
func (game *Game) Roll(pins int) {
package foodchain
import (
"fmt"
"strings"
)
// TestVersion is the version of this code.
const TestVersion = 1
@alebaffa
alebaffa / designer.html
Created November 2, 2014 19:42
designer
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
@alebaffa
alebaffa / gist:fec37f1def1987c0802c
Last active August 29, 2015 14:07
Palindrome program in Java. Source: Java Geek Code (http://goo.gl/rFN0vv).
package com.javacodegeeks.core.palindrome;
public class PalindromeExample {
private static final String STR1 = "uabbcbbau";
private static final String STR2 = "isdovosjd";