ref #49 basic regex support (but not in when yet)
This commit is contained in:
1 parent
2743511b62
commit
ead2f7168e
11 files changed
+397
-208
No files matched your search
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Count "happy tickets": 6-digit numbers where sum of first three
|
||||
digits is equal to those of last three. Just to demonstrate and
|
||||
test the Lyng way. It is not meant to be effective.
|
||||
*/
|
||||
|
||||
fun naiveCountHappyNumbers() {
|
||||
var count = 0
|
||||
for( n1 in 0..9 )
|
||||
for( n2 in 0..9 )
|
||||
for( n3 in 0..9 )
|
||||
for( n4 in 0..9 )
|
||||
for( n5 in 0..9 )
|
||||
for( n6 in 0..9 )
|
||||
if( n1 + n2 + n3 == n4 + n5 + n6 ) count++
|
||||
count
|
||||
}
|
||||
|
||||
import lyng.time
|
||||
|
||||
//
|
||||
// After all optimizations it takes ~120ms.
|
||||
//
|
||||
//for( r in 1..100 ) {
|
||||
// val start = Instant.now()
|
||||
val found = naiveCountHappyNumbers()
|
||||
// println("Found happy numbers: %d time %s"(found, Instant.now() - start))
|
||||
assert( found == 55252 )
|
||||
// delay(0.01)
|
||||
//}
|
||||
Reference in new issue
Block a user