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_easy_problem_173.clj
Last active November 3, 2022 14:37
Intro to Destructuring 2 – Rich 4Clojure Problem 173 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.easy.problem-173
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Intro to Destructuring 2 =
;; By 4Clojure user: hangkous
;; Difficulty: Easy
;; Tags: [Destructuring]
;;
;; Sequential destructuring allows you to bind symbols to
;; parts of sequential things (vectors, lists, seqs,
@PEZ
PEZ / rich4clojure_medium_problem_171.clj
Last active May 11, 2023 07:32
Intervals – Rich 4Clojure Problem 171 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.medium.problem-171
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Intervals =
;; By 4Clojure user: aiba
;; Difficulty: Medium
;;
;; Write a function that takes a sequence of integers and
;; returns a sequence of "intervals". Each interval is a a
;; vector of two integers, start and end, such that all
@PEZ
PEZ / rich4clojure_medium_problem_168.clj
Last active April 10, 2023 13:43
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 August 20, 2022 18:11
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 October 10, 2022 19:06
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 January 20, 2023 01:05
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 March 30, 2024 17: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: