core_templates1/collatz.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 25 Nov 2022 00:03:15 +0000
changeset 448 db2a3e3287a9
parent 430 274c865b3878
child 470 86a456f8cb92
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
396
3ffe978a5664 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 345
diff changeset
     1
// Core Part 1 about the 3n+1 conjecture
343
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
     2
//============================================
11
417869f65585 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
396
3ffe978a5664 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 345
diff changeset
     4
object C1 {
11
417869f65585 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
428
cdfa6a293453 updated solutions and templates
Christian Urban <christian.urban@kcl.ac.uk>
parents: 396
diff changeset
     6
// ADD YOUR CODE BELOW
cdfa6a293453 updated solutions and templates
Christian Urban <christian.urban@kcl.ac.uk>
parents: 396
diff changeset
     7
//======================
11
417869f65585 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
428
cdfa6a293453 updated solutions and templates
Christian Urban <christian.urban@kcl.ac.uk>
parents: 396
diff changeset
     9
cdfa6a293453 updated solutions and templates
Christian Urban <christian.urban@kcl.ac.uk>
parents: 396
diff changeset
    10
//(1) 
343
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
    11
def collatz(n: Long) : Long = ???
11
417869f65585 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
417869f65585 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
428
cdfa6a293453 updated solutions and templates
Christian Urban <christian.urban@kcl.ac.uk>
parents: 396
diff changeset
    14
//(2) 
343
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
    15
def collatz_max(bnd: Long) : (Long, Long) = ???
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
    16
428
cdfa6a293453 updated solutions and templates
Christian Urban <christian.urban@kcl.ac.uk>
parents: 396
diff changeset
    17
//(3)
343
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
    18
def is_pow_of_two(n: Long) : Boolean = ???
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
    19
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
    20
def is_hard(n: Long) : Boolean = ???
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
    21
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
    22
def last_odd(n: Long) : Long = ???
11
417869f65585 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
281
87b9e3e2c1a7 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    24
}
11
417869f65585 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    25