Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Java, (削除) 404 (削除ここまで)(削除) 388 (削除ここまで)(削除) 354 (削除ここまで)(削除) 348 (削除ここまで)(削除) 320 (削除ここまで) 318 bytes

Java, (削除) 404 (削除ここまで)(削除) 388 (削除ここまで)(削除) 354 (削除ここまで)(削除) 348 (削除ここまで)(削除) 320 (削除ここまで) 318 bytes

#Java, (削除) 404 (削除ここまで)(削除) 388 (削除ここまで)(削除) 354 (削除ここまで)(削除) 348 (削除ここまで)(削除) 320 (削除ここまで) 318 bytes

Java, (削除) 404 (削除ここまで)(削除) 388 (削除ここまで)(削除) 354 (削除ここまで)(削除) 348 (削除ここまで)(削除) 320 (削除ここまで) 318 bytes

added 12 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

#Java, (削除) 404 (削除ここまで) (削除) 388 (削除ここまで) (削除) 354 (削除ここまで) (削除) 348 (削除ここまで) 320(削除) 320 (削除ここまで) 318 bytes

import java.awt.*;import java.awt.event.*;interface M{static void main(String[]a){new Frame(){{add(new TextArea(){{addKeyListener(new KeyAdapter(){long t,i=96;publici=64;public void keyPressed(KeyEvent e){t=t>0?t:e.getWhen();if(e.getKeyChar()!=++i|i>121=++i|i>89){System.out.print(i>121i>89?e.getWhen()-t:"Fail");dispose();}}});}});show();}};}}
import java.awt.*; // Required import for Frame and TextField
import java.awt.event.*; // Required import for KeyAdapter and KeyEvent
interface M{ // Class
 static void main(String[]a){ // Mandatory main-method
 new Frame(){ // Create the GUI-Frame
 { // With an initialization-block
 add(new TextArea(){ // Add an input-field
 { // With it's own initialization-block
 addKeyListener(new KeyAdapter(){
 // Add a KeyAdapter to the input-field
 long t, // Long to save the time
 i=96;i=64; // Previous character, starting at 96code (of 'a'-1)
 public void keyPressed(KeyEvent e){ 
 // Override the keyPressed-method:
 t=t>0? // If `t` is already set:
 t // Leave it the same
 : // Else:
 e.getWhen(); // Save the current time (== start the timer)
 if(e.getKeyChargetKeyCode()!=++i
 // As soon as an incorrect character is pressed,
 |i>121|i>89){ // or we've reached 'z':
 System.out.print(i>121i>89?
 // If we're at 'z':
 e.getWhen()-t // Print the end-time in ms to the Console
 : // Else (an incorrect character was pressed)
 "Fail"); // Print "Fail" to the Console
 dispose();} // And exit the application
 } // End of keyPressed-method
 }); // End of KeyAdapter
 } // End of input-field initialization-block
 }); // End of input-field
 show(); // Initially show the Frame
 } // End of Frame initialization-block
 }; // End of Frame 
 } // End of main-method
} // End of class

#Java, (削除) 404 (削除ここまで) (削除) 388 (削除ここまで) (削除) 354 (削除ここまで) (削除) 348 (削除ここまで) 320 bytes

import java.awt.*;import java.awt.event.*;interface M{static void main(String[]a){new Frame(){{add(new TextArea(){{addKeyListener(new KeyAdapter(){long t,i=96;public void keyPressed(KeyEvent e){t=t>0?t:e.getWhen();if(e.getKeyChar()!=++i|i>121){System.out.print(i>121?e.getWhen()-t:"Fail");dispose();}}});}});show();}};}}
import java.awt.*; // Required import for Frame and TextField
import java.awt.event.*; // Required import for KeyAdapter and KeyEvent
interface M{ // Class
 static void main(String[]a){ // Mandatory main-method
 new Frame(){ // Create the GUI-Frame
 { // With an initialization-block
 add(new TextArea(){ // Add an input-field
 { // With it's own initialization-block
 addKeyListener(new KeyAdapter(){
 // Add a KeyAdapter to the input-field
 long t, // Long to save the time
 i=96; // Previous character, starting at 96 ('a'-1)
 public void keyPressed(KeyEvent e){ 
 // Override the keyPressed-method:
 t=t>0? // If `t` is already set:
 t // Leave it the same
 : // Else:
 e.getWhen(); // Save the current time (== start the timer)
 if(e.getKeyChar()!=++i
 // As soon as an incorrect character is pressed,
 |i>121){ // or we've reached 'z':
 System.out.print(i>121?
 // If we're at 'z':
 e.getWhen()-t // Print the end-time in ms to the Console
 : // Else (an incorrect character was pressed)
 "Fail"); // Print "Fail" to the Console
 dispose();} // And exit the application
 } // End of keyPressed-method
 }); // End of KeyAdapter
 } // End of input-field initialization-block
 }); // End of input-field
 show(); // Initially show the Frame
 } // End of Frame initialization-block
 } // End of Frame 
 } // End of main-method
} // End of class

#Java, (削除) 404 (削除ここまで) (削除) 388 (削除ここまで) (削除) 354 (削除ここまで) (削除) 348 (削除ここまで) (削除) 320 (削除ここまで) 318 bytes

import java.awt.*;import java.awt.event.*;interface M{static void main(String[]a){new Frame(){{add(new TextArea(){{addKeyListener(new KeyAdapter(){long t,i=64;public void keyPressed(KeyEvent e){t=t>0?t:e.getWhen();if(e.getKeyChar()!=++i|i>89){System.out.print(i>89?e.getWhen()-t:"Fail");dispose();}}});}});show();}};}}
import java.awt.*; // Required import for Frame and TextField
import java.awt.event.*; // Required import for KeyAdapter and KeyEvent
interface M{ // Class
 static void main(String[]a){ // Mandatory main-method
 new Frame(){ // Create the GUI-Frame
 { // With an initialization-block
 add(new TextArea(){ // Add an input-field
 { // With it's own initialization-block
 addKeyListener(new KeyAdapter(){
 // Add a KeyAdapter to the input-field
 long t, // Long to save the time
 i=64; // Previous character, starting at code of 'a'-1
 public void keyPressed(KeyEvent e){ 
 // Override the keyPressed-method:
 t=t>0? // If `t` is already set:
 t // Leave it the same
 : // Else:
 e.getWhen(); // Save the current time (== start the timer)
 if(e.getKeyCode()!=++i
 // As soon as an incorrect character is pressed,
 |i>89){ // or we've reached 'z':
 System.out.print(i>89?
 // If we're at 'z':
 e.getWhen()-t // Print the end-time in ms to the Console
 : // Else (an incorrect character was pressed)
 "Fail"); // Print "Fail" to the Console
 dispose();} // And exit the application
 } // End of keyPressed-method
 }); // End of KeyAdapter
 } // End of input-field initialization-block
 }); // End of input-field
 show(); // Initially show the Frame
 } // End of Frame initialization-block
 }; // End of Frame 
 } // End of main-method
} // End of class
added 153 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

#Java, (削除) 404 (削除ここまで) (削除) 388 (削除ここまで) (削除) 354 (削除ここまで) 348(削除) 348 (削除ここまで) 320 bytes

import java.awt.*;import java.awt.event.*;class*;interface M{static extendsvoid main(String[]a){new Frame(){{TextArea f=newadd(new TextArea();add(f);f.{{addKeyListener(new KeyAdapter(){long t,i=96,c;publici=96;public void keyPressed(KeyEvent e){t=t>0?t:e.getWhen();c=e;if(e.getKeyChar();if(c!=++i|i>121){System.out.print(i>121?e.getWhen()-t:"Fail");dispose();}}});show();}public static void main(String[]a}){new M;show();}};}}

-5078 bytes thanks to @OlivierGrégoire.

import java.awt.*; // Required import for Frame and TextField
import java.awt.event.*; // Required import for KeyAdapter and KeyEvent
classinterface M{ extends Frame{ // Class static void main(extendingString[]a){ // Mandatory main-method
  new Frame(){ // Create the GUI-Frame
 { { // Class- With an initialization-block
 TextArea f=new TextArea add(new TextArea(){  // Instantiate Add an input-field
 add(f); {  // Add the input-field toWith theit's Frameown initialization-block
 f.addKeyListener(new KeyAdapter(){
 // Add a KeyAdapter to the input-field
 long t, long t, // Long to save the time
 i=96, i=96; // Previous character, starting at 96 ('a'-1)
 c;  // Current character
 public void keyPressed(KeyEvent e){ 
 // Override the keyPressed-method:
 t=t>0? t=t>0? // If `t` is already set:
 t t // Leave it the same
 : : // Else:
 e.getWhen(); e.getWhen(); // Save the current time (== start the timer)
 c=e.getKeyChar(); if(e.getKeyChar()!=++i
 // Get the character pressed by the user
 if(c!=++i // // As soon as an incorrect character is pressed,
 |i>121){ |i>121){ // or we've reached 'z':
 System.out.print(i>121? // If we're at 'z':
 e.getWhen()-t // //  Print the end-time in ms to the Console
 : : // Else (an incorrect character was pressed)
 "Fail")); "Fail"); // Print "Fail" to the Console
 dispose();} dispose();} // And exit the application
 } } // End of keyPressed-method
 }); }); // End of KeyAdapter
 show(); }  // Initially show the Frame
End of }input-field initialization-block
  }); // End of classinput-initializationfield
 public static void main show(String[]a){; // Initially show the Frame
 } // Mandatory main End of Frame initialization-methodblock
 new} M(); // Create an instance of// itself (of theEnd of Frame)
 } // End of main-method
} // End of class

#Java, (削除) 404 (削除ここまで) (削除) 388 (削除ここまで) (削除) 354 (削除ここまで) 348 bytes

import java.awt.*;import java.awt.event.*;class M extends Frame{{TextArea f=new TextArea();add(f);f.addKeyListener(new KeyAdapter(){long t,i=96,c;public void keyPressed(KeyEvent e){t=t>0?t:e.getWhen();c=e.getKeyChar();if(c!=++i|i>121){System.out.print(i>121?e.getWhen()-t:"Fail");dispose();}}});show();}public static void main(String[]a){new M();}}

-50 bytes thanks to @OlivierGrégoire.

import java.awt.*; // Required import for Frame and TextField
import java.awt.event.*; // Required import for KeyAdapter and KeyEvent
class M extends Frame{ // Class (extending Frame)
 { // Class-initialization
 TextArea f=new TextArea () // Instantiate an input-field
 add(f); // Add the input-field to the Frame
 f.addKeyListener(new KeyAdapter(){
 // Add a KeyAdapter to the input-field
 long t, // Long to save the time
 i=96, // Previous character, starting at 96 ('a'-1)
 c;  // Current character
 public void keyPressed(KeyEvent e){ 
 // Override the keyPressed-method:
 t=t>0? // If `t` is already set:
 t // Leave it the same
 : // Else:
 e.getWhen(); // Save the current time (== start the timer)
 c=e.getKeyChar(); // Get the character pressed by the user
 if(c!=++i // As soon as an incorrect character is pressed,
 |i>121){ // or we've reached 'z':
 System.out.print(i>121? // If we're at 'z':
 e.getWhen()-t //  Print the end-time in ms to the Console
 : // Else (an incorrect character was pressed)
 "Fail")); // Print "Fail" to the Console
 dispose();} // And exit the application
 } // End of keyPressed-method
 }); // End of KeyAdapter
 show(); // Initially show the Frame
 } // End of class-initialization
 public static void main(String[]a){ // Mandatory main-method
 new M(); // Create an instance of itself (of the Frame)
 } // End of main-method
} // End of class

#Java, (削除) 404 (削除ここまで) (削除) 388 (削除ここまで) (削除) 354 (削除ここまで) (削除) 348 (削除ここまで) 320 bytes

import java.awt.*;import java.awt.event.*;interface M{static void main(String[]a){new Frame(){{add(new TextArea(){{addKeyListener(new KeyAdapter(){long t,i=96;public void keyPressed(KeyEvent e){t=t>0?t:e.getWhen();if(e.getKeyChar()!=++i|i>121){System.out.print(i>121?e.getWhen()-t:"Fail");dispose();}}});}});show();}};}}

-78 bytes thanks to @OlivierGrégoire.

import java.awt.*; // Required import for Frame and TextField
import java.awt.event.*; // Required import for KeyAdapter and KeyEvent
interface M{ // Class static void main(String[]a){ // Mandatory main-method
  new Frame(){ // Create the GUI-Frame
 { //  With an initialization-block
 add(new TextArea(){  // Add an input-field
 {  // With it's own initialization-block
 addKeyListener(new KeyAdapter(){
 // Add a KeyAdapter to the input-field
 long t, // Long to save the time
 i=96; // Previous character, starting at 96 ('a'-1)
 public void keyPressed(KeyEvent e){ 
 // Override the keyPressed-method:
 t=t>0? // If `t` is already set:
 t // Leave it the same
 : // Else:
 e.getWhen(); // Save the current time (== start the timer)
 if(e.getKeyChar()!=++i
 // As soon as an incorrect character is pressed,
 |i>121){ // or we've reached 'z':
 System.out.print(i>121? // If we're at 'z':
 e.getWhen()-t // Print the end-time in ms to the Console
 : // Else (an incorrect character was pressed)
 "Fail"); // Print "Fail" to the Console
 dispose();} // And exit the application
 } // End of keyPressed-method
 }); // End of KeyAdapter
 }  // End of input-field initialization-block
  }); // End of input-field
  show(); // Initially show the Frame
 } //  End of Frame initialization-block
 } // End of Frame
 } // End of main-method
} // End of class
deleted 92 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
added 169 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
edited body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
added 214 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading

AltStyle によって変換されたページ (->オリジナル) /