Lecture 4: Loops over Strings, Guess-and-Check, and Binary

MIT OpenCourseWare April 11, 2024
Video Thumbnail
MIT OpenCourseWare Logo

MIT OpenCourseWare

View Channel

About

A free and open online publication of educational material from thousands of MIT courses, covering the entire MIT curriculum, ranging from introductory to the most advanced graduate courses. On the OCW website, each course includes a syllabus, instructional material like notes and reading lists, and learning activities like assignments and solutions. Some courses also have videos, online textbooks, and faculty insights on teaching. Knowledge is your reward. There's no signup or enrollment, and no start or end dates. OCW is self-paced learning at its best. Whether you’re a student, a teacher, or simply a curious person that wants to learn, MIT OpenCourseWare (OCW) offers a wealth of insight, inspiration, videos, and a whole lot more! Get the full picture on the OCW website at https://ocw.mit.edu. Accessibility: https://accessibility.mit.edu/ User comments policy: https://ocw.mit.edu/comments/ (Channel banner photo by Nietnagel on Flickr: https://flic.kr/p/8WXxfK.)

You May Also Like

Enhance Your Coding Journey

AI-recommended products based on this video

Loading...
Freenove Ultimate Starter Kit for BBC micro bit (V2 Included), 316-Page Detailed Tutorial, 225 Items, 44 Projects, Blocks and Python Code

Freenove Ultimate Starter Kit for BBC micro bit (V2 Included), 316-Page Detailed Tutorial, 225 Items, 44 Projects, Blocks and Python Code

(382)
$94.95
PrimeFREE delivery Sat, Jun 14
Loading...
10.1 Inch Touch Portable Monitor IPS Screen 1366x768P 60Hz 400 Brightness 99% sRGB HDMI USB-C Monitors Switch for Xbox PS3/4/5 Laptop Compatible with Raspberry Pi, Mini Touch Screen

10.1 Inch Touch Portable Monitor IPS Screen 1366x768P 60Hz 400 Brightness 99% sRGB HDMI USB-C Monitors Switch for Xbox PS3/4/5 Laptop Compatible with Raspberry Pi, Mini Touch Screen

(1)
$99.99
FREE delivery Mon, Aug 11
Loading...
ELECROW 8 Inch Portable Monitor, 1280x800 Mini HD Display with Built-in Speakers, USB Powered, Non-Touch LCD Screen for Raspberry Pi, PC, Laptop, Jetson Nano, Game Consoles

ELECROW 8 Inch Portable Monitor, 1280x800 Mini HD Display with Built-in Speakers, USB Powered, Non-Touch LCD Screen for Raspberry Pi, PC, Laptop, Jetson Nano, Game Consoles

(49)
$117.29$102.21
$6.86 delivery Thu, Aug 14
Loading...
7 Inch Portable Monitor Touchscreen HD 1024x600 LED Display Dual HDMI Port Small Monitor for PC Raspberry Pi Laptop Computer Xbox PS4/5 Switch Built-in Speakers

7 Inch Portable Monitor Touchscreen HD 1024x600 LED Display Dual HDMI Port Small Monitor for PC Raspberry Pi Laptop Computer Xbox PS4/5 Switch Built-in Speakers

(61)
$68.99
FREE delivery Tue, Aug 12
Loading...
BrosTrend 1800Mbps WiFi 6 Linux WiFi Adapter for PC and Raspberry Pi 2+, Long Range USB WiFi Dongle Linux for Ubuntu, Mint, Debian, Kubuntu, Lubuntu, Zorin, Windows 11/10, Dual Band Wireless Antenna

BrosTrend 1800Mbps WiFi 6 Linux WiFi Adapter for PC and Raspberry Pi 2+, Long Range USB WiFi Dongle Linux for Ubuntu, Mint, Debian, Kubuntu, Lubuntu, Zorin, Windows 11/10, Dual Band Wireless Antenna

(288)
$54.14
FREE delivery Sun, Jun 22
Loading...
Logitech M185 Wireless Mouse, 2.4GHz with USB Mini Receiver, 12-Month Battery Life, 1000 DPI Optical Tracking, Ambidextrous, Compatible with PC, Mac, Laptop - Black

Logitech M185 Wireless Mouse, 2.4GHz with USB Mini Receiver, 12-Month Battery Life, 1000 DPI Optical Tracking, Ambidextrous, Compatible with PC, Mac, Laptop - Black

(43,809)
$14.99$11.99
FREE delivery Mon, Sep 22 on your first order
1K+ bought in past month
Loading...
Logitech G203 Wired Gaming Mouse, 8,000 DPI, Rainbow Optical Effect LIGHTSYNC RGB, 6 Programmable Buttons, On-Board Memory, Screen Mapping, PC/Mac Computer and Laptop Compatible - Black
Best Seller

Logitech G203 Wired Gaming Mouse, 8,000 DPI, Rainbow Optical Effect LIGHTSYNC RGB, 6 Programmable Buttons, On-Board Memory, Screen Mapping, PC/Mac Computer and Laptop Compatible - Black

(17,871)
$27.98$22.38
FREE delivery Tue, Oct 14 on your first order
500+ bought in past month
Loading...
Logitech G305 LIGHTSPEED Wireless Gaming Mouse, Hero 12K Sensor, 12,000 DPI, Lightweight, 6 Programmable Buttons, 250h Battery Life, On-Board Memory, PC/Mac - Black

Logitech G305 LIGHTSPEED Wireless Gaming Mouse, Hero 12K Sensor, 12,000 DPI, Lightweight, 6 Programmable Buttons, 250h Battery Life, On-Board Memory, PC/Mac - Black

(21,223)
$44.98
FREE delivery Tue, Oct 14
1K+ bought in past month
Loading...
Logitech G502 HERO High Performance Wired Gaming Mouse, HERO 25K Sensor, 25,600 DPI, RGB, Adjustable Weights, 11 Programmable Buttons, On-Board Memory, PC / Mac, Black
Best Seller

Logitech G502 HERO High Performance Wired Gaming Mouse, HERO 25K Sensor, 25,600 DPI, RGB, Adjustable Weights, 11 Programmable Buttons, On-Board Memory, PC / Mac, Black

(54,445)
$49.98$44.98
FREE delivery Tue, Oct 14
1K+ bought in past month
Loading...
NEEWER Advanced 18 inch LED Ring Light for Phone, LCD Touch Screen, 2.4G Remote Lights Control, 3200-5600K, Tripod Light for iPhone Action Camera, for Studio Makeup TikTok YouTube Video Salon (Black)

NEEWER Advanced 18 inch LED Ring Light for Phone, LCD Touch Screen, 2.4G Remote Lights Control, 3200-5600K, Tripod Light for iPhone Action Camera, for Studio Makeup TikTok YouTube Video Salon (Black)

(2,807)
$181.49
FREE delivery Sun, Aug 10
Loading...
Anker USB C Charger Cable (6ft 100W, 2Pack), USB 2.0 Type C Fast Charging Cable for iPhone 15 / 15Pro / 15Plus / 15ProMax MacBook Pro 2020, iPad Pro 2020, iPad Air 4, Samsung Galaxy S23+/S23 Ultra ClimatePartner certified

Anker USB C Charger Cable (6ft 100W, 2Pack), USB 2.0 Type C Fast Charging Cable for iPhone 15 / 15Pro / 15Plus / 15ProMax MacBook Pro 2020, iPad Pro 2020, iPad Air 4, Samsung Galaxy S23+/S23 Ultra ClimatePartner certified

(44,904)
$17.99
FREE delivery Wed, Aug 20 on your first order
6K+ bought in past month
Loading...
Anker USB C Cable, [2-Pack, 6 ft] Type C Charger Premium Nylon USB Cable, USB A to Type C Charging Cable Fast Charge for Samsung Galaxy S10 S10+ / Note 8, LG V20 and Other USB C Charger (Black)

Anker USB C Cable, [2-Pack, 6 ft] Type C Charger Premium Nylon USB Cable, USB A to Type C Charging Cable Fast Charge for Samsung Galaxy S10 S10+ / Note 8, LG V20 and Other USB C Charger (Black)

(103,365)
$13.49
5K+ bought in past month
Loading...
TP-Link AC1300 USB WiFi Adapter (Archer T3U) - 2.4G/5G Dual Band Wireless Network Adapter for PC Desktop, MU-MIMO WiFi Dongle, USB 3.0, Supports Windows 11/10/8.1/8/7/XP, Mac OS 10.9-10.14

TP-Link AC1300 USB WiFi Adapter (Archer T3U) - 2.4G/5G Dual Band Wireless Network Adapter for PC Desktop, MU-MIMO WiFi Dongle, USB 3.0, Supports Windows 11/10/8.1/8/7/XP, Mac OS 10.9-10.14

(19,238)
$19.99$15.96
FREE delivery Sun, Jun 22 on your first order
500+ bought in past month
Loading...
TP-Link AC1300 High Gain WiFi USB Adapter (Archer T4U)- Dual Band Wireless Network Adapter for Desktop with 2.4GHz/5GHz High Gain Antennas, MU-MIMO, Support Windows 10/8.1/8/7/XP, Mac OS

TP-Link AC1300 High Gain WiFi USB Adapter (Archer T4U)- Dual Band Wireless Network Adapter for Desktop with 2.4GHz/5GHz High Gain Antennas, MU-MIMO, Support Windows 10/8.1/8/7/XP, Mac OS

(47,080)
$24.99$21.17
FREE delivery Sun, Jun 22 on your first order
100+ bought in past month
Loading...
RAOYI 5pcs 32GB USB 3.0 Flash Drive Memory Stick Fold Storage Thumb Stick Pen Drive U Disk Swivel Design (5 Mixed Colors: Black Red Blue Green Purple)

RAOYI 5pcs 32GB USB 3.0 Flash Drive Memory Stick Fold Storage Thumb Stick Pen Drive U Disk Swivel Design (5 Mixed Colors: Black Red Blue Green Purple)

(1,667)
$31.99
FREE delivery Sat, Jun 14 on your first order
Loading...
Dell 24 Monitor - SE2425HM - 23.8-inch Full HD (1920x1080) 16:9 100Hz Display, IPS Panel, 16.70 Million Colors, Anti-Glare, 1 HDMI / 1 VGA Port, TÜV Rheinland 3-Star*, Comfortview Plus - Black

Dell 24 Monitor - SE2425HM - 23.8-inch Full HD (1920x1080) 16:9 100Hz Display, IPS Panel, 16.70 Million Colors, Anti-Glare, 1 HDMI / 1 VGA Port, TÜV Rheinland 3-Star*, Comfortview Plus - Black

(169)
$119.99$103.99
FREE delivery Tue, Oct 7
300+ bought in past month
Loading...
Dell S2425HS Monitor - 23.8 Inch, FHD (1920x1080) Display, 100Hz Refresh Rate 1500:1 Contrast Ratio, TÜV Rheinland Eye Comfort 4 Star, Integrated 2x5W Speaker, Height/Tilt/Swivel/Pivot - Ash White

Dell S2425HS Monitor - 23.8 Inch, FHD (1920x1080) Display, 100Hz Refresh Rate 1500:1 Contrast Ratio, TÜV Rheinland Eye Comfort 4 Star, Integrated 2x5W Speaker, Height/Tilt/Swivel/Pivot - Ash White

(15)
$139.99
FREE delivery Tue, Oct 7
300+ bought in past month
Loading...
USB C Docking Station Dual Monitor for Dell Hp,15-in-1 Laptop Docking Station 3 Monitors USB C Hub with Dual 4K HDMI,8K DP,Button,PD Charging,Ethernet,6 USB A&C,SD/TF, Audio USB-C Multiport Adapter

USB C Docking Station Dual Monitor for Dell Hp,15-in-1 Laptop Docking Station 3 Monitors USB C Hub with Dual 4K HDMI,8K DP,Button,PD Charging,Ethernet,6 USB A&C,SD/TF, Audio USB-C Multiport Adapter

(1,359)
$67.98
FREE delivery Sun, Aug 24
100+ bought in past month
Loading...
Dell 24 Monitor - P2425H EPEAT

Dell 24 Monitor - P2425H EPEAT

(57)
$239.99$189.05
FREE delivery Tue, Oct 7
50+ bought in past month
Loading...
Apple 2025 MacBook Air 13-inch Laptop with M4 chip: Built for Apple Intelligence, 16GB Unified Memory, 256GB SSD Storage, Touch ID; Sky Blue - English Keyboard

Apple 2025 MacBook Air 13-inch Laptop with M4 chip: Built for Apple Intelligence, 16GB Unified Memory, 256GB SSD Storage, Touch ID; Sky Blue - English Keyboard

(687)
$1,249.99
PrimeFREE delivery Sat, Jun 14
100+ bought in past month
Loading...
Air Tracker Tags 4 Pack, Bluetooth Tracker & Item Locator Work with Apple Find My (iOS Only), Replaceable Battery, Waterproof Smart Tag for Keys, Wallet, Suitcases

Air Tracker Tags 4 Pack, Bluetooth Tracker & Item Locator Work with Apple Find My (iOS Only), Replaceable Battery, Waterproof Smart Tag for Keys, Wallet, Suitcases

(231)
$49.99
FREE delivery Wed, Sep 24
Loading...
Air Tracker Tags-4 Pack: Smart Bluetooth Tracker, Item Finder Works with Apple Find My (iOS Only) App, Trakcer Tag Locator for Keys, Luggage, Satchel, Backpack etc. (Not for Android Devices)

Air Tracker Tags-4 Pack: Smart Bluetooth Tracker, Item Finder Works with Apple Find My (iOS Only) App, Trakcer Tag Locator for Keys, Luggage, Satchel, Backpack etc. (Not for Android Devices)

(441)
$49.99
FREE delivery Sat, Sep 13
2K+ bought in past month
Loading...
HATALKIN Case Compatible with Apple AirTags Case Keychain Air tag Holder Air Tag Key Ring Cases Air Tags Protective Cover Airtag Key Chain Loop Holders Silicone for Luggage Dog Cat Pet Collar 4 Pack

HATALKIN Case Compatible with Apple AirTags Case Keychain Air tag Holder Air Tag Key Ring Cases Air Tags Protective Cover Airtag Key Chain Loop Holders Silicone for Luggage Dog Cat Pet Collar 4 Pack

(19,279)
$9.78
FREE delivery Mon, Aug 25 on your first order
1K+ bought in past month