This file contains 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
(ns dop) | |
(require '(clojure.string)) | |
(defn read-file | |
[filename] | |
(->> (slurp filename) | |
(clojure.string/split-lines) | |
(#(hash-map | |
:N (Integer/parseInt (nth % 0)) | |
:C (vec (nth % 1)) |
This file contains 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
M1:{"id":"./src/SearchField.client.js","chunks":["client5"],"name":""} | |
M2:{"id":"./src/EditButton.client.js","chunks":["client1"],"name":""} | |
S3:"react.suspense" | |
J0:["$","div",null,{"className":"main","children":[["$","section",null,{"className":"col sidebar","children":[["$","section",null,{"className":"sidebar-header","children":[["$","img",null,{"className":"logo","src":"logo.svg","width":"22px","height":"20px","alt":"","role":"presentation"}],["$","strong",null,{"children":"React Notes"}]]}],["$","section",null,{"className":"sidebar-menu","role":"menubar","children":[["$","@1",null,{}],["$","@2",null,{"noteId":null,"children":"New"}]]}],["$","nav",null,{"children":["$","$3",null,{"fallback":["$","div",null,{"children":["$","ul",null,{"className":"notes-list skeleton-container","children":[["$","li",null,{"className":"v-stack","children":["$","div",null,{"className":"sidebar-note-list-item skeleton","style":{"height":"5em"}}]}],["$","li",null,{"className":"v-stack","children":["$","div",null,{"className":"s |
This file contains 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
(ns w03) | |
(defn remove-nth | |
[n v] | |
(into (subvec v 0 n) (subvec v (inc n)))) | |
(defn valid-sol? | |
[sol] | |
(let [last-two (take-last 2 sol)] | |
(cond |
This file contains 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
// The make built-in function allocates and initializes an object of type | |
// slice, map, or chan (only). Like new, the first argument is a type, not a | |
// value. Unlike new, make's return type is the same as the type of its | |
// argument, not a pointer to it. The specification of the result depends on | |
// the type: | |
// Slice: The size specifies the length. The capacity of the slice is | |
// equal to its length. A second integer argument may be provided to | |
// specify a different capacity; it must be no smaller than the | |
// length. For example, make([]int, 0, 10) allocates an underlying array | |
// of size 10 and returns a slice of length 0 and capacity 10 that is |
This file contains 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
GOMAXPROCS=1 go test -v -bench=. -count=3 -run=none -benchmem | tee bench.txt | |
# run `go get -u golang.org/x/perf/cmd/benchstat` if benchstat failed | |
benchstat bench.txt |
This file contains 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 ( | |
"testing" | |
) | |
const it = uint(1 << 24) | |
func BenchmarkSetWithBoolValueWrite(b *testing.B) { | |
set := make(map[uint]bool) |
This file contains 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
type comparable interface { | |
type int, int8, int16, int32, int64, | |
uint, uint8, uint16, uint32, uint64, | |
float32, float64 | |
} | |
func Max[T comparable](x, y T) T { | |
return T(math.Max(float64(x), float64(y))) | |
} |
This file contains 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
func max(x, y int) int { | |
if x < y { | |
return y | |
} | |
return x | |
} |
This file contains 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
func max(x, y int) int { | |
return int(math.Max(float64(x), float64(y))) | |
} |
This file contains 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
(ns w01) | |
(def key-pad-1 [[\1 \2 \3] [\4 \5 \6] [\7 \8 \9]]) | |
(def key-pad-2 [[\0 \0 \1 \0 \0] [\0 \2 \3 \4 \0] [\5 \6 \7 \8 \9] [\0 \A \B \C \0] [\0 \0 \D \0 \0]]) | |
(def delta-map {\U [-1 0] \D [1 0] \L [0 -1] \R [0 1]}) | |
(defn read-file [filename] | |
(->> | |
(slurp filename) | |
(re-seq #"\w+"))) |
NewerOlder