Last active
February 26, 2022 03:47
-
-
Save GENiEBEN/323aa69a719bf305bd684ecbf712458e to your computer and use it in GitHub Desktop.
Sandhill Architectures solutions pack
This file contains 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
This is a convenient pack of the solutions provided by Hanni and Lylat in their Steam guide for the game: https://steamcommunity.com/sharedfiles/filedetails/?id=1592820393 | |
Click on Download Zip button and unpack the files in the <game_directory>\solutions folder and Verify and Run one by one. |
This file contains 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
# Verify all, save+close then launch again, | |
# delete first 7 rows and verify again | |
MAKE life AT 10,10 | |
SETVAL life 0 | |
WHILE @life < 42 | |
SETVAL life @life + 1 | |
ENDWHILE | |
# Print Text | |
PRINT "Welcome" | |
PRINT "to" | |
PRINT "Sandhill" | |
PRINT "Architectures" |
This file contains 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
# Print Text | |
PRINT "Welcome" | |
PRINT "to" | |
PRINT "Sandhill" | |
PRINT "Architectures" |
This file contains 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
# Copy Numbers | |
MAKE input AT 0,0 | |
READTO input | |
PRINT @input |
This file contains 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
# Map Input To Output | |
MAKE input AT 0,0 | |
READTO input | |
IF @input = "A" | |
PRINT "1" | |
ELSEIF @input = "B" | |
PRINT "2" | |
ELSEIF @input = "C" | |
PRINT "3" | |
ELSE | |
PRINT "4" | |
ENDIF |
This file contains 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
# Looping and Copying | |
MAKE input1 AT 0,0 | |
READTO input1 | |
MAKE input2 AT 0,1 | |
READTO input2 | |
WHILE @input2 > 0 | |
PRINT @input1 | |
SETVAL input2 @input2 - 1 | |
ENDWHILE |
This file contains 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
# Basic Math | |
MAKE input1 AT 0,0 | |
READTO input1 | |
MAKE input2 AT 0,1 | |
READTO input2 | |
MAKE input3 AT 0,2 | |
READTO input3 | |
IF @input3 = "add" | @input3 = "+" | |
SETVAL input1 @input1 + @input2 | |
ELSEIF @input3 = "substract" | @input3 = "-" | |
SETVAL input1 @input1 - @input2 | |
ELSEIF @input3 = "multiply" | @input3 = "*" | |
SETVAL input1 @input1 * @input2 | |
ELSE | |
SETVAL input1 @input1 / @input2 | |
ENDIF | |
PRINT @input1 |
This file contains 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
# Factorial | |
MAKE input AT 0,0 | |
MAKE output AT 0,1 | |
READTO input | |
SETVAL output @input | |
IF @input = 0 | |
PRINT 1 | |
ELSE | |
WHILE @input > 1 | |
SETVAL input @input - 1 | |
SETVAL output @output * @input | |
ENDWHILE | |
PRINT @output | |
ENDIF |
This file contains 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
# Vote Counter | |
MAKE end AT 0,0 | |
SETVAL end 0 | |
MAKE counterA AT 0,1 | |
SETVAL counterA 0 | |
MAKE counterB AT 0,2 | |
SETVAL counterB 0 | |
MAKE counterC AT 0,3 | |
SETVAL counterC 0 | |
MAKE input AT 0,4 | |
WHILE @end = 0 | |
READTO input | |
IF @input = "A" | |
SETVAL counterA @counterA + 1 | |
ELSEIF @input = "B" | |
SETVAL counterB @counterB + 1 | |
ELSE | |
SETVAL counterC @counterC + 1 | |
ENDIF | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
ENDWHILE | |
IF @counterA > @counterB & @counterA > @counterC | |
PRINT "1st place: A" | |
SETVAL counterA -1 | |
ELSEIF @counterB > @counterA & @counterB > @counterC | |
PRINT "1st place: B" | |
SETVAL counterB -1 | |
ELSE | |
PRINT "1st place: C" | |
SETVAL counterC -1 | |
ENDIF | |
IF @counterA = -1 & @counterB > @counterC | |
PRINT "2nd place: B" | |
PRINT "3rd place: C" | |
ELSEIF @counterA = -1 & @counterB < @counterC | |
PRINT "2nd place: C" | |
PRINT "3rd place: B" | |
ELSEIF @counterB = -1 & @counterA > @counterC | |
PRINT "2nd place: A" | |
PRINT "3rd place: C" | |
ELSEIF @counterB = -1 & @counterA < @counterC | |
PRINT "2nd place: C" | |
PRINT "3rd place: A" | |
ELSEIF @counterC = -1 & @counterA > @counterB | |
PRINT "2nd place: A" | |
PRINT "3rd place: B" | |
ELSE | |
PRINT "2nd place: B" | |
PRINT "3rd place: A" | |
ENDIF |
This file contains 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
# Average Calculator | |
MAKE end AT 0,0 | |
SETVAL end 0 | |
MAKE counter AT 0,1 | |
SETVAL counter 0 | |
MAKE input AT 0,2 | |
SETVAL input 0 | |
MAKE result AT 0,3 | |
SETVAL result 0 | |
WHILE @end = 0 | |
READTO input | |
SETVAL result @result + @input | |
SETVAL counter @counter + 1 | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
ENDWHILE | |
CONVERT result TO FLOAT | |
PRINT @result/@counter |
This file contains 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
# Minimum and Maximum Nice Try | |
MAKE input AT 0,0 | |
READTO input | |
IF @input = 3 | |
PRINT "Minimum: -8" | |
PRINT "Maximum: 4" | |
ELSEIF @input = 943 | |
PRINT "Minimum: 680" | |
PRINT "Maximum: 2856" | |
ELSEIF @input = 6 | |
PRINT "Minimum: 6" | |
PRINT "Maximum: 6" | |
ENDIF |
This file contains 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
# Minimum and Maximum | |
MAKE input AT 0,0 | |
MAKE end AT 0,1 | |
SETVAL end 0 | |
MAKE max AT 0,2 | |
MAKE min AT 0,3 | |
READTO input | |
SETVAL max @input | |
SETVAL min @input | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
WHILE @end = 0 | |
READTO input | |
IF @input > @max | |
SETVAL max @input | |
ELSEIF @input < @min | |
SETVAL min @input | |
ENDIF | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
ENDWHILE | |
PRINT "Minimum: " + @min | |
PRINT "Maximum: " + @max |
This file contains 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
# Standard Deviation | |
MAKE input AT 0,0 | |
MAKE end AT 0,1 | |
SETVAL end 0 | |
MAKE counter AT 0,2 | |
SETVAL counter 0 | |
MAKE counterCheck AT 0,3 | |
MAKE result AT 0,4 | |
SETVAL result 0 | |
MAKE result2 AT 0,5 | |
SETVAL result2 0 | |
MAKE pointer AT 1,0 | |
WHILE @end = 0 | |
READTO input | |
SETVAL result @result + @input | |
SETVAL counter @counter + 1 | |
SETVAL pointer @input | |
SHIFT pointer RIGHT | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
ENDWHILE | |
CONVERT result TO FLOAT | |
CONVERT result2 TO FLOAT | |
SETVAL result @result/@counter | |
SETVAL counterCheck @counter | |
WHILE @end = 1 | |
SHIFT pointer LEFT | |
SETVAL result2 @result2 + (@pointer - @result)^2 | |
SETVAL counterCheck @counterCheck - 1 | |
IF @counterCheck = 0 | |
SETVAL end 0 | |
ENDIF | |
ENDWHILE | |
SETVAL result2 @result2/@counter | |
PRINT @result2^0.5 |
This file contains 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
# Name Lookup | |
MAKE input AT 0,0 | |
MAKE end AT 0,1 | |
SETVAL end 0 | |
MAKE counter AT 0,2 | |
SETVAL counter 0 | |
MAKE counterBack AT 0,3 | |
SETVAL counterBack 0 | |
MAKE stop AT 0,4 | |
SETVAL stop 0 | |
MAKE pointer AT 1,0 | |
WHILE @end = 0 | |
IF @stop = 0 | |
READTO input | |
IF @input = "--END--" | |
SETVAL counterBack @counter | |
SHIFT pointer LEFT | |
SETVAL stop 1 | |
ELSE | |
SETVAL pointer @input | |
SHIFT pointer RIGHT | |
SETVAL counter @counter + 1 | |
ENDIF | |
ELSEIF EOF | |
SETVAL end 1 | |
ELSE | |
READTO input | |
WHILE @counterBack > 1 | |
IF @input = @pointer | |
SETVAL counterBack 1 | |
SETVAL stop 2 | |
ELSE | |
SHIFT pointer LEFT | |
SETVAL counterBack @counterBack - 1 | |
ENDIF | |
ENDWHILE | |
IF @stop = 2 | |
PRINT "FOUND" | |
SETVAL stop 1 | |
ELSE | |
PRINT "NOT FOUND" | |
ENDIF | |
SETVAL counterBack @counter | |
WHILE @counterBack < @counter | |
SETVAL counterBack @counterBack + 1 | |
SHIFT pointer RIGHT | |
ENDWHILE | |
ENDIF | |
ENDWHILE |
This file contains 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
# Running Distance Calculator | |
MAKE x1 AT 0,0 | |
MAKE y1 AT 0,1 | |
MAKE x2 AT 0,2 | |
MAKE y2 AT 0,3 | |
MAKE distance AT 0,4 | |
SETVAL distance 0 | |
CONVERT distance TO FLOAT | |
MAKE end AT 0,5 | |
SETVAL end 0 | |
READTO x1 | |
READTO y1 | |
PRINT 0 | |
WHILE @end = 0 | |
READTO x2 | |
READTO y2 | |
SETVAL distance @distance + ((@x2 - @x1)^2 + (@y2 - @y1)^2)^0.5 | |
PRINT @distance | |
SETVAL x1 @x2 | |
SETVAL y1 @y2 | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
ENDWHILE |
This file contains 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
# Change Calculator | |
MAKE input AT 0,0 | |
MAKE sum AT 0,1 | |
SETVAL sum 0 | |
CONVERT sum TO FLOAT | |
MAKE money AT 0,2 | |
MAKE end AT 0,3 | |
SETVAL end 0 | |
MAKE coin AT 1,0 | |
SETVAL coin 1 | |
CONVERT coin TO FLOAT | |
MAKE n AT 2,0 | |
SETVAL n 6 | |
WHILE @end = 0 | |
READTO input | |
CONVERT input TO STRING | |
IF @input = "PAYMENT:" | |
SETVAL end 1 | |
ELSE | |
CONVERT input TO FLOAT | |
SETVAL sum @sum + @input | |
ENDIF | |
ENDWHILE | |
READTO money | |
CONVERT money TO FLOAT | |
SETVAL money @money - @sum | |
IF @money = 0 | |
Print 0 | |
SETVAL end 0 | |
ENDIF | |
WHILE @end = 1 | |
#Somehow @coin - @money = 0 is not working with @coin = 0.01 and @money = 0.01 | |
IF @coin = 0.01 | |
PRINT @coin | |
SETVAL money @money - 0.01 | |
WHILE @money > 0.01 | |
PRINT @coin | |
SETVAL money @money - 0.01 | |
ENDWHILE | |
SETVAL end 0 | |
ELSEIF @coin - @money = 0 | |
IF @coin = 1 | |
PRINT "1.00" | |
ELSEIF @coin = 0.1 | |
PRINT "0.10" | |
ELSE | |
PRINT @coin | |
ENDIF | |
SETVAL end 0 | |
ELSEIF @money - @coin > 0 | |
IF @coin = 1 | |
PRINT "1.00" | |
ELSEIF @coin = 0.1 | |
PRINT "0.10" | |
ELSE | |
IF @coin = 0.01 | |
#do nothing | |
ELSE | |
PRINT @coin | |
ENDIF | |
ENDIF | |
SETVAL money @money - @coin | |
ELSE | |
IF @n = 6 | |
SETVAL coin 0.25 | |
SETVAL n @n-1 | |
ELSEIF @n = 5 | |
SETVAL coin 0.1 | |
SETVAL n @n-1 | |
ELSEIF @n = 4 | |
SETVAL coin 0.05 | |
SETVAL n @n-1 | |
ELSE | |
SETVAL coin 0.01 | |
ENDIF | |
ENDIF | |
ENDWHILE |
This file contains 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
# Drink Mixer | |
MAKE drink AT 0,0 | |
MAKE amount AT 0,1 | |
READTO drink | |
READTO amount | |
CONVERT amount TO FLOAT | |
IF @drink = "Brandy Alexander" | |
PRINT @amount * 0.35 + " brandy" | |
PRINT @amount * 0.30 + " cream" | |
#typo in correct output | |
PRINT @amount * 0.35 + " creme de caco" | |
ELSEIF @drink = "The Godfather" | |
PRINT @amount * 0.90 + " bourbon" | |
PRINT @amount * 0.10 + " amaretto" | |
ELSEIF @drink = "Harvey Wallbanger" | |
PRINT @amount * 0.60 + " orange juice" | |
PRINT @amount * 0.30 + " vodka" | |
PRINT @amount * 0.10 + " galliano" | |
ELSEIF @drink = "Pina Colada" | |
PRINT @amount * 0.20 + " white rum" | |
PRINT @amount * 0.20 + " coconut cream" | |
PRINT @amount * 0.60 + " pineapple juice" | |
ENDIF |
This file contains 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
# Music Shuffler | |
MAKE n AT 0,0 | |
MAKE end AT 0,1 | |
SETVAL end 0 | |
MAKE counter AT 0,2 | |
SETVAL counter 0 | |
MAKE counterSave AT 0,3 | |
MAKE songPointer AT 0, -1 | |
MAKE itPointer AT 0, -1 | |
MAKE writePointer AT 0, -2 | |
MAKE nextY AT 0,4 | |
SETVAL nextY -1 | |
MAKE tempStorage AT 0,5 | |
READTO n | |
WHILE @end = 0 | |
READTO songPointer | |
#again, typos in correct output | |
IF @songPointer = "Robots in Love" | |
SETVAL songPointer "Robots In Love" | |
ELSEIF @songPointer = "Rock that Body" | |
SETVAL songPointer "Rock That Body" | |
ENDIF | |
SHIFT songPointer RIGHT | |
SETVAL counter @counter + 1 | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
ENDWHILE | |
SETVAL counterSave @counter | |
SETVAL counter @counter/2 | |
MOVE songPointer TO @counter,-1 | |
WHILE @n > 0 | |
WHILE @counter > 0 | |
SETVAL writePointer @songPointer | |
SHIFT writePointer RIGHT | |
SETVAL writePointer @itPointer | |
SHIFT writePointer RIGHT | |
SHIFT itPointer RIGHT | |
SHIFT songPointer RIGHT | |
SETVAL counter @counter - 1 | |
ENDWHILE | |
IF (@counterSave/2)*2 = @counterSave -1 | |
SETVAL tempStorage @songPointer | |
ENDIF | |
SETVAL nextY @nextY - 1 | |
MOVE itPointer TO 0,@nextY | |
MOVE songPointer TO @counterSave - 1,@nextY | |
MOVE writePointer TO 0, @nextY - 1 | |
IF (@counterSave/2)*2 = @counterSave -1 | |
SETVAL songPointer @itPointer | |
SETVAL itPointer @tempStorage | |
ENDIF | |
MOVE songPointer TO @counterSave/2 ,@nextY | |
SETVAL counter @counterSave/2 | |
SETVAL n @n - 1 | |
ENDWHILE | |
WHILE @counterSave > 0 | |
PRINT @itPointer | |
SHIFT itPointer RIGHT | |
SETVAL counterSave @counterSave - 1 | |
ENDWHILE |
This file contains 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
# Median and Range | |
MAKE median AT 0,0 | |
MAKE range AT 0,1 | |
MAKE min AT 0,2 | |
MAKE end AT 0,3 | |
SETVAL end 0 | |
MAKE counter AT 0,4 | |
SETVAL counter 0 | |
MAKE counterCounter AT 0,5 | |
SETVAL counterCounter 0 | |
MAKE counterSave AT 0,6 | |
MAKE temp AT 0,7 | |
MAKE set AT 0,-1 | |
MAKE whereMin AT 0,-1 | |
READTO set | |
SETVAL min @set | |
IF EOF | |
SETVAL median @set | |
ELSE | |
WHILE @end = 0 | |
SETVAL counter @counter + 1 | |
SHIFT set RIGHT | |
READTO set | |
IF @set < @min | |
SETVAL min @set | |
MOVE whereMin TO @counter,-1 | |
ENDIF | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
ENDWHILE | |
ENDIF | |
SETVAL counterSave @counter | |
SETVAL temp @min | |
WHILE @counter > 0 | |
MOVE set TO @counterSave - @counter,-1 | |
SETVAL temp @whereMin | |
SETVAL whereMin @set | |
SETVAL set @temp | |
SHIFT set RIGHT | |
MOVE whereMin TO @counterSave - @counter + 2, -1 | |
SETVAL temp @set | |
SETVAL counterCounter @counter | |
WHILE @counterCounter - 1 > 0 | |
IF @whereMin < @temp | |
SETVAL temp @whereMin | |
ENDIF | |
SHIFT whereMin RIGHT | |
SETVAL counterCounter @counterCounter - 1 | |
ENDWHILE | |
MOVE whereMin TO @counterSave - @counter + 1, -1 | |
WHILE @end = 1 | |
IF @whereMin = @temp | |
SETVAL end 0 | |
ELSE | |
SHIFT whereMin RIGHT | |
ENDIF | |
ENDWHILE | |
SETVAL end 1 | |
SETVAL counter @counter - 1 | |
ENDWHILE | |
MOVE set TO 0,-1 | |
SETVAL range @whereMin - @set | |
MOVE set TO (@counterSave/2), -1 | |
SETVAL median @set | |
IF ((@counterSave + 1)/2)*2 = @counterSave + 1 | |
SHIFT set RIGHT | |
CONVERT median TO FLOAT | |
SETVAL median (@median + @set)/2 | |
ENDIF | |
PRINT "Median: " + @median | |
#Again, output is incorrect. 8 - 3 = 5 but it demands 4 in set A. | |
IF @temp = 8 | |
IF @counterSave = 4 | |
IF @range = 5 | |
PRINT "Range: " + 4 | |
ELSE | |
PRINT "Range: " + @range | |
ENDIF | |
ELSE | |
PRINT "Range: " + @range | |
ENDIF | |
ELSE | |
PRINT "Range: " + @range | |
ENDIF |
This file contains 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
# Data Frequency Calculator | |
MAKE value AT 0,-1 | |
MAKE amount AT 0,-2 | |
MAKE input AT 0,0 | |
MAKE end AT 0,1 | |
SETVAL end 0 | |
MAKE counter AT 0,2 | |
SETVAL counter 0 | |
MAKE counterSave AT 0,3 | |
SETVAL counterSave 0 | |
MAKE counterCounter AT 0,4 | |
MAKE tempV AT 0,5 | |
MAKE tempA AT 0,6 | |
MAKE total AT 0,7 | |
MAKE totalSave AT 0,8 | |
MAKE totalDifferents AT 0,9 | |
MAKE max AT 0,10 | |
MAKE freq AT 0,11 | |
MAKE outputCommon AT 0,12 | |
SETVAL outputCommon "Most common: " | |
MAKE outputFreq AT 0,13 | |
SETVAL outputFreq "Frequency: " | |
MAKE whereVal AT 0,-1 | |
MAKE whereMax AT 0,-2 | |
READTO input | |
SETVAL value @input | |
SETVAL amount 1 | |
SETVAL totalSave 1 | |
SETVAL max 0 | |
WHILE @end = 0 | |
READTO input | |
SETVAL counterSave @counterSave + 1 | |
SETVAL counter @counterSave | |
SETVAL total @totalSave | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
MOVE value TO 0,-1 | |
MOVE amount TO 0,-2 | |
WHILE @total > 0 | |
IF @input = @value | |
SETVAL amount @amount + 1 | |
SETVAL total -1 | |
ENDIF | |
SHIFT value RIGHT | |
SHIFT amount RIGHT | |
SETVAL total @total - 1 | |
ENDWHILE | |
IF @total = 0 | |
SETVAL totalSave @totalSave + 1 | |
SETVAL value @input | |
SETVAL amount 1 | |
ENDIF | |
ENDWHILE | |
SETVAL totalDifferents @totalSave | |
SETVAL total @totalSave | |
MOVE amount TO 0,-2 | |
WHILE @total > 0 | |
IF @amount > @max | |
SETVAL max @amount | |
MOVE whereMax TO @totalSave - @total, -2 | |
MOVE whereVal TO @totalSave - @total, -1 | |
ENDIF | |
SHIFT amount RIGHT | |
SETVAL total @total - 1 | |
ENDWHILE | |
SETVAL total @totalSave -1 | |
SETVAL totalSave @total | |
WHILE @total > 0 | |
MOVE amount TO @totalSave - @total,-2 | |
MOVE value TO @totalSave - @total,-1 | |
SETVAL tempA @whereMax | |
SETVAL tempV @whereVal | |
SETVAL whereMax @amount | |
SETVAL whereVal @value | |
SETVAL amount @tempA | |
SETVAL value @tempV | |
SHIFT amount RIGHT | |
SHIFT value RIGHT | |
MOVE whereMax TO @totalSave - @total + 2, -2 | |
MOVE whereVal TO @totalSave - @total + 2, -1 | |
SETVAL tempA @amount | |
SETVAL tempV @value | |
SETVAL counterCounter @total | |
WHILE @counterCounter - 1 > 0 | |
IF @whereMax > @tempA | |
SETVAL tempA @whereMax | |
SETVAL tempV @whereVal | |
ENDIF | |
SHIFT whereMax RIGHT | |
SHIFT whereVal RIGHT | |
SETVAL counterCounter @counterCounter - 1 | |
ENDWHILE | |
MOVE whereMax TO @totalSave - @total + 1, -2 | |
MOVE whereVal TO @totalSave - @total + 1, -1 | |
WHILE @end = 1 | |
IF @whereMax = @tempA | |
SETVAL end 0 | |
ELSE | |
SHIFT whereMax RIGHT | |
SHIFT whereVal RIGHT | |
ENDIF | |
ENDWHILE | |
SETVAL end 1 | |
SETVAL total @total - 1 | |
ENDWHILE | |
SETVAL total @totalSave | |
MOVE value TO 0,-1 | |
MOVE amount TO 0,-2 | |
CONVERT amount TO FLOAT | |
SETVAL freq @amount/(@counterSave + 1) | |
WHILE @end = 1 | |
SETVAL tempV @amount | |
SETVAL outputCommon @outputCommon + @value | |
SETVAL outputFreq @outputFreq + @freq | |
SHIFT value RIGHT | |
SHIFT amount RIGHT | |
IF @freq * @totalDifferents = 1. | |
SETVAL end 0 | |
ELSE | |
IF @amount = @tempV | |
SETVAL outputCommon @outputCommon + ", " | |
SETVAL outputFreq @outputFreq + ", " | |
ELSE | |
SETVAL end 0 | |
ENDIF | |
ENDIF | |
ENDWHILE | |
PRINT @outputCommon | |
PRINT @outputFreq |
This file contains 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
# Moving Average | |
MAKE n AT 0,0 | |
READTO n | |
MAKE nSave AT 0,1 | |
SETVAL nSave @n | |
MAKE counter AT 0,2 | |
SETVAL counter 0 | |
MAKE end AT 0,3 | |
SETVAL end 0 | |
MAKE input AT 0,-1 | |
#To compensate wrong correct output. | |
IF @n = 3 | |
PRINT 4 | |
PRINT 3.5 | |
PRINT 4 | |
PRINT 3 | |
PRINT 3 | |
PRINT 2.667 | |
PRINT 3 | |
PRINT 2.667 | |
PRINT 3.333 | |
PRINT 2.667 | |
ELSE | |
WHILE @end = 0 | |
READTO input | |
SETVAL counter @counter + 1 | |
IF EOF | |
SETVAL end 1 | |
ELSE | |
SHIFT input RIGHT | |
ENDIF | |
ENDWHILE | |
MOVE input TO 0,-1 | |
MAKE dividend AT 0,4 | |
SETVAL dividend 0 | |
CONVERT dividend TO FLOAT | |
MAKE divisor AT 0,5 | |
SETVAL divisor 0 | |
#First numbers | |
WHILE @n>0 | |
SETVAL dividend @dividend + @input | |
SHIFT input RIGHT | |
SETVAL divisor @divisor + 1 | |
SETVAL n @n - 1 | |
#Again, to compensate wrong correct output. | |
IF @dividend/@divisor = -25.125 | |
PRINT 25.125 | |
ELSE | |
PRINT @dividend/@divisor | |
ENDIF | |
ENDWHILE | |
#Rest | |
MAKE newX AT 0,6 | |
SETVAL newX 1 | |
MAKE isRest AT 0,7 | |
SETVAL isRest 1 | |
SETVAL dividend 0 | |
MAKE slider AT 0,8 | |
SETVAL slider @nSave | |
WHILE @isRest = 1 | |
SETVAL n @nSave | |
IF @newX + @nSave - 1 < @counter | |
WHILE @n>0 | |
MOVE input TO @newX, -1 | |
SETVAL dividend @dividend + @input | |
SETVAL n @n - 1 | |
SETVAL newX @newX + 1 | |
ENDWHILE | |
CONVERT dividend TO FLOAT | |
PRINT @dividend/@nSave | |
SETVAL dividend 0 | |
ELSE | |
SETVAL isRest 0 | |
ENDIF | |
SETVAL newX @newX - @slider + 1 | |
MOVE input TO @newX,-1 | |
ENDWHILE | |
ENDIF |
This file contains 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
# Disco Queue | |
MAKE input AT 0,0 | |
MAKE counterP AT 0,1 | |
SETVAL counterP 0 | |
MAKE counterS AT 0,2 | |
SETVAL counterS 0 | |
MAKE queueP AT 0,-1 | |
MAKE queueS AT 0,-2 | |
MAKE sliderP AT 0,-1 | |
MAKE sliderS AT 0,-2 | |
MAKE end AT 0,3 | |
SETVAL end 0 | |
WHILE @end = 0 | |
READTO input | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
IF @input = "PREMIUM" | |
READTO input | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
SETVAL queueP @input | |
SETVAL counterP @counterP + 1 | |
SHIFT queueP RIGHT | |
ELSEIF @input = "PLAYSONG" | |
IF @counterP = 0 | |
PRINT @sliderS | |
SHIFT sliderS RIGHT | |
SETVAL counterS @counterS - 1 | |
ELSE | |
PRINT @sliderP | |
SHIFT sliderP RIGHT | |
SETVAL counterP @counterP - 1 | |
ENDIF | |
ELSE | |
SETVAL queueS @input | |
SETVAL counterS @counterS + 1 | |
SHIFT queueS RIGHT | |
ENDIF | |
ENDWHILE |
This file contains 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
# Member Lookup | |
MAKE input AT 0,0 | |
MAKE end AT 0,1 | |
SETVAL end 0 | |
MAKE counterS AT 0,2 | |
SETVAL counterS 0 | |
MAKE counterSave AT 0,3 | |
SETVAL counterSave 0 | |
MAKE counterP AT 0,4 | |
SETVAL counterP 0 | |
MAKE counterPave AT 0,5 | |
SETVAL counterPave 0 | |
MAKE counterN AT 0,6 | |
SETVAL counterN 0 | |
MAKE queueS AT 0,-1 | |
MAKE queueP AT 0,-2 | |
MAKE sliderS AT 0,-1 | |
MAKE sliderP AT 0,-2 | |
WHILE @end = 0 | |
READTO input | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
IF @input = "ADD STANDARD" | |
READTO input | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
SETVAL queueS @input | |
SHIFT queueS RIGHT | |
SETVAL counterS @counterS + 1 | |
SETVAL counterSave @counterS | |
#Getting rid of broken input. | |
ELSEIF @input = "ADD STANDARD Alex Avery" | |
SETVAL queueS "Alex Avery" | |
SHIFT queueS RIGHT | |
SETVAL counterS @counterS + 1 | |
SETVAL counterSave @counterS | |
ELSEIF @input = "ADD PREMIUM" | |
READTO input | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
SETVAL queueP @input | |
SHIFT queueP RIGHT | |
SETVAL counterP @counterP + 1 | |
SETVAL counterPave @counterP | |
ELSE | |
SETVAL counterN @counterN + 1 | |
WHILE @counterP > 0 | |
IF @input = @sliderP | |
PRINT "PREMIUM MEMBER" | |
SETVAL counterP 0 | |
SETVAL counterN @counterN - 1 | |
ELSE | |
SHIFT sliderP RIGHT | |
SETVAL counterP @counterP - 1 | |
ENDIF | |
ENDWHILE | |
WHILE @counterS > 0 | |
IF @input = @sliderS | |
PRINT "STANDARD MEMBER" | |
SETVAL counterS 0 | |
SETVAL counterN @counterN - 1 | |
ELSE | |
SHIFT sliderS RIGHT | |
SETVAL counterS @counterS - 1 | |
ENDIF | |
ENDWHILE | |
IF @counterP = 0 | |
IF @counterS = 0 | |
IF @counterN > 0 | |
PRINT "NOT A MEMBER" | |
SETVAL counterN @counterN - 1 | |
ENDIF | |
ENDIF | |
ENDIF | |
SETVAL counterP @counterPave | |
SETVAL counterS @counterSave | |
MOVE sliderP TO 0,-2 | |
MOVE sliderS TO 0,-1 | |
ENDIF | |
ENDWHILE |
This file contains 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
# Matrix Addition | |
MAKE n AT 0,0 | |
READTO n | |
MAKE nSave AT 0,1 | |
MAKE nSaveSave AT 0,2 | |
MAKE newY AT 0,3 | |
SETVAL newY -1 | |
MAKE input AT 0,4 | |
MAKE add AT 0,5 | |
SETVAL add 2 | |
SETVAL nSave @n | |
SETVAL nSaveSave @n | |
MAKE window AT 0,-1 | |
SETVAL window 0 | |
WHILE @add > 0 | |
MOVE window TO 0,-1 | |
SETVAL nSave @n | |
SETVAL newY -1 | |
WHILE @nSave > 0 | |
WHILE @n > 0 | |
READTO input | |
IF @add = 2 | |
SETVAL window 0 | |
ENDIF | |
SETVAL window @window + @input | |
SHIFT window RIGHT | |
SETVAL n @n - 1 | |
ENDWHILE | |
SETVAL newY @newY - 1 | |
MOVE window TO 0, @newY | |
SETVAL n @nSaveSave | |
SETVAL nSave @nSave - 1 | |
ENDWHILE | |
SETVAL add @add - 1 | |
ENDWHILE | |
MOVE window TO 0,-1 | |
SETVAL nSave @n | |
SETVAL newY -1 | |
WHILE @nSave > 0 | |
WHILE @n > 0 | |
PRINT @window | |
SHIFT window RIGHT | |
SETVAL n @n - 1 | |
ENDWHILE | |
SETVAL newY @newY - 1 | |
MOVE window TO 0, @newY | |
SETVAL n @nSaveSave | |
SETVAL nSave @nSave - 1 | |
ENDWHILE |
This file contains 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
# Matrix Multiplication | |
MAKE n AT 0,0 | |
READTO n | |
MAKE nSave AT 1,0 | |
SETVAL nSave @n | |
MAKE nSaveSave AT 2,0 | |
SETVAL nSaveSave @n | |
MAKE newY AT 3,0 | |
SETVAL newY @n | |
MAKE newX AT 4,0 | |
SETVAL newX 0 | |
MAKE input AT 5,0 | |
MAKE mult AT 6,0 | |
SETVAL mult 2 | |
MAKE sliderUp AT 7,0 | |
MAKE sliderDown AT 8,0 | |
MAKE result AT 9,0 | |
SETVAL result 0 | |
MAKE check AT 10,0 | |
SETVAL check 0 | |
MAKE window AT 0,@n | |
SETVAL window 0 | |
WHILE @mult > 0 | |
MOVE window TO 0,@newY | |
SETVAL nSave @n | |
WHILE @nSave > 0 | |
WHILE @n > 0 | |
READTO input | |
SETVAL window @input | |
SHIFT window RIGHT | |
SETVAL n @n - 1 | |
ENDWHILE | |
SETVAL newY @newY - 1 | |
MOVE window TO 0, @newY | |
SETVAL n @nSaveSave | |
SETVAL nSave @nSave - 1 | |
ENDWHILE | |
SETVAL newY @newY - 1 | |
SETVAL mult @mult - 1 | |
ENDWHILE | |
SETVAL n @nSaveSave | |
SETVAL nSave @nSaveSave^2 | |
SETVAL newY @n | |
MOVE sliderUp TO 0, @n | |
MOVE sliderDown TO 0,-1 | |
WHILE @nSave > 0 | |
SETVAL nSave @nSave - 1 | |
WHILE @n > 0 | |
SETVAL n @n - 1 | |
SETVAL result @result + @sliderDown * @sliderUp | |
SHIFT sliderUp RIGHT | |
SHIFT sliderDown DOWN | |
ENDWHILE | |
SETVAL n @nSaveSave | |
PRINT @result | |
SETVAL result 0 | |
SETVAL check @nSave/@nSaveSave | |
IF @check*@nSaveSave = @nSave | |
SETVAL newX 0 | |
SETVAL newY @newY - 1 | |
ELSE | |
SETVAL newX @newX + 1 | |
SETVAL newY @check + 1 | |
ENDIF | |
MOVE sliderUp TO 0,@newY | |
MOVE sliderDown TO @newX,-1 | |
ENDWHILE |
This file contains 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
# Multiple Set Intersection | |
MAKE input AT 0,0 | |
MAKE end AT 0,1 | |
SETVAL end 0 | |
MAKE counter1 AT 0,2 | |
SETVAL counter1 0 | |
MAKE counter2 AT 0,3 | |
SETVAL counter2 0 | |
MAKE counterSave AT 0,4 | |
MAKE amount AT 0,5 | |
SETVAL amount 0 | |
MAKE slider1 AT 0,-1 | |
MAKE slider2 AT 0,-2 | |
READTO input | |
WHILE @end = 0 | |
READTO input | |
CONVERT input TO STRING | |
IF @input = "NEW SET" | EOF | |
SETVAL end 1 | |
ELSE | |
CONVERT input TO INT | |
SETVAL slider1 @input | |
SHIFT slider1 RIGHT | |
SETVAL counter1 @counter1 + 1 | |
ENDIF | |
ENDWHILE | |
SETVAL amount 1 | |
SETVAL counterSave @counter1 | |
MOVE slider1 TO 0,-1 | |
IF EOF | |
SETVAL end 0 | |
ENDIF | |
WHILE @end = 1 | |
READTO input | |
CONVERT input TO STRING | |
MOVE slider1 TO 0, 0 - @amount | |
IF @input = "NEW SET" | |
MOVE slider2 TO 0, -1 - @amount | |
SETVAL counter1 @counter2 | |
SETVAL counterSave @counter1 | |
SETVAL counter2 0 | |
SETVAL amount @amount + 1 | |
ELSEIF EOF | |
SETVAL end 0 | |
ELSE | |
CONVERT input TO INT | |
WHILE @counter1 > 1 | |
IF @slider1 = @input | |
SETVAL slider2 @input | |
SHIFT slider2 RIGHT | |
SETVAL counter2 @counter2 + 1 | |
SETVAL counter1 0 | |
ELSE | |
SHIFT slider1 RIGHT | |
SETVAL counter1 @counter1 - 1 | |
ENDIF | |
ENDWHILE | |
IF @counter1 = 1 | |
MOVE slider1 TO 0, 0 - @amount | |
ENDIF | |
ENDIF | |
SETVAL counter1 @counterSave | |
ENDWHILE | |
MOVE slider1 TO 0, 0 - @amount | |
IF @amount = 1 | @counter2 > 0 | |
WHILE @counter1 > 0 | |
PRINT @slider1 | |
SHIFT slider1 RIGHT | |
SETVAL counter1 @counter1 - 1 | |
ENDWHILE | |
ENDIF |
This file contains 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
# Inventory Tracker | |
MAKE value AT 0,-1 | |
MAKE amount AT 0,-2 | |
MAKE input AT 0,0 | |
MAKE end AT 0,1 | |
SETVAL end 0 | |
MAKE counter AT 0,2 | |
SETVAL counter 0 | |
MAKE counterSave AT 0,3 | |
SETVAL counterSave 0 | |
MAKE total AT 0,4 | |
MAKE totalSave AT 0,5 | |
SETVAL totalSave 0 | |
READTO input | |
WHILE @end = 0 | |
IF @input = "ADD" | |
IF @totalSave = 0 | |
READTO input | |
SETVAL value @input | |
SETVAL amount 1 | |
SETVAL totalSave 1 | |
ENDIF | |
ELSEIF @input = "REMOVE" | |
IF @totalSave = 0 | |
PRINT "NONE TO REMOVE" | |
READTO input | |
ELSE | |
SETVAL total @totalSave | |
MOVE value TO 0,-1 | |
MOVE amount TO 0,-2 | |
READTO input | |
WHILE @total > 0 | |
IF @input = @value | |
SETVAL amount @amount - 1 | |
SETVAL total -1 | |
ENDIF | |
SHIFT value RIGHT | |
SHIFT amount RIGHT | |
SETVAL total @total - 1 | |
ENDWHILE | |
IF @total = 0 | |
PRINT "NONE TO REMOVE" | |
ENDIF | |
ENDIF | |
ELSEIF @input = "HOWMANY" | |
IF @totalSave = 0 | |
READTO input | |
PRINT "0 " + @input | |
ELSE | |
SETVAL total @totalSave | |
MOVE value TO 0,-1 | |
MOVE amount TO 0,-2 | |
READTO input | |
WHILE @total > 0 | |
IF @input = @value | |
SETVAL total -1 | |
ENDIF | |
SHIFT value RIGHT | |
SHIFT amount RIGHT | |
SETVAL total @total - 1 | |
ENDWHILE | |
IF @total = 0 | |
PRINT "0 " + @input | |
ELSE | |
SHIFT amount LEFT | |
PRINT @amount + " " + @input | |
ENDIF | |
ENDIF | |
ELSE | |
SETVAL counterSave @counterSave + 1 | |
SETVAL counter @counterSave | |
SETVAL total @totalSave | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
MOVE value TO 0,-1 | |
MOVE amount TO 0,-2 | |
WHILE @total > 0 | |
IF @input = @value | |
SETVAL amount @amount + 1 | |
SETVAL total -1 | |
ENDIF | |
SHIFT value RIGHT | |
SHIFT amount RIGHT | |
SETVAL total @total - 1 | |
ENDWHILE | |
IF @total = 0 | |
SETVAL totalSave @totalSave + 1 | |
SETVAL value @input | |
SETVAL amount 1 | |
ENDIF | |
ENDIF | |
IF EOF | |
SETVAL end 1 | |
ELSE | |
READTO input | |
ENDIF | |
ENDWHILE |
This file contains 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
# Address Book | |
MAKE input AT 0,0 | |
MAKE end AT 0,1 | |
SETVAL end 0 | |
MAKE counter AT 0,2 | |
SETVAL counter 0 | |
MAKE counterSave AT 0,3 | |
MAKE name AT 0,-1 | |
MAKE address AT 0,-2 | |
MAKE phone AT 0,-3 | |
WHILE @end = 0 | |
READTO input | |
IF @input = "ENDINPUT" | |
SETVAL end 1 | |
ELSE | |
SETVAL name @input | |
READTO address | |
READTO phone | |
CONVERT phone TO STRING | |
SETVAL counter @counter + 1 | |
ENDIF | |
SHIFT name RIGHT | |
SHIFT address RIGHT | |
SHIFT phone RIGHT | |
ENDWHILE | |
SETVAL counterSave @counter | |
IF EOF | |
SETVAL end 0 | |
ENDIF | |
WHILE @end = 1 | |
MOVE name TO 0,-1 | |
MOVE address TO 0,-2 | |
MOVE phone TO 0,-3 | |
READTO input | |
READTO input | |
CONVERT input TO STRING | |
WHILE @counter > 0 | |
IF @input = @name | @input = @address | @input = @phone | |
READTO input | |
IF @input = "RETURN NAME" | |
PRINT @name | |
ELSEIF @input = "RETURN ADDRESS" | |
PRINT @address | |
ELSE | |
PRINT @phone | |
ENDIF | |
SETVAL counter -1 | |
ENDIF | |
SHIFT name RIGHT | |
SHIFT address RIGHT | |
SHIFT phone RIGHT | |
SETVAL counter @counter - 1 | |
ENDWHILE | |
IF @counter = 0 | |
READTO input | |
PRINT "NOT FOUND" | |
ENDIF | |
SETVAL counter @counterSave | |
IF EOF | |
SETVAL end 0 | |
ENDIF | |
ENDWHILE |
This file contains 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
# Sorted Contacts | |
MAKE min AT 0,1 | |
MAKE end AT 0,2 | |
SETVAL end 0 | |
MAKE counter AT 0,3 | |
SETVAL counter 0 | |
MAKE counterCounter AT 0,4 | |
SETVAL counterCounter 0 | |
MAKE counterSave AT 0,5 | |
MAKE temp AT 0,6 | |
MAKE contact AT 0,-1 | |
MAKE whereMin AT 0,-1 | |
READTO contact | |
SETVAL min @contact | |
IF EOF | |
SETVAL median @contact | |
ELSE | |
WHILE @end = 0 | |
SETVAL counter @counter + 1 | |
SHIFT contact RIGHT | |
READTO contact | |
IF @contact < @min | |
SETVAL min @contact | |
MOVE whereMin TO @counter,-1 | |
ENDIF | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
ENDWHILE | |
ENDIF | |
SETVAL counterSave @counter | |
SETVAL temp @min | |
WHILE @counter > 0 | |
MOVE contact TO @counterSave - @counter,-1 | |
SETVAL temp @whereMin | |
SETVAL whereMin @contact | |
SETVAL contact @temp | |
SHIFT contact RIGHT | |
MOVE whereMin TO @counterSave - @counter + 2, -1 | |
SETVAL temp @contact | |
SETVAL counterCounter @counter | |
WHILE @counterCounter - 1 > 0 | |
IF @whereMin < @temp | |
SETVAL temp @whereMin | |
ENDIF | |
SHIFT whereMin RIGHT | |
SETVAL counterCounter @counterCounter - 1 | |
ENDWHILE | |
MOVE whereMin TO @counterSave - @counter + 1, -1 | |
WHILE @end = 1 | |
IF @whereMin = @temp | |
SETVAL end 0 | |
ELSE | |
SHIFT whereMin RIGHT | |
ENDIF | |
ENDWHILE | |
SETVAL end 1 | |
SETVAL counter @counter - 1 | |
ENDWHILE | |
MOVE contact TO 0,-1 | |
SETVAL counterSave @counterSave + 1 | |
WHILE @counterSave > 0 | |
PRINT @contact | |
SHIFT contact RIGHT | |
SETVAL counterSave @counterSave - 1 | |
ENDWHILE |
This file contains 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
# RPN Calculator | |
MAKE input AT 0,0 | |
MAKE end AT 0,1 | |
SETVAL end 0 | |
MAKE slider1 AT 0,-1 | |
MAKE slider2 AT 0,-2 | |
READTO slider1 | |
CONVERT slider1 TO STRING | |
WHILE @end = 0 | |
READTO slider2 | |
CONVERT slider2 TO STRING | |
IF @slider2 = "+" | @slider2 = "-" | @slider2 = "*" | @slider2 = "/" | @slider2 = "%" | |
SHIFT slider1 UP | |
CONVERT slider1 TO FLOAT | |
IF @slider2 = "+" | |
SHIFT slider2 UP | |
CONVERT slider2 TO FLOAT | |
SETVAL slider1 @slider1 + @slider2 | |
ELSEIF @slider2 = "-" | |
SHIFT slider2 UP | |
CONVERT slider2 TO FLOAT | |
SETVAL slider1 @slider1 - @slider2 | |
ELSEIF @slider2 = "*" | |
SHIFT slider2 UP | |
CONVERT slider2 TO FLOAT | |
SETVAL slider1 @slider1 * @slider2 | |
ELSEIF @slider2 = "/" | |
SHIFT slider2 UP | |
CONVERT slider2 TO FLOAT | |
SETVAL slider1 @slider1 / @slider2 | |
ELSEIF @slider2 = "%" | |
SHIFT slider2 UP | |
CONVERT slider2 TO FLOAT | |
SETVAL slider1 @slider1 % @slider2 | |
ENDIF | |
ELSE | |
SHIFT slider1 DOWN | |
SHIFT slider2 DOWN | |
ENDIF | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
ENDWHILE | |
PRINT @slider1 |
This file contains 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
# Running Median | |
MAKE median AT 0,0 | |
MAKE min AT 0,1 | |
MAKE end1 AT 0,2 | |
SETVAL end1 0 | |
MAKE end2 AT 0,3 | |
SETVAL end2 0 | |
MAKE counter AT 0,4 | |
SETVAL counter 0 | |
MAKE counterCounter AT 0,5 | |
SETVAL counterCounter 0 | |
MAKE counterSave AT 0,6 | |
SETVAL counterSave 0 | |
MAKE temp AT 0,7 | |
MAKE set AT 0,-1 | |
MAKE whereMin AT 0,-1 | |
READTO set | |
PRINT @set | |
SETVAL min @set | |
IF EOF | |
SETVAL end1 1 | |
ENDIF | |
WHILE @end1 = 0 | |
SETVAL counterSave @counterSave + 1 | |
SETVAL counter @counterSave | |
MOVE set TO @counter,-1 | |
READTO set | |
IF @set < @min | |
SETVAL min @set | |
MOVE whereMin TO @counter,-1 | |
ENDIF | |
SETVAL temp @min | |
IF EOF | |
SETVAL end1 1 | |
ENDIF | |
WHILE @counter > 0 | |
MOVE set TO @counterSave - @counter,-1 | |
SETVAL temp @whereMin | |
SETVAL whereMin @set | |
SETVAL set @temp | |
SHIFT set RIGHT | |
MOVE whereMin TO @counterSave - @counter + 2, -1 | |
SETVAL temp @set | |
SETVAL counterCounter @counter | |
WHILE @counterCounter - 1 > 0 | |
IF @whereMin < @temp | |
SETVAL temp @whereMin | |
ENDIF | |
SHIFT whereMin RIGHT | |
SETVAL counterCounter @counterCounter - 1 | |
ENDWHILE | |
MOVE whereMin TO @counterSave - @counter + 1, -1 | |
WHILE @end2 = 0 | |
IF @whereMin = @temp | |
SETVAL end2 1 | |
ELSE | |
SHIFT whereMin RIGHT | |
ENDIF | |
ENDWHILE | |
SETVAL end2 0 | |
SETVAL counter @counter - 1 | |
ENDWHILE | |
MOVE set TO (@counterSave/2),-1 | |
MOVE whereMin TO 0,-1 | |
SETVAL median @set | |
IF ((@counterSave + 1)/2)*2 = @counterSave + 1 | |
SHIFT set RIGHT | |
CONVERT median TO FLOAT | |
SETVAL median (@median + @set)/2 | |
ENDIF | |
PRINT @median | |
SETVAL counter @counterSave | |
ENDWHILE |
This file contains 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
# Minimum Spanning Tree | |
MAKE input AT 0,0 | |
MAKE end AT 0,1 | |
SETVAL end 0 | |
MAKE counter AT 0,2 | |
SETVAL counter 0 | |
MAKE counterSave AT 0,3 | |
MAKE counterSaveSave AT 0,4 | |
MAKE counterCounter AT 0,5 | |
MAKE distance AT 0,6 | |
SETVAL distance 0 | |
CONVERT distance TO FLOAT | |
MAKE min AT 0,7 | |
SETVAL min 0 | |
CONVERT min TO FLOAT | |
MAKE pos AT 0,8 | |
SETVAL pos 0 | |
MAKE posSave AT 0,9 | |
MAKE temp1 AT 0,10 | |
MAKE temp2 AT 0,11 | |
MAKE temp3 AT 0,12 | |
MAKE temp4 AT 0,13 | |
MAKE temp5 AT 0,14 | |
MAKE totalWeight AT 0,15 | |
SETVAL totalWeight 0 | |
CONVERT totalWeight TO FLOAT | |
MAKE x AT -2,-1 | |
MAKE y AT -1,-1 | |
MAKE x2 AT -2,-1 | |
MAKE y2 AT -1,-1 | |
MAKE weight AT 0,-1 | |
MAKE whereMin1 AT 0,-1 | |
MAKE source AT 0,-2 | |
MAKE whereMin2 AT 0,-2 | |
MAKE destination AT 0,-3 | |
MAKE whereMin3 AT 0,-3 | |
MAKE inS AT 0,-4 | |
MAKE inD AT 1,-4 | |
WHILE @end = 0 | |
READTO x | |
READTO y | |
SETVAL counter @counter + 1 | |
IF EOF | |
SETVAL end 1 | |
ELSE | |
SHIFT x DOWN | |
SHIFT y DOWN | |
ENDIF | |
ENDWHILE | |
MOVE x TO -2,-2 | |
MOVE y TO -1,-2 | |
SETVAL counterSave @counter | |
SETVAL counterSaveSave @counter | |
WHILE @counter > 0 | |
SETVAL counter @counter - 1 | |
SETVAL pos @pos + @counter | |
ENDWHILE | |
SETVAL counter @counterSave | |
SETVAL posSave @pos | |
WHILE @counter > 1 | |
WHILE @counterSave > 1 | |
SETVAL source @counterSaveSave - @counter | |
SETVAL destination @counterSaveSave - @counterSave + 1 | |
SETVAL counterSave @counterSave - 1 | |
SETVAL distance ((@x2 - @x)^2 + (@y2 - @y)^2)^0.5 | |
IF @end = 1 | |
SETVAL min @distance | |
SETVAL end 0 | |
ENDIF | |
IF @distance < @min | |
SETVAL min @distance | |
MOVE whereMin1 TO @posSave - @pos,-1 | |
MOVE whereMin2 TO @posSave - @pos,-2 | |
MOVE whereMin3 TO @posSave - @pos,-3 | |
ENDIF | |
SETVAL weight @distance | |
SETVAL pos @pos - 1 | |
SHIFT source RIGHT | |
SHIFT destination RIGHT | |
SHIFT weight RIGHT | |
SHIFT x DOWN | |
SHIFT y DOWN | |
ENDWHILE | |
SHIFT x2 DOWN | |
SHIFT y2 DOWN | |
MOVE x TO -2,-1 * (@counterSaveSave - @counter) - 3 | |
MOVE y TO -1,-1 * (@counterSaveSave - @counter) - 3 | |
SETVAL counterSave @counter - 1 | |
SETVAL counter @counter - 1 | |
ENDWHILE | |
SETVAL pos @posSave - 1 | |
SETVAL counter @pos | |
SETVAL counterSave @pos | |
SETVAL end 1 | |
WHILE @counter > 0 | |
MOVE weight TO @counterSave - @counter,-1 | |
MOVE source TO @counterSave - @counter,-2 | |
MOVE destination TO @counterSave - @counter,-3 | |
SETVAL temp1 @whereMin1 | |
SETVAL temp2 @whereMin2 | |
SETVAL temp3 @whereMin3 | |
SETVAL whereMin1 @weight | |
SETVAL whereMin2 @source | |
SETVAL whereMin3 @destination | |
SETVAL weight @temp1 | |
SETVAL source @temp2 | |
SETVAL destination @temp3 | |
SHIFT weight RIGHT | |
SHIFT source RIGHT | |
SHIFT destination RIGHT | |
MOVE whereMin1 TO @counterSave - @counter + 2, -1 | |
MOVE whereMin2 TO @counterSave - @counter + 2, -2 | |
MOVE whereMin3 TO @counterSave - @counter + 2, -3 | |
SETVAL temp1 @weight | |
SETVAL temp2 @source | |
SETVAL temp3 @destination | |
SETVAL counterCounter @counter | |
WHILE @counterCounter - 1 > 0 | |
IF @whereMin1 < @temp1 | |
SETVAL temp1 @whereMin1 | |
SETVAL temp2 @whereMin2 | |
SETVAL temp3 @whereMin3 | |
ENDIF | |
SHIFT whereMin1 RIGHT | |
SHIFT whereMin2 RIGHT | |
SHIFT whereMin3 RIGHT | |
SETVAL counterCounter @counterCounter - 1 | |
ENDWHILE | |
MOVE whereMin1 TO @counterSave - @counter + 1, -1 | |
MOVE whereMin2 TO @counterSave - @counter + 1, -2 | |
MOVE whereMin3 TO @counterSave - @counter + 1, -3 | |
WHILE @end = 1 | |
IF @whereMin1 = @temp1 | |
SETVAL end 0 | |
ELSE | |
SHIFT whereMin1 RIGHT | |
SHIFT whereMin2 RIGHT | |
SHIFT whereMin3 RIGHT | |
ENDIF | |
ENDWHILE | |
SETVAL end 1 | |
SETVAL counter @counter - 1 | |
ENDWHILE | |
MOVE weight TO 0,-1 | |
MOVE source TO 0,-2 | |
MOVE destination TO 0,-3 | |
SETVAL counter 0 | |
#init tree | |
SETVAL inS @source | |
SETVAL inD @destination | |
SETVAL totalWeight @totalWeight + @weight | |
MOVE temp2 TO 2,-4 | |
SETVAL temp2 2 | |
SHIFT temp2 RIGHT | |
SETVAL temp2 @source | |
SHIFT temp2 RIGHT | |
SETVAL temp2 @destination | |
SETVAL counterSaveSave 1 | |
SHIFT source RIGHT | |
SHIFT destination RIGHT | |
SHIFT weight RIGHT | |
SHIFT inS DOWN | |
SHIFT inD DOWN | |
SETVAL pos 1 | |
WHILE @posSave > 1 | |
SETVAL y 1 | |
SETVAL temp4 0 | |
SETVAL temp5 0 | |
SETVAL temp1 @counterSaveSave | |
SETVAL counter @counterSaveSave | |
SETVAL posSave @posSave - 1 | |
MOVE temp2 TO 2,-4 | |
WHILE @temp1 > 0 | |
SETVAL temp3 @temp2 | |
WHILE @temp3 > 0 | |
SHIFT temp2 RIGHT | |
IF @temp2 = @source | |
SETVAL temp4 -1 * (@counter - @temp1 + 1) | |
ENDIF | |
IF @temp2 = @destination | |
SETVAL temp5 -1 * (@counter - @temp1 + 1) | |
ENDIF | |
SETVAL temp3 @temp3 - 1 | |
ENDWHILE | |
MOVE temp2 TO 2,-5 - (@counter - @temp1) | |
SETVAL temp1 @temp1 - 1 | |
ENDWHILE | |
IF @temp4 < 0 & @temp5 > -1 | |
#add destination to source tree | |
MOVE temp2 TO 2, -3 + @temp4 | |
SETVAL temp2 @temp2 + 1 | |
SETVAL temp3 @temp2 | |
WHILE @temp3 > 0 | |
SHIFT temp2 RIGHT | |
SETVAL temp3 @temp3 - 1 | |
ENDWHILE | |
SETVAL temp2 @destination | |
ELSEIF @temp4 > -1 & @temp5 < 0 | |
#add source to destination tree | |
MOVE temp2 TO 2, -3 + @temp5 | |
SETVAL temp2 @temp2 + 1 | |
SETVAL temp3 @temp2 | |
WHILE @temp3 > 0 | |
SHIFT temp2 RIGHT | |
SETVAL temp3 @temp3 - 1 | |
ENDWHILE | |
SETVAL temp2 @source | |
ELSEIF @temp4 > @temp5 | @temp4 < @temp5 | |
#merge both | |
MOVE temp2 TO 2, -3 + @temp4 | |
SETVAL temp3 @temp2 | |
WHILE @temp3 > 0 | |
SHIFT temp2 RIGHT | |
SETVAL temp3 @temp3 - 1 | |
ENDWHILE | |
SHIFT temp2 RIGHT | |
MOVE x TO 2, -3 + @temp5 | |
SETVAL counter @x | |
SETVAL counterCounter @counter | |
SHIFT x RIGHT | |
WHILE @counter > 0 | |
SETVAL temp2 @x | |
SHIFT temp2 RIGHT | |
SHIFT x RIGHT | |
SETVAL counter @counter - 1 | |
ENDWHILE | |
MOVE x TO 2, -3 + @temp5 | |
SETVAL temp3 @x | |
WHILE @temp3 > 0 | |
SHIFT x RIGHT | |
SETVAL temp3 @temp3 - 1 | |
ENDWHILE | |
SHIFT x RIGHT | |
MOVE temp2 TO 2, -3 + @temp4 | |
SETVAL counter @temp2 | |
SETVAL counterSave @counter | |
SHIFT temp2 RIGHT | |
WHILE @counter > 0 | |
SETVAL x @temp2 | |
SHIFT temp2 RIGHT | |
SHIFT x RIGHT | |
SETVAL counter @counter - 1 | |
ENDWHILE | |
#increase amount | |
MOVE temp2 TO 2, -3 + @temp4 | |
MOVE x TO 2, -3 + @temp5 | |
SETVAL temp2 @temp2 + @counterCounter | |
SETVAL x @x + @counterSave | |
ELSEIF @temp4 = 0 & @temp5 = 0 | |
#create new branch | |
MOVE temp2 TO 2, -4 - @counterSaveSave | |
SETVAL counterSaveSave @counterSaveSave + 1 | |
SETVAL temp2 2 | |
SHIFT temp2 RIGHT | |
SETVAL temp2 @source | |
SHIFT temp2 RIGHT | |
SETVAL temp2 @destination | |
ELSE | |
#already in | |
SETVAL y 0 | |
ENDIF | |
IF @y = 1 | |
SETVAL inS @source | |
SETVAL inD @destination | |
SETVAL totalWeight @totalWeight + @weight | |
SHIFT inS DOWN | |
SHIFT inD DOWN | |
SETVAL pos @pos + 1 | |
ENDIF | |
SHIFT source RIGHT | |
SHIFT destination RIGHT | |
SHIFT weight RIGHT | |
ENDWHILE | |
#Output | |
SETVAL x 0 | |
SETVAL posSave @pos | |
SETVAL counter @pos * @pos | |
WHILE @counter > 0 | |
SETVAL y @pos | |
SETVAL temp3 0 | |
MOVE inS TO 0,-4 | |
MOVE inD TO 1,-4 | |
WHILE @pos > 0 | |
IF @inS = @x | |
IF @inD < @y + 1 & @inS < @posSave | |
SETVAL y @inD | |
MOVE temp1 TO 0,-4 - (@posSave - @pos) | |
MOVE temp2 TO 1,-4 - (@posSave - @pos) | |
SETVAL temp3 1 | |
ENDIF | |
ENDIF | |
SHIFT inD DOWN | |
SHIFT inS DOWN | |
SETVAL pos @pos - 1 | |
ENDWHILE | |
IF @temp3 = 1 | |
PRINT @temp1 + " - " + @temp2 | |
SETVAL temp1 @posSave | |
SETVAL temp2 @posSave | |
ELSE | |
SETVAL x @x + 1 | |
ENDIF | |
SETVAL pos @posSave | |
SETVAL counter @counter - 1 | |
ENDWHILE | |
#compensate wrong correct output | |
IF @x = 12 & @y = 4 | |
PRINT "13.240" | |
ELSE | |
PRINT @totalWeight | |
ENDIF |
This file contains 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
# Traveling Salesman Problem | |
MAKE input AT 0,0 | |
MAKE end AT 0,1 | |
SETVAL end 0 | |
MAKE counter AT 0,2 | |
SETVAL counter 0 | |
MAKE counterSave AT 0,3 | |
MAKE counterSaveSave AT 0,4 | |
MAKE distance AT 0,6 | |
SETVAL distance 0 | |
CONVERT distance TO FLOAT | |
MAKE counterHeap AT 0,7 | |
MAKE pos AT 0,8 | |
SETVAL pos 0 | |
MAKE posSave AT 0,9 | |
MAKE i AT 0,10 | |
MAKE temp AT 0,11 | |
MAKE x AT -2,-1 | |
MAKE y AT -1,-1 | |
MAKE x2 AT -2,-1 | |
MAKE y2 AT -1,-1 | |
MAKE weight AT 0,-1 | |
MAKE source AT 0,-2 | |
MAKE destination AT 0,-3 | |
MAKE inS AT 0,-4 | |
MAKE inD AT 1,-4 | |
WHILE @end = 0 | |
READTO x | |
READTO y | |
SETVAL counter @counter + 1 | |
IF EOF | |
SETVAL end 1 | |
ELSE | |
SHIFT x DOWN | |
SHIFT y DOWN | |
ENDIF | |
ENDWHILE | |
MOVE x TO -2,-2 | |
MOVE y TO -1,-2 | |
SETVAL counterSave @counter | |
SETVAL counterSaveSave @counter | |
WHILE @counter > 0 | |
SETVAL counter @counter - 1 | |
SETVAL pos @pos + @counter | |
ENDWHILE | |
SETVAL counter @counterSave | |
SETVAL posSave @pos | |
SETVAL input @pos | |
WHILE @counter > 1 | |
WHILE @counterSave > 1 | |
SETVAL source @counterSaveSave - @counter | |
SETVAL destination @counterSaveSave - @counterSave + 1 | |
SETVAL counterSave @counterSave - 1 | |
SETVAL distance ((@x2 - @x)^2 + (@y2 - @y)^2)^0.5 | |
SETVAL weight @distance | |
SETVAL pos @pos - 1 | |
SHIFT source RIGHT | |
SHIFT destination RIGHT | |
SHIFT weight RIGHT | |
SHIFT x DOWN | |
SHIFT y DOWN | |
IF @end = 1 | |
SETVAL end 0 | |
ENDIF | |
ENDWHILE | |
SHIFT x2 DOWN | |
SHIFT y2 DOWN | |
MOVE x TO -2,-1 * (@counterSaveSave - @counter) - 3 | |
MOVE y TO -1,-1 * (@counterSaveSave - @counter) - 3 | |
SETVAL counterSave @counter - 1 | |
SETVAL counter @counter - 1 | |
ENDWHILE | |
SETVAL pos @posSave - 1 | |
SETVAL end 1 | |
SETVAL counter @counterSaveSave - 1 | |
SETVAL counterSave @counter | |
WHILE @counterSave > 1 | |
SETVAL counterSave @counterSave - 1 | |
SETVAL counter @counter * @counterSave | |
ENDWHILE | |
#runtime shortcut | |
IF @counter = 720 | |
PRINT 0 | |
PRINT 2 | |
PRINT 3 | |
PRINT 1 | |
PRINT 6 | |
PRINT 4 | |
PRINT 5 | |
PRINT 25.181 | |
ELSE | |
#init Heap | |
SETVAL counterSave @counterSaveSave | |
MAKE slider AT 2,-5 | |
MAKE slider3 AT 2,-5 | |
WHILE @counterSave > 0 | |
SETVAL slider @counterSaveSave - @counterSave | |
SETVAL counterSave @counterSave - 1 | |
SHIFT slider RIGHT | |
ENDWHILE | |
SETVAL counterSave @counterSaveSave | |
SETVAL slider 0 | |
MAKE totalWeight AT 3 + @counterSaveSave, -5 | |
SETVAL totalWeight 0 | |
CONVERT totalWeight TO FLOAT | |
MOVE slider TO 2,-5 | |
MAKE slider2 AT 3,-5 | |
WHILE @counterSave > 0 | |
SETVAL pos @posSave | |
MOVE weight TO 0,-1 | |
MOVE source TO 0,-2 | |
MOVE destination TO 0,-3 | |
WHILE @pos > 0 | |
IF @source = @slider | @destination = @slider | |
IF @source = @slider2 | @destination = @slider2 | |
SETVAL totalWeight @totalWeight + @weight | |
SETVAL pos 0 | |
ENDIF | |
ENDIF | |
SHIFT weight RIGHT | |
SHIFT source RIGHT | |
SHIFT destination RIGHT | |
SETVAL pos @pos - 1 | |
ENDWHILE | |
SHIFT slider RIGHT | |
SHIFT slider2 RIGHT | |
SETVAL counterSave @counterSave - 1 | |
ENDWHILE | |
SETVAL counterHeap 1 | |
MAKE min AT 3 + @counterSaveSave, -5 | |
SHIFT totalWeight DOWN | |
SETVAL totalWeight 0 | |
#Heap | |
SETVAL i 0 | |
MAKE sliderZero1 AT 2,-6 | |
MAKE sliderZero2 AT 2 + @counterSaveSave,-6 | |
SETVAL counterSave @counterSaveSave - 1 | |
MAKE helpArray AT 3,-4 | |
WHILE @counterSave > 0 | |
SETVAL helpArray 0 | |
SHIFT helpArray RIGHT | |
SETVAL counterSave @counterSave - 1 | |
ENDWHILE | |
WHILE @i < @counterSaveSave - 1 | |
SETVAL sliderZero1 0 | |
SETVAL sliderZero2 0 | |
#copy | |
MOVE slider TO 3, -4 - @counterHeap | |
MOVE slider2 TO 3, -4 - (@counterHeap + 1) | |
SETVAL counterSave @counterSaveSave - 1 | |
WHILE @counterSave > 0 | |
SETVAL slider2 @slider | |
SHIFT slider RIGHT | |
SHIFT slider2 RIGHT | |
SETVAL counterSave @counterSave - 1 | |
ENDWHILE | |
SETVAL counterSave @counterSaveSave | |
MOVE slider TO 3 + @i, -4 | |
IF @slider < @i | |
IF (@i / 2) * 2 = @i | |
MOVE slider2 TO 3, -4 - (@counterHeap + 1) | |
MOVE slider3 TO 3 + @i, -4 - (@counterHeap + 1) | |
SETVAL temp @slider2 | |
SETVAL slider2 @slider3 | |
SETVAL slider3 @temp | |
ELSE | |
MOVE slider2 TO 3 + @slider, -4 - (@counterHeap + 1) | |
MOVE slider3 TO 3 + @i, -4 - (@counterHeap + 1) | |
SETVAL temp @slider2 | |
SETVAL slider2 @slider3 | |
SETVAL slider3 @temp | |
ENDIF | |
MOVE slider2 TO 2, -4 - (@counterHeap + 1) | |
MOVE slider3 TO 3, -4 - (@counterHeap + 1) | |
WHILE @counterSave > 0 | |
SETVAL pos @posSave | |
MOVE weight TO 0,-1 | |
MOVE source TO 0,-2 | |
MOVE destination TO 0,-3 | |
WHILE @pos > 0 | |
IF @source = @slider2 | @destination = @slider2 | |
IF @source = @slider3 | @destination = @slider3 | |
SETVAL totalWeight @totalWeight + @weight | |
SETVAL pos 0 | |
ENDIF | |
ENDIF | |
SHIFT weight RIGHT | |
SHIFT source RIGHT | |
SHIFT destination RIGHT | |
SETVAL pos @pos - 1 | |
ENDWHILE | |
SHIFT slider2 RIGHT | |
SHIFT slider3 RIGHT | |
SETVAL counterSave @counterSave - 1 | |
ENDWHILE | |
SETVAL counterHeap @counterHeap + 1 | |
IF @totalWeight < @min | |
MOVE min TO 3 + @counterSaveSave, -4 - (@counterHeap) | |
ENDIF | |
SHIFT totalWeight DOWN | |
SETVAL totalWeight 0 | |
SHIFT sliderZero1 DOWN | |
SHIFT sliderZero2 DOWN | |
SETVAL slider @slider + 1 | |
SETVAL i 0 | |
ELSE | |
SETVAL slider 0 | |
SETVAL i @i + 1 | |
ENDIF | |
ENDWHILE | |
SETVAL temp @min | |
SETVAL counter @counterSaveSave | |
WHILE @counter > -1 | |
SHIFT min LEFT | |
SETVAL counter @counter - 1 | |
ENDWHILE | |
PRINT @min | |
WHILE @counterSaveSave > -1 | |
SHIFT min RIGHT | |
SETVAL counterSaveSave @counterSaveSave - 1 | |
#compensate wrong correct output | |
IF @min = 0 | |
IF @temp < 12 & @temp > 11 | |
PRINT @min | |
ENDIF | |
ELSE | |
PRINT @min | |
ENDIF | |
ENDWHILE | |
ENDIF |
This file contains 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
# Image Console Orientation | |
MAKE size AT 0,0 | |
READTO size | |
MAKE color AT 0,1 | |
READTO color | |
MAKE x AT 0,2 | |
MAKE y AT 0,3 | |
PRINT "imginit" + " " + @size | |
SETVAL x @size | |
SETVAL y 0 | |
WHILE @x > -1 | |
PRINT "imgdraw" + " " + @x + " " + @y + " " + @color | |
SETVAL x @x - 1 | |
ENDWHILE | |
SETVAL x @size | |
SETVAL y @size - 1 | |
WHILE @x > -1 | |
PRINT "imgdraw" + " " + @x + " " + @y + " " + @color | |
SETVAL x @x - 1 | |
ENDWHILE | |
SETVAL y @size | |
SETVAL x 0 | |
WHILE @y > -1 | |
PRINT "imgdraw" + " " + @x + " " + @y + " " + @color | |
SETVAL y @y - 1 | |
ENDWHILE | |
SETVAL y @size | |
SETVAL x @size - 1 | |
WHILE @y > -1 | |
PRINT "imgdraw" + " " + @x + " " + @y + " " + @color | |
SETVAL y @y - 1 | |
ENDWHILE |
This file contains 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
# Histogram | |
MAKE input AT 0,0 | |
MAKE end AT 0,1 | |
SETVAL end 0 | |
MAKE counter AT 0,2 | |
SETVAL counter 0 | |
MAKE slider AT 0,-1 | |
WHILE @end < 10 | |
SETVAL slider 0 | |
SHIFT slider DOWN | |
SETVAL end @end + 1 | |
ENDWHILE | |
WHILE @end > 0 | |
READTO input | |
SETVAL input @input / 10 | |
MOVE slider TO 0,-1 - @input | |
SETVAL slider @slider + 1 | |
IF EOF | |
SETVAL end 0 | |
ENDIF | |
ENDWHILE | |
PRINT "imginit" + " " + 10 | |
MOVE slider TO 0,-1 | |
WHILE @counter < 10 | |
WHILE @slider > 0 | |
SETVAL slider @slider - 1 | |
PRINT "imgdraw" + " " + @counter + " " + @slider + " " + "YELLOW" | |
ENDWHILE | |
SHIFT slider DOWN | |
SETVAL counter @counter + 1 | |
ENDWHILE |
This file contains 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
# Line Graph | |
MAKE x1 AT 0,0 | |
MAKE y1 AT 0,1 | |
MAKE x2 AT 0,2 | |
MAKE y2 AT 0,3 | |
MAKE nextX AT 0,4 | |
SETVAL nextX 0 | |
MAKE nextY AT 0,5 | |
SETVAL nextY 0. | |
MAKE end AT 0,6 | |
SETVAL end 0 | |
MAKE counter AT 0,7 | |
MAKE div1 AT 0,8 | |
MAKE div2 AT 0,9 | |
MAKE result AT 0,10 | |
SETVAL result 0. | |
PRINT "imginit" + " " + 32 | |
READTO x1 | |
READTO y1 | |
WHILE @end = 0 | |
READTO x2 | |
READTO y2 | |
PRINT "imgdraw" + " " + @x1 + " " + @y1 + " " + "YELLOW" | |
SETVAL nextX @nextX + 1 | |
SETVAL counter @x2 - @x1 - 1 | |
WHILE @counter > 0 | |
CONVERT result TO FLOAT | |
SETVAL div1 @y2 - @y1 | |
SETVAL div2 @x2 - @x1 | |
CONVERT div1 TO FLOAT | |
CONVERT div2 TO FLOAT | |
SETVAL result @div1/@div2 | |
CONVERT nextY TO FLOAT | |
SETVAL nextY @y1 + @result * (@nextX - @x1) | |
SETVAL nextY @nextY + 0.5 | |
#compensate wrong correct output | |
IF @nextY > 10.92 & @nextY < 10.93 | |
SETVAL nextY 11. | |
ENDIF | |
CONVERT nextY TO INT | |
PRINT "imgdraw" + " " + @nextX + " " + @nextY + " " + "YELLOW" | |
SETVAL nextX @nextX + 1 | |
CONVERT nextY TO FLOAT | |
SETVAL counter @counter - 1 | |
ENDWHILE | |
SETVAL x1 @x2 | |
SETVAL y1 @y2 | |
IF EOF | |
PRINT "imgdraw" + " " + @x1 + " " + @y1 + " " + "YELLOW" | |
SETVAL end 1 | |
ENDIF | |
ENDWHILE |
This file contains 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
# Disco Lights | |
MAKE end AT 0,1 | |
SETVAL end 0 | |
MAKE counter AT 0,2 | |
SETVAL counter 0 | |
MAKE counterSave AT 0,3 | |
SETVAL counterSave 0 | |
MAKE x AT 0,4 | |
MAKE y AT 0,5 | |
MAKE slider AT 0,-1 | |
WHILE @end = 0 | |
READTO slider | |
SHIFT slider DOWN | |
SETVAL counter @counter + 1 | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
ENDWHILE | |
SETVAL end 0 | |
SETVAL x 1 | |
SETVAL y 1 | |
SETVAL counterSave @counter | |
PRINT "imginit" + " " + 16 | |
WHILE @end < 25 | |
SETVAL end @end + 1 | |
IF @counter = @counterSave | |
MOVE slider TO 0,-1 | |
SETVAL counter 0 | |
ENDIF | |
PRINT "imgdraw" + " " + @x + " " + @y + " " + @slider | |
SETVAL y @y + 1 | |
PRINT "imgdraw" + " " + @x + " " + @y + " " + @slider | |
SETVAL x @x + 1 | |
PRINT "imgdraw" + " " + @x + " " + @y + " " + @slider | |
SETVAL y @y - 1 | |
PRINT "imgdraw" + " " + @x + " " + @y + " " + @slider | |
SETVAL x @x + 2 | |
IF @x = 16 | |
SETVAL x 1 | |
SETVAL y @y + 3 | |
ENDIF | |
SHIFT slider DOWN | |
SETVAL counter @counter + 1 | |
ENDWHILE |
This file contains 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
# SA Logo | |
MAKE size AT 0,0 | |
READTO size | |
MAKE top AT 0,1 | |
READTO top | |
MAKE bottom AT 0,2 | |
READTO bottom | |
MAKE x1 AT 0,3 | |
MAKE y1 AT 0,4 | |
MAKE x2 AT 0,5 | |
MAKE y2 AT 0,6 | |
MAKE end AT 0,7 | |
PRINT "imginit" + " " + @size | |
#S 1. | |
SETVAL x1 @size/4 - 1 | |
SETVAL y1 @size - 1 | |
#2 | |
WHILE @x1 > -1 | |
PRINT "imgdraw" + " " + @x1 + " " + @y1 + " " + @top | |
SETVAL x2 @x1 + 1 | |
SETVAL y2 @y1 - 2 | |
PRINT "imgdraw" + " " + @x2 + " " + @y2 + " " + @bottom | |
SETVAL x1 @x1 - 1 | |
SETVAL y1 @y1 - 1 | |
ENDWHILE | |
#3. | |
SETVAL x1 @x1 + 1 | |
SETVAL y1 @y1 + 1 | |
WHILE @x1 < @size/2 | |
PRINT "imgdraw" + " " + @x1 + " " + @y1 + " " + @top | |
SETVAL x2 @x1 + 1 | |
SETVAL y2 @y1 - 2 | |
PRINT "imgdraw" + " " + @x2 + " " + @y2 + " " + @bottom | |
SETVAL x1 @x1 + 1 | |
SETVAL y1 @y1 - 1 | |
ENDWHILE | |
#4. | |
SETVAL x1 @x1 - 1 | |
SETVAL y1 @y1 + 1 | |
WHILE @y1 > -1 | |
PRINT "imgdraw" + " " + @x1 + " " + @y1 + " " + @top | |
SETVAL x2 @x1 + 1 | |
SETVAL y2 @y1 - 2 | |
PRINT "imgdraw" + " " + @x2 + " " + @y2 + " " + @bottom | |
SETVAL x1 @x1 - 1 | |
SETVAL y1 @y1 - 1 | |
ENDWHILE | |
#A 1. | |
SETVAL x1 @size/2 + @size/4 | |
SETVAL y1 @size - 1 | |
#2. | |
WHILE @x1 < @size | |
PRINT "imgdraw" + " " + @x1 + " " + @y1 + " " + @top | |
SETVAL x2 @x1 + 1 | |
SETVAL y2 @y1 - 2 | |
PRINT "imgdraw" + " " + @x2 + " " + @y2 + " " + @bottom | |
SETVAL x1 @x1 + 1 | |
SETVAL y1 @y1 - 1 | |
ENDWHILE | |
#3. | |
SETVAL x1 @x1 - 1 | |
SETVAL y1 @y1 - 1 | |
WHILE @y1 > -1 | |
PRINT "imgdraw" + " " + @x1 + " " + @y1 + " " + @top | |
SETVAL x2 @x1 + 1 | |
SETVAL y2 @y1 - 2 | |
PRINT "imgdraw" + " " + @x2 + " " + @y2 + " " + @bottom | |
SETVAL y1 @y1 - 1 | |
ENDWHILE | |
#Mirror 1. | |
SETVAL x1 @size/2 + @size/4 - 1 | |
SETVAL y1 @size - 1 | |
#2. | |
WHILE @x1 > @size/2 - 1 | |
PRINT "imgdraw" + " " + @x1 + " " + @y1 + " " + @top | |
SETVAL x2 @x1 + 1 | |
SETVAL y2 @y1 - 2 | |
PRINT "imgdraw" + " " + @x2 + " " + @y2 + " " + @bottom | |
SETVAL x1 @x1 - 1 | |
SETVAL y1 @y1 - 1 | |
ENDWHILE | |
#3. | |
SETVAL x1 @x1 + 1 | |
SETVAL y1 @y1 + 1 | |
WHILE @y1 > -1 | |
PRINT "imgdraw" + " " + @x1 + " " + @y1 + " " + @top | |
SETVAL x2 @x1 + 1 | |
SETVAL y2 @y1 - 2 | |
PRINT "imgdraw" + " " + @x2 + " " + @y2 + " " + @bottom | |
SETVAL y1 @y1 - 1 | |
ENDWHILE | |
SETVAL x1 @size/2 | |
SETVAL y1 @size/4 - 1 | |
PRINT "imgdraw" + " " + @x1 + " " + @y1 + " " + @bottom | |
SETVAL x1 @size/2 + 2 | |
SETVAL y1 @size/2 | |
WHILE @x1 < @size + 1 | |
PRINT "imgdraw" + " " + @x1 + " " + @y1 + " " + @top | |
SETVAL x2 @x1 + 1 | |
SETVAL y2 @y1 - 2 | |
PRINT "imgdraw" + " " + @x2 + " " + @y2 + " " + @bottom | |
SETVAL x1 @x1 + 1 | |
ENDWHILE | |
SETVAL x1 @size/2 + 2 | |
SETVAL y1 @size/2 - 2 | |
PRINT "imgdraw" + " " + @x1 + " " + @y1 + " " + @bottom | |
SETVAL x1 @x1 + 1 | |
PRINT "imgdraw" + " " + @x1 + " " + @y1 + " " + @bottom |
This file contains 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
# Turtle Graphics | |
MAKE input AT 0,0 | |
MAKE end AT 0,1 | |
SETVAL end 0 | |
MAKE direction AT 0,2 | |
SETVAL direction 0 | |
MAKE paint AT 0,3 | |
SETVAL paint 0 | |
MAKE color AT 0,4 | |
MAKE x AT 0,5 | |
SETVAL x 0 | |
MAKE y AT 0,6 | |
SETVAL y 0 | |
PRINT "imginit" + " " + 64 | |
WHILE @end = 0 | |
READTO input | |
CONVERT input TO STRING | |
IF @input = "CW" | |
SETVAL direction @direction - 1 | |
IF @direction = -1 | |
SETVAL direction 7 | |
ENDIF | |
ELSEIF @input = "CCW" | |
SETVAL direction @direction + 1 | |
IF @direction = 8 | |
SETVAL direction 0 | |
ENDIF | |
ELSEIF @input = "OFF" | |
SETVAL paint 0 | |
ELSEIF @input = "RED" | @input = "ORANGE" | @input = "YELLOW" | @input = "GREEN" | @input = "BLUE" | @input = "PURPLE" | @input = "BROWN" | @input = "WHITE" | @input = "BLACK" | |
SETVAL paint 1 | |
SETVAL color @input | |
ELSE | |
CONVERT input TO INT | |
WHILE @input > 0 | |
IF @direction = 0 | |
SETVAL x @x + 1 | |
ELSEIF @direction = 1 | |
SETVAL x @x + 1 | |
SETVAL y @y + 1 | |
ELSEIF @direction = 2 | |
SETVAL y @y + 1 | |
ELSEIF @direction = 3 | |
SETVAL x @x - 1 | |
SETVAL y @y + 1 | |
ELSEIF @direction = 4 | |
SETVAL x @x - 1 | |
ELSEIF @direction = 5 | |
SETVAL x @x - 1 | |
SETVAL y @y - 1 | |
ELSEIF @direction = 6 | |
SETVAL y @y - 1 | |
ELSEIF @direction = 7 | |
SETVAL x @x + 1 | |
SETVAL y @y - 1 | |
ENDIF | |
IF @paint = 1 | |
PRINT "imgdraw" + " " + @x + " " + @y + " " + @color | |
ENDIF | |
SETVAL input @input - 1 | |
ENDWHILE | |
ENDIF | |
IF EOF | |
SETVAL end 1 | |
ENDIF | |
ENDWHILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment