Skip to content

Instantly share code, notes, and snippets.

View PEZ's full-sized avatar
🎯
Focusing

Peter Strömberg PEZ

🎯
Focusing
View GitHub Profile
@PEZ
PEZ / rich4clojure_medium_problem_168.clj
Last active January 9, 2025 22:15
Infinite Matrix – Rich 4Clojure Problem 168 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.medium.problem-168
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Infinite Matrix =
;; By 4Clojure user: maximental
;; Difficulty: Medium
;; Tags: [seqs recursion math]
;;
;; In what follows, m, n, s, t denote nonnegative
;; integers, f denotes a function that accepts two
@PEZ
PEZ / rich4clojure_easy_problem_166.clj
Last active November 16, 2024 15:24
Comparisons – Rich 4Clojure Problem 166 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.easy.problem-166
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Comparisons =
;; By 4Clojure user: daowen
;; Difficulty: Easy
;;
;; For any orderable data type it's possible to derive all
;; of the basic comparison operations (<, ≤, =, ≠, ≥, and
;; >) from a single operation (any operator but = or ≠
@PEZ
PEZ / rich4clojure_hard_problem_164.clj
Last active July 25, 2021 16:58
Language of a DFA – Rich 4Clojure Problem 164 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.hard.problem-164
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Language of a DFA =
;; By 4Clojure user: daowen
;; Difficulty: Hard
;; Tags: [automata seqs]
;;
;; A deterministic finite automaton (DFA) is an abstract
;; machine that recognizes a regular language. Usually a
@PEZ
PEZ / rich4clojure_elementary_problem_162.clj
Last active September 7, 2021 12:22
Logical falsity and truth – Rich 4Clojure Problem 162 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.elementary.problem-162
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Logical falsity and truth =
;; By 4Clojure user: hangkous
;; Difficulty: Elementary
;; Tags: [logic]
;;
;; In Clojure, only nil and false represent the values of
;; logical falsity in conditional tests - anything else is
@PEZ
PEZ / rich4clojure_elementary_problem_161.clj
Last active September 7, 2021 12:19
Subset and Superset – Rich 4Clojure Problem 161 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.elementary.problem-161
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Subset and Superset =
;; By 4Clojure user: hangkous
;; Difficulty: Elementary
;; Tags: [set-theory]
;;
;; Set A is a subset of set B, or equivalently B is a
;; superset of A, if A is "contained" inside B. A and B
@PEZ
PEZ / rich4clojure_medium_problem_158.clj
Last active January 7, 2025 22:13
Decurry – Rich 4Clojure Problem 158 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.medium.problem-158
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Decurry =
;; By 4Clojure user: amcnamara
;; Difficulty: Medium
;; Tags: [partial-functions]
;;
;; Write a function that accepts a curried function of
;; unknown arity n. Return an equivalent function of n
@PEZ
PEZ / rich4clojure_easy_problem_157.clj
Last active November 16, 2024 15:14
Indexing Sequences – Rich 4Clojure Problem 157 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.easy.problem-157
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Indexing Sequences =
;; By 4Clojure user: jaycfields
;; Difficulty: Easy
;; Tags: [seqs]
;;
;; Transform a sequence into a sequence of pairs
;; containing the original elements along with their
@PEZ
PEZ / rich4clojure_elementary_problem_156.clj
Last active October 15, 2024 10:01
Map Defaults – Rich 4Clojure Problem 156 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.elementary.problem-156
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Map Defaults =
;; By 4Clojure user: jaycfields
;; Difficulty: Elementary
;; Tags: [seqs]
;;
;; When retrieving values from a map, you can specify
;; default values in case the key is not found:
@PEZ
PEZ / rich4clojure_easy_problem_153.clj
Last active November 15, 2024 22:18
Pairwise Disjoint Sets – Rich 4Clojure Problem 153 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.easy.problem-153
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Pairwise Disjoint Sets =
;; By 4Clojure user: maximental
;; Difficulty: Easy
;; Tags: [set-theory]
;;
;; Given a set of sets, create a function which returns
;; true if no two of those sets have any elements in
@PEZ
PEZ / rich4clojure_hard_problem_152.clj
Last active July 25, 2021 16:57
Latin Square Slicing – Rich 4Clojure Problem 152 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.hard.problem-152
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Latin Square Slicing =
;; By 4Clojure user: maximental
;; Difficulty: Hard
;; Tags: [data-analysis math]
;;
;; A Latin square of order n is an n x n array that
;; contains n different elements, each occurring exactly