Saturday July 15th

Spinnaker and a beautiful day of sailing!

  • My my, this is quickly becoming a sailing and coding blog!

  • But they do intersect, don’t they? Just a while ago I was talking about Netflix’s Spinnaker, and today I put one up! :)

  • It was actually a Gennaker, but it was a wonderful day!

We saw dolphins!

  • We sailed all the way to Malibu and back.

  • We even saw this guy!

I have to get up early in the morning…

  • Got to get started on my labs. If not, I’ll do them in LA; I should have access to them then, too. But I’d like to get them done this weekend

In the meantime…

  • Our beautiful Gennaker/ A-sail!

Katas

  • Sum the strings
function sumStr(a,b) {
  if ((a  == null) || (b == null))
  {
    return "0"
  }
  else if ((a == "") && (b == "")){
    return "0"
  }
  else if ((a == null) || (a == "")){
    return b
  }
  else if ((b == null) || (b == "")){
    return a
  }
  else{
    return (parseInt(a) + parseInt(b)).toString();
  }
}
  • take the derivative
function derive(coefficient,exponent) {
  var a = coefficient * exponent
  var b = exponent - 1
  return a.toString() + "x^" + b.toString();
}
  • Sushi go-round
def total_bill(s):
    # 0 length return 0
    if len(s) == 0:
      return 0
    else:
      arr = []
      a1 = list(s)
      
      a1 = [x.strip(' ') for x in a1]
      a2 = ''.join(a1)
     
      a = len(a2) / 5
      b = len(a2) *  2
      c = b - a - a 
      return c
  • Aspect ratio (the biggest problem with this problem is rounding to pass tests)
function aspectRatio(x,y){
  var arr = []
  var x1 = 1.0/(9.0/16.0) * y * 1.0
  var y1 = y
  arr.push(Math.ceil(x1))
  arr.push(y1)
  return arr;
}
  • Odd one…return index of first odd number in array or -1 if no odd
function oddNum(arr) {
  var arr1 = []
  for (var i = 0; i < arr.length; i++)
  {
    if (arr[i] % 2 != 0)
    {
      arr1.push(i)
    }
  }
  if (arr1.length == 0){
    return -1;
  }
  else{
  return arr1[0]
  }
}
  • Return char * length of string a eg. contamination(‘aabb’, ‘x’) should return ‘xxxx’
def contamination(text, char):
    a = len(text)
    c = ""
    for i in range(0, a):
      c = c + char
    
    return c
  • Find total in ascii… but a = 1, b = 2, etc.

  • Basically, just make a = 1 by using ascii and subtracting 96. The others will be correct, and then loop through a list of each char of the string, and find total.

def WordsToMarks(String):
  total = 0
  word = list(String)
  
  for i in word:
    total = total + (ord(i) - 96)
    
   
  return total

Interesting…

Written on July 15, 2017