Skip to content

Instantly share code, notes, and snippets.

View macdavid313's full-sized avatar

gty macdavid313

View GitHub Profile
@macdavid313
macdavid313 / sharp-!.lisp
Last active March 26, 2024 23:50
Reading multiple lines of string in Common Lisp
(in-package #:cl-user)
(defun sharp-exclamation-mark (stream _c _arg)
(declare (ignore _c _arg))
(with-output-to-string (s)
(do ((level 1)
(prev (read-char stream) char)
(char (read-char stream)
(read-char stream)))
(())
@macdavid313
macdavid313 / n-sum.ss
Last active March 25, 2024 05:15
nSum problem
;;;; n-sum.ss
;;; 1. Two sum problem: https://leetcode.com/problems/two-sum/
;;; 15. 3Sum problem: https://leetcode.com/problems/3sum/
;;; 167. Two Sum II - Input Array Is Sorted: https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/
;;; 18. 4Sum problem: https://leetcode.com/problems/4sum/
#!chezscheme
(library (n-sum)
(export n-sum)
(import (chezscheme))
@macdavid313
macdavid313 / while.lisp
Created October 31, 2022 01:47
while-lang
;;;; while.lisp
;;;; A solution to Hackerrank's While Language problem --
;;;; https://www.hackerrank.com/challenges/while-language-fp/problem
;;;; Author: Tianyu Gu (macdavid313@gmail.com)
(in-package #:cl-user)
(defpackage #:while
(:use #:cl)
(:nicknames #:while-lang)
(:export #:gen-lisp-code #:run-program))