This file contains 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 scalaninetynine | |
/* | |
* S99 P11 http://aperiodic.net/phil/scala/s-99/ | |
* Modified run-length encoding. | |
* Modify the result of problem P10 in such a way that if an element has no | |
* duplicates it is simply copied into the result list. Only elements with | |
* duplicates are transferred as (N, E) terms. | |
* | |
* Example: | |
* |
This file contains 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
/* | |
* S99 P12 http://aperiodic.net/phil/scala/s-99/ | |
* | |
* Decode a run-length encoded list. | |
* | |
* Given a run-length code list generated as specified in problem P10, | |
* construct its uncompressed version. | |
* | |
* Example: | |
* |
This file contains 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
/* | |
* S99 P15 http://aperiodic.net/phil/scala/s-99/ | |
* (**) Duplicate the elements of a list a given number of times. | |
* | |
* Example: | |
* | |
* scala> duplicateN(3, List('a, 'b, 'c, 'c, 'd)) | |
* res0: List[Symbol] = List('a, 'a, 'a, 'b, 'b, 'b, 'c, 'c, 'c, 'c, 'c, 'c, 'd, 'd, 'd) | |
*/ |
This file contains 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
/* | |
* S99 P16 http://aperiodic.net/phil/scala/s-99/ | |
* (**) Drop every Nth element from a list. | |
* | |
* Example: | |
* | |
* scala> drop(3, List('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k)) | |
* res0: List[Symbol] = List('a, 'b, 'd, 'e, 'g, 'h, 'j, 'k) | |
* | |
*/ |
This file contains 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
#################### | |
# centos 5.8 | |
# post installation | |
# adapted from | |
# https://github.com/jedi4ever/veewee/tree/master/templates/CentOS-5.7-i386-netboot | |
#################### | |
yum -y install sudo | |
/usr/sbin/groupadd vagrant |
This file contains 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
/* | |
* S99 P19 http://aperiodic.net/phil/scala/s-99/ | |
* | |
* (**) Rotate a list N places to the left. | |
* | |
* Examples: | |
* | |
* scala> rotate(3, List('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k)) | |
* res0: List[Symbol] = List('d, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'a, 'b, 'c) | |
* |
This file contains 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 scala.annotation.tailrec | |
/* | |
* S99 P22 http://aperiodic.net/phil/scala/s-99/ | |
* | |
* Create a list containing all integers within a given range. | |
* Example: | |
* scala> range(4, 9) | |
* res0: List[Int] = List(4, 5, 6, 7, 8, 9) | |
* |
This file contains 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 scalaninetynine | |
import scala.annotation.tailrec | |
import scala.collection.Iterable | |
import scala.collection.IndexedSeq | |
/* | |
* S99 P6 http://aperiodic.net/phil/scala/s-99/ | |
* | |
* Generate the combinations of K distinct objects chosen from the N elements of a list. | |
* In how many ways can a committee of 3 be chosen from a group of 12 people? We all know that there are C(12,3) = 220 possibilities (C(N,K) denotes the well-known binomial coefficient). For pure mathematicians, this result may be great. | |
* But we want to really generate all the possibilities. |
This file contains 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
/** | |
* D Holbrook | |
* | |
* Code Club: PO1 | |
* | |
* (*) Define a binary tree data structure and related fundamental operations. | |
* | |
* Use whichever language features are the best fit (this will depend on the language you have selected). The following operations should be supported: | |
* | |
* Constructors |
This file contains 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
/** | |
* D Holbrook | |
* | |
* Code Club: Sudoku solver | |
* | |
* Brute force solver | |
*/ | |
object Sudoku extends App { | |
val valid = Range(1, 10) |