Skip to content

Instantly share code, notes, and snippets.

View pavloo's full-sized avatar
🎯
Focusing

Pavlo Osadchyi pavloo

🎯
Focusing
View GitHub Profile
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'span',
actions: {
highlight(part, event) {
this.get('message').forEach((part) => {
part.set('isHighlighted', false);
});
;; 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))
(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)
)
)
)
(defun size-of-square (N)
(let ((d 1))
(loop
(when (>= (* d d) N) (return d))
(setq d (+ d 2))
)
)
)
(defun generate-empty-square (size)
(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
(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)
(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))
)
)
)
(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))
)
(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
(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))