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 <vector> | |
| #include <string> | |
| #include <unordered_map> | |
| #include <fstream> | |
| #include <utility> | |
| #include <algorithm> | |
| #include <cassert> | |
| #include <string_view> | |
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 consecsum (array) | |
| (loop :with res := (make-array 1 :adjustable t :fill-pointer 0) | |
| :with acc := (aref array 0) | |
| :for i :from 1 :below (length array) | |
| :for j := (- i 1) | |
| :if (= (aref array i) (aref array j)) | |
| :do (incf acc (aref array i)) | |
| :else | |
| :do (vector-push-extend acc res) | |
| (setf acc (aref array 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
| (defun diophantine-equation (a b) | |
| (declare (fixnum a) (fixnum b) | |
| (optimize (speed 3))) | |
| (let ((left-side-a 1) (left-side-b 0) | |
| (right-side-a 0) (right-side-b 1)) | |
| (declare (fixnum left-side-a) (fixnum left-side-b) | |
| (fixnum right-side-a) (fixnum right-side-b)) | |
| (loop :until (or (= 0 a) (= 0 b)) | |
| :if (> a b) |
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 tug-of-war (people) | |
| (declare (optimize (speed 3)) | |
| ((simple-array fixnum (*)) people)) | |
| (setf people (sort people #'>)) | |
| (let ((sum (reduce #'+ people))) | |
| (declare (fixnum sum)) | |
| (if (evenp sum) | |
| (let ((sum (floor sum 2))) | |
| (labels ((recursive-walk (upto currentsum) | |
| (declare (fixnum currentsum)) |
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
| 30 | |
| 14 | |
| 21 41 85 91 15 13 77 26 90 44 99 23 77 82 | |
| 11 | |
| 7 69 22 96 26 15 18 53 87 90 89 | |
| 39 | |
| 60 31 12 77 47 48 73 21 55 64 20 18 96 55 99 28 21 28 90 27 15 96 43 21 29 41 56 27 41 79 34 59 34 19 54 85 28 36 53 | |
| 14 | |
| 81 46 13 67 48 86 98 51 25 89 19 58 26 5 | |
| 13 |
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
| dnl AMD64 mpn_mul_1. | |
| dnl Copyright 2003-2005, 2007, 2008, 2012 Free Software Foundation, Inc. | |
| dnl This file is part of the GNU MP Library. | |
| dnl | |
| dnl The GNU MP Library is free software; you can redistribute it and/or modify | |
| dnl it under the terms of either: | |
| dnl | |
| dnl * the GNU Lesser General Public License as published by the Free |
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
| ;;;; cl-overload.lisp | |
| (in-package #:cl-overload) | |
| (defgeneric generic-find (item sequence &key test) | |
| (:generic-function-class fast-generic-functions:fast-generic-function)) | |
| (defmethod generic-find (item (list list) &key (test #'eql)) | |
| (and (member item list :test test) |
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
| (defpackage #:optimizations | |
| (:use #:cl) | |
| (:shadow #:+)) | |
| (in-package #:optimizations) | |
| (declaim (inline quaternion)) | |
| (defstruct quaternion |
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
| (defpackage #:optimizations | |
| (:use #:cl) | |
| (:shadow #:+)) | |
| (in-package #:optimizations) | |
| (declaim (inline quaternion)) | |
| (defstruct quaternion |
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
| CL-USER> (disassemble (lambda (a b) (declare (optimize (speed 3) (safety 0) (compilation-speed 0))) | |
| (declare (long-float a) (long-float b)) | |
| (+ a b))) | |
| ; disassembly for (LAMBDA (A B)) | |
| ; Size: 65 bytes. Origin: #x52C50EE0 ; (LAMBDA (A B)) | |
| ; EE0: F20F58D1 ADDSD XMM2, XMM1 | |
| ; EE4: 49896D28 MOV [R13+40], RBP ; thread.pseudo-atomic-bits | |
| ; EE8: 498B5568 MOV RDX, [R13+104] ; thread.alloc-region | |
| ; EEC: 4C8D5A10 LEA R11, [RDX+16] | |
| ; EF0: 4D3B5D70 CMP R11, [R13+112] |