Skip to main content
added 446 characters in body
Source Link
Olivier Grégoire
  • 14.4k
  • 3
  • 32
  • 56

Intended solution:

class A {
  public A() {
    // The access restriction is on System.getProperty(String), not System.getProperties().
    // It's an irk of Java, but is consistent through its history, and is clearly documented as such
    int a = Integer.parseInt(System.getProperties().get("a"));
    int b = Integer.parseInt(System.getProperties().get("b"));
    System.out.println(a+b);
  }
}

Input method: command line arguments

Input method: command line arguments

Intended solution:

class A {
  public A() {
    // The access restriction is on System.getProperty(String), not System.getProperties().
    // It's an irk of Java, but is consistent through its history, and is clearly documented as such
    int a = Integer.parseInt(System.getProperties().get("a"));
    int b = Integer.parseInt(System.getProperties().get("b"));
    System.out.println(a+b);
  }
}

Input method: command line arguments

added 73 characters in body
Source Link
Olivier Grégoire
  • 14.4k
  • 3
  • 32
  • 56

Java 8, OS-agnostic!, cracked by Ilmari Karonen

Java 8, OS-agnostic!

Java 8, OS-agnostic, cracked by Ilmari Karonen

added 51 characters in body
Source Link
Olivier Grégoire
  • 14.4k
  • 3
  • 32
  • 56
  • Don't limit to a single OS, the solution is OS-agnostic as it doesn't rely on anything the OS has to offer. I won't accept an answer that works only on a subset of systems where Java runs.
  • You have to create a class named A with a public no-param constructor (or a static block) to get your code running. That's your entry point. You may declare that the constructor throws something, if you want.
  • You don't need to create any other class + method than A and it's constructor. At least the intended solution doesn't.
  • It's not because I import something that it's used, even in the solution. Don't think I "forgot to remove it" before posting.
  • Don't overthink it, a first year student can solve it. Actually, he/she has a better shot than you to solve it ;)
  • Don't limit to a single OS, the solution is OS-agnostic. I won't accept an answer that works only on a subset of systems where Java runs.
  • You have to create a class named A with a public no-param constructor (or a static block) to get your code running. That's your entry point. You may declare that the constructor throws something, if you want.
  • You don't need to create any other class + method than A and it's constructor. At least the intended solution doesn't.
  • It's not because I import something that it's used, even in the solution. Don't think I "forgot to remove it" before posting.
  • Don't overthink it, a first year student can solve it. Actually, he/she has a better shot than you to solve it ;)
  • Don't limit to a single OS, the solution is OS-agnostic as it doesn't rely on anything the OS has to offer. I won't accept an answer that works only on a subset of systems where Java runs.
  • You have to create a class named A with a public no-param constructor (or a static block) to get your code running. That's your entry point. You may declare that the constructor throws something, if you want.
  • You don't need to create any other class + method than A and it's constructor. At least the intended solution doesn't.
  • It's not because I import something that it's used, even in the solution. Don't think I "forgot to remove it" before posting.
  • Don't overthink it, a first year student can solve it. Actually, he/she has a better shot than you to solve it ;)
added 68 characters in body
Source Link
Olivier Grégoire
  • 14.4k
  • 3
  • 32
  • 56
Loading
added 81 characters in body
Source Link
Olivier Grégoire
  • 14.4k
  • 3
  • 32
  • 56
Loading
Source Link
Olivier Grégoire
  • 14.4k
  • 3
  • 32
  • 56
Loading