Skip to main content
added 37 characters in body
Source Link
Riker
  • 7.9k
  • 4
  • 39
  • 73

Scala (interpreted), 85 Bytes

if(System getProperty "v"eq "")print(2)else{System.setProperty("v","");print("1\r")};
if(System getProperty "v"eq "")print(2)else{System.setProperty("v","");print("1\r")};

Commented

if(System getProperty "v"eq "") // If the system property "v" is set to ""
  print(2)                      // Print 2
else{                           // Otherwise
  System.setProperty("v","");   // Set the system property "v" to ""
  print("1\r")                  // Print 1 with a carriage return
};
if(System getProperty "v"eq "") // If the system property "v" is set to ""
  print(2)                      // Print 2
else{                           // Otherwise
  System.setProperty("v","");   // Set the system property "v" to ""
  print("1\r")                  // Print 1 with a carriage return
};


Text that ends with a carriage return and not a newline will be overwritten if anything else is written to the line.


Note: likely doesn't work on all consoles, tested on Windows 8.1 command prompt. For example the TIO console.

Scala (interpreted), 85 Bytes

if(System getProperty "v"eq "")print(2)else{System.setProperty("v","");print("1\r")};

Commented

if(System getProperty "v"eq "") // If the system property "v" is set to ""
  print(2)                      // Print 2
else{                           // Otherwise
  System.setProperty("v","");   // Set the system property "v" to ""
  print("1\r")                  // Print 1 with a carriage return
};


Text that ends with a carriage return and not a newline will be overwritten if anything else is written to the line.


Note: likely doesn't work on all consoles, tested on Windows 8.1 command prompt. For example the TIO console.

Scala (interpreted), 85 Bytes

if(System getProperty "v"eq "")print(2)else{System.setProperty("v","");print("1\r")};

Commented

if(System getProperty "v"eq "") // If the system property "v" is set to ""
  print(2)                      // Print 2
else{                           // Otherwise
  System.setProperty("v","");   // Set the system property "v" to ""
  print("1\r")                  // Print 1 with a carriage return
};


Text that ends with a carriage return and not a newline will be overwritten if anything else is written to the line.


Note: likely doesn't work on all consoles, tested on Windows 8.1 command prompt. For example the TIO console.

Source Link

Scala (interpreted), 85 Bytes

if(System getProperty "v"eq "")print(2)else{System.setProperty("v","");print("1\r")};

Commented

if(System getProperty "v"eq "") // If the system property "v" is set to ""
  print(2)                      // Print 2
else{                           // Otherwise
  System.setProperty("v","");   // Set the system property "v" to ""
  print("1\r")                  // Print 1 with a carriage return
};


Text that ends with a carriage return and not a newline will be overwritten if anything else is written to the line.


Note: likely doesn't work on all consoles, tested on Windows 8.1 command prompt. For example the TIO console.