Fuzz Buzz in bunt

This commit is contained in:
Ingo Rohlf 2025-10-22 16:06:09 +02:00
parent 57c56a4235
commit cd16b94917
3 changed files with 20 additions and 12 deletions

View file

@ -13,17 +13,28 @@ struct RangeView: TabContent {
@State var texte: [String] @State var texte: [String]
var body: some View { func farbe(for i: Int ) -> Color {
List(2...16, id: \.self) { i in return i % 3 == 0 ? Color.green : Color.yellow
HStack(spacing:0){ }
Text("\(i)")
if i.isMultiple(of: 3) { Text("Fizz")}
if i.isMultiple(of: 5) { Text("Buzz")} var body: some View {
LazyHGrid(rows: [GridItem(.adaptive(minimum: 120))]){
ForEach(2...16, id: \.self) { i in
ZStack{
if i % 4 == 0{
Circle().fill(farbe(for: i))
} else {
RoundedRectangle(cornerRadius: 25).fill(farbe(for: i))
}
VStack(spacing:0){
Text("\(i)")
if i.isMultiple(of: 3) { Text("Fizz")}
if i.isMultiple(of: 4) { Text("Buzz")}
}}
} }
} }
} }
} }
@ -88,5 +99,5 @@ struct RangeView: TabContent {
#Preview { #Preview {
RangeView() RangeView()
} }

View file

@ -20,9 +20,6 @@ struct UnicycleView: View {
Text("Einrad von \(uni.createdAt.description)") Text("Einrad von \(uni.createdAt.description)")
}.onDelete { }.onDelete {
for index in $0 { for index in $0 {
modelContext.delete(unis[index]) modelContext.delete(unis[index])
} }
} }