The deck contains 104 cards numbered 1104 a card from

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: !! !"!"" this sequence will eventually reach 1 (at which point the sequence terminates). For example, c0=6 generates the sequence 3,10,5,16,8,4,2,1. This conjecture has not been proven, but no counter ­examples have been found for c0 < 5*260. Complete the Python function collatz_converges that consumes a positive integer (n) and a nonnegative integer (limit), and produces True if the sequence starting from c0=n reaches 1 within limit steps, and False otherwise. For example, • collatz_converges(1, 0) => True (since c0=1), • collatz_converges(6, 5) => False (since c0=6 leads to c5=8 and has not converged), • collatz_converges(6, 10) => True (since c0=6, leads to c8==1). You must use recursion to solve this problem. 4. 6 Nmmt® is a game in which the players play cards from their hands onto one of four existing piles of cards, based on the value of the card at the top of each pile. The deck contains 104 cards, numbered 1 ­104. A card from a player’s hand is placed on the pile whose top card is closest in value, without being larger than the card being played. For example, suppose 33 is at the top of pile 1, 43 is at the top of pile 2, 18 is at...
View Full Document

This document was uploaded on 01/19/2014.

Ask a homework question - tutors are online