summaryrefslogtreecommitdiff
path: root/7-kyu/a-rule-of-divisibility-by-7.rkt
blob: 6859107cd0f0a4f9bb84dc6572493c626837ec2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#lang racket

;; https://www.codewars.com/kata/55e6f5e58f7817808e00002e

(provide seven)

(define (seven m)
  (define (impl cur steps)
    (define x (quotient cur 10))
    (define y (modulo cur 10))
    (define next (- x (* 2 y)))
    (if (< cur 100)
        (cons cur steps)
        (impl next (+ 1 steps))))
  (impl m 0))