This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RomanNumbers { | |
private static String[] dictionary = {"I", "II", "III"}; | |
public String convertToRoman(int number) { | |
return dictionary[number - 1]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fizzbuzz | |
import ( | |
"bytes" | |
"strconv" | |
) | |
func FizzBuzz(max int) string { | |
var result bytes.Buffer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
go func(v string){ | |
channel <- Frequency(v) | |
}(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package letter | |
type FreqMap map[rune]int | |
func Frequency(s string) FreqMap { | |
m := FreqMap{} | |
for _, r := range s { | |
m[r]++ | |
} | |
return m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bowling | |
type Game struct { | |
throws [21]int | |
currentThrow int | |
} | |
const maxFrames = 10 | |
func (game *Game) Roll(pins int) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foodchain | |
import ( | |
"fmt" | |
"strings" | |
) | |
// TestVersion is the version of this code. | |
const TestVersion = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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%; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javacodegeeks.core.palindrome; | |
public class PalindromeExample { | |
private static final String STR1 = "uabbcbbau"; | |
private static final String STR2 = "isdovosjd"; |