Sha256: 7e081be09564386ca6e8761d5b4cb170bdd6b6f765cf3779d4483162fb2342bc
Contents?: true
Size: 886 Bytes
Versions: 185
Compression:
Stored size: 886 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) { const 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
185 entries across 185 versions & 1 rubygems