code
stringlengths
114
1.05M
path
stringlengths
3
312
quality_prob
float64
0.5
0.99
learning_prob
float64
0.2
1
filename
stringlengths
3
168
kind
stringclasses
1 value
The crux of the idea is the we are only allowed to jump backwards 1 time. Lets say we are at position i after jumping form i-a, then we can only goto i-b, so if we look at values from i-b...i+a, and suppose (i-b+a) was forbidden. what if we had choosen i-a, position to jump back to i-a-b and then jump f...
submissions/1654.Minimum_Jumps_To_Reach_Home.go
0.510741
0.632389
1654.Minimum_Jumps_To_Reach_Home.go
starcoder
package data import ( "fmt" "strings" ) // Data wrapper on map[string]interface{} to provide values for keys type Data map[string]interface{} func (d Data) navigate(key string) (interface{}, error) { parts := strings.SplitN(key, ".", 2) if len(parts) == 1 { return d[parts[0]], nil } if val, ok := d[parts[0...
data.go
0.581897
0.437042
data.go
starcoder
package utils import ( "bytes" "encoding/gob" "fmt" "github.com/pkg/errors" "github.com/rs/zerolog/log" "math" "strings" ) // DefaultWidth defaults to a default screen dumps size const DefaultWidth = 46 // 10 bytes per line on a []byte < 999 // boxLineOverheat Overheat per line when drawing boxes const boxLi...
plc4go/internal/plc4go/spi/utils/hex.go
0.536313
0.442275
hex.go
starcoder
package geometry import ( "encoding/binary" ) const qMaxItems = 32 const qMaxDepth = 16 type qNode struct { split bool items []uint32 quads [4]*qNode } func (n *qNode) insert(series *baseSeries, bounds, rect Rect, item, depth int) { if depth == qMaxDepth { // limit depth and insert now n.items = append(n.i...
geometry/qtree.go
0.59796
0.439988
qtree.go
starcoder
package gorota import "errors" const maxRunLength = 1 << 7 type Slots struct { Bytes []byte } type SlotsPatch struct { Start uint Patch Slots } var ( ErrNoTime = errors.New("no temporal data given") ErrDiscontinuity = errors.New("temporal discontinuity in given intervals") ) func NewSlo...
slots.go
0.762247
0.467332
slots.go
starcoder
package goglbackend import ( "image" "math" "unsafe" "github.com/tfriedel6/canvas/backend/backendbase" "github.com/tfriedel6/canvas/backend/goglbackend/gl" ) func (b *GoGLBackend) Clear(pts [4]backendbase.Vec) { b.activate() // first check if the four points are aligned to form a nice rectangle, which can be...
backend/goglbackend/fill.go
0.598312
0.468912
fill.go
starcoder
package animation import ( "github.com/wieku/danser-go/bmath" "math" ) type TransformationType int64 type TransformationStatus int64 const ( Fade = TransformationType(1 << iota) Rotate Scale ScaleVector Move MoveX MoveY Color3 Color4 HorizontalFlip VerticalFlip Additive ) const ( NotStarted = Transfo...
animation/transformation.go
0.76366
0.509947
transformation.go
starcoder
package utils import ( "fmt" "strings" "time" ) // Seconds-based time units const ( Minute = 60 Hour = 60 * Minute Day = 24 * Hour Week = 7 * Day Month = 30 * Day Year = 12 * Month ) func computeTimeDiff(diff int64) (int64, string) { diffStr := "" switch { case diff <= 0: diff = 0 diffStr =...
apiv2-utils/time.go
0.521715
0.425426
time.go
starcoder
package main import ( "github.com/faiface/pixel" "github.com/faiface/pixel/imdraw" ) type birdSeed struct { Finished bool center pixel.Vec height float64 width float64 seedCount float64 originalSeedCount float64 seedsPerRow float64 // How much to scale the seed in ter...
birdSeed.go
0.764804
0.401717
birdSeed.go
starcoder
package tetra3d import ( "math" "github.com/kvartborg/vector" ) // BoundingCapsule represents a 3D capsule, whose primary purpose is to perform intersection testing between itself and other Bounding Nodes. type BoundingCapsule struct { *Node Height float64 Radius float64 internalSphere *Boundin...
boundsCapsule.go
0.924048
0.621168
boundsCapsule.go
starcoder
package leetcode /* * @lc app=leetcode id=621 lang=golang * * [621] Task Scheduler * * https://leetcode.com/problems/task-scheduler/description/ * * algorithms * Medium (50.84%) * Likes: 4023 * Dislikes: 788 * Total Accepted: 221.6K * Total Submissions: 434K * Testcase Example: '["A","A","A","B","B...
leetcode/621.task-scheduler.go
0.900681
0.462473
621.task-scheduler.go
starcoder
package easy //go:generate go run sort_template.go import "sort" // Int8sAsc attaches the methods of sort.Interface to []int8, sorting in ascending order. type Int8sAsc []int8 func (x Int8sAsc) Len() int { return len(x) } func (x Int8sAsc) Less(i, j int) bool { return x[i] < x[j] } func (x Int8sAsc) Swap...
easy/sort_gen.go
0.653016
0.409516
sort_gen.go
starcoder
package environment import ( "fmt" "math" ) const CartpoleMaxAbsAction = 1.0 const CartpoleMaxAbsThetaDot = 10.0 type Cartpole struct { g, m, l, dt, ml, mass float64 initState, s [4]float64 // [x, theta, xdot, thetadot] } func (cp *Cartpole) Init() error { cp.g = 9.80665 // 重力加速度 cp.m = 0.1 // 棒の質量 cp...
environment/cartpole.go
0.575349
0.504211
cartpole.go
starcoder
package list import ( "github.com/flowonyx/functional/math" "github.com/flowonyx/functional/option" "golang.org/x/exp/constraints" ) func checker[TInt constraints.Integer](start, end TInt, step int) (stepOut int, check func(i TInt) bool) { if start < end { return math.Abs(step), func(i TInt) bool { return i <= ...
list/range.go
0.73029
0.500061
range.go
starcoder
package main import ( "bufio" "fmt" "math" "os" "sort" ) type Asteroid struct { X int Y int } type Vector Asteroid var Asteroids []Asteroid func blocked(c, a, b Asteroid) bool { v_ac := Vector{c.X - a.X, c.Y - a.Y} v_ab := Vector{b.X - a.X, b.Y - a.Y} v_ca := Vector{a.X - c.X, a.Y - c.Y} v_cb := Vector...
day10/star2.go
0.578567
0.466177
star2.go
starcoder
package plaid import ( "encoding/json" ) // HoldingsOverride Specify the holdings on the account. type HoldingsOverride struct { // The last price given by the institution for this security InstitutionPrice float32 `json:"institution_price"` // The date at which `institution_price` was current. Must be formatted...
plaid/model_holdings_override.go
0.81257
0.525125
model_holdings_override.go
starcoder
package goanneal import ( "fmt" "math" "math/rand" "os" "time" ) // State is an interface of a state of a problem. // These three methods will handle the state. type State interface { Copy() interface{} // Returns an address of an exact copy of the current state Move() // Move to a different state ...
anneal.go
0.776242
0.66236
anneal.go
starcoder
package chip8 import ( "errors" "fmt" "math/bits" ) // Fetch return the next opCode and increment the program counter. // All instructions are 2 bytes long and are stored most-significant-byte first. // In memory, the first byte of each instruction should be located at an even addresses. // If a program includes s...
pkg/chip8/instructions.go
0.586523
0.628635
instructions.go
starcoder
package main import ( "fmt" "github.com/emer/emergent/env" "github.com/emer/emergent/erand" "github.com/emer/etable/etensor" ) // FSAEnv generates states in a finite state automaton (FSA) which is a // simple form of grammar for creating non-deterministic but still // overall structured sequences. type FSAEnv s...
examples/deep_fsa/fsa_env.go
0.644449
0.471588
fsa_env.go
starcoder
package coder import ( "fmt" "math" ) const ( ValueSum = iota CheckSumProduct CheckMinSum CheckNormalizedMinSum CheckOffsetMinSum ) func BuildRecorder(recorderType int, param ...float64) interface{} { switch recorderType { case ValueSum: return BuildSumRecorder() case CheckMinSum: return BuildMinRecord...
information/LDPC/coder/recoder.go
0.524151
0.468426
recoder.go
starcoder
package binarytree import ( "fmt" "math" "github.com/MehdiEidi/gods/queue/linkedqueue" "github.com/MehdiEidi/gods/stack/linkedstack" ) type BinaryTree[T any] struct { Root *Node[T] Size int } // New constructs and returns an empty binary tree. func New[T any]() *BinaryTree[T] { return &BinaryTree[T]{} } // ...
tree/binarytree/binary_tree.go
0.831143
0.552479
binary_tree.go
starcoder
package chaingame import ( "fmt" "math/rand" "strings" ) // Board is a row ordered 2D matrix of colored blocks. // It's a directly addressable regular slice of slices. type Board [][]Color // NewBoard allocates storage for a h*w board with row first structure. func NewBoard(h, w int) Board { if h*w == 0 { re...
pkg/chaingame/board.go
0.794664
0.474266
board.go
starcoder
package trees_and_graphs import ( "bytes" "math/rand" "strconv" ) type RandomTreeNode struct { Value int Parent *RandomTreeNode Count int Left *RandomTreeNode Right *RandomTreeNode } func CreateRandomTreeNode(value int, parent *RandomTreeNode) *RandomTreeNode { return &RandomTreeNode{ Value: value, ...
go/04_trees_and_graphs/11_random_node.go
0.578091
0.427636
11_random_node.go
starcoder
package core // TrueColor representation type TrueColor uint // Rgb returns the tree components of the color as bytes (r, g and b) func (color TrueColor) Rgb() (byte, byte, byte) { return byte((color >> 16) & 0xFF), byte((color >> 8) & 0xFF), byte(color & 0xFF) } // R returns the byte containing the color's Red com...
core/color.go
0.791096
0.753988
color.go
starcoder
package tin import ( "math" ) type Mesh struct { Vertices []Vertex Normals []Normal Faces []Face Triangles []Triangle BBox [2][3]float64 } func (m *Mesh) initFromDecomposed(vertices []Vertex, faces []Face, norl []Normal) { m.Vertices = vertices m.Faces = faces m.Normals = norl m.Triangles = mak...
mesh.go
0.544075
0.514827
mesh.go
starcoder
package streams // CreateConnectionQueryParams represents valid query parameters for the CreateConnection operation // For convenience CreateConnectionQueryParams can be formed in a single statement, for example: // `v := CreateConnectionQueryParams{}.SetSkipValidation(...)` type CreateConnectionQueryParams struct...
services/streams/param_generated.go
0.903386
0.489381
param_generated.go
starcoder
package jbtracer import ( "log" "math" ) type Camera struct { Hsize int Vsize int FieldOfView float64 HalfHeight float64 HalfWidth float64 PixelSize float64 Transform *Matrix } // NewCamera returns a new Camera, with default Transform func NewCamera(hsize, vsize int, fov float64) *Camera ...
camera.go
0.858051
0.600071
camera.go
starcoder
package steady import ( "math" "math/big" "github.com/pylls/steady/lc" ) const ( // LeafPrefix is the domain separation prefix for leaf hashes. LeafPrefix = 0x00 // NodePrefix is the domain separation prefix for internal block nodes. NodePrefix = 0x01 ) // AuditPath as in RFC6962 func AuditPath(m int, data ...
merkle.go
0.677047
0.484746
merkle.go
starcoder
package gl import ( mgl "github.com/go-gl/mathgl/mgl32" "math" "github.com/go-gl/glfw/v3.3/glfw" ) type OrbitalCamera struct { center mgl.Vec3 Position mgl.Vec3 startDragX float64 startDragY float64 mouseX float64 mouseY float64 dragging bool ScaleFactor float32 Sensativity float32...
Open/gl/camera.go
0.741861
0.44559
camera.go
starcoder
// Package proof contains the following implementations // - proof of discrete logarithm (PDL) subprotocol from [spec] §8 // - multiplicative-to-additive (MtA) subprotocol from [spec] §7 // - proof of knowledge of a discrete log modulo a composite (fig 16), i.e., ProveCompositeDL and VerifyCompositeDL package proof...
pkg/tecdsa/gg20/proof/pdl.go
0.732974
0.461381
pdl.go
starcoder
package layout import ( "errors" "image" "math" "runtime" ) type L struct { Bounds image.Rectangle Points map[image.Point][]image.Point } func runCount() int { var ( maxProcs = runtime.GOMAXPROCS(0) numGR = runtime.NumGoroutine() available = maxProcs - numGR - 1 // save 1 for the reader goroutine ...
layout/generator.go
0.600305
0.457016
generator.go
starcoder
// Create a custom error type called appError that contains three fields, err error, // message string and code int. Implement the error interface providing your own message // using these three fields. Implement a second method named temporary that returns false // when the value of the code field is 9. Write a funct...
content/docs/design/error_handling/exercise2/exercise2.go
0.760917
0.530176
exercise2.go
starcoder
package maputil func CheckEnum(s string, allowed []string) error { for _, v := range allowed { if v == s { return nil } } return EnumStringError{ Value: s, Enum: allowed, } } // GetArray fetches a value from the map and converts it to an array. func GetArray(m map[string]interface{}, key string) ([]in...
access.go
0.784071
0.419707
access.go
starcoder
package core import ( "fmt" "image/color" "math" "github.com/Laughs-In-Flowers/flip" "github.com/Laughs-In-Flowers/warhola/lib/canvas" "github.com/Laughs-In-Flowers/warhola/lib/util/mth" ) var adjust = NewCommand( "", "adjust", "Adjust the brightness,gamma,contrast,hue or saturation of an image", 1, func(o *...
lib/core/adjust.go
0.594434
0.405596
adjust.go
starcoder
package fsm import ( "sort" ) // Handler represents a callback to be called when the machine performs a // certain transition between states. type Handler func(m *Machine) // Transition represents a transition between two states. type Transition struct { start bool from uint8 fromSet bool to u...
transition.go
0.782829
0.479382
transition.go
starcoder
package main import ( "fmt" "strconv" ) // isValid function checks whether the given scrambled puzzle contains valid values or not // returns false if invalid // returns true if otherwise func (puzzle matrix) isValid() bool { values := make(map[string]int) for i := 1; i <= 8; i++ { values[strconv.Itoa(i)] = 0 ...
algorithms/a_star/8_puzzle/a_star.go
0.639511
0.488771
a_star.go
starcoder
package digitalocean import ( "reflect" "github.com/pkg/errors" "github.com/pulumi/pulumi/sdk/v2/go/pulumi" ) // Provides a DigitalOcean Kubernetes node pool resource. While the default node pool must be defined in the `.KubernetesCluster` resource, this resource can be used to add additional ones to a cluster. ...
sdk/go/digitalocean/kubernetesNodePool.go
0.774796
0.446917
kubernetesNodePool.go
starcoder
package glm import ( "fmt" "math" ) type Matrix4 [16]float32 // Construct the identity 4x4 matrix func Matrix4Identity() Matrix4 { return Matrix4{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1} } func MatrixMultiply(m1, m2 Matrix4) Matrix4 { out := Matrix4Identity() out[0] = Dot4(m1.Row(0), m2.Column(...
matrix.go
0.776877
0.566978
matrix.go
starcoder
package alphametics import ( "errors" "fmt" "strconv" "strings" ) // PermutationNext generates the next permutation of a slice of int; modifies data in-place. // Data must be sorted initially. // Returns true if successfull, false if exhausted. // http://en.wikipedia.org/wiki/Permutation#Generation_in_lexicograph...
alphametics/alphametics.go
0.607663
0.479686
alphametics.go
starcoder
package main import "github.com/go-gl/mathgl/mgl32" type CameraMovement int const ( MoveForward CameraMovement = iota MoveBackward MoveLeft MoveRight ) type Camera struct { pos mgl32.Vec3 up mgl32.Vec3 right mgl32.Vec3 front mgl32.Vec3 wfront mgl32.Vec3 rotatex, rotatey, rotatesens float32 Sen...
camera.go
0.696578
0.466177
camera.go
starcoder
package validate import ( "reflect" "strconv" "time" ) // ValidatorType is used for validator type definitions. type ValidatorType string // Following validators are available. const ( // ValidatorEq (equals) compares a numeric value of a number or compares a count of elements in a string, a map, a slice, or an ...
validators.go
0.874104
0.694808
validators.go
starcoder
package main // Adapted from: https://towardsdatascience.com/answering-monty-hall-problem-with-monte-carlo-6c6069e39bfe /* Note: This example could be improved and extended in a few ways, if required, but this is just designed as a quick way to showcase the power of simulations. */ import ( "flag" "fmt" "math/rand...
MonteCarlo-MontyHall/main.go
0.728362
0.463444
main.go
starcoder
package function import ( "fmt" "math" "math/rand" "github.com/anywhereQL/anywhereQL/common/value" ) func Abs(args []value.Value) (value.Value, error) { r := value.Value{} if len(args) != 1 { return r, fmt.Errorf("Arg too long") } v := args[0] switch v.Type { case value.INTEGER: r.Type = value.INTEGER...
runtime/function/math.go
0.605916
0.437223
math.go
starcoder
package main import ( matrix "github.com/skelterjohn/go.matrix" "fmt" "math" ) var relation = []float64{4,1,1,0} var relation_mat = matrix.MakeDenseMatrix(relation, 2,2) var initial_seq_values = []float64{8,2} var init_mat = matrix.MakeDenseMatrix(initial_seq_values, 2,1) var dict = make(map[float64]*matrix.Den...
Problem2/go/problem2.go
0.58676
0.558086
problem2.go
starcoder
package cc import ( "sync" "github.com/fluxio/multierror" ) // Pool manages a pool of concurrent workers. It works a bit like a Waitgroup, but with error reporting and concurrency limits // You create one with New, and run functions with Run. Then you wait on it like a regular WaitGroup. type Pool struct { errors...
cc.go
0.658308
0.427397
cc.go
starcoder
package martini import ( "errors" "math" ) type Martini struct { GridSize int NumTriangles int NumParentTriangles int Indices []uint16 Coords []uint16 } func NewMartini(gridSize int) (*Martini, error) { mt := Martini{} mt.GridSize = gridSize tileSize := gridSize - 1 ...
martini.go
0.546738
0.475057
martini.go
starcoder
package quadtree import "github.com/taylorza/go-compgeo/pkg/geom2d" // QuadTree data structure used to index spacial data. The index opimizes queries looking for all the points that are within a specified area. type QuadTree struct { root *quadTreeNode maxPerNode int maxDepth int } // Option is a function...
pkg/quadtree/quadtree.go
0.870652
0.735713
quadtree.go
starcoder
package seqtree import ( "fmt" "github.com/KlyuchnikovV/stack" ) type SequentialAVLTree struct { root *Node size int } func New(data interface{}) *SequentialAVLTree { return &SequentialAVLTree{ root: newNode(data), size: 1, } } func (tree *SequentialAVLTree) Insert(data interface{}, position int) error {...
tree.go
0.645679
0.470919
tree.go
starcoder
package collection import "math" func geodeticDistAlgo(center [2]float64) ( algo func(min, max [2]float64, data interface{}, item bool) (dist float64), ) { const earthRadius = 6371e3 return func(min, max [2]float64, data interface{}, item bool) (dist float64) { return earthRadius * pointRectDistGeodeticDeg( c...
internal/collection/geodesic.go
0.834946
0.648188
geodesic.go
starcoder
package bulkprocess import ( "fmt" "image" "image/color" "image/draw" "strconv" ) // ImageGrid is a hack that converts a SAX stack (structured as all 50 // timepoints for series 1, all 50 timepoints for series 2, etc) into a grid // that simultaneously shows each series side-by-side. It highlights the active // ...
ukbb/bulkprocess/imagegrid.go
0.626467
0.595757
imagegrid.go
starcoder
package types import "fmt" func isNamed(typ Type) bool { if _, ok := typ.(*Basic); ok { return ok } _, ok := typ.(*Named) return ok } func isBoolean(typ Type) bool { t, ok := typ.Underlying().(*Basic) return (ok && t.info&IsInteger != 0) || isPointer(typ.Underlying()) } func isInteger(typ Type) bool { t, o...
src/subc/types/predicates.go
0.664214
0.41324
predicates.go
starcoder
package insightstore import ( "fmt" "time" "github.com/pipe-cd/pipe/pkg/model" ) // deploy frequency // DeployFrequencyChunk represents a chunk of DeployFrequency data points. type DeployFrequencyChunk struct { AccumulatedTo int64 `json:"accumulated_to"` DataPoints DeployFrequencyDataPoi...
pkg/insightstore/chunk.go
0.77949
0.587292
chunk.go
starcoder
package vect import ( "math" ) type Float float32 var ( Vector_Zero = Vect{0, 0} ) func FMin(a, b Float) Float { if a > b { return b } return a } func FAbs(a Float) Float { if a < 0 { return -a } return a } func FMax(a, b Float) Float { if a > b { return a } return b } func FClamp(val, min, max ...
chipmunk/vect/vect.go
0.879348
0.59305
vect.go
starcoder
package prometheusextension import ( "fmt" "math" "sort" "sync" "github.com/prometheus/client_golang/prometheus" dto "github.com/prometheus/client_model/go" ) // WeightedHistogram generalizes Histogram: each observation has // an associated _weight_. For a given `x` and `N`, // `1` call on `ObserveWithWeight(x...
staging/src/k8s.io/component-base/metrics/prometheusextension/weighted_histogram.go
0.796372
0.484258
weighted_histogram.go
starcoder
package vec import ( "math" "github.com/angelsolaorbaiceta/inkmath/nums" ) // A ReadOnlyVector is a Vector whose operations never mutate the internal state. type ReadOnlyVector interface { /* Properties */ Length() int Norm() float64 /* Methods */ Value(i int) float64 Opposite() ReadOnlyVector Scaled(facto...
vec/vector.go
0.877188
0.683439
vector.go
starcoder
package sliceutils import "golang.org/x/exp/constraints" // Filter - given a slice of type T, executes the given predicate function on each element in the slice. // The predicate is passed the current element, the current index and the slice itself as function arguments. // If the predicate returns true, the value i...
sliceutils/sliceutils.go
0.879561
0.66815
sliceutils.go
starcoder
package tsppd import ( "encoding/json" "math" "strings" ) // Problem represents a TSPPD instance. type Problem struct { Name string Comment string Nodes []string Precedence map[string]string Edges [][]int64 index map[string]int } // Decode converts a JSON byte array into a TSPPD Problem ...
tsppd/problem.go
0.743634
0.472988
problem.go
starcoder
package voxel import noise "github.com/ojrac/opensimplex-go" // ChunkSize - size of chunk on all sides const ChunkSize = 16 // Chunk struct type Chunk struct { X, Y, Z int Blocks [ChunkSize][ChunkSize][ChunkSize]Block } // NewChunk - creates a new chunk pointer func NewChunk(x, y, z int) *Chunk { var c Chunk c...
server/engine/voxel/chunk.go
0.67694
0.525612
chunk.go
starcoder
package main import ( "bufio" "io" "math" "strconv" "strings" "unicode" ) var _ = declareDay(10, func(part2 bool, inputReader io.Reader) interface{} { points := day10Parse(inputReader) elapsed := points.minimizeArea() if part2 { return elapsed } return points.String() }) func day10Parse(inputReader io.R...
day10.go
0.538498
0.434761
day10.go
starcoder
package core import ( "github.com/pingcap/tidb/expression" "github.com/pingcap/tidb/parser/model" ) const ( collectPredicateColumns uint64 = 1 << iota collectHistNeededColumns ) // columnStatsUsageCollector collects predicate columns and/or histogram-needed columns from logical plan. // Predicate columns are th...
planner/core/collect_column_stats_usage.go
0.65368
0.532547
collect_column_stats_usage.go
starcoder
package main import ( "bufio" "fmt" "os" ) func main() { // A 'map' is a reference to the data structure created by 'make' counts := make(map[string]int) // The 'os' package provides functions and other values for dealing with the platform- // independent fashion // os.Args is a slice of strings; this examp...
golang/dup.go
0.501221
0.443661
dup.go
starcoder
package reporting import ( "sort" "strings" ) type SparseTable struct { // title for the entire table title string // rows contains the captions for each row rows []string // rowWidth is the length of the longest row caption rowWidth int // cols contains the captions for each column cols []string // colWid...
v2/tools/generator/internal/reporting/sparse_table.go
0.734024
0.566558
sparse_table.go
starcoder
package z85 import ( "bytes" "encoding/binary" "github.com/nofeaturesonlybugs/errors" ) var ( encoder = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#" decoder = []byte{ 0x00, 0x44, 0x00, 0x54, 0x53, 0x52, 0x48, 0x00, 0x4B, 0x4C, 0x46, 0x41, 0x00, 0x3F, 0x3E, 0x45, 0...
z85.go
0.561696
0.400603
z85.go
starcoder
package dbx import ( "database/sql" "reflect" "strings" "github.com/pkg/errors" ) var iScanner = reflect.TypeOf((*sql.Scanner)(nil)).Elem() func isScalar(tValue reflect.Type) bool { if tValue.Kind() == reflect.Ptr { tValue = tValue.Elem() } if tValue.String() == "time.Time" { return true } if isScanne...
dbx/helpers.go
0.571288
0.454291
helpers.go
starcoder
package btcec import ( "fmt" ) // getDoublingPoints returns all the possible G^(2^i) for i in // 0..n-1 where n is the curve's bit size (256 in the case of secp256k1) // the coordinates are recorded as Jacobian coordinates. func (curve *KoblitzCurve) getDoublingPoints() [][3]fieldVal { bitSize := curve.Params().Bi...
gensecp256k1.go
0.621541
0.412944
gensecp256k1.go
starcoder
package n0715 import "sort" type Range struct { Left, Right int } type RangeModule struct { SortedRanges []Range } func Constructor() RangeModule { return RangeModule{SortedRanges: make([]Range, 0)} } func (this *RangeModule) AddRange(left int, right int) { newRange := []Range{} i := 0 var mergeRangeLeft = le...
src/n0715/solution.go
0.583915
0.449695
solution.go
starcoder
package fields import ( "fmt" "github.com/twuillemin/modes/pkg/bitutils" ) // AltitudeStatus is the status of the Altitude type AltitudeStatus byte const ( // AltitudeInvalid signifies that altitude information is not available or that the altitude has been determined invalid. AltitudeInvalid AltitudeStatus = 0 ...
pkg/acas/ra/fields/threat_identity_altitude.go
0.729809
0.44071
threat_identity_altitude.go
starcoder
package ad import ( "math" "reflect" ) // ElementalGradientFunc accepts the function value and the // parameters and returns a vector of partial gradients. // Depending on the function, either the value or the parameters // may be ignored in the computation of the gradient. type ElementalGradientFunc func(value flo...
ad/elementals.go
0.744378
0.472683
elementals.go
starcoder
package main import ( "encoding/json" "fmt" "math" "os" "strings" ) type NumberNode struct { left *NumberNode right *NumberNode value int } func ParseTokenTree(tokenTree []interface{}) NumberNode { if len(tokenTree) != 2 { panic("Expected a pair of 2 elements!") } newNode := NumberNode{nil, nil, 0} s...
18-go/Snailfish.go
0.636014
0.460471
Snailfish.go
starcoder
package xmath import ( "fmt" "math" "math/big" ) // Real is a big.Float like implementation for real numbers. // It rounds the big.Float to half away from zero by given precision and base after all of writing operations. // A Real can be created with new(Real) or NewReal and etc. // A Real which is created by new(...
real.go
0.793786
0.493836
real.go
starcoder
package story import ( "fmt" "math" "github.com/asahnoln/mesproc/pkg/store" ) // Step is a building block of a story. // It holds information on what message it expects from the user to advance the story // and how it would respond to proper or a wrong message. type Step struct { expectation string responses ...
pkg/story/step.go
0.801936
0.55941
step.go
starcoder
package tfutil import ( "fmt" tf "github.com/tensorflow/tensorflow/tensorflow/go" "github.com/tensorflow/tensorflow/tensorflow/go/op" ) // ApplyOperators successively applies operators (last one first) // For instance if the operator list is [op1, op2, op3], // then it will be executed as op1(op2(op3(input))) fun...
pkg/tfutil/apply.go
0.767254
0.490602
apply.go
starcoder
package palette import "github.com/pegasus-toolset/color" // Eclipse represents the Eclipse-style palette. var Eclipse = color.Palette{ color.RGB{R: 166, G: 202, B: 240}, color.RGB{R: 192, G: 220, B: 192}, color.RGB{R: 192, G: 192, B: 192}, color.RGB{R: 0, G: 128, B: 128}, color.RGB{R: 128, G: 0, B: 128}, color...
palette/eclipse.go
0.703549
0.517632
eclipse.go
starcoder
package sqlchemy // Filter method filters a SQL query with given ICondition // equivalent to add a clause in where conditions func (tq *SQuery) Filter(cond ICondition) *SQuery { if tq.groupBy != nil && len(tq.groupBy) > 0 { if tq.having == nil { tq.having = cond } else { tq.having = AND(tq.having, cond) ...
vendor/yunion.io/x/sqlchemy/filter.go
0.829906
0.493531
filter.go
starcoder
package sliceutils import ( "github.com/pkg/errors" ) // BoolSelect returns a slice containing the elements at the given indices of the input slice. // CAUTION: This function panics if any index is out of range. func BoolSelect(a []bool, indices ...int) []bool { if len(indices) == 0 { return nil } result := ma...
pkg/sliceutils/gen-builtins-generic_base.go
0.849316
0.584271
gen-builtins-generic_base.go
starcoder
package ewkb import ( "database/sql/driver" "errors" "fmt" "github.com/kcasctiv/go-ewkb/geo" ) // MultiPolygon presents MultiPolygon geometry object type MultiPolygon struct { header mp geo.MultiPolygon } // NewMultiPolygon returns new MultiPolygon, // created from geometry base and coords data func NewMultiP...
multi_polygon.go
0.776962
0.419172
multi_polygon.go
starcoder
package model import ( "fmt" "reflect" "strconv" ) type ( //PlayerBasicBox represents a players basic statlines in a game PlayerBasicBox struct { Name string MP string `bref:"mp"` FG int `bref:"fg"` FGA int `bref:"fga"` FGPct float64 `bref:"fg_pct"` ThreeP int...
model/player.go
0.574156
0.410993
player.go
starcoder
package ast // A Visitor's Visit method is invoked for each node encountered by Walk. // If the result visitor w is not nil, Walk visits each of the children // of node with the visitor w, followed by a call of w.Visit(nil). type Visitor interface { Visit(node Node) (w Visitor) } // Walk traverses an AST in depth-fi...
ast/walk.go
0.710427
0.438845
walk.go
starcoder
package findorder /* * @lc app=leetcode id=210 lang=golang * * [210] Course Schedule II * * https://leetcode.com/problems/course-schedule-ii/description/ * * algorithms * Medium (34.19%) * Total Accepted: 143.4K * Total Submissions: 415.2K * Testcase Example: '2\n[[1,0]]' * * There are a total of n co...
210-findorder/210.course-schedule-ii.go
0.819316
0.580084
210.course-schedule-ii.go
starcoder
package iso20022 // Provides the details of each individual foreign exchange swap transaction. type ForeignExchangeSwapTransaction2 struct { // Defines the status of the reported transaction, that is details on whether the transaction is a new transaction, an amendment of a previously reported transaction, a cancell...
ForeignExchangeSwapTransaction2.go
0.820685
0.582847
ForeignExchangeSwapTransaction2.go
starcoder
package contracts import ( "os" "sync" "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/assert" "github.com/adamluzsi/testcase/random" ) type CustomTB struct { NewSubject func(testing.TB) testcase.TBRunner } func (spec CustomTB) Test(t *testing.T) { spec.Spec(t) } func (spec CustomTB...
contracts/CustomTB.go
0.600657
0.633212
CustomTB.go
starcoder
package raftbench // raftbench provides common benchmarking functions which can be used by // anything which implements the raft.LogStore and raft.StableStore interfaces. // All functions accept these interfaces and perform benchmarking. This // makes comparing backend performance easier by sharing the tests. import ...
go-lang/go/src/github.com/hashicorp/raft/bench/bench.go
0.668123
0.498047
bench.go
starcoder
// Package ecdsa implements the Elliptic Curve Digital Signature Algorithm, as // defined in FIPS 186-3. package ecdsa // References: // [NSA]: Suite B implementer's guide to FIPS 186-3, // http://www.nsa.gov/ia/_files/ecdsa.pdf // [SECG]: SECG, SEC1 // http://www.secg.org/download/aid-780/sec1-v2.pdf im...
src/pkg/crypto/ecdsa/ecdsa.go
0.809953
0.403655
ecdsa.go
starcoder
package astmodel import ( "fmt" "github.com/pkg/errors" ) // Types is a map of TypeName to TypeDefinition, representing a set of types. type Types map[TypeName]TypeDefinition // Add adds a type to the set, with safety check that it has not already been defined func (types Types) Add(def TypeDefinition) { key := ...
hack/generator/pkg/astmodel/types.go
0.7917
0.474875
types.go
starcoder
package utils import ( "crypto/sha256" "github.com/Fantom-foundation/lachesis-base/common/littleendian" "github.com/Fantom-foundation/lachesis-base/hash" "github.com/Fantom-foundation/lachesis-base/inter/pos" ) type weightedShuffleNode struct { thisWeight pos.Weight leftWeight pos.Weight rightWeight pos.Wei...
utils/weighted_shuffle.go
0.793746
0.40295
weighted_shuffle.go
starcoder
package draw2d import ( "math" ) type PathConverter struct { converter VertexConverter ApproximationScale, AngleTolerance, CuspLimit float64 startX, startY, x, y float64 } func NewPathConverter(converter VertexConverter) *PathConverter { ...
src/code.google.com/p/draw2d/draw2d/path_converter.go
0.669313
0.451387
path_converter.go
starcoder
package freshservice import ( "context" "fmt" fs "github.com/theapsgroup/go-freshservice/freshservice" "github.com/turbot/steampipe-plugin-sdk/v3/grpc/proto" "github.com/turbot/steampipe-plugin-sdk/v3/plugin" "github.com/turbot/steampipe-plugin-sdk/v3/plugin/transform" ) func tableProblem() *plugin.Table { ret...
freshservice/table_problem.go
0.590897
0.411288
table_problem.go
starcoder
package shortuuid import ( "fmt" "math" "math/big" "strings" "github.com/google/uuid" ) type base57 struct { // alphabet is the character set to construct the UUID from. alphabet alphabet } // Encode encodes uuid.UUID into a string using the least significant bits // (LSB) first according to the alphabet. if...
base57.go
0.73077
0.405007
base57.go
starcoder
package dynamicvector import ( "sync" "time" "github.com/golang/protobuf/proto" "github.com/prometheus/client_golang/prometheus" dto "github.com/prometheus/client_model/go" ) // Histogram is a histogram dynamicvector type Histogram struct { *Vector } // NewHistogram will return a new dynamicvector histogram....
histogram.go
0.845177
0.541288
histogram.go
starcoder
package midas import ( "math" ) func max(a float64, b float64) float64 { if a > b { return a } return b } func biggest(values []int) int { b := values[0] for _, v := range values { if b < v { b = v } } return b } type MidasModel struct { curCount *EdgeHash totalCount *EdgeHash curT int } // Cr...
midas.go
0.708818
0.456894
midas.go
starcoder
package main /* Day 10: Knot Hash 3, 4, 1, 5 Begin with a list of numbers from 0 to 255, a current position which begins at 0 (the first element in the list), a skip size (which starts at 0), and a sequence of lengths (your puzzle input). Then, for each length: * Reverse the order of that length of elements in the...
2017/10-knot-hash/main.go
0.599954
0.576959
main.go
starcoder
package draw2dimg import ( "image" "image/color" "image/draw" "math" "bosun.org/_third_party/github.com/llgcode/draw2d" ) // ImageFilter defines the type of filter to use type ImageFilter int const ( // LinearFilter defines a linear filter LinearFilter ImageFilter = iota // BilinearFilter defines a bilinea...
_third_party/github.com/llgcode/draw2d/draw2dimg/rgba_interpolation.go
0.752286
0.53783
rgba_interpolation.go
starcoder
package rtph264 // naluType is the type of a NALU. type naluType uint8 // NALU types, augmented for RTP. const ( naluTypeNonIDR naluType = 1 naluTypeDataPartitionA naluType = 2 naluTypeDataPartitionB naluType = 3 naluTypeDataPartitionC naluType =...
pkg/rtph264/nalutype.go
0.500488
0.469034
nalutype.go
starcoder
package imaging import ( "image" "image/color" "math" ) // FlipH flips the image horizontally (from left to right) and returns the transformed image. func FlipH(img image.Image) *image.NRGBA { src := toNRGBA(img) srcW := src.Bounds().Max.X srcH := src.Bounds().Max.Y dstW := srcW dstH := srcH dst := image.New...
vendor/github.com/disintegration/imaging/transform.go
0.901283
0.545286
transform.go
starcoder
package byteutils import ( "bytes" "math/big" "sort" "strings" "github.com/centrifuge/go-centrifuge/errors" "github.com/centrifuge/go-centrifuge/utils" "github.com/ethereum/go-ethereum/common/hexutil" ) // AddZeroBytesSuffix appends zero bytes such that result byte length == required func AddZeroBytesSuffix(d...
utils/byteutils/bytes.go
0.751739
0.415254
bytes.go
starcoder
package crontab import ( "fmt" "math" "strconv" "strings" ) func getRange(expr string, r bounds) (uint64, error) { var ( start, end, step uint rangeAndStep = strings.Split(expr, "/") lowAndHigh = strings.Split(rangeAndStep[0], "-") singleDigit = len(lowAndHigh) == 1 err erro...
pkg/crontab/parse.go
0.533154
0.40592
parse.go
starcoder
package js // Object is a container for a native JavaScript object. Calls to its methods are treated specially by GopherJS and translated directly to their JavaScript syntax. type Object interface { // Get returns the object's property with the given key. Get(key string) Object // Set assigns the value to the obj...
frontend/js/js.go
0.824991
0.547041
js.go
starcoder
package ediscovery import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // RedundancyDetectionSettings type RedundancyDetectionSettings struct { // Stores additional data not described in the OpenAPI description found when des...
models/ediscovery/redundancy_detection_settings.go
0.715523
0.415136
redundancy_detection_settings.go
starcoder
package scanner import ( "unicode" "github.com/PaulioRandall/scarlet-go/scarlet/token" ) type ( // ParseToken is designed to be used in a recursice fashion. It returns a // lexeme and another ParseToken function to obtain the subsequent lexeme. // On the last lexeme the ParseToken will be nil. Parsing may also ...
scarlet/scanner/scanner.go
0.578448
0.480966
scanner.go
starcoder
package camera import ( "engine/core" "engine/math32" ) // Perspective is a perspective camera. type Perspective struct { Camera // Embedded camera fov float32 // field of view in degrees aspect float32 // aspect ratio (width/height) near float32 // ...
camera/perspective.go
0.919688
0.534127
perspective.go
starcoder