Skip to content

Instantly share code, notes, and snippets.

View vderyagin's full-sized avatar

Victor Deryagin vderyagin

  • Ternopil, Ukraine
View GitHub Profile
@vderyagin
vderyagin / priority_queue.go
Last active November 27, 2022 18:50
Priority Queue data structure implementation in Go
package priority_queue
import "errors"
type Elem struct {
Score int
Data interface{}
}
type priorityQueue struct {
@vderyagin
vderyagin / FizzBuzz
Last active December 11, 2015 09:19
FizzBuzz solution in Haskell
#! /usr/bin/env runhaskell
import Control.Monad (when, unless)
main :: IO ()
main = mapM_ fb [1..100]
fb :: Int -> IO ()
fb n = do
let divBy3 = n `mod` 3 == 0
@vderyagin
vderyagin / pascal_triangle.go
Last active December 11, 2015 09:38
Generating and printing Pascal Triangle of given size implemented in Go
package main
import (
"fmt"
"log"
"os"
"strconv"
)
func MakePascalTriangle(height int) [][]int {
@vderyagin
vderyagin / sieve_of_eratosthenes.go
Last active December 11, 2015 09:38
Sieve of Erathosthenes prime numbers finding algorithm implemented in Go
package main
import (
"fmt"
"log"
"os"
"strconv"
)
func Primes(n int) []int {
module CaesarCipher
(
encrypt
, decrypt
, cipher
) where
import Data.Char
isAsciiLetter :: Char -> Bool
package singly_linked_list
import (
"bytes"
"errors"
"fmt"
)
type sListNode struct {
value interface{}
package binary_search
import "errors"
// For testing:
// var Find = FindRecursive
var Find = FindIterative
func FindRecursive(list []int, num int) (int, error) {
if len(list) == 0 {
@vderyagin
vderyagin / bag.go
Last active December 11, 2015 15:09
Bag data structure implemented in Go
package bag
import (
"bytes"
"errors"
"fmt"
)
type bag struct {
m map[interface{}]int
@vderyagin
vderyagin / queue.go
Last active December 11, 2015 17:08
Thread-safe implementation of Queue data structure in Go
package queue
import (
"bytes"
"errors"
"fmt"
"sync"
)
type node struct {
@vderyagin
vderyagin / stack.go
Last active December 11, 2015 17:08
Thread-safe implementation of Stack data structure in Go
package stack
import (
"bytes"
"errors"
"fmt"
"sync"
)
type node struct {