[Java] One type of alphabet prohibited With binding Hello, world! [Binding]

Overview

In Java, I verified which alphabet can be written by prohibiting one alphabet (writing without using one of a to z). Just play.

rule

1.java10,Windows10 2. Compile with javac, execute with java, no options (or rather write in Eclipse and execute) 3. Output Hello, world! To standard output 4. No extra standard output or error output (line breaks are OK) 5. Prohibition of using only one type of alphabet 6. Case insensitive 7. Prohibit external files (only Java standard library is possible) 8. Unicode escape prohibited (2018-08-26 postscript) * Details will be described later

Conclusion

Possible: bfhjklpquwxyz Impossible: acdegimnorstv

Details

I'm writing a code that is roughly tied in alphabetical order. fjkqxz It doesn't appear in the Hello World I wrote normally. By the way, variable names and class names are in Japanese so as not to use alphabets. I wonder if there are people who use the fact that the class name can use anything other than the alphabet ... (I saw it once used in educational source code.)

Hello World.java


class Hello World{
	public static void main(String[]argument) {
		System.out.print("Hello, World!");
	}
}

b Since public is implicitly added to the method in interface, there is no need to write it in the main statement. I think it was a function from java7 or 8. However, since there are many characters used elsewhere, only b can be dealt with.

Hello World.java


interface Hello World{
	static void main(String[]argument) {
		System.out.print("Hello, World!");
	}
}

hlpw Enter the character code in the format format so that the character string contained only in Hello, world is not used. By using format instead of printf, we avoid using p, and by using interface, we avoid using pl in public.

Hello World.java


interface Hello World{
	static void main(String[]argument) {
		System.out.format("%c%c%c%c%c, %c%c%c%c%c!",72,101,108,108,111,87,111,114,108,100);
	}
}

uy Since it is in s [y] stem.o [u] t, I somehow do standard output without using it. There is a class that can execute a script language called ScriptEngine, and when you output with a script, it is output as standard. However, since the getB [y] Name method is used when getting the ScriptEngine, execute this from the character string using getClass, getMethod, invoke, and in the character string, get y from the number and solve it.

Hello World.java


import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

interface Hello World{
	static void main(String[]argument) throws Exception {
		ScriptEngineManager manager = new ScriptEngineManager();
		ScriptEngine engine = (ScriptEngine)manager.getClass()
				.getMethod("getEngineB"+(char)121+"Name", String.class).invoke(manager, "javascript");
		String script = "print('Hello, World!')";
		engine.eval(script);
	}
}

Untied characters and reasons

acdgimnorstv Since static void main (String [] argument) is absolutely necessary, the alphabet contained in it cannot be omitted. Without this, it cannot be executed in the first place. Is there a way to deal with this? (2018-08-26 postscript) I got the information that if you inherit JavaFX Application, you do not have to write the main statement.

Hello World.java


public class hello world extends javafx.application.Application{
	public void start(javafx.stage.Stage Stage){
		System.out.print("Hello, World!");
	}
}

However, even with this, most of the characters were used and none of the bindings were resolved. You can use m with Syste [m] .out, but you can't use ScriptEngine [M] analger, and you can't use [m] ethod and na [m] e, so you can't leave it to reflection.

e Like uy, it is in Syst [e] m.out, so it would be nice if it could be output without using this, but it is in Script [E] ngin [e], and even if you try to get it from a string, in the first place It is in g [e] tClass. Or rather, since it is in g [e] t, the method to get something cannot be used. Even if it isn't, the alphabet is fairly easy to use, so it's easy to get caught.

At the end

From the above Possible: bfhjklpquwxyz Impossible: acdegimnorstv Will be. The main statement is too disturbing. There seems to be a way to solve e somehow ... Please let me know if there is a way to do it. It might be interesting to do something around fizzbuzz.

(2018-08-26 postscript) Unicode escape prohibited

Comment for information. In Java, you can write the source code in Unicode escape (\ uxxxx) format. If you use this, theoretically only abcdefu that combines hexadecimal numbers a ~ f and u will come out, and even if a ~ f is converted to Unicode escape, each does not include alphabets, so convert only each alphabet to Unicode escape. Will be resolved. Other than u, it is possible to bind regardless of the code. If that is the case, I don't think it makes much sense to tie it up, so I ban it from my own tying up. It's interesting to see information that you wouldn't use in a normal program if you do something strange like this.

Recommended Posts

[Java] One type of alphabet prohibited With binding Hello, world! [Binding]
[Java] One type of alphabet prohibited FizzBuzz with binding [Binding]
Try Hello World with the minimum configuration of Heroku Java spring-boot
Hello world with Java template engine Thymeleaf
Java development with Codenvy: Hello World! Run
Java, Hello, world!
Java Hello World
[Java] Hello World with Java 14 x Spring Boot 2.3 x JUnit 5 ~
"Hello World" in Java
Java Learning (1)-Hello World
Hello World in Java
Hello World with Micronaut
Hello World with Spring Boot
Hello World with Spring Boot!
Hello World with VS Code!
Initialization with an empty string to an instance of Java String type
java hello world, compile, run
Hello World with Spring Boot
Java beginners read Hello World
Hello World with SpringBoot / Gradle
Hello, World! With Asakusa Framework!
Until you run Hello World of JavaFX with VS Code + Gradle
Compare Hello, world! In Spring Boot with Java, Kotlin and Groovy
Hello World for ImageJ Java Plugin
Until "Hello World" with Spring Boot
Hello World on AWS Lambda + Java
Hello world with Kotlin and JavaFX
Hello World with Docker and C
Hello World in java in eclipse now
(Intellij) Hello World with Spring Boot
Hello World with GlassFish 5.1 + Servlet + JSP
Create PDF with itext7 ~ Hello World ~
"Hello world" for ImageJ with Eclipse
[Java] Correct comparison of String type
Hello World with GWT 2.8.2 and Maven
Hello world in Java and Gradle
Try writing "Hello, World" with a combination of various languages and libraries
Hello World with Eclipse + Spring Boot + Maven
"Hello, World!" With Kotlin + CLI in 5 minutes
Hello World on Mac VS Code Java
[Basic knowledge of Java] About type conversion
Hello world with Kotlin and Tornado FX
[Java] Comparison of String type character strings
Java Summary of frequently searched type conversions
How Spring Security works with Hello World
(IntelliJ + gradle) Hello World with Spring Boot
Minimal Java environment construction and Hello World
[Java] How to convert one element of a String type array to an Int type
Hello World with Java Servlet and JSP (Easy web server startup with Maven + Jetty)
Hello World, a cross-platform GUI app with Groovy running on the Java platform