Sha256: 9cfe712247444920da8680d64eb6d11e9f2c39e34b07dc9cd6ab1ae16764ccca
Contents?: true
Size: 880 Bytes
Versions: 211
Compression:
Stored size: 880 Bytes
Contents
const defaultChildren = [ 'Alice', 'Bob', 'Charlie', 'David', 'Eve', 'Fred', 'Ginny', 'Harriet', 'Ileana', 'Joseph', 'Kincaid', 'Larry' ]; const plants = { G: 'grass', V: 'violets', R: 'radishes', C: 'clover' }; function getPlants(pots, index) { let plants = []; const position = 2*index; plants.push(pots[0][position]); plants.push(pots[0][position+1]); plants.push(pots[1][position]); plants.push(pots[1][position+1]); return plants; } function parse(diagram) { return diagram.split('\n').map((row) => [...row].map((sign) => plants[sign])); } class Garden { constructor(diagram, students) { this.students = students || defaultChildren; this.students.sort(); this.students.forEach((student, index) => { this[student.toLowerCase()] = getPlants(parse(diagram), index); }); } } export default Garden;
Version data entries
211 entries across 211 versions & 1 rubygems