Skip to content

Instantly share code, notes, and snippets.

bairuw7rip5rabgdvot3trp6dudhwewxhtst5nooioecnxnunfea
@sanatgersappa
sanatgersappa / sudoku.clj
Created April 24, 2020 12:04 — forked from orb/sudoku.clj
updated for the latest core.logic, with some minor tweaks for (I hope) clarity
(ns sudoku
(:refer-clojure :exclude [==])
(:use [clojure.core.logic])
(:require [clojure.core.logic.fd :as fd]))
(defn init-board [vars puzzle]
(matche [vars puzzle]
([[] []]
succeed)
(defn distinct-by [f n] (map first (vals (group-by f n))))

Keybase proof

I hereby claim:

  • I am sanatgersappa on github.
  • I am sanatgersappa (https://keybase.io/sanatgersappa) on keybase.
  • I have a public key ASBGNtlX3A54K29ZljNFsNlEPmqnvU1mac-IVyrPFrI8xQo

To claim this, I am signing this object:

package main
//implements the SFTP Service. Needs to be installed and managed using NSSM.
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
"os"
(defn get-digit [n]
(cond
(nil? n) "_"
(nil? (re-find #"\d" (str n))) ""
:else n))
(defn get-char [n]
(cond
(nil? n) "_"
(nil? (re-find #"[A-Za-z]" (str n))) ""
(def people [
{:Name "Bob", :Age 31}
{:Name "John" :Age 42}
{:Name "Michael" :Age 17}
{:Name "Jenny" :Age 26}
]
)
(println people)
(println (sort-by :Age people))
package main
import (
"fmt"
"sort"
)
type Person struct {
Name string
Age int
(defn relevant? [n]
"returns true if n is divisible by 3 or 5"
(or (= 0 (rem n 3)) (= 0 (rem n 5))))
(reduce + (filter relevant? (range 1000)))
package main
import "fmt"
func main() {
for i := 1; i <= 100; i++ {
if i%15 == 0 { //divisible by 5 and 3
fmt.Println("FizzBuzz")
} else if i%5 == 0 { //divisible by 5