Pirate Ship II

You're the captain of a pirate ship and would like to calculate the state of the ship. There are two parameters - `gold` and `pirates`.

If there's less gold than pirates, that's always bad. If there's at least as much gold as pirates, that's good (even though the gold cannot be divided equally). If the gold can be divided by the pirates equally, that's great. However, if gold + pirates > 100, that's always bad since the ship may sink. Return an `int` corresponding to the state of the ship, according to the following:

• 1 - Good
• 2 - Great

Input Note:
Boilerplate code is provided for Java. To solve this in another language, you just need to read in a list of number pairs from the standard input, where the first number is `gold` and the second number is `pirates`.

Challenge

What is the State of the Ship?

Alternatively, you can try out Learneroo before signing up.

• Michael

please fix If there's at least as much gold as pirates, that's good. it should if the gold is greater but cannot divided equal to pirates

• Dino Šišić

if someone is having trouble with inconpatible types (boolean/integer) pay attention to:

public static boolean doStuff(int gold, int pirates)

Hope it helps :)

• saeed

I am having big trouble with inconpatible types (boolean/integer);
even when I replace cheet answer...?!!?!

Main.java:7: error: incompatible types
return 0;
^
required: boolean
found: int

• Learneroo

@saeed, the header of your method should say `static int doStuff`, not `static boolean doStuff`

• Peter Fekete

"If there's at least as much gold as pirates, that's good (even though the gold cannot be divided equally)" this would produce 1 at the input 10 10

• Islam Elzohary

my code

``````             if (pirates > gold || pirates + gold > 100) return 0;
else if (gold%pirates == 0) return 2;
else return 1;
``````
• Nouman Khalid

return (gold100)?0:gold%pirates==0?2:1;

if you want to do it in one line

• Hanlise

def function1(gold, pirate):
sum1=gold+pirate
if sum1 < 100: #True
if gold > pirate and not gold % pirate == 0:
return 1
if gold % pirate == 0:
return 2
else:
return 0
else:
return 0

using python

• Rajat

gold = int(input("enter the value"))
pirates = int(input("enter the value"))
sum1 = gold+ pirates
if gold > pirates and not gold % pirates == 0:
return 1
elif gold % pirates == 0: