Scheme: Kan, Ga and Roo Race

The Problem:

Three runners, Kan, Ga and Roo took part in a cross country race. Prior to the race,
four spectators from the audience, A, B, C, and D, made their prognoses, as follows:
A: Either Kan or Ga will win.
B: If Ga is the second, Roo will win.
C: If Ga is the third, Kan will not win.
D: Either Ga or Roo will be the second.

After the race, it turned out that all four statements were correct. In what order did the runners finish?
1. Kan, Ga, Roo 
2. Kan, Roo, Ga 
3. Roo, Ga, Kan 
4. Ga, Roo, Kan 
5. Impossible to determine

Every statement must be converted into an equivalent formula that is in CNF (conjunctive normal form), therefore all patterns of match are OR joined ( is a disjunction of simple terms) and matches are AND joined ( is a conjunction of statements).

The Solution:

(define (check-race-result x)
  (and
   ;prognose A - Either Kan or Ga will win
   (match x
     [(list 'Kan _ _) #t]
     [(list 'Ga _ _) #t]
     [_ #f]
    )

    ;prognose B - If Ga is the second, Roo will win.
    (match x
      [(list 'Roo _ _) #t]
      [(not (list  _ 'Ga _ )) #t]
      [_ #f]
    )
   
   ;prognose C -  If Ga is the third, Kan will not win
    (match x
      [(not (list 'Kan _ _)) #t]
      [(not (list _ _ 'Ga)) #t]
      [_ #f]
    )
   
   ;prognose D - Either Ga or Roo will be the second.
   (match x
     [(list _  'Ga _) #t]
     [(list _ 'Roo _) #t]
     [_ #f]
    )
  )
)

(filter check-race-result (permutations '(Kan Ga Roo)))

Google OAuth credentials don't persist across TB sessions

I am using latest Thunderbird with built in calendar and Provider for Google Calendar 1.0.4
It was the issue that Google OAuth credentials don't persist across TB sessions with constant OAuth popups, and lack of using the saved OAuth credentials. I have checked firewall, antivirus, smart security and so on. without success.

We never read manuals, oh! It was just necessary to enter email on "new calendar create" form!



1. Remove all google calendar
2. Create new calendar
3. Enter email into "pickup an existing session or enter your email address" input field
4. In following pop up window you should enter only password!

Enjoy!

VMware error: VMnetDHCP - No subnet declaration for VMnet

VMware Workstation 12 Player

I have rewritten as always the files vmnetdhcp.conf and vmnetnat.conf to keep infrastructure consistent and it appears error message in EventViewer "No subnet declaration for VMnet8 (192.168.113.1). Please write a subnet declaration for the network segment to which interface VMnet8 is attached."

I have found that vmnetdcp.exe looks for value in registry
HKLM\System\CurrentControlSet\services\VMnetDHCP\Parameters\VirtualEthernetSegments\1\HostIpAddress

The registry key was still containing old IP address and didn't allow to start DHCP service. You should change it to actual one.
Please note that address has reverse HEX notation. e.g.
192.168.1.1 is reversed to 1.1.168.192 and key value is 0101A8C0


Enjoy!

Scheme: Another Math Kangaroo Problem

with quick solution

Under the numbers {1, 4, 8, 10, 20, 25, 50} there are three, the product is 100. 
What is the sum of these three numbers?

Let's define combination function to find all possible sets of three numbers and shortcut for product.

(define (combinations k nlst)
  (cond ((zero? k)
         '(()))
        ((null? nlst)
         '())
        (else
         (append (map (lambda (k-1)
                        (cons (car nlst) k-1))
                      (combinations (- k 1) (cdr nlst)))
                 (combinations k (cdr nlst))))))

(define (product xlst)
  (foldl * 1 xlst))

(filter (lambda(x) (= (product x) 100)) (combinations 3 '(1 4 8 10 20 25 50 )))

Answer is 30 and set is {1, 4, 25}

Enjoy!

Scheme: Math Kangaroo Contest 2013



It was really nice question at Math Kangaroo Contest 2013
Four cars enter a roundabout at the same time, each one from a different
direction, as shown in the diagram. Each of the cars drives less than a full
round of the roundabout, and no two cars leave the roundabout in the
same direction. How many different ways are there for the cars to leave
the roundabout? 

I would like to introduce elegant solution in scheme
(let ([src '(A B C D)])
 (length ( filter-not
           (lambda(x)
             (ormap eq? x src))
           (permutations src)) )
  
)

So you can find correct answer for four cars (9) , five cars (44) and more

Enjoy!

HOWTO: Repair Logitech M325 Mouse

FixIt says that you will find single screw under CE label. It isn't always true.