Giter VIP home page Giter VIP logo

cse5539's Introduction

Welcome to My Profile!

This week's code snippet, Josephus Problem in Commodore Basic, is brought to you by Subete and the Sample Programs repo.

5 REM Input N
10 GOSUB 1000
20 IF V = 0 OR C <> -1 THEN GOTO 140: REM invalid or not end of value
30 N = NR
35 REM Input K
40 GOSUB 1000
50 IF V = 0 OR C >= 0 THEN GOTO 140: REM invalid or not end character
60 K = NR
70 G = 0
80 IF N < 2 THEN GOTO 120
85 REM Calculate Josephus Problem using this:
86 REM https://en.wikipedia.org/wiki/Josephus_problem#The_general_case
90 FOR M = 2 TO N
100     G = G + K - INT((G + K) / M) * M
110 NEXT M
120 PRINT MID$(STR$(G + 1), 2)
130 END
140 PRINT "Usage: please input the total number of people and number of people to skip."
150 END
1000 REM Read input value one character at a time since Commodore BASIC
1001 REM has trouble reading line from stdin properly
1002 REM NR = number
1003 REM V = 1 if valid number, 0 otherwise
1004 REM C = -2 if end of input, -1 if end of value,
1005 REM   32 if whitespace, ASCII code of last character otherwise
1006 REM Initialize
1010 NR = 0
1020 V = 0
1030 S = 1
1035 REM Loop while leading spaces
1040 GOSUB 1500
1050 IF C = 43 OR C = 45 THEN GOTO 1100: REM + or -
1060 IF C >= 48 AND C <= 57 THEN GOTO 1150: REM 0 to 9
1070 IF C = 32 THEN GOTO 1040: REM whitespace
1080 RETURN: REM other character
1085 REM Loop while sign
1090 GOSUB 1500
1100 IF C = 43 THEN GOTO 1090: REM +
1110 IF C >= 48 AND C <= 57 THEN GOTO 1150: REM 0 to 9
1120 IF C <> 45 THEN RETURN: REM not -
1130 S = -S
1140 GOTO 1090
1145 REM Set valid flag
1150 V = 1
1155 REM Loop while digits
1160 NR = (ABS(NR) * 10 + C - 48) * S
1170 GOSUB 1500
1180 IF C >= 48 AND C <= 57 THEN GOTO 1160: REM 0 to 9
1185 REM Loop while trailing spaces
1190 IF C < 0 OR C <> 32 THEN RETURN: REM end character or not whitespace
1200 GOSUB 1500
1210 GOTO 1180
1500 REM Get input character
1501 REM A$ = input character
1502 REM C = One of the following:
1502 REM - -1 if end of value
1503 REM - -2 if end of input
1504 REM - 32 if whitespace
1505 REM - ASCII code otherwise
1510 GET A$
1520 C = ASC(A$)
1530 IF C = 13 THEN C = -1
1540 IF C = 255 THEN C = -2
1550 IF C = 9 OR C = 10 THEN C = 32
1560 RETURN

Below you'll find an up-to-date list of articles by me on The Renegade Coder. For ease of browsing, emojis let you know the article category (i.e., blog: βœ’οΈ, code: πŸ’», meta: πŸ’­, teach: 🍎)

Also, here are some fun links you can use to support my work.


This document was automatically rendered on 2024-05-17 using SnakeMD.

cse5539's People

Contributors

jrg94 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

cse5539's Issues

Explore WAV Parsing

From what I understand, the parsing is really easy and Python has a library built in to support it. Doing analysis should be relatively easy.

Map Parse Results to MusicFile Object

With the dictionary output, we should be able to quickly map our findings into a MusicFile object that we can use for data analytics. For starters, I'd like to map the meta data. Then, we can get to mapping the samples.

Project Proposal Ideas

I'll copy my email exchange with the professor:

Email 1

Hi Professor Wang,

I wanted to reach out because the syllabus mentions that we should discuss potential projects before writing the proposal.

I was wondering if a coding project would be acceptable. I'm in the graphics group with Professor Han-Wei Shen, and I'm interested in the intersection between data visualization, education, and music. In particular, I'd like to do a bit of data mining on some music signal files (i.e. mp3) to see if I can visualize anything useful.

Obviously, I'll need to nail down the details a bit more before the 11th, but I don't want to go down that path if it isn't an acceptable project.

Thanks!

Email 2

Hey Professor Wang,

I've been doing some reading, and I think I have a more specific proposal. How would something like the following sound for a term project?

I'd like to do some signal processing on music files to try to collect some time series data which might includes information like loudness, onset density, auditory roughness, pitch range, etc. Then, I'd like to aggregate that data and average it over different genres, visualizes the results, and try to see if I can find anything interesting.

My long term goal is to use this project as a springboard into my research which will likely be data visualization for music education. Unfortunately, I don't know a ton of signal processing yet, so I'd like to get my feet wet with a little bit of it in this course.

Let me know if this sounds like a good plan.

Response

What you suggest is fine as a term project. I would suggest adding some processing functions, like pitch detection (we'll have a mid-term programming on this) and onset detection.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.