datawhale玩转通义四大新模型 202509
30B:模型总参数量300亿
A3B: 推理时激活的参数量是30亿
thinking: 深度思考推理模型
instruct:日常指令遵循
创建应用:
通义千问3-30B-A3B 既融合了思考模型,也融合了非思考模式,是千问3的重大创新。
创建API key:
在cherry studio中的设置:
可以添加阿里云的各种模型:
编程:
Create a single-page app in a single HTML hle with the following requirements:
Name: Music Theory Trainer
Goal: Teach notes, scales, and chords.
. Features: interactive piano
. The Ul should be music-themed, interactive, and fun.
# Music Theory TrainerI'll create an interactive single-page app that teaches music theory through an interactive piano interface. The design will be music-themed with a dark, elegant aesthetic.```html
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Music Theory Trainer</title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"><style>* {margin: 0;padding: 0;box-sizing: border-box;font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;}body {background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);color: #fff;min-height: 100vh;padding: 20px;display: flex;flex-direction: column;align-items: center;}header {text-align: center;padding: 20px 0;width: 100%;max-width: 900px;}h1 {font-size: 3.5rem;margin-bottom: 10px;background: linear-gradient(to right, #ff7e5f, #feb47b);-webkit-background-clip: text;-webkit-text-fill-color: transparent;text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);}.subtitle {font-size: 1.2rem;opacity: 0.9;margin-bottom: 20px;}.container {display: flex;flex-direction: column;gap: 30px;width: 100%;max-width: 900px;}.card {background: rgba(255, 255, 255, 0.08);border-radius: 15px;padding: 25px;box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);backdrop-filter: blur(10px);border: 1px solid rgba(255, 255, 255, 0.1);}.card-header {display: flex;align-items: center;margin-bottom: 20px;}.card-header i {font-size: 1.8rem;margin-right: 15px;color: #ff7e5f;}.card-title {font-size: 1.8rem;font-weight: 600;}.content {display: flex;flex-wrap: wrap;gap: 20px;}.theory-section {flex: 1;min-width: 300px;}.piano-section {flex: 2;min-width: 300px;}.section-title {font-size: 1.4rem;margin-bottom: 15px;color: #feb47b;}.theory-content {background: rgba(0, 0, 0, 0.2);border-radius: 10px;padding: 20px;margin-bottom: 20px;line-height: 1.6;}.theory-content p {margin-bottom: 15px;}.examples {display: flex;flex-wrap: wrap;gap: 10px;margin-top: 10px;}.example {background: rgba(255, 126, 95, 0.2);padding: 8px 15px;border-radius: 20px;font-size: 0.9rem;}.piano-container {position: relative;height: 250px;margin-top: 20px;}.piano {position: relative;width: 100%;height: 100%;}.white-keys {display: flex;height: 100%;}.white-key {flex: 1;background: linear-gradient(to bottom, #fff 0%, #f5f5f5 100%);border: 1px solid #ddd;border-radius: 0 0 5px 5px;margin: 0 1px;cursor: pointer;position: relative;box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);transition: all 0.1s ease;}.white-key.active {background: linear-gradient(to bottom, #ff7e5f 0%, #feb47b 100%);box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.3);transform: translateY(2px);}.black-keys {position: absolute;top: 0;left: 0;width: 100%;height: 60%;display: flex;pointer-events: none;}.black-key {width: 7%;height: 100%;background: linear-gradient(to bottom, #000 0%, #333 100%);border-radius: 0 0 4px 4px;margin: 0 1.5%;cursor: pointer;position: relative;z-index: 2;pointer-events: auto;box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);transition: all 0.1s ease;}.black-key.active {background: linear-gradient(to bottom, #ff7e5f 0%, #feb47b 100%);box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.5);transform: translateY(2px);}.key-label {position: absolute;bottom: 10px;width: 100%;text-align: center;font-weight: bold;color: #333;}.black-key .key-label {color: #fff;bottom: 5px;}.controls {display: flex;justify-content: space-between;margin-top: 20px;gap: 15px;}.btn {flex: 1;padding: 12px;border: none;border-radius: 8px;background: linear-gradient(to right, #ff7e5f, #feb47b);color: white;font-weight: bold;cursor: pointer;transition: all 0.3s ease;box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);}.btn:hover {transform: translateY(-3px);box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);}.btn:active {transform: translateY(1px);}.btn-secondary {background: rgba(255, 255, 255, 0.1);}.quiz-section {margin-top: 20px;}.quiz-question {font-size: 1.2rem;margin-bottom: 15px;}.quiz-options {display: flex;flex-wrap: wrap;gap: 10px;}.quiz-option {flex: 1;min-width: 120px;padding: 12px;background: rgba(255, 255, 255, 0.1);border-radius: 8px;text-align: center;cursor: pointer;transition: all 0.2s ease;}.quiz-option:hover {background: rgba(255, 126, 95, 0.3);}.quiz-option.selected {background: linear-gradient(to right, #ff7e5f, #feb47b);color: white;}.feedback {margin-top: 15px;padding: 12px;border-radius: 8px;text-align: center;font-weight: bold;display: none;}.correct {background: rgba(46, 204, 113, 0.2);display: block;}.incorrect {background: rgba(231, 76, 60, 0.2);display: block;}footer {margin-top: 30px;text-align: center;padding: 20px;font-size: 0.9rem;opacity: 0.7;}@media (max-width: 768px) {h1 {font-size: 2.5rem;}.content {flex-direction: column;}.controls {flex-direction: column;}}</style>
</head>
<body><header><h1>Music Theory Trainer</h1><p class="subtitle">Learn notes, scales, and chords with our interactive piano</p></header><div class="container"><div class="card"><div class="card-header"><i class="fas fa-music"></i><h2 class="card-title">Interactive Piano</h2></div><div class="content"><div class="theory-section"><h3 class="section-title">Learn Music Theory</h3><div class="theory-content"><p><strong>Notes:</strong> The building blocks of music. The musical alphabet consists of 12 notes: A, A#, B, C, C#, D, D#, E, F, F#, G, G#.</p><p><strong>Scales:</strong> A sequence of notes in ascending or descending order. Major scales follow the pattern: Whole, Whole, Half, Whole, Whole, Whole, Half.</p><p><strong>Chords:</strong> Three or more notes played together. Major chords consist of the 1st, 3rd, and 5th notes of a major scale.</p></div><h3 class="section-title">Examples</h3><div class="examples"><div class="example">C Major Scale: C - D - E - F - G - A - B - C</div><div class="example">C Major Chord: C - E - G</div><div class="example">A Minor Scale: A - B - C - D - E - F - G - A</div></div></div><div class="piano-section"><h3 class="section-title">Play the Piano</h3><div class="piano-container"><div class="piano"><div class="white-keys"><div class="white-key" data-note="C"><span class="key-label">C</span></div><div class="white-key" data-note="D"><span class="key-label">D</span></div><div class="white-key" data-note="E"><span class="key-label">E</span></div><div class="white-key" data-note="F"><span class="key-label">F</span></div><div class="white-key" data-note="G"><span class="key-label">G</span></div><div class="white-key" data-note="A"><span class="key-label">A</span></div><div class="white-key" data-note="B"><span class="key-label">B</span></div><div class="white-key" data-note="C2"><span class="key-label">C</span></div></div><div class="black-keys"><div class="black-key" data-note="C#" style="left: 7.1%;"><span class="key-label">C#</span></div><div class="black-key" data-note="D#" style="left: 21.4%;"><span class="key-label">D#</span></div><div class="black-key" data-note="F#" style="left: 50%;"><span class="key-label">F#</span></div><div class="black-key" data-note="G#" style="left: 64.3%;"><span class="key-label">G#</span></div><div class="black-key" data-note="A#" style="left: 78.6%;"><span class="key-label">A#</span></div></div></div></div><div class="controls"><button class="btn" id="play-scale">Play C Major Scale</button><button class="btn btn-secondary" id="clear">Clear Selection</button></div></div></div></div><div class="card quiz-section"><div class="card-header"><i class="fas fa-graduation-cap"></i><h2 class="card-title">Quick Quiz</h2></div><div class="quiz-question">What notes make up a C Major chord?</div><div class="quiz-options"><div class="quiz-option" data-answer="C-E-G">C - E - G</div><div class="quiz-option" data-answer="C-D-E">C - D - E</div><div class="quiz-option" data-answer="C-F-G">C - F - G</div><div class="quiz-option" data-answer="C-E-F">C - E - F</div></div><div class="feedback" id="quiz-feedback">Correct! A C Major chord consists of the notes C, E, and G.</div></div></div><footer><p>Music Theory Trainer © 2023 | Learn music theory in a fun and interactive way</p></footer><script>document.addEventListener('DOMContentLoaded', function() {// Piano functionalityconst whiteKeys = document.querySelectorAll('.white-key');const blackKeys = document.querySelectorAll('.black-key');const clearBtn = document.getElementById('clear');const playScaleBtn = document.getElementById('play-scale');const quizOptions = document.querySelectorAll('.quiz-option');const quizFeedback = document.getElementById('quiz-feedback');// Add event listeners to all keys[...whiteKeys, ...blackKeys].forEach(key => {key.addEventListener('click', function() {this.classList.toggle('active');// Create a visual effect when playing a noteconst note = this.getAttribute('data-note');this.style.transform = 'translateY(2px)';setTimeout(() => {this.style.transform = '';}, 100);});});// Clear button functionalityclearBtn.addEventListener('click', function() {[...whiteKeys, ...blackKeys].forEach(key => {key.classList.remove('active');});});// Play scale functionalityplayScaleBtn.addEventListener('click', function() {// Clear previous selectionsclearBtn.click();// Play C Major scale: C - D - E - F - G - A - B - Cconst scaleNotes = ['C', 'D', 'E', 'F', 'G', 'A', 'B', 'C2'];let delay = 0;scaleNotes.forEach(note => {setTimeout(() => {const key = document.querySelector(`.white-key[data-note="${note}"]`);if (key) {key.classList.add('active');// Remove active class after a delaysetTimeout(() => {key.classList.remove('active');}, 300);}}, delay);delay += 300;});});// Quiz functionalityquizOptions.forEach(option => {option.addEventListener('click', function() {// Remove selected class from all optionsquizOptions.forEach(opt => opt.classList.remove('selected'));// Add selected class to clicked optionthis.classList.add('selected');// Check if answer is correctconst answer = this.getAttribute('data-answer');if (answer === 'C-E-G') {quizFeedback.className = 'feedback correct';quizFeedback.textContent = 'Correct! A C Major chord consists of the notes C, E, and G.';} else {quizFeedback.className = 'feedback incorrect';quizFeedback.textContent = 'Incorrect. Try again! A C Major chord consists of the notes C, E, and G.';}});});// Add keyboard support for pianodocument.addEventListener('keydown', function(e) {const keyMap = {'a': 'C','s': 'D','d': 'E','f': 'F','g': 'G','h': 'A','j': 'B','k': 'C2','w': 'C#','e': 'D#','t': 'F#','y': 'G#','u': 'A#'};const note = keyMap[e.key.toLowerCase()];if (note) {const key = document.querySelector(`[data-note="${note}"]`);if (key) {key.classList.add('active');// Remove active class after a delaysetTimeout(() => {key.classList.remove('active');}, 300);}}});});</script>
</body>
</html>
```## Features of the Music Theory Trainer:1. **Interactive Piano**:- 13-key piano with both white and black keys- Visual feedback when keys are pressed- Keyboard support (A-K for white keys, W-U for black keys)2. **Educational Content**:- Clear explanations of notes, scales, and chords- Examples of common scales and chords- Visual examples for quick reference3. **Interactive Elements**:- Play C Major Scale button that demonstrates the scale- Clear Selection button to reset the piano- Quick Quiz section to test knowledge4. **Music-Themed Design**:- Dark gradient background with music-themed colors- Glass-morphism cards for content sections- Responsive layout that works on all devices- Elegant typography and spacing5. **Engaging Features**:- Visual feedback when keys are pressed- Animated scale demonstration- Interactive quiz with immediate feedback- Responsive design for all screen sizesThe app is completely self-contained in a single HTML file with no external dependencies other than Font Awesome for icons. Simply copy and paste the code into an HTML file and open it in any modern browser to start learning music theory!
点击琴键听不到声音,请加上声音
leetcode刷题:第10题
def isMatch(s: str, p: str) -> bool:"""实现支持 '.' 和 '*' 的正则表达式匹配'.' 匹配任意单个字符'*' 匹配零个或多个前面的那一个元素Args:s: 要匹配的字符串p: 字符规律(正则表达式)Returns:bool: 是否完全匹配"""# dp[i][j] 表示 s 的前 i 个字符与 p 的前 j 个字符是否匹配m, n = len(s), len(p)dp = [[False] * (n + 1) for _ in range(m + 1)]# 空字符串与空模式匹配dp[0][0] = True# 处理空字符串与模式的匹配情况(主要处理 a*, a*b* 等情况)for j in range(2, n + 1):if p[j - 1] == '*':dp[0][j] = dp[0][j - 2]# 填充 dp 表for i in range(1, m + 1):for j in range(1, n + 1):# 如果当前模式字符是 '*'if p[j - 1] == '*':# 匹配 0 次:忽略前面的字符和 '*'dp[i][j] = dp[i][j - 2]# 如果前面的字符匹配,则可以匹配 1 次或多次if p[j - 2] == '.' or p[j - 2] == s[i - 1]:dp[i][j] |= dp[i - 1][j]else:# 普通字符或 '.' 的情况if p[j - 1] == '.' or p[j - 1] == s[i - 1]:dp[i][j] = dp[i - 1][j - 1]return dp[m][n]# 测试函数
def test_regex():"""测试正则表达式匹配函数"""test_cases = [("aa", "a", False),("aa", "a*", True),("ab", ".*", True),("aab", "c*a*b", True),("mississippi", "mis*is*p*.", False),("", "a*", True),("", ".*", True),("a", ".*", True),("aaa", "a*a", True),("aaa", "ab*a*c*a", True)]print("正则表达式匹配测试结果:")print("-" * 50)for i, (s, p, expected) in enumerate(test_cases):result = isMatch(s, p)status = "✓" if result == expected else "✗"print(f"测试 {i+1}: {status} isMatch('{s}', '{p}') = {result}")if result != expected:print(f" 期望: {expected}, 实际: {result}")print("-" * 50)# 运行测试
if __name__ == "__main__":test_regex()# 示例测试print("\n题目示例测试:")print(f"示例 1: isMatch('aa', 'a') = {isMatch('aa', 'a')}") # Falseprint(f"示例 2: isMatch('aa', 'a*') = {isMatch('aa', 'a*')}") # Trueprint(f"示例 3: isMatch('ab', '.*') = {isMatch('ab', '.*')}") # True
帮我用P5.js写一个浪漫烟花的粒子特效,鼠标点击触发爆炸,烟花用爱心形状的
<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>浪漫爱心烟花</title><script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script><style>body {margin: 0;padding: 0;background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);overflow: hidden;font-family: 'Arial', sans-serif;}#canvas-container {position: relative;width: 100vw;height: 100vh;}#title {position: absolute;top: 20px;left: 0;width: 100%;text-align: center;color: #fff;font-size: 2.5rem;text-shadow: 0 0 10px rgba(255, 105, 180, 0.8);z-index: 10;pointer-events: none;}#instructions {position: absolute;bottom: 20px;left: 0;width: 100%;text-align: center;color: rgba(255, 255, 255, 0.7);font-size: 1.2rem;z-index: 10;pointer-events: none;}.heart {position: absolute;color: #ff6b6b;font-size: 24px;animation: float 5s ease-in-out infinite;pointer-events: none;z-index: 1;}@keyframes float {0% {transform: translateY(0) rotate(0deg);opacity: 1;}100% {transform: translateY(-100vh) rotate(360deg);opacity: 0;}}</style>
</head>
<body><div id="canvas-container"><div id="title">💖 浪漫爱心烟花 💖</div><div id="instructions">点击屏幕任意位置释放爱心烟花</div></div><script>// 粒子系统let particles = [];let fireworks = [];let heartEmojis = ['💖', '💗', '💓', '💞', '💕', '💘', '💝', '💟'];// 创建背景爱心function createBackgroundHearts() {const container = document.getElementById('canvas-container');for (let i = 0; i < 20; i++) {const heart = document.createElement('div');heart.className = 'heart';heart.innerHTML = heartEmojis[Math.floor(Math.random() * heartEmojis.length)];heart.style.left = Math.random() * 100 + 'vw';heart.style.animationDuration = (Math.random() * 5 + 5) + 's';heart.style.animationDelay = Math.random() * 5 + 's';heart.style.fontSize = (Math.random() * 20 + 10) + 'px';container.appendChild(heart);}}// 粒子类class Particle {constructor(x, y, hue, isHeart = false) {this.pos = createVector(x, y);this.vel = p5.Vector.random2D();this.vel.mult(random(2, 10));this.acc = createVector(0, 0.1);this.life = 255;this.hue = hue;this.isHeart = isHeart;this.emoji = isHeart ? heartEmojis[Math.floor(Math.random() * heartEmojis.length)] : null;this.size = isHeart ? random(15, 25) : random(2, 8);}applyForce(force) {this.acc.add(force);}update() {this.vel.add(this.acc);this.pos.add(this.vel);this.acc.mult(0);this.life -= 3;}display() {if (this.isHeart && this.emoji) {// 显示爱心emojifill(this.hue, 255, 255, this.life);noStroke();textSize(this.size);text(this.emoji, this.pos.x, this.pos.y);} else {// 显示普通粒子fill(this.hue, 255, 255, this.life);noStroke();ellipse(this.pos.x, this.pos.y, this.size);}}isDead() {return this.life <= 0;}}// 烟花类class Firework {constructor(x, y) {this.pos = createVector(x, y);this.vel = createVector(0, random(-12, -8));this.acc = createVector(0, 0.1);this.hue = random(330, 360); // 粉红色调this.exploded = false;this.particles = [];}applyForce(force) {this.acc.add(force);}update() {if (!this.exploded) {this.vel.add(this.acc);this.pos.add(this.vel);this.acc.mult(0);// 当速度接近0时爆炸if (this.vel.y >= 0) {this.explode();}}}explode() {this.exploded = true;// 创建爱心形状的粒子const particleCount = 150;for (let i = 0; i < particleCount; i++) {// 创建爱心形状分布const angle = map(i, 0, particleCount, 0, TWO_PI);const radius = random(30, 100);// 心形方程参数const x = 16 * pow(sin(angle), 3);const y = -(13 * cos(angle) - 5 * cos(2*angle) - 2 * cos(3*angle) - cos(4*angle));// 调整心形大小和位置const px = this.pos.x + x * 2;const py = this.pos.y + y * 2;// 创建粒子(部分为爱心emoji)const isHeartParticle = random() < 0.3;const p = new Particle(px, py, this.hue, isHeartParticle);// 给粒子一个向外的初始速度const vel = p5.Vector.sub(createVector(px, py), this.pos);vel.normalize();vel.mult(random(2, 8));p.vel = vel;this.particles.push(p);}}display() {if (!this.exploded) {fill(this.hue, 255, 255);noStroke();ellipse(this.pos.x, this.pos.y, 8);}for (let i = this.particles.length - 1; i >= 0; i--) {this.particles[i].applyForce(this.acc);this.particles[i].update();this.particles[i].display();if (this.particles[i].isDead()) {this.particles.splice(i, 1);}}}isDone() {return this.exploded && this.particles.length === 0;}}// P5.js 设置function setup() {const canvas = createCanvas(windowWidth, windowHeight);canvas.parent('canvas-container');colorMode(HSB);createBackgroundHearts();}// P5.js 绘制循环function draw() {// 半透明背景产生拖尾效果background(0, 0, 0, 25);// 更新和显示烟花for (let i = fireworks.length - 1; i >= 0; i--) {fireworks[i].update();fireworks[i].display();if (fireworks[i].isDone()) {fireworks.splice(i, 1);}}// 添加随机烟花if (random() < 0.02) {const x = random(width);const y = random(height/2, height);fireworks.push(new Firework(x, y));}}// 鼠标点击触发烟花function mousePressed() {fireworks.push(new Firework(mouseX, mouseY));}// 窗口大小调整function windowResized() {resizeCanvas(windowWidth, windowHeight);}</script>
</body>
</html>