Skip to main content
Commonmark migration
Source Link

Java 8, 57 56 55 50 bytes

#Java 8, 57 56 55 50 bytes Thanks to @Numberknot for 1 byte Thanks to @Kevin Cruijssen for 5 bytes

i->{for(;++i%3<1|(i+"").contains("3"););return i;}

This is a Function<Integer, Integer>

Explanation

Naive implementation that simply increments until it reaches an acceptable number.

Test Class

public class CodeGolf {

    public static void main(String[] args) {
        Function<Integer, Integer> countingGame = i->{for(;++i%3<1|(i+"").contains("3"););return i;};
        int val = 1;
        for (int i = 0; i < 10; i++) {
            System.out.print(val + " ");
            val = countingGame.apply(val);
        }
    }

}

Output of Test Class:

1 2 4 5 7 8 10 11 14 16

#Java 8, 57 56 55 50 bytes Thanks to @Numberknot for 1 byte Thanks to @Kevin Cruijssen for 5 bytes

i->{for(;++i%3<1|(i+"").contains("3"););return i;}

This is a Function<Integer, Integer>

Explanation

Naive implementation that simply increments until it reaches an acceptable number.

Test Class

public class CodeGolf {

    public static void main(String[] args) {
        Function<Integer, Integer> countingGame = i->{for(;++i%3<1|(i+"").contains("3"););return i;};
        int val = 1;
        for (int i = 0; i < 10; i++) {
            System.out.print(val + " ");
            val = countingGame.apply(val);
        }
    }

}

Output of Test Class:

1 2 4 5 7 8 10 11 14 16

Java 8, 57 56 55 50 bytes

Thanks to @Numberknot for 1 byte Thanks to @Kevin Cruijssen for 5 bytes

i->{for(;++i%3<1|(i+"").contains("3"););return i;}

This is a Function<Integer, Integer>

Explanation

Naive implementation that simply increments until it reaches an acceptable number.

Test Class

public class CodeGolf {

    public static void main(String[] args) {
        Function<Integer, Integer> countingGame = i->{for(;++i%3<1|(i+"").contains("3"););return i;};
        int val = 1;
        for (int i = 0; i < 10; i++) {
            System.out.print(val + " ");
            val = countingGame.apply(val);
        }
    }

}

Output of Test Class:

1 2 4 5 7 8 10 11 14 16
added 42 characters in body
Source Link
Socratic Phoenix
  • 1.7k
  • 1
  • 11
  • 26

#Java 8, 57 56 5555 50 bytes Thanks to @Numberknot for 1 byte Thanks to @Kevin Cruijssen for 5 bytes

i->{do i++;whilefor(i%3<1|;++i%3<1|(i+"").contains("3"););return i;}

This is a Function<Integer, Integer>

Explanation

Naive implementation that simply increments until it reaches an acceptable number.

Test Class

public class CodeGolf {

    public static void main(String[] args) {
        Function<Integer, Integer> countingGame = i->{do i++;whilefor(i%3<1|;++i%3<1|(i+"").contains("3"););return i;};
        int val = 1;
        for (int i = 0; i < 10; i++) {
            System.out.print(val + " ");
            val = countingGame.apply(val);
        }
    }

}

Output of Test Class:

1 2 4 5 7 8 10 11 14 16

#Java 8, 57 56 55 bytes Thanks to @Numberknot for 1 byte

i->{do i++;while(i%3<1|(i+"").contains("3"));return i;}

This is a Function<Integer, Integer>

Explanation

Naive implementation that simply increments until it reaches an acceptable number.

Test Class

public class CodeGolf {

    public static void main(String[] args) {
        Function<Integer, Integer> countingGame = i->{do i++;while(i%3<1|(i+"").contains("3"));return i;};
        int val = 1;
        for (int i = 0; i < 10; i++) {
            System.out.print(val + " ");
            val = countingGame.apply(val);
        }
    }

}

Output of Test Class:

1 2 4 5 7 8 10 11 14 16

#Java 8, 57 56 55 50 bytes Thanks to @Numberknot for 1 byte Thanks to @Kevin Cruijssen for 5 bytes

i->{for(;++i%3<1|(i+"").contains("3"););return i;}

This is a Function<Integer, Integer>

Explanation

Naive implementation that simply increments until it reaches an acceptable number.

Test Class

public class CodeGolf {

    public static void main(String[] args) {
        Function<Integer, Integer> countingGame = i->{for(;++i%3<1|(i+"").contains("3"););return i;};
        int val = 1;
        for (int i = 0; i < 10; i++) {
            System.out.print(val + " ");
            val = countingGame.apply(val);
        }
    }

}

Output of Test Class:

1 2 4 5 7 8 10 11 14 16
added 1 character in body
Source Link
Socratic Phoenix
  • 1.7k
  • 1
  • 11
  • 26

#Java 8, 57 56 55 bytes Thanks to @Numbernot@Numberknot for 1 byte

i->{do i++;while(i%3<1|(i+"").contains("3"));return i;}

This is a Function<Integer, Integer>

Explanation

Naive implementation that simply increments until it reaches an acceptable number.

Test Class

public class CodeGolf {

    public static void main(String[] args) {
        Function<Integer, Integer> countingGame = i->{do i++;while(i%3<1|(i+"").contains("3"));return i;};
        int val = 1;
        for (int i = 0; i < 10; i++) {
            System.out.print(val + " ");
            val = countingGame.apply(val);
        }
    }

}

Output of Test Class:

1 2 4 5 7 8 10 11 14 16

#Java 8, 57 56 55 bytes Thanks to @Numbernot for 1 byte

i->{do i++;while(i%3<1|(i+"").contains("3"));return i;}

This is a Function<Integer, Integer>

Explanation

Naive implementation that simply increments until it reaches an acceptable number.

Test Class

public class CodeGolf {

    public static void main(String[] args) {
        Function<Integer, Integer> countingGame = i->{do i++;while(i%3<1|(i+"").contains("3"));return i;};
        int val = 1;
        for (int i = 0; i < 10; i++) {
            System.out.print(val + " ");
            val = countingGame.apply(val);
        }
    }

}

Output of Test Class:

1 2 4 5 7 8 10 11 14 16

#Java 8, 57 56 55 bytes Thanks to @Numberknot for 1 byte

i->{do i++;while(i%3<1|(i+"").contains("3"));return i;}

This is a Function<Integer, Integer>

Explanation

Naive implementation that simply increments until it reaches an acceptable number.

Test Class

public class CodeGolf {

    public static void main(String[] args) {
        Function<Integer, Integer> countingGame = i->{do i++;while(i%3<1|(i+"").contains("3"));return i;};
        int val = 1;
        for (int i = 0; i < 10; i++) {
            System.out.print(val + " ");
            val = countingGame.apply(val);
        }
    }

}

Output of Test Class:

1 2 4 5 7 8 10 11 14 16
added 43 characters in body
Source Link
Socratic Phoenix
  • 1.7k
  • 1
  • 11
  • 26
Loading
added 10 characters in body
Source Link
Socratic Phoenix
  • 1.7k
  • 1
  • 11
  • 26
Loading
Source Link
Socratic Phoenix
  • 1.7k
  • 1
  • 11
  • 26
Loading