Skip to content

Instantly share code, notes, and snippets.

View cod3smith's full-sized avatar
🤩
Always Be Coding, Always Be Learning

Kelyn Paul Njeri cod3smith

🤩
Always Be Coding, Always Be Learning
View GitHub Profile
const calculateTotal = () => {
// Assume this your cart.
let cartArr = [
{
'price': 1000,
'quantity': 12
},
{
'price': 2000,
'quantity': 22
FROM golang:1.16.5
ADD ./ /go/src/app
WORKDIR /go/src/app
RUN go get ./
RUN go build -o ./.build/sortika main.go
build:
docker:
web: Dockerfile
run:
web: ./.build/sortika
class Stack:
def __init__(self):
self.STACK = []
def push(self, element):
self.STACK.append(element)
return self.STACK
def check_empty(self):
return len(self.STACK) == 0
package main
import "fmt"
type Stack []string
// IsEmpty: check if stack is empty
func (s *Stack) IsEmpty() bool {
return len(*s) == 0
}
def solve_n_queens(n):
def is_safe(board, row, col):
# Check if a queen can be placed at the given position without conflicting
# with any other queens on the board
for i in range(row):
if board[i] == col or \
board[i] - i == col - row or \
board[i] + i == col + row:
return False
return True
class Queue:
def __init__(self):
self.items = []
def enqueue(self, item):
self.items.append(item)
def dequeue(self):
if not self.is_empty():
return self.items.pop(0)
package main
import "fmt"
type Queue struct {
items []interface{}
}
func (q *Queue) Enqueue(item interface{}) {
q.items = append(q.items, item)
class CircularQueue:
def __init__(self, k):
self.queue = [None] * k
self.head = self.tail = -1
self.size = 0
def enqueue(self, item):
if self.is_full():
return False
if self.is_empty():
package main
type CircularQueue struct {
items []interface{}
head int
tail int
size int
}
func NewCircularQueue(k int) *CircularQueue {