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
| #include <cstdio> | |
| int sumOfNaturalDivisibleByThreeAndFive (int limit) | |
| { | |
| int sum = 0; | |
| for (int i = 1; i <= limit; ++i) | |
| { | |
| if (i % 5 == 0 && i % 3 == 0) sum += i; | |
| } | |
| return sum; |
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
| /* | |
| Given an array of size length, return an array of [mean, mode] | |
| */ | |
| typedef struct nums nums | |
| { | |
| int *data; | |
| int size; | |
| } |
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
| /* | |
| Define a doubly linked list of heap-allocated strings. | |
| Write functions to insert, find, and delete items from it. | |
| Test them. | |
| */ | |
| #define NULL 0 | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <assert.h> |
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
| <html> | |
| <head> | |
| <title>strip end</title> | |
| <style> | |
| div, input { | |
| flex-direction: column; | |
| flex: 1; | |
| } | |
| </style> | |
| <script> |
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
| """1000 integers in a random order + one duplicate pair. | |
| How to find an integer that has been duplicated?""" | |
| import random | |
| def generate_nums(list_size: int) -> list[int]: | |
| """ | |
| generate a list of numbers from 1 to list_size in a random order | |
| """ | |
| sorted_nums = [i for i in range(1, list_size+1)] | |
| randomized_nums = [] |
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
| struct Binary { | |
| num_bits: usize, | |
| binary_str: String, | |
| } | |
| impl Binary { | |
| fn new(num_bits: usize) -> Binary { | |
| let mut new_binary = String::new(); | |
| for _ in 0..num_bits { |