core_templates1/collatz.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Thu, 02 Nov 2023 13:53:37 +0000
changeset 474 b528d1d3d3c3
parent 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
428
cdfa6a293453 updated solutions and templates
Christian Urban <christian.urban@kcl.ac.uk>
parents: 396
diff changeset
    13
//(2) 
343
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
    14
def collatz_max(bnd: Long) : (Long, Long) = ???
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
    15
428
cdfa6a293453 updated solutions and templates
Christian Urban <christian.urban@kcl.ac.uk>
parents: 396
diff changeset
    16
//(3)
343
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
    17
def is_pow_of_two(n: Long) : Boolean = ???
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
    18
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
    19
def is_hard(n: Long) : Boolean = ???
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
    20
c8fcc0e0a57f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 281
diff changeset
    21
def last_odd(n: Long) : Long = ???
11
417869f65585 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
470
86a456f8cb92 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 430
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