Pirate Ship I Comments
Comments
-
I tries using only booleans but didn't work for all conditions, the following worked for me.
if (gold>=pirates &&gold+pirates <100){
return true;
}
else{
return false;
}
} -
public class Main {
public static boolean doStuff(int gold, int pirates){ //your code here boolean success = true; if (gold < pirates)
{ success = false; } else if (gold + pirates > 100) { success = false; } return success; }
-
-
My solution
return(!(gold+pirates > 100) && gold >= pirates); -
-
return gold+pirates>100?false:gold>=pirates?true:false;
works for me -
def function1(gold, pirates):
sum1=gold+pirates
if gold >= pirates and sum1 < 100:
return True
else:
return FalseI use python
-
function pirateShip(gold, pirates) {
let x = gold + pirates
if (x > 100) {
return 'ship sank'
} else if (gold >= pirates) {
return 'success'
} else {
return 'failed'
}
}using js
David
Mar 2, 12:31 PMLOL had to go back to Booleans chapter.... people Booleans is different from booleans, careful when defining your boolean.