Skip to content

Instantly share code, notes, and snippets.

@SergeyTLV
Created October 2, 2020 04:44
Show Gist options
  • Save SergeyTLV/592d0ef92a49aafd70c89db87dde3b89 to your computer and use it in GitHub Desktop.
Save SergeyTLV/592d0ef92a49aafd70c89db87dde3b89 to your computer and use it in GitHub Desktop.
func potatoes (_ p0: Int, _ w0: Int, _ p1: Int) -> Int {
let dryMatter = (Double(w0) / 100) * Double(100 - p0)
let finalPercentOfDryMatter = 100 - p1
let w1:Int = Int(dryMatter) / (Int(finalPercentOfDryMatter) / 100)
return (Int(w1))
}
/*
ERROR
solution.swift:8:5: warning: variable 'w1' was never mutated; consider changing to 'let' constant
var w1:Int = Int(dryMatter) / (Int(finalPercentOfDryMatter) / 100)
~~~ ^
let
Fatal error: Division by zero
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment