Skip to content

Remove stub solution from scale generator #872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,38 +1,3 @@
import Foundation

class ScaleGenerator {
let flatTones = ["Ab", "A", "Bb", "B", "C", "Db", "D", "Eb", "E" ,"F", "Gb", "G"]
let sharpTones = ["A", "A#", "B", "C", "C#", "D", "D#", "E", "F" ,"F#", "G", "G#"]
let sharpTonesTypes = ["G", "D", "A","a", "E", "B","F#", "f#","e", "b", "c♯", "g♯", "d♯", "C"]
let translator = ["A": 3, "M": 2, "m": 1]
var tones: [String] = []

init (tonic: String) {
if sharpTonesTypes.contains(tonic) {
let tonic = tonic.capitalized
let index = sharpTones.firstIndex(of: tonic)!
self.tones = Array(sharpTones[index...] + sharpTones[...index])
}else {
let tonic = tonic.capitalized
let index = flatTones.firstIndex(of: tonic)!
self.tones = Array(flatTones[index...] + flatTones[...index])
}
}

func chromatic() -> [String] {
return Array(tones[0...(tones.count - 2)])
}

func interval(_ intervals : String) -> [String] {
var steps : [Int] = [0]
for char in intervals {
steps.append(steps.last! + translator[String(char)]!)
}
var result : [String] = []
for step in steps[0...(steps.count - 2)] {
result.append(tones[step])
}
result.append(tones[0])
return result
}
// Write your code for the 'ScaleGenerator' exercise in this file.
}