Daily Challenge #25

Number 25 already.

I hope you still enjoy the daily challenges. Like i said before if you want you can also make a daily challenge. The challenge is then also to do it before i do. :crazy_face:

Oddish vs. Evenish

Create a procedure that determines whether a number is Oddish or Evenish . A number is Oddish if the sum of all of its digits is odd, and a number is Evenish if the sum of all of its digits is even. If a function is Oddish , return "Oddish" . Otherwise, return "Evenish" .

For example, oddishOrEvenish(121) should return "Evenish" , since 1 + 2 + 1 = 4. oddishOrEvenish(41) should return "Oddish" , since 4 + 1 = 5.

Examples

oddishOrEvenish(43) ➞ "Oddish"

oddishOrEvenish(373) ➞ "Oddish"

oddishOrEvenish(4433) ➞ "Evenish"
5 Likes

Here it is:
blocks%20(27)

And for this:

oddishOrEvenish(43) ➞ “Oddish”
oddishOrEvenish(373) ➞ “Oddish”
oddishOrEvenish(4433) ➞ “Evenish”

Here is a solution:

    public String OddishOrEvenish(int num){

    int sum = 0;

    String str = String.valueOf(num);

    String[] n = str.split("(?<=.)");

    for ( String i:n) {
        sum += Integer.parseInt(i);
    }
    String result = "Oddish";
    if(sum%2==0){
        result = "Evenish";
    }
    return result;
}

Blockly saves so much time and labour

7 Likes

Thank you :grinning:

For extension developers

We can make 25 new extensions one from each challenge or a single extension having 25 blocks

3 Likes

This post was flagged by the community and is temporarily hidden.

(remainder of) not%20finding
I am not finding this block in Kodular…

1 Like

Search for ‘modulo of’

4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.