Showing posts with label fun. Show all posts
Showing posts with label fun. Show all posts

Friday, June 17, 2011

Yet another Great doodle!




Google's new doodle eclipses everything


"this doodle not only shows you the moon's movement, but allows you to move a dial as far backwards and forwards as you like in order to observe whichever minute detail takes your fancy."


This is amazing! In fact many of Google's doodles are awesome. Yet another one I love is this, for pacman!

BTW, I learned of this when searching for this article, it is amazing too - Les paul!

Monday, January 24, 2011

Nice putnam question

Prove that this is not prime for any n.

I found this question in putnam question paper and it has real elegant solution too.
It is too good to not to solve it yourself.

Monday, February 4, 2008

Tuesday, March 27, 2007

Monday, March 26, 2007

Are you colour blind?

Check whether you are colour blind at:
www.geocities.com/Heartland/8833/coloreye.html

Only males are generally colour blind, that too generally for Red-Green. See
Videos of Professor Koch on neural science! for details.

Friday, February 23, 2007

solution to Interesting puzzle about baby girls!

Scheme solution to Interesting puzzle about baby girls!
;Written by Fakrudeen Ali Ahmed
;Date January 12, 2007
(define (try n tries)
(define (populate girls boys people tries)
(if (or (= tries 0) (= people 0)) (list girls boys)
(let ((moregirls (countgirls people))) (begin ;(display moregirls)(newline)
(populate (+ girls moregirls) (+ boys (- people moregirls)) (- people moregirls) (- tries 1))))
)
)
(populate 0 0 n tries)
)

(define (countgirls n)
(define (loop k count)
(if (> k n) count
(loop (+ k 1) (+ count (random 2)))
)
)
(loop 1 0)
)

(define (run file n limit repeat)(with-output-to-file file (lambda()(loop (lambda()(begin (display (try n limit))(newline))) repeat))))

Wednesday, February 21, 2007

Fastest way to fibonacci number!

;Written by Fakrudeen Ali Ahmed
;December 30, 2006

(define matrix-upperleft (lambda(x)(car x)) )
(define matrix-upperright (lambda(x)(cadr x)))
(define matrix-lowerleft (lambda(x)(caddr x)))
(define matrix-lowerright (lambda(x)(cadddr x)))

(define (mmul matrix1 matrix2)
(list
; upperLeft*right.upperLeft + upperRight*right.lowerLeft,
(+ (* (matrix-upperleft matrix1) (matrix-upperleft matrix2))
(* (matrix-upperright matrix1) (matrix-upperright matrix2)))
; upperLeft*right.upperRight + upperRight*right.lowerRight,
(+ (* (matrix-upperleft matrix1) (matrix-upperright matrix2))
(* (matrix-upperright matrix1) (matrix-lowerright matrix2)))
; lowerLeft*right.upperLeft + lowerRight*right.lowerLeft,
(+ (* (matrix-lowerleft matrix1) (matrix-upperleft matrix2))
(* (matrix-lowerright matrix1) (matrix-lowerleft matrix2)))
; lowerLeft*right.upperRight + lowerRight*right.lowerRight);
(+ (* (matrix-lowerleft matrix1) (matrix-upperright matrix2))
(* (matrix-lowerright matrix1) (matrix-lowerright matrix2)))
))
(define b '(1 1 1 0))
(define i '(1 0 0 1))

(define (power-res n power value residue)
(list
(mmul value value)
(if (= 0 (fix:and n power)) residue (mmul residue value))
))

(define (loop n power list)
(if (< (/ n 2) power) (mmul (car list) (cadr list)) (loop n (fix:lsh power 1) (power-res n power (car list) (cadr list))) )) (define (fib n) (cadr (loop n 1 (list b i))))

Friday, December 29, 2006

Prime numbers!

Here is a simple scheme program to generate prime numbers in scheme.
;Written by Fakrudeen Ali Ahmed
;Date 9 January 2007
;primes above a bound
(define (primes-above n count)
(define (loop k count)
(if (= count 0) '()
(if (prime? k) (begin (display k) (newline) (loop (+ k 1) (- count 1))) (loop (+ k 1) count))))
(loop n count)
)

;primes less than n
(define (primes-less-than n)
(define (loop k)
(if (= k n) '()
(begin (if (prime? k) (begin (display k) (newline))) (loop (+ k 1)))))
(loop 2)
)

;whether n is prime?
(define (prime? n)
(cond
((or (= n 2) (= n 3)) true)
((or(= 0 (remainder n 2)) (= 0 (remainder n 3))) false)
(else (let ((limit (expt n (/ 1 2))))
(define (loop k)
(let* ( (j (- (* 6 k) 1) ) (l (+ j 2)) )
(cond
((< limit j) true)

((or(= 0 (remainder n j)) (= 0 (remainder n l))) false)
(else (loop (+ 1 k))))))
(loop 1)))))