CSC108H A Word Game

【信息科学与工程学】【数据科学】数据科学领域 第六篇 算法设计 07 堆、栈、表、矩阵、集合、队列、数组、字符串、树、图、动态规划、结构体、元组的算法01 当前段必须包含所有字符的最后出现位置。1. 字符串分割成最多片段2. 基因序列功能域划分3. 文本段落划分4. 音频声道分离5. 图像色彩分区6. 社交网络社群划分7. 蛋白质结构域8. 音乐乐章分段9. 代码模块划分10. 章节划分特征:一次扫描,贪心确定边界。 阅读详情

CSC108H Assignment 1: Wordlock

Due Date:Wednesday September 25,2024 before 4:00 p.m

Wordlock: A Word Game

In this assignment,you will write functions to implement a puzzle game that requires the player to use a number of simple moves to unscrambled a given word.The goal of the game is to discover the correct answer word.

Goals of this Assignment

·Use  the Function Design Recipe (https:/lq.utoronto.calcourses/352998/files/32275858?wrap=1) (https://q.utoronto.calcourses/352998/files/32275858/download?download_frd=1) to  plan,implement, and test functions.

·Write function  bodies  using  variables,numeric types,strings,and  conditional  statements.You can do this whole assignment with only the concepts from the Weeks 1,2,and 3 Prepare Exercises for CSC108.

·Learn to use  Python 3,Wing  101,provided  starter code,a checker module,and other tools.

The Wordlock Game

Before you begin writing any code,you first need to understand the Wordlock game.Gameplay is described in the paragraphs below,so read carefully!

Game Mechanics

In the game,the player is presented with a scrambled version of the answer string.The answer string has been scrambled by first spliting it into sections,each having the same length,and then rearranging each section randomly,as in Figure 1.

Figure 1:Strings are scrambled in sections.

In Figure 1,the section'ROCK' has been scrambled to become'OCKR'and the section|'LAKE'has been

scrambled to become EAKL'

The sections in the string are numbered 1 to N,where N is the total number of sections.The section length is fixed for each run of the game,and every section will have the same length.For example,

consider   the   string 'treerocklake' and   a   section   length   of[4.There  are  3  sections  in  total  and  section  2

is 'rock

The player's objective is to unscramble the string using as few moves as they can.The player has three   types of move available each turn:Check,Rotate,and Swap.Each move is applied to a single section of the string.We will use the phrase game state to refer to the current state of the string that the player is    trying to unscramble.

The   three    move   types:Check,Rotate,and    Swap

The Check move does not modify the game state.It is used to check if a given section of the game state has been correctly rearranged to match the corresponding section in the answer string.

The  Rotate  move  is  a  circular  Rotate  of  the  string  to  the   right,which   means  each  character  is  moved  one position to the right and the last character is moved to the front.For example,the second last character   of the section becomes the last character of the section in the new game state,and the last character

before the rotate is moved to be at the beginning of the section.

In the Swap move,the first and last characters of the section are exchanged in the game state.

The Rotate and Swap moves are illustrated in the figure below.

The   three   modes   of   gameplay:Test,Normal,and   Hint

The game allows for 3 modes of play:Test,Normal,and Hint.Enabling Test mode allows the player to set the correct answer and the number of sections before the game begins.(Otherwise,the player is presented with a scrambled word and told the section size.)Normal mode involves playing the game as we have described above.Hint mode provides one additional move that allows the player to receive hints  on  which  sections  and  moves  to  choose  each  round.

Gameplay

When the game begins,the player is first asked to choose a game mode.Then,the player is repeatedly asked to provide both:

1.The section number corresponding to the section they want to manipulate.(A string with N sections will have its sections numbered 1 to N.)

2.The move they would like to apply to the section.

If the player is playing in Hint mode,they will be offered the chance to get a hint for a section to choose,

or a move to make on a particular section.Getting a hint counts towards the player's total number of moves.

The game continues until the player has completely unscrambled the string and discovered the answer string.When the game is over,the player's total number of moves is reported.

Here is a video of the game being played (note that the video is difficult to see unless you watch it in the highest quality,use the settings gear and set the video quality to the highest number of kbps):

Files to Download

Click here to download the Assianment 1 Files (https://a.utoronto.ca/courses/352998/files/33105723? wrap=1)_山 (https://q.utoronto.calcourses/352998/files/33105723/download?download_frd=1),and  then    extract the zip file.The following paragraphs explain the files you have been given.

Starter code: wordlock functions.py

This file contains some constants,and a complete docstring (but not body!)for the first function you are  to write.You will update this file to include the complete functions that you write.This is the only file you will submit for grading.

Main program code: wordlock game.py

This file contains the main program code for playing the game.When it is run,the functions that you

wrote and put in the wordlock functions.py file will be called.When you have written all of the functions in wordlock functions.py ,you may play the full game by running wordlock game.py].You can further test your   code by running in Test mode where you are prompted for the ANSWER and SECTION LENGTH] that the game  should use.Do NOT make any changes to the wordlock game.py file,as you will  not submit this file.We    do not expect you to understand all of the code in this file at this point in the course.

Checker: a1 checker.py      checker generic.py   and  al   pyta.json

These files provide a checker program that you should use to perform. a simple test of your code.See   below in the section called CSC108 A1 Checker for more information about a1 checker.py].The   checker program requires the files checker generic.py and a1 pyta.json]. You do not need to do anything with

these files,other than keep them all in the same folder as your wordlock functions.py and wordlock game.py file.

What to do

In  the  starter  code  file wordlock functions.py ,complete  the  functions   as   described  in  the  table   below.Use

the Function     Design      Recipe      (https://g,utoronto.calcourses/352998/files/32275858?wrap=1)↓

(https://q.utoronto.calcourses/352998/files/32275858/download?download_frd=1)       that   we have    been learning  in  class,and  write  complete  docstrings  for  each  function.

Using Constants

The starter code in wordlock functions.py starts with the definition of some constants.Your code should make use of these provided constants.If the value of one of those constants were changed,and your

program rerun,your functions should work with those new values.We will test your code using different   values for the various moves and modes by updating the values of the constants -your code should sill  work with these updated values!The one exception to this is the constant HINT MoDE SECTION LENGTH].This   constant will always be set to 3 and your functions only need to work for this value.(We are constraining this value in order to make the assignment difficulty level appropriate for this stage in the course.)

Your docstring examples can use the values of the constants in the provided starter code,and do not need to changeif we change the values of the constants.

Students often choose to use the literal values of constants when references to the constants should be used instead.If you are confused about the difference,look into Piazza or come in to office hours!

Preconditions

When writing your functions,you may always assume that:1.the game state is a valid scrambling of the answer,and 2.both the game state and answer can be evenly split into sections with the given section    length.Yo u must not make any other assumptions other than this and what is given in the table below for each function.For example,you must not assume all characters are uppercase.

Regarding preconditions:1.You do not have to write any of the preconditions into the docstrings for this assignment,and 2.You can not assume any preconditions other than what we already mention about    the type contracts and parameters in the table below.

论文阅读——Bayesian Knowledge Fusion(贝叶斯知识融合) 该篇论文解决了不确定环境中的信息融合问题。想象一下,有多位专家针对同一情况构建概率模型,我们希望汇总他们提供的信息。直接合并每个信息可能会遇到几个问题。例如,专家们可能不同意某个事件发生的概率,或者他们可能不同意两个事件之间因果关系的方向(例如,一个人认为 A 导致 B,而另一个人认为 B 导致 A)。他们甚至可能不同意概率网络中一组变量之间的整个依赖结构。 阅读详情

相关推荐

利用树莓派制作智能音箱

利用树莓派制作智能音箱

qq_61803022的博客 1779

CSC108 Class5 Note

1. Python 中的 List: List(列表), 是Python中常用的一种数据储存工具,例如,如果我们想要存储三个学生的期末成绩,就可以创建以下的list: grade = [70, 80, 90, 100, 100, 110] 对于List,我们有类似于对于str的索引办法,相似的,List的中的元素,也是从0开始排列,如果从后往前索引,第一个元素的index是-1。于是,对于我们创建的grade这个list,我们可以得到以下的结果 grade[0] >>> 70

psychopaul的博客 180

在 Linux/Debian/Ubuntu 上使用 Brasero 刻录光盘

在 Ubuntu 系统中,Brasero 是一个非常方便的光盘刻录工具。无论是创建数据光盘、音频光盘还是刻录光盘镜像文件,Brasero 都能轻松胜任。本文将介绍如何在 Ubuntu 上安装和使用 Brasero 进行光盘刻录。

I AM COMING BACK... 3553

【python】15个经典Python实训题目(附源代码)

Python是目前最好的编程语言之一。由于其可读性和对初学者的友好性,已被广泛使用。 那么要想学会并掌握Python,可以实战的练习项目是必不可少的。 接下来,我将给大家介绍15个非常实用的Python项目,帮助大家更好的学习Python。 本文中的代码仅供大家参考,最好就是自家试着构建一下,这样更能提升自己的编码水平。 如果文章有帮助到您,感谢您的关注与支持!

a1234567822的博客 3841

低功耗和UPF介绍

参考[UPF]低功耗(Low Power Design)and UPF介紹

青春易逝,愿不负昭华,期待梦与远方 1万+

STM32G030C8T6 ADC+DMA实战:同时采集外部电压和芯片温度的完整代码流程

本文详细介绍了STM32G030C8T6芯片通过ADC+DMA实现外部电压和芯片内部温度采集的完整流程。从硬件设计到CubeMX配置,再到驱动模块化实现与系统优化,提供了高精度多通道采集系统的实战指南,特别适合嵌入式开发者在工业控制和环境监测项目中应用。

weixin_42653691的博客 473

学习C#开源报表组件Seal Report(45:报表服务安全配置)

学习Seal Server Manager软件内与报表服务安全配置相关的各类属性的用途

gc_2299的博客 156

scottplot5中使用signalXY图,如何更新数据?

🏆本文收录于《优快云问答解答》专栏,主要记录项目实战过程中的Bug之前因后果及提供真实有效的解决方案,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&订阅!持续更新中,up!up!up!!

**My Coding Family** 2453

Advance Steel工具栏菜单的创建

创建jigdesignpalettedata.xml文件并放置于...\INT\Steel\Support\Toolbars\目录下,随后修改C:\ProgramData\Autodesk\Advance Steel 2025\INT\ASSettings_User.xml,添加对应键值对以加载该配置。示例中设置面板位置、大小及可见性,通过ParentId指定父窗口,确保自定义工具栏正确显示。

Advance Steel二次开发 39

基于Simulink的固态变压器(SST)多级协同控制​

本文介绍了基于Simulink的固态变压器(SST)多级协同控制方法。SST作为智能电网关键设备,其三级架构(AC-DC整流、DC-DC隔离、DC-AC逆变)存在级间耦合问题。文章提出纵向解耦与横向联动相结合的协同控制策略,详细推导了各级控制算法,并通过Simulink实现了10kV/400V级联型SST系统建模。仿真结果显示,在±20%电网波动和0-100%负载跳变下,系统能保持直流母线电压波动<2%。文章还提供了工程部署建议和代码生成方法,为SST的研发提供了实用指导。

amy_mhd的博客 303

蓝牙芯片驱动开发-第11章第1题-WiFi蓝牙共存的关键策略有哪些

蓝牙芯片驱动开发-第11章第1题-WiFi蓝牙共存的关键策略有哪些

weixin_42162924的博客 32

C# 系列教程_12 字符串 string 保姆级系统教程(面向新手,大量示例 + 原理讲解)

C#中string与String为同一类型,均为不可变引用类型,任何“修改”操作均返回新字符串。常用创建方式包括字面量、逐字字符串@""、插值$""及new String()。字符串本质是字符数组,支持索引访问但不可修改。所有方法如IndexOf、Substring、Replace等均不改变原字符串,返回新实例。

zhanghaha1314的博客 281

Unity3D实现项目限制功能(使用次数限制和时间限制)

大家好,我是心疼你的一切,不定时更新Unity开发技巧,觉得有用记得一键三连哦。在软件开发的时候,可能会遇到程序的使用次数限制,以及时间的限制,下面就写一下这两种方法是新建注册表,增加键值对,修改键值,完成对程序的控制提示:以下是本篇文章正文内容,下面案例可供参考以上就是讲了两种限制方法不定时更新Unity开发技巧,觉得有用记得一键三连哦。

心疼你的一切博客 1813

Swift 字符详解:从 Character 到字符串遍历

Swift中Character代表扩展字形簇,符合人类对“一个字符”的直观理解。它与String为集合关系,可通过for-in遍历或数组拼接。Character基于Unicode,组合字符(如带重音字母、表情符号)视为整体,count统计字形簇数而非码点或字节。访问需用String.Index,不可直接整数下标。字符支持比较、大小写转换及ASCII互转,但必须用双引号声明,且与String类型区分。理解其设计可避免常见错误,提升字符串处理可靠性。

2402_85743155的博客 303

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

第6章第4节:自定义分词器

本节详解Elasticsearch自定义分词器,解析analyzer三段式结构(char_filter→tokenizer→filter),掌握常用组件如ik_max_word、synonym_graph、ngram等。通过_analyze API调试分词效果,实现“索引时扩展同义词、搜索时不带”的生产级方案,提升中文搜索与智能提示体验。

啊渊的专栏 798

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

C#转Python第5.3篇:类型提示与静态分析:Python 的“伪静态类型“

Python的类型提示是“伪静态类型”——注解由IDE和工具(如mypy)使用,解释器运行时忽略。与C#强制编译时类型检查不同,Python类型注解仅作开发辅助,提升代码可读性、智能提示与静态分析能力。通过List[int]、Optional[str]、Protocol等特性,实现类型安全与泛型支持。Python 3.14起引入延迟求值与annotationlib,优化性能并支持前向引用。核心理念:类型注解是“给开发者看的文档”,而非运行时保障。

hanzhixintianxia的博客 266

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

C# 数据结构和特殊类型

.NET Core(现称.NET)提供丰富数据结构,优化性能与开发效率。日常开发首选List<T>和Dictionary<TKey,TValue>;高性能场景推荐Span<T>与Memory<T>减少内存分配;并发环境使用ConcurrentDictionary等线程安全集合;避免非泛型集合如ArrayList。

cccloveforever的博客 765

SQL 基础查询与模糊查询全解 + C# WinForm 数据库连接实战:ADO.NET、参数化查询与 where 1=1 动态条件

上篇把表建好、关系连好。,再。从select *到,从到,从拼字符串到参数化,最后讲清楚where 1=1到底解决什么问题——顺便把课上那道选择题的答案讲透。

2501_94699871的博客 172

C# NModbus4 实战:ModbusTCP 读取以太网温湿度传感器

本文基于C#与NModbus4库,实战演示如何通过ModbusTCP协议读取以太网温湿度传感器(如H-THRJ45)数据。涵盖设备配置、寄存器地址解析、缩放换算及常见调试坑点,提供可运行的控制台Demo,适用于机房动环、GSP库房等物联网场景。代码支持异步扩展、数据持久化与告警逻辑,助力快速搭建自研采集系统。

weixin_41865733的博客 284

BPE分词器的完整实现:字节对合并与词表构建

本文深入解析了大语言模型分词器的核心机制,以字节级BPE为例,揭示其如何将文本转化为token。通过字节编码实现无外生词(OOV)问题,但带来跨语言价差与计数故障等挑战。文章完整实现BPE训练与编码逻辑,强调预切分正则与语料配比的关键作用,并指出分词器不仅是技术组件,更是决定模型感知粒度与成本结构的底层决策——它塑造了模型对文字的理解方式,也影响着每一次推理的效率与费用。

2601_96733043的博客 270

C# 系列教程_10 方法(Methods)保姆级精讲

本文系统讲解C#方法的定义与使用,涵盖语法结构、参数传递、返回值、作用域及重载机制。通过无参无返回值、有参、有返回值等示例,阐明方法如何减少冗余、提升代码可读性与维护性。重点强调方法重载(同名异参)、返回值类型不可单独决定重载、局部变量作用域限制等核心概念,并提醒新手常见误区,如缺少return、误判重载条件等。最后介绍可选参数与传值机制,帮助初学者掌握方法调用的规范与技巧。

zhanghaha1314的博客 340

C# ScottPlot 曲线控件

本文介绍使用ScottPlot.WinForms在WinForms中绘制高性能图表的实践。通过NuGet安装后,实现多种图形绘制:添加水平/垂直参考线、信号图与散点图(支持百万级数据)、自定义线段及多曲线叠加,并通过异步任务实现实时动态曲线更新,结合Refresh()与AutoScale优化渲染性能,有效解决大数据量下的显示问题。

m0_47020592的博客 43

C# SerpBase 谷歌搜索API:请求、建模与核账实战

上周二晚上 9 点 40 分,我还在改一个 .NET 看板:运营要监控 300 个品牌词在谷歌美国区的排名,第二天早上 10 点演示。原来基于 HtmlAgilityPack 硬解析页面的服务连续三天被拦截,返回忽长忽短。我决定连夜换成结构化搜索 API,用 C# 接,最后选了 SerpBase——它是纯 HTTP 的 POST JSON 接口,Base URL 固定为,.NET 这边不用任何第三方 SDK,一个HttpClient就能打通,而且同一个 Key 可以覆盖文档里列出的 43 个端点。

Y381532662的博客 194

用Python删除PPTX中的牛皮癣广告

本文介绍了一款免费的PPTX广告清理工具,利用Python与python-pptx库实现批量删除模板中的广告元素。该工具可自动清除幻灯片备注、母版名称、文档属性、最后两页广告页,并支持关键词搜索替换隐藏广告。通过GUI界面实现文件导入与一键清理,大幅提升效率,避免手动操作耗时出错。代码开源免费,适合需要快速处理大量带广告PPT模板的用户。

henanlion的博客 233

如何使用C#代码清理 Excel 表格中的空白行与空白列

通过 C# 代码,可以自动检查并删除 Excel 工作表中的空白行和空白列。利用IsBlank属性判断行或列是否为空,再分别调用和方法,即可完成清理操作。与手动逐行、逐列检查相比,这种方式更适合处理包含大量数据的 Excel 文件,能够减少重复操作,提高数据整理效率,使工作表保持整洁、清晰。在实际使用中,建议从工作表的末尾向前遍历并删除空白行和空白列,避免删除操作改变索引位置,影响后续检查。

2501_93070778的博客 239

QML学习日记 Day2:布局控件+登录界面

Column是纵向布局,里面的子控件,不要写 top、bottom、verticalCenter;Row是横向布局,里面的子控件,不要写 left、right、horizontalCenter;定位器规则:自动排布子控件,布局方向上,子控件不要写同方向锚点,会冲突;锚点原理:把控件边缘绑定到父控件、或者别的控件的边缘,窗口缩放时自动适配位置。作用:基础可视容器,用来做背景、色块、边框、圆角面板,包裹其他子控件。控件放满一行,自动换行。1. QtQuick:底层图形、基础容器、基础文字、基础输入、定位器;

2201_75293893的博客 435
上一篇: COMPSCI 315 Web Server Workload Characterization
下一篇: ECON 3720: Introduction to Econometrics
vx___codinghelp
博客等级 码龄2年 778粉丝 101原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值