6 kyu

Infected Zeroes

Description:

In this kata, the number 0 is infected. You are given a list. Every turn, any item in the list that is adjacent to a 0 becomes infected and transforms into a 0. How many turns will it take for the whole list to become infected?

[0,1,1,0] ==> [0,0,0,0] 
All infected in 1 turn.

[1,1,0,1,1] --> [1,0,0,0,1] --> [0,0,0,0,0]
All infected in 2 turns

[0,1,1,1] --> [0,0,1,1] --> [0,0,0,1] --> [0,0,0,0]
All infected in 3 turns.

All lists will contain at least one item, and at least one zero, and the only items will be 0s and 1s. Lists may be very very long, so pure brute force approach will not work.

Fundamentals

More By Author:

Check out these other kata created by marbiru

Stats:

CreatedJan 6, 2018
PublishedJan 6, 2018
Warriors Trained933
Total Skips21
Total Code Submissions2469
Total Times Completed282
Python Completions282
Total Stars35
% of votes with a positive feedback rating94% of 89
Total "Very Satisfied" Votes79
Total "Somewhat Satisfied" Votes10
Total "Not Satisfied" Votes0
Total Rank Assessments7
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • marbiru Avatar
  • Blind4Basics Avatar
  • Voile Avatar
  • Awesome A.D. Avatar
  • Wei-Ting Yang Avatar
Ad