This file contains hidden or 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
(defn find-possibles [j js] | |
(take-while #(<= % (+ j 3)) js)) | |
(defn possibilities [j js] | |
(cond | |
;; we've made it to the end of jolts, this is a possibility | |
(empty? js) | |
1 |
This file contains hidden or 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
const functions = require('firebase-functions'); | |
// The Firebase Admin SDK to access Cloud Firestore. | |
const admin = require('firebase-admin'); | |
admin.initializeApp(); | |
function createDB() { | |
let db = admin.firestore(); | |
let podoDoc = db.collection('android').doc('podo'); |
This file contains hidden or 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 purelyfun.382.core) | |
(defn uniques | |
[values] | |
(map first (filter #(= (count %) 1) (vals (group-by identity values))))) |
This file contains hidden or 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 purelyfun.379) | |
;; My solution to the weekly challenge here: | |
;; https://purelyfunctional.tv/issues/purelyfunctional-tv-newsletter-379-get-produces-unexpected-behavior-as-expected/ | |
(comment | |
;; My approach is to use a very basic LR parser. | |
;; First, I create a nested map datastructure to act as a lookup |
This file contains hidden or 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
(defrecord ListNode [value next]) | |
(defn add-node [^ListNode curr v] | |
(if curr | |
(assoc curr :next (add-node (:next curr) v)) | |
(ListNode. v nil))) | |
(def result | |
(loop [l nil i 0] | |
(if (< i 100000) |
This file contains hidden or 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
// Javascript uses 4 patterns of invoking a function. These all differ | |
// in the way that `this` is treated. The 4 patterns are: | |
// 1. method invocation | |
// 2. function invocation | |
// 3. constructor invocation | |
// 4. apply invocation | |
// 1. method invocation - When a function is stored as a property of | |
// an object, it's referred to as a "method" and `this` is bound to |
This file contains hidden or 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
;; Copyright (c) Alan Dipert and Micha Niskin. All rights reserved. | |
;; The use and distribution terms for this software are covered by the | |
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) | |
;; which can be found in the file epl-v10.html at the root of this distribution. | |
;; By using this software in any fashion, you are agreeing to be bound by | |
;; the terms of this license. | |
;; You must not remove this notice, or any other, from this software. | |
(ns upgradingdave.castra | |
(:require [cognitect.transit :as t] | |
[goog.labs.net.xhr :as gxhr]) |
This file contains hidden or 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
Given an array that looks like this: | |
[2 4 5 1 2 9 3 8 6 5 2 4 5 1 2 9 3 8 6 5] | |
This method will print something like this: | |
2 | |
4 5 | |
1 2 9 3 | |
8 6 5 |
This file contains hidden or 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
#include <iostream> | |
#include <string> | |
using namespace std; | |
void underscore2answer(string text, string answer){ | |
int text_idx = 0; | |
int answer_idx = 0; | |
for (int text_idx = 0; text_idx<text.length();text_idx++){ | |
if (text[text_idx] == '_'){ |
This file contains hidden or 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
Here's an example of tracing the variables thru the call: | |
permute(cat) | |
| word | f | r | i | next | result | res | | |
|------+---+----+---+------+----------------------------+----------------| | |
| cat | c | at | 0 | cat | permute(at) = ["at", "ta"] | ["cat", "cta"] | | |
| cat | | | | act | ... | ... | | |
permute(at) | |
| word | f | r | i | next | result | res | |
NewerOlder