From 8777ff071f7bb37631baa7b6717ad29961e50911 Mon Sep 17 00:00:00 2001 From: "H.J" Date: Wed, 9 Oct 2024 11:36:55 -0400 Subject: sorting by language --- leetcode/lc-1221-split-a-string-balanced.rkt | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 leetcode/lc-1221-split-a-string-balanced.rkt (limited to 'leetcode/lc-1221-split-a-string-balanced.rkt') diff --git a/leetcode/lc-1221-split-a-string-balanced.rkt b/leetcode/lc-1221-split-a-string-balanced.rkt deleted file mode 100644 index 4c75770..0000000 --- a/leetcode/lc-1221-split-a-string-balanced.rkt +++ /dev/null @@ -1,19 +0,0 @@ -#lang racket -(require rackunit) - -(define/contract (balanced-string-split s) - (-> string? exact-integer?) - (for/fold ([acc 0] - [count 0] - #:result count) - ([c (string->list s)]) - (let* ([increment (case c - [(#\R) 1] - [(#\L) -1])] - [new-acc (+ increment acc)] - [new-count (case new-acc - [(0) (add1 count)] - [else count])]) - (values new-acc new-count)))) - -(check-eq? (balanced-string-split "RLRRLLRLRL") 4) \ No newline at end of file -- cgit v1.2.3