Skip to content

Instantly share code, notes, and snippets.

Sid Heroor shortsightedsid

Block or report user

Report or block shortsightedsid

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@shortsightedsid
shortsightedsid / magic-squares.lisp
Created Apr 10, 2016
Check if a 2D Vector is a Magic Square
View magic-squares.lisp
;;; Magic Squares - https://www.reddit.com/r/dailyprogrammer/comments/4dccix/20160404_challenge_261_easy_verifying_3x3_magic/
(defun magic-square? (square)
(let* ((dims (array-dimensions square))
(size (car dims)))
(if (and (typep square 'simple-array)
(eq 2 (array-rank square))
(eq size (cadr dims)))
(loop for i from 0 below size
for j from 0 below size
View list-shuffler.lisp
;; Easy Daily Programmer https://www.reddit.com/r/dailyprogrammer/comments/3e0hmh/20150720_challenge_224_easy_shuffling_a_list/
(defun list-shuffler-recursive (input-list &optional accumulator)
"Shuffle a list using tail call recursion."
(if (eq input-list nil)
accumulator
(progn
(rotatef (car input-list)
(nth (random (length input-list)) input-list))
(list-shuffler-recursive (cdr input-list)
@shortsightedsid
shortsightedsid / eel-of-fortune.lisp
Created Jul 20, 2015
Find Problem words that can be offensive when playing "EEL of Fortune"
View eel-of-fortune.lisp
;; Solution for Reddit Daily Programmer problem -
;; https://www.reddit.com/r/dailyprogrammer/comments/3ddpms/20150715_challenge_223_intermediate_eel_of_fortune/
;; Elegant but incorrent solution -
;;
;; This is almost right except for the case when
;; checking for snond as a subword of mispronounced.
;; The naive understanding is that it should return t. However,
;; when looking at the sequence at which letters are called out
;; in EEL of Fortune, one never sees snond. Instead we see
@shortsightedsid
shortsightedsid / multiplication-tables.lisp
Last active Mar 24, 2019
Print Multiplication Tables
View multiplication-tables.lisp
;; Print Multiplication Tables
;;
;; This demonstrates CL's format function and it's ability
;; to print out Roman Numerals, Numbers in Words etc..
;;
;; Unlikely to be ever used!
(defun multiplication-table (number)
(loop for i from 1 below 12
do (format t "~10<~@r~;times~> ~:d = ~r~%" i number (* i number))
@shortsightedsid
shortsightedsid / garland.lisp
Last active Aug 29, 2015
Garland Word length calculator in Common Lisp
View garland.lisp
;; See https://www.reddit.com/r/dailyprogrammer/comments/3d4fwj/20150713_challenge_223_easy_garland_words/
;;
;; A Garland word is one that starts and ends with the same N letters in the same order,
;; for some N greater than 0, but less than the length of the word.
;; Eg. onion -> 2
;; ceramic -> 1
;; programmer -> 0
;; alfalfa -> 4
@shortsightedsid
shortsightedsid / cl-udpip.lisp
Created Oct 27, 2014
Short guide to UDP/IP Client/Server programming in Common Lisp using usockets
View cl-udpip.lisp
; Short guide to UDP/IP Client/Server programming in Common Lisp using usockets
;
; The main reason for this guide is because there are very few examples that
; explain how to get started with socket programming with Common Lisp that I
; could understand.
; After working on a short example on TCP, I found the
; need for a UDP tutorial. So, here goes.
; As usual, we will use quicklisp to load usocket.
@shortsightedsid
shortsightedsid / cl-tcpip.lisp
Last active Dec 7, 2019
Short guide to TCP/IP Client/Server programming in Common Lisp using usockets
View cl-tcpip.lisp
; Short guide to TCP/IP Client/Server programming in Common Lisp using usockets
;
; The main reason for this guide is because there are very few examples that
; explain how to get started with socket programming with Common Lisp that I
; could understand. After spending a day trying, I finally came up with a small
; bit of code that makes it easy to understand the basics. I've written this
; primarily for myself, but should help others get started as well.
; As usual, we will use quicklisp to load usocket.
View hello_world_clpdf.lisp
;; CL-PDF Hello World
;;
;; Use ASDF to load the CL-PDF library
;;
(asdf:operate 'asdf:load-op 'cl-pdf)
;;
;; Function to generate a Hello World pdf file.
;; On calling this function, you should see a pdf file
You can’t perform that action at this time.