Compare commits

..

No commits in common. "master" and "1402-daily-problem" have entirely different histories.

5 changed files with 0 additions and 161 deletions

View File

@ -1,14 +0,0 @@
# Audio
Compile the program with
```bash
gcc -lm waves.c
```
Execute and hear the output with
```bash
./a.out | aplay
```

View File

@ -1,67 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// Tyler Perkins
// 12-30-20
// Testing command line audio
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
int main(int argc, char** argv){
if(argc != 1){
printf("Usage: %s\n", argv[0]);
return -1;
}
//sawtooth wave
for(int t=0, osc=0; t<8000; t++, osc += 14){
putchar(osc);
}
//square wave
for(int t=0, osc=0; t<8000; t++, osc += 14){
putchar(osc & 0x80);
}
//sine wave
for(int t=0, osc=0; t<8000; t++, osc += 14){
putchar(127 * sin(osc/255.0*2*3.1415) + 128);
}
/* kinda bass guitar?
*
* The idea here is an array full of random data, with
* an array size equal to the period of the wave
* (for 440 its ~18) then loop the array.
* Then we average out the current value and next one
* Till we get a faded noise to silence
*
* Pretty cool ngl
*/
unsigned char a[18];
//init the array with random data
FILE *fp;
fp = fopen("/dev/random", "r");
if(fp == NULL){
printf("Couldnt open random stream!\n");
return -1;
}
if(fgets(a,sizeof(a),fp)==NULL){
printf("Failed to read the random stream!\n");
return -1;
}
fclose(fp);
//play the bass guitar
for(int t=0;t<8000;t++){
int i = t % sizeof(a);
int j = (t+1) % sizeof(a);
putchar(a[i] = (a[i] + a[j])/2);
}
return 0;
}

View File

@ -1 +0,0 @@
output.csv

View File

@ -1,18 +0,0 @@
# See-it Generator
The See it sequence is exactly as the name implies, what you see is the next entry in the sequence. For example,
$$
1
11
21
1211
111221
312211
13112221
1113213211
$$
I learned about this sequence from [Genius at Play](https://www.amazon.com/Genius-At-Play-Curious-Horton/dp/1620405938).
This code just generates this sequence.

View File

@ -1,61 +0,0 @@
import pandas as pd
import time
def main():
"""
Print out a sequence following the see-it sequence
"""
upper_bound = 100
seed = "1"
file_location = "output.csv"
df = pd.DataFrame(columns=["Iteration", "Length", "Value"])
val = seed
for i in range(0,upper_bound):
#print(f"Iteration : {i}")
#print(f"Length : {len(val)}")
#print(val)
df.loc[len(df)] = [i, len(val), val]
start_time = time.time()
val = next_step(val)
elasped_time = time.time() - start_time
print(f"Iteration : {i} of {upper_bound} (took {elasped_time:.4f} seconds)")
df.to_csv(file_location, index=False)
print("Progress saved to file")
print("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
print("Result logged to {file_location.csv}")
def next_step(sequence: str) -> str:
last_char = None
last_char_count = 0
ret = ""
for char in sequence:
if last_char == None:
last_char = char
last_char_count = 1
elif char == last_char:
last_char_count += 1
else:
ret += str(last_char_count)
ret += str(last_char)
last_char_count = 1
last_char = char
if ret != None:
ret += str(last_char_count)
ret += str(last_char)
return ret
if __name__ == "__main__":
main()