Starting from:
$30

$24

Homework 1 Solution

In how many ways may 3 officers (President, V.P. & Secretary) be picked from a 12 member club, if two people, Ahmet and Hasan, won’t serve together?









How many 3-digit even numbers have no repeating digits? (Note that the first digit can’t be a 0; otherwise, it becomes a two digit number.)






In how many ways you can seat 12 people at two round tables (i.e. seats at a table are all the same, but your left and right neighbors do matter) with six places each?



If the two tables are distinguishable (i.e., it matters at which table one sits).






If the two tables are not distinguishable (i.e., it doesn’t matter at which table one sits).



What is the number of different ways to color n ordered objects a1,a2,…,an (n ≥ 3) using 3 colors if every color must be used at least once? Why?









Write a Haskell function count for counting the number of occurrences of a given character in a string. In Haskell, a character is an object of type Char, and a string an object of type String, so the type declaration should run: count::Char-String-Int.



Write a Haskell function, nubS, that removes duplicate characters in its argument, which is a string, and outputs the resulting new string. (E.g. input string = “strange characters” should be processed into the output string = “strange ch”)



(This was a test question last year.)




Use map to write a function: lengths that takes a list of lists and returns a list of the corresponding list lengths. Then, write another function sumLengths that takes a list of lists and returns the sum of their lengths.



Write a Haskell function takeOdds that takes odd numbers from a given list of integers to create another list.



Write two Haskell functions that take as input a string containing a number with a decimal point (for example, “23.455”).



The first function, wholePart, returns a string that contains the whole part of the number (i.e., the part to the left of the decimal point. For the example above: “23”).



The second function, fracPart, returns a string that contains the fractional part (the part to the right of the decimal point. For the example above: “455”).
Write a third function, wholePart2Int, that converts the string containing the whole part above into an integer as its output. (For the example above: 23.)



(This was a test question in previous years.)




Excel uses column names like A, B, C ... AA, AB, AC up to infinite. Write a function to convert the column name to its column index.



(This is a question asked in an interview for a software developer position in a Silicon Valley company.)

More products