Skip to content

Instantly share code, notes, and snippets.

Im Herzen der digitalen Welt,
Wo Code und Logik sich vereinen,
Java strahlt als stolzer Held,
Es lässt uns nicht alleine.
Die Syntax klar und rein,
Ein Hauch von Eleganz,
In Java wird verflochten sein,
Der Code in seinem Tanz.
package superprof;
import java.io.*;
public class DateiKram {
public static void main(String[] args) {
// Pfad zur Textdatei
String dateiName = "test.txt";
package org.example;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
package superprof;
public class Unroll {
static int zaehler = 0;
public static void main(String[] args) {
int x = 1;
// Test '1'
package superprof;
public class Unroll {
static int zaehler = 0;
public static void main(String[] args) {
int x = 1;
// Test '1'
package superprof;
public class Bugs {
public static void main(String[] args) {
System.out.println(factorial(13));// korrekt: 6227020800
euler1();
}
private static void euler1() {
//https://projecteuler.net/problem=1
package hod.euler
import scala.collection.mutable
object Euler178 {
private val cache = mutable.HashMap.empty[(Int, Int, Int), Long]
private def numberSnakeCounts(n: Int) = {
def snakedySnake(remaining: Int, lastStep: Int, seenDigits: Int): Long = {
val seenDigitCount = Integer.bitCount(seenDigits)
import java.lang.Character.digit
import kotlin.math.roundToInt
object N19 {
@JvmStatic
fun main(args: Array<String>) {
fun rand() = (Math.random() * 1000000).roundToInt()
val seq = generateSequence { rand() }
val samples = seq.take(10000)
println(samples.count { it % 19 == 0 })
import kotlin.math.roundToInt
object N19 {
@JvmStatic
fun main(args: Array<String>) {
fun rand() = (Math.random()*1000000).roundToInt()
val seq = generateSequence { rand() }
val samples = seq.take(10000)
println(samples.count { it % 19 == 0 })
}
def convergentFractions:Iterator[(BigInt, BigInt)] = {
val fractions = continuedFractions.memoizedByIndex
val forDenominator = (i:Int) => fractions(i+1)
val cache = mutable.HashMap.empty[(Int,Boolean), BigInt]
def eval(n:Int, isNumerator:Boolean): BigInt = {
cache.getOrElseUpdate((n, isNumerator), {
val on = if (isNumerator) fractions else forDenominator
n match {
case larger if larger > 2 =>
val a = on(larger - 2)