This file contains hidden or 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
import java.util.stream.LongStream; | |
public class Replicate { | |
public static void replicate(String s, long max) { | |
LongStream.iterate(0, n -> n + 1).limit(max).forEach(n -> System.out.print("A")); | |
System.out.println(); | |
} | |
public static void main(String []args) { | |
int n = 11; |
This file contains hidden or 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 main | |
import ( | |
"bufio" | |
"fmt" | |
"io" | |
"os" | |
"strconv" | |
"strings" | |
) |
This file contains hidden or 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
import Data.List | |
import qualified Data.Map.Strict as Map | |
import qualified Data.Tree as Tree | |
import qualified Data.Graph as Graph | |
points :: [[Int]] -> Int -> Int -> [((Int,Int), Int)] | |
points area width height = zip keys (concat area) | |
where | |
keys = [(r,c) | r <- [0..(height-1)], c <- [0..(width-1)]] |
This file contains hidden or 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 main | |
import ( | |
"fmt" | |
"go/ast" | |
"go/parser" | |
"go/token" | |
"os" | |
"strings" | |
) |
This file contains hidden or 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 main | |
import ( | |
"bytes" | |
"fmt" | |
"strings" | |
) | |
func main() { | |
// Read first line |
This file contains hidden or 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
import Control.Monad (replicateM) | |
parseTokens:: String -> [String] | |
parseTokens tokenStr = parseTokens' [] "" False tokenStr | |
where | |
parseTokens' acc word isGroup "" = acc | |
parseTokens' acc word isGroup (x:xs) | |
| not isGroup && x == '(' = parseTokens' acc "" True xs | |
| not isGroup && x /= '(' = parseTokens' (acc++[[x]]) "" False xs |
This file contains hidden or 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
rotate xs n | n >= 0 = zipWith (\_ x -> x) xs $ drop n $ cycle xs | |
| otherwise = take len $ drop dropLen $ (cycle xs) | |
where | |
len = length xs | |
dropLen = (len + (n `mod` (-len))) |
This file contains hidden or 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
rotate xs n | n >= 0 = drop n xs ++ take n xs | |
| otherwise = drop (length xs + n) xs ++ take (length xs + n) xs |
This file contains hidden or 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 main | |
import ( | |
"bufio" | |
"flag" | |
"fmt" | |
"os" | |
"strings" | |
) |
This file contains hidden or 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
replace xs a b = replace' [] xs | |
where | |
replace' acc [] = acc | |
replace' acc (x:xs) | x == a = replace' (acc ++ [b]) xs | |
| otherwise = replace' (acc ++ [x]) xs |