Kinderswift 8 Challenge Answers

Watch the video for any commentary. Here are two answers. There a lot of possible ones.

Answer 1

func blueColor(blueVal:Int) -> UIColor {
let color = CGFloat(CGFloat(blueVal) / 255.0)
return UIColor(red: 0.0, green: 0.0, blue: color, alpha: 1.0)
}


blueColor(255)
blueColor(23)
blueColor(128)

Answer 2


//necessary code to run the answer
func pizzaArea(z:Double) ->Double {
//area of pizza : pi * z * z = a
    let pi = 3.14159265358
    return pi * z * z
}


func deepDishVolume(diameter:Double,height:Double){
    let radius = diameter * 0.5
    let area = pizzaArea(radius)
    let volume = area * height
    println(radius,area,height)
}

deepDishVolume(13, 2)


One thought on “Kinderswift 8 Challenge Answers”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s