Coding the Matrix: Linear Algebra through Computer Science Applications

本次作业分成三部分,第一部分点击打开链接 已经记录过,后两部分也早已完成,趁有时间记下来。

hw0 比较简单,如果有问题在论坛都可以找到答案。不过要注意使用python3运行。不过没有想到python里面也支持j作为虚数单位。

# Please fill out this stencil and submit using the provided submission script.## Problem 1
def myFilter(L, num): return [x for x in L if x%num]## Problem 2
def myLists(L): return [list(range(1,x+1)) for x in L]## Problem 3
def myFunctionComposition(f, g): return {x:g[f[x]] for x in f.keys()}## Problem 4
# Please only enter your numerical solution.complex_addition_a = 5+3j
complex_addition_b = 0+1j
complex_addition_c = -1+.001j
complex_addition_d = .001+9j## Problem 5
GF2_sum_1 = 1
GF2_sum_2 = 0
GF2_sum_3 = 0## Problem 6
def mySum(L):sumL=0for x in L:sumL+=xreturn sumL## Problem 7
def myProduct(L):sumL=1for x in L:sumL*=xreturn sumL## Problem 8
def myMin(L):sumL=L[0]for x in L:if sumL>x:sumL=xreturn sumL## Problem 9
def myConcat(L):output=''for x in L:output+=xreturn output## Problem 10
def myUnion(L):output=set()for x in L:output=output | xreturn output

inverse_index_lab也比较简单:

from random import randint
from dictutil import *## Task 1
def movie_review(name):"""Input: the name of a movieOutput: a string (one of the review options), selected at random using randint"""review_options = ["See it!", "A gem!", "Ideological claptrap!"]return review_options[randint(0,len(review_options)-1)]## Tasks 2 and 3 are in dictutil.py## Task 4
def makeInverseIndex(strlist):"""Input: a list of documents as stringsOutput: a dictionary that maps each word in any document to the set consisting of thedocument ids (ie, the index in the strlist) for all documents containing the word.Note that to test your function, you are welcome to use the files stories_small.txtor stories_big.txt included in the download."""output={}for (i,x) in list(enumerate(strlist)):tmp=x.split()for word in tmp:if word in output:output[word]=output[word] | {i}else:output[word]={i}return output## Task 5
def orSearch(inverseIndex, query):"""Input: an inverse index, as created by makeInverseIndex, and a list of words to queryOutput: the set of document ids that contain _any_ of the specified words"""output=set()for word in query:output=output | inverseIndex[word]return output## Task 6
def andSearch(inverseIndex, query):"""Input: an inverse index, as created by makeInverseIndex, and a list of words to queryOutput: the set of all document ids that contain _all_ of the specified words"""output=set()if len(query)==0:return outputoutput=inverseIndex[query[0]]for word in query:output=output & inverseIndex[word]return output

Coding the Matrix Week 0 作业相关推荐

  1. Coding the Matrix Week 2 The Vector Space作业

    Coding the Matrix: Linear Algebra through Computer Science Applications 本周的作业较少,只有一个编程任务hw2.作业比较简单,如 ...

  2. Coding the Matrix Week 1 The vector 作业

    Coding the Matrix: Linear Algebra through Computer Science Applications 这次作业难度不小,第一个作业hw1还好,第二个全部都可以 ...

  3. Coding the Matrix作业Python Lab及提交方法

    Coding the Matrix: Linear Algebra through Computer Science Applications 这是一门用python实现矩阵运算的课,第一次作业就感觉 ...

  4. Coding the Matrix Week 1 The Vector Space作业

    Coding the Matrix: Linear Algebra through Computer Science Applications 本周的作业较少,只有一个编程任务hw2.作业比较简单,如 ...

  5. Coding the Matrix Week 3 The Matrix 矩阵

    本周共有三次作业.所花费的时间为一天左右,还算可以,需要注意的是考虑一些特殊情况,写出能够通用的程序,这就行了. 体会 set()和{}结果相同,可以通用,可以采取后者. >>> t ...

  6. 免费ETL调度管理平台,自动化运维工具 TASKCTL 8.0作业设计功能使用

    TASKCTL 8.0 8.0是一款基于B/S架构[轻量企业级免费ETL任务批量处理工具]它支持各类脚本任务程序和扩展:具备可视化图形拖拽设计界面,以及可视化任务作业管理.计划调度.实时监控.消息提醒 ...

  7. Hadoop hdfs副本存储和纠删码(Erasure Coding)存储优缺点

    The advantages and disadvantages of hadoop hdfs replicating storage and erasure coding storage. Hado ...

  8. 2020人工神经网络第一次作业-参考答案第六部分

    本文是 2020人工神经网络第一次作业 的参考答案第六部分 ➤06 第六题参考答案 1.题目分析 按照题意,构造如下的神经网络. 隐层的传递函数使用sigmoid函数,输出层的传递函数采用线性传递函数 ...

  9. java客户服务器程序预约口罩_团队作业(二):Github实训:口罩预约

    这个作业要求在哪里 这个作业的目标 使用Github进行团队协作 其他参考文献 <构建之法> Part 1 关于此次作业 (1)组员职责分工 221701436:组织小组参与讨论分工,测试 ...

最新文章

  1. 目标检测中的anchor-based 和anchor free
  2. 求小数的小数点的第n位是什么
  3. 利用OTP为odoo增强安全访问
  4. java学习笔记11--集合总结
  5. html中怎样引入外部字体文件路径,CSS引入外部字体
  6. oracle上机题库_Oracle数据库考试试题库
  7. 事件监听机制——鼠标事件MouseEvent
  8. 2016年湖南省第十二届大学生计算机程序设计竞赛
  9. BeanPropertyRowMapper使用注意事项
  10. python必背代码-Python高手必修课:如何让 Python 代码更易读,推荐收藏
  11. OracleDG主库丢失归档增量同步
  12. spring boot 集成paypal支付 rest api v2的实现
  13. 三步解决NLP数据标注难题,百度大脑EasyDL专业版上线文本智能标注功能
  14. 关于XShell下载安装和连接Ubuntu(linux)
  15. 哈工大2022年春季学期计算机系统大作业——程序人生
  16. Cesium专栏-空间分析之地形等高线(附源码下载)
  17. Ctrl+Space冲突解决及输入法精简
  18. 智能内存整理 [免费绿色] 3.0.0.0
  19. 数据库多表联查的方式
  20. python倒计时定时器_使用python修饰器的定时器倒计时

热门文章

  1. GraphX:基于Spark的弹性分布式图计算系统
  2. u盘模式 linux hi3518,嵌入式 RT3070_STA驱动移植到hi3518c平台小结
  3. php事件检测,细说浏览器特性检测(2)-通用事件检测_jquery
  4. 实现粗糙表面_什么是表面粗糙度,你真懂吗?
  5. 如何快速的入门git实现版本控制
  6. 新计算机主板不亮,电脑组装完毕之后点不亮怎么办 新电脑组装好开不了机的解决办法...
  7. c语言多线程详,如何用C语言实现多线程
  8. mac scp工具_Mac远程ssh连接乌班图并实现爬虫操作
  9. dnf剑魂buff等级上限_DNF:又是随机大坑?8月新护石装备可升级,但升3个需要刷半年...
  10. html一个页面多个动画,如何在单个html页面中添加两个相同的adobe边缘动画?