Tag Archives: cards

The first hand : Mendel in Wonderland

In wonderland, much depends upon the suit and rank of a card. In the time of Alice, the Hearts held power, but since then, the Queen of Hearts has been imprisoned and the Kind of Spades now rules the land.

Families now strive to have children of high suits in order to give them the best chance at a good life.

Suit values are as follows:

Clubs < Diamonds < Hearts < Spades


Conveniently, the inheritance of the suits follows the same order. That is Spades are dominant over all suits, Hearts are dominant over Diamonds and Clubs, and Diamonds are dominant over Clubs.

SC < SD < SH < SS

Two cards come into your clinic to get genetic counseling. They want to know what chance they have of having a Hearts or Spades baby.

Mom is the Three of Hearts

Dad is the Five of Diamonds

They already have three children: a Two of Hearts, a Seven of Clubs, and a Jack of Clubs.


From the information provided above, what do you know?

Is it possible that they can have a Hearts Baby?


Posted by on November 7, 2014 in Uncategorized


Tags: , , , , , ,

Blackjack game is driving me crazy

I’ve been working on the blackjack name for codecademy all day today without luck.  The challenge / puzzle / assignment is to have a hand of cards generated and scored.

The hand is an object that includes two ‘card’ objects. each card is generated randomly with two features (number and suit*).The suit is defined by a random number 1-4 and defined by a method for matching this numeral to a suit. The number is defined as 1-13 and set to values such that 1 (ace) = 11, 1-10 =face value and 11-13 are face cards worth 10pts each.


I simply can’t do it. My code looks reasonable to me (but I don’t really feel comfortable with it at all), but I’m getting crazy results. Here’s what I have, try copying it into a javascript field and see if you can make heads or tails of it:


// Make your card constructor again here, but make sure to use private
// variables!
function Card(s,n){
this.number = n;
this.suit = s;

this.getSuit = function(suit){
//console.log(“I’m about to switch”);
switch (this.suit){
case 1:
this.suit = “clubs”;
case 2:
this.suit = “diamonds”;
case 3:
this.suit = “hearts”;
case 4:
this.suit = “spades”;

this.getValue = function(number){
if(this.number === 1){
//console.log(“value = 11”);
this.value = 11;
return 11;
else if (this.number >=11){
//console.log(“value = 10”);
this.value = 10;
return 10;
//console.log(“value = “+ this.number);
this.value = number;
return this.number;

// Make a deal function here. It should return a new card with a suit
// that is a random number from 1 to 4, and a number that is a random
// number between 1 and 13
var deal = function(){
var suit = Math.floor(Math.random()*4)+1;
var number = Math.floor(Math.random()*13)+1;
return new Card(suit,number);

var Hand = function(){
this.card1 = deal();
console.log(“card1 is “+card1.number+ ” of “+card1.suit);
this.card2 = deal();
console.log(“card2 is “+card2.number+ ” of “+card2.suit);




*by the way, it is clear that there is nothing that prevents the same card from being drawn twice from what presumably is a single deck.

Leave a comment

Posted by on July 24, 2012 in Codecademy, Coding


Tags: , , , , , ,