What do you want to save?
Add Code snippet
New code examples
-
Python 2021-10-19 13:02:13
Find majority element (Boyer–Moore Majority Vote Algorithm)
def majorityElement(A): # `m` stores the majority element (if present) m = -1 # initialize counter `i` with 0 i = 0 # do for each element `A[j]` in the list for j in range(len(A)): # if counter `i` becomes 0 ... Add solution -
C++ 2021-10-18 04:44:07
Box and Circle collisions C++
bool AABBvsCircle( Manifold *m ) { // Setup a couple pointers to each object Object *A = m->A Object *B = m->B // Vector from A to B Vec2 n = B->pos - A->pos  ... Add solution -
Go 2021-10-18 00:36:06
rock paper scissors in golang
package main import ( "fmt" "math/rand" ) func rpsGame() int { won := false turns := 0 for !won { fmt.Println("Rock Paper Scissors") fmt.Println("1=Rock 2=Paper 3=Scissors") fmt.Println("VVV Enter ... Add solution -
C++ 2021-10-17 18:04:06
console colors in C++
//This is a header file taken from cplusplus.com //http://www.cplusplus.com/articles/Eyhv0pDG/ //concol.h #ifndef _INC_EKU_IO_CONCOL #define _INC_EKU_IO_CONCOL /*Header file to color text and background in windows console applications Global variables - ... Add solution -
Other 2021-10-17 15:47:12
if sma_20 > sma_50: if context.aapl not in open_orders order_target_percent(context.aapl,1.0)#order_target_percent(card,% of profoil)'''
hist = data.history(context.aapl,'price', 50, '1d') sma_50 = hist.mean() sma_20 = hist[-20:].mean() open_orders = get_open_orders() if sma_20 > sma_50: if context.aapl not in open_orders: order_tar... Add solution