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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: 'span', | |
actions: { | |
highlight(part, event) { | |
this.get('message').forEach((part) => { | |
part.set('isHighlighted', false); | |
}); |
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
;; Part 1 | |
(defun sum (list) | |
"Solution for Part #1 http://adventofcode.com/2017/day/1" | |
(let ((s 0) next-i next val (n (length list))) | |
(dotimes (i n) | |
(progn | |
(setq val (nth i list)) | |
(setq next-i (+ i 1)) | |
(when (= next-i n) (setq next-i 0)) | |
(setq next (nth next-i list)) |
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
(defun read-numbers-from-file (file-path) | |
(with-temp-buffer | |
(insert-file-contents file-path) | |
(mapcar | |
(lambda (arg) (mapcar 'string-to-number(split-string arg))) | |
(split-string (string-trim (buffer-string)) "\n" t) | |
) | |
) | |
) |
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
(defun size-of-square (N) | |
(let ((d 1)) | |
(loop | |
(when (>= (* d d) N) (return d)) | |
(setq d (+ d 2)) | |
) | |
) | |
) | |
(defun generate-empty-square (size) |
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
(defun read-words-from-file (file-path) | |
(with-temp-buffer | |
(insert-file-contents file-path) | |
(mapcar 'split-string (split-string (buffer-string) "\n" t)) | |
) | |
) | |
(defun is-all-unique (list predicate) | |
(let ((n (1- (length list))) (has-similar)) | |
(loop |
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
(defun read-words-from-file (file-path) | |
(with-temp-buffer | |
(insert-file-contents file-path) | |
(mapcar 'string-to-number (split-string (buffer-string) "\n" t)) | |
) | |
) | |
(read-words-from-file "./input.txt") | |
(defun escape-maze (list) |
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
(defun find-idx-of-max (list) | |
(let ((max_i 0) (val) (max)) | |
(dotimes (i (length list) max_i) | |
(setq val (nth i list)) | |
(setq max (nth max_i list)) | |
(when (> val max) (setq max_i i)) | |
) | |
) | |
) |
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
(defstruct node name weight parent) | |
(defun split-and-trim-each (&rest args) | |
(mapcar 'string-trim (apply 'split-string (append args (list t)))) | |
) | |
(defun parse-weight (str) | |
(string-to-number (substring str 1 -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
(defstruct statement instruction condition) | |
(defstruct instruction reg value op) | |
(defstruct condition reg value con) | |
;; 1. Parse each line as Instruction | |
;; 2. Create Memory hash table with regs name - value (default of each reg is 0) + | |
;; 3. Execute each Instruction populating Memory + | |
;; 4. The largest reg value in Memory + | |
;; Part 2 | |
;; 5. Add eval-after-statement hook for eval-statement |
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
(defun calculate-score (str) | |
(let ((list (split-string str "" t)) garbage (depth 0) (s 0) (g-count 0) ch) | |
(loop | |
for i from 0 to (1- (length list)) | |
do | |
(progn | |
(setq ch (nth i list)) | |
(cond | |
((string= ch "!") | |
(setq i (+ i 1)) |