core_templates1/collatz.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Wed, 02 Nov 2022 13:22:59 +0000
changeset 429 126d0e47ac85
parent 428 cdfa6a293453
child 430 274c865b3878
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
396
3ffe978a5664 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 345
diff changeset
    26
3ffe978a5664 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 345
diff changeset
    27
429
126d0e47ac85 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 428
diff changeset
    28
// This template code is subject to copyright 
126d0e47ac85 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 428
diff changeset
    29
// owned by King's College London. Do not 
126d0e47ac85 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 428
diff changeset
    30
// make this template code public in any shape or 
126d0e47ac85 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 428
diff changeset
    31
// form, and do not exchange it with other students 
126d0e47ac85 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 428
diff changeset
    32
// under any circumstance.