This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def number_difference(num): | |
| # Convert number to string and pad with zeros if needed | |
| num_str = str(num).zfill(4) | |
| # Convert to list of digits and sort | |
| digits = list(num_str) | |
| # Create ascending and descending numbers | |
| ascending = int(''.join(sorted(digits))) | |
| descending = int(''.join(sorted(digits, reverse=True))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Okay, so I need to figure out a shape where the number of sides is equal to the number of letters in its name. Let me start by thinking about some basic shapes and their names. | |
| First, a triangle. Triangle has three sides, and the word "triangle" has eight letters. Hmm, that's way more letters than sides. Not a match. | |
| Next, a square. A square has four sides, and the word "square" has six letters. Still not the same. | |
| How about a pentagon? Five sides, and "pentagon" is eight letters. Nope. Hexagon? Six sides, seven letters. Getting closer, but still not equal. | |
| Wait, maybe I should check simpler shapes. Let's go back. A "circle" is a shape, but it doesn't have sides. So that's out. What about a "line"? A line doesn't really have sides either. Maybe polygons only? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Code inspired from https://gist.github.com/karpathy/00103b0037c5aaea32fe1da1af553355 | |
| # slerp function is entirely lifted from the above gist. | |
| import torch | |
| from diffusers import DiffusionPipeline | |
| import numpy as np | |
| def slerp(t, v0, v1, DOT_THRESHOLD=0.9995): | |
| """ helper function to spherically interpolate two arrays v1 v2 """ | |
| inputs_are_torch = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Code inspired from https://gist.github.com/karpathy/00103b0037c5aaea32fe1da1af553355 | |
| # slerp function is entirely lifted from the above gist. | |
| import torch | |
| from diffusers import DiffusionPipeline | |
| import numpy as np | |
| def interpolate(v1, v2, step, total_steps): | |
| alpha = step / (total_steps - 1) |