Skip to content

substanceof/howToGetMAXINT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

howToGetMAXINT

cannot get maxint? cuz' we can help u

just scroll down

mda

  • src/andrej.java
public static int getIntMaxValue() {
    return getIntMaxValue(0);
}

private static int getIntMaxValue(int x) {
    return (x + 1 >= 0)? 1 + getIntMaxValue(x + 1) : 0;
}
  • src/ivan1.java
int getMaxInt() { return ~(1«31); }
  • src/ivan2.java
import one.util.streamex.IntStreamEx;
 
public static int getMaxInt() {
    return IntStreamEx.iterate(1, i -> i++)
      .takeWhileInclusive(i -> i + 1 > 0)
      .map(i -> 1)
      .sum();
}
  • src/substancia1.java
public static int getIntMaxValue() {
while (1 == 1) {
int old = i;
i++;
if (i >= 0) {
i = old;
break;
}
}
return i;
}

// pls no spaces
  • src/substancia2.scala
def getMaxInt() {
  val (maxint, _) = Stream.continually(())
    .zipWithIndex
    .map {
      case (_, i) => (i, i + 1)
    }
    .takeWhile {
      case (c, p) => p > 0
    }
    .last
  maxint
}
  • src/vlados1.d
// fully rewritten by substancia
 
int getMaxInt() {
  return (cast(uint)(0 - 1)) / 2;
}

About

cannot get maxint? cuz' we can help u

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published