This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package superprof; | |
import java.io.*; | |
public class DateiKram { | |
public static void main(String[] args) { | |
// Pfad zur Textdatei | |
String dateiName = "test.txt"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package superprof; | |
public class Unroll { | |
static int zaehler = 0; | |
public static void main(String[] args) { | |
int x = 1; | |
// Test '1' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package superprof; | |
public class Unroll { | |
static int zaehler = 0; | |
public static void main(String[] args) { | |
int x = 1; | |
// Test '1' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |