Skip to main content
Commonmark migration
Source Link

#SmileBASIC, 104 81 bytes DEF B A@D SWAP A[0],A[RND(LEN(A))]FOR I=0TO LEN(A)-2IF A[I]<A[I+1]GOTO@D NEXT END

SmileBASIC, 104 81 bytes

DEF B A@D
SWAP A[0],A[RND(LEN(A))]FOR I=0TO LEN(A)-2IF A[I]<A[I+1]GOTO@D
NEXT
END

#SmileBASIC, 104 81 bytes DEF B A@D SWAP A[0],A[RND(LEN(A))]FOR I=0TO LEN(A)-2IF A[I]<A[I+1]GOTO@D NEXT END

SmileBASIC, 104 81 bytes

DEF B A@D
SWAP A[0],A[RND(LEN(A))]FOR I=0TO LEN(A)-2IF A[I]<A[I+1]GOTO@D
NEXT
END
deleted 573 characters in body
Source Link
12Me21
  • 6.7k
  • 1
  • 22
  • 40

#SmileBASIC, 104104 81 bytes DEF B AA@D DIM T[LENSWAP A[0],A[RND(LEN(A))]FOR I=0TO LEN(A)-1T[I]=RNDF()IF I&&A[I-1]>A[I]GOTO@B2IF A[I]<A[I+1]GOTO@D NEXT RETURN@B SORT T,A B A END Explanation:

DEF BOGOSORT ARRAY[] 'create function
 DIM TEMP[LEN(ARRAY)] 'create array used for scrambling
 FOR I=0 TO LEN(ARRAY)-1 'loop through array
  TEMP[I]=RNDF() 'fill TEMP with random numbers
  IF I && ARRAY[I-1]>ARRAY[I] GOTO @BREAK 'if array is not sorted, exit the loop (skip check if I is 0)
 NEXT
 RETURN
 @BREAK
 SORT TEMP,ARRAY 'sort A using the random array
 BOGOSORT ARRAY 'call the function again (much shorter than using a loop, but often causes a stack overflow)
END

#SmileBASIC, 104 bytes DEF B A DIM T[LEN(A)]FOR I=0TO LEN(A)-1T[I]=RNDF()IF I&&A[I-1]>A[I]GOTO@B NEXT RETURN@B SORT T,A B A END Explanation:

DEF BOGOSORT ARRAY[] 'create function
 DIM TEMP[LEN(ARRAY)] 'create array used for scrambling
 FOR I=0 TO LEN(ARRAY)-1 'loop through array
  TEMP[I]=RNDF() 'fill TEMP with random numbers
  IF I && ARRAY[I-1]>ARRAY[I] GOTO @BREAK 'if array is not sorted, exit the loop (skip check if I is 0)
 NEXT
 RETURN
 @BREAK
 SORT TEMP,ARRAY 'sort A using the random array
 BOGOSORT ARRAY 'call the function again (much shorter than using a loop, but often causes a stack overflow)
END

#SmileBASIC, 104 81 bytes DEF B A@D SWAP A[0],A[RND(LEN(A))]FOR I=0TO LEN(A)-2IF A[I]<A[I+1]GOTO@D NEXT END

added 11 characters in body
Source Link
12Me21
  • 6.7k
  • 1
  • 22
  • 40

#SmileBASIC, 104 bytes DEF B A DIM T[LEN(A)]FOR I=0TO LEN(A)-1T[I]=RNDF()IF I&&A[I-1]>A[I]GOTO@B NEXT RETURN@B SORT T,A B A END Explanation:

DEF BOGOSORT ARRAY[] 'create function
 DIM TEMP[LEN(ARRAY)] 'create array used for scrambling
 FOR I=0 TO LEN(ARRAY)-1 'loop through array
  TEMP[I]=RNDF() 'fill TEMP with random numbers
  IF I && ARRAY[I-1]>ARRAY[I] GOTO @BREAK 'if array is not sorted, exit the loop (skip check if I is 0)
 NEXT
 RETURN
 @BREAK
 SORT TEMP,ARRAY 'sort A using the random array
 BBOGOSORT AARRAY 'call the function again (much shorter than using a loop, but often causes a stack overflow)
END

#SmileBASIC, 104 bytes DEF B A DIM T[LEN(A)]FOR I=0TO LEN(A)-1T[I]=RNDF()IF I&&A[I-1]>A[I]GOTO@B NEXT RETURN@B SORT T,A B A END Explanation:

DEF BOGOSORT ARRAY[] 'create function
 DIM TEMP[LEN(ARRAY)] 'create array used for scrambling
 FOR I=0 TO LEN(ARRAY)-1 'loop through array
  TEMP[I]=RNDF() 'fill TEMP with random numbers
  IF I && ARRAY[I-1]>ARRAY[I] GOTO @BREAK 'if array is not sorted, exit the loop (skip check if I is 0)
 NEXT
 RETURN
 @BREAK
 SORT TEMP,ARRAY 'sort A using the random array
 B A 'call the function again (much shorter than using a loop, but often causes a stack overflow)
END

#SmileBASIC, 104 bytes DEF B A DIM T[LEN(A)]FOR I=0TO LEN(A)-1T[I]=RNDF()IF I&&A[I-1]>A[I]GOTO@B NEXT RETURN@B SORT T,A B A END Explanation:

DEF BOGOSORT ARRAY[] 'create function
 DIM TEMP[LEN(ARRAY)] 'create array used for scrambling
 FOR I=0 TO LEN(ARRAY)-1 'loop through array
  TEMP[I]=RNDF() 'fill TEMP with random numbers
  IF I && ARRAY[I-1]>ARRAY[I] GOTO @BREAK 'if array is not sorted, exit the loop (skip check if I is 0)
 NEXT
 RETURN
 @BREAK
 SORT TEMP,ARRAY 'sort A using the random array
 BOGOSORT ARRAY 'call the function again (much shorter than using a loop, but often causes a stack overflow)
END
Source Link
12Me21
  • 6.7k
  • 1
  • 22
  • 40
Loading