Skip to main content
updated code for arbitrary input
Source Link
PunPun1000
  • 993
  • 4
  • 7

Java (OpenJDK 8), Score: ??? (possibly 2^31)

This clocks in at 969980 bytes, since I had so much to work with I decided to make it a little more readable. Basically I'm generating all the possible programs for length n and iterating them for n*nn^x times for some x. Intuitively a smallfuck program length n which runs longer than n*n steps should be in an infinite loop since the tape x is currently 3 but it can be modified arbitrarily to any size, limited only contain Booleanby the limitation of the JVM's precission. This will work for arbitrarily large input values if x is increased, howeverbut I have not proven it. Without higher test cases I'm not sure where it fails set to generate all the possible outcomes, if ever. If all smallfuck programs of length n terminate within n*n steps, this will work3 for all positive ints java can handle, i.etio. 1 to 2^31-1

import java.util.*; public class Main{ public static void main(String[] args){ int i = new Scanner(System.in).nextInt(); int x = 3; l:for(int j=0;j<Math.pow(5, i);j++){ try { String s=""; for(int k=j;s.length()<i;k/=5) s="+<>][".charAt(k%5)+s; Stack<Integer>y=new Stack<Integer>(); Map<Integer,Integer>f=new HashMap<>(),b=new HashMap<>(); for(int m=0; m<s.length();m++){ char c=s.charAt(m); if(c=='[')y.push(m); if(c==']'){int n=y.pop();f.put(n, m);b.put(m, n);} } if(y.size()>0) continue; boolean[] t= new boolean[s.length()]; int l=0,n=0; for(long m=0;l<s.length()&m<(long)i*&m<Math.pow(longi,x)i;l++;l++,m++){ switch(s.charAt(l)){ case'+':t[n]=!t[n];break; case'>':n++;break; case'<':n--; if(n < 0)continue l;break; case'[':if(!t[n])l=f.get(l);break; case']':l=b.get(l)-1;break; } } if(l>=s.length()){ System.out.println(s); } } catch(Exception e){continue;} } } } 

Try it online!Try it online!

Java (OpenJDK 8), Score: ??? (possibly 2^31)

This clocks in at 969 bytes, since I had so much to work with I decided to make it a little more readable. Basically I'm generating all the possible programs for length n and iterating them for n*n times. Intuitively a smallfuck program length n which runs longer than n*n steps should be in an infinite loop since the tape can only contain Boolean values, however I have not proven it. Without higher test cases I'm not sure where it fails to generate all the possible outcomes, if ever. If all smallfuck programs of length n terminate within n*n steps, this will work for all positive ints java can handle, i.e. 1 to 2^31-1

import java.util.*; public class Main{ public static void main(String[] args){ int i = new Scanner(System.in).nextInt(); l:for(int j=0;j<Math.pow(5, i);j++){ try { String s=""; for(int k=j;s.length()<i;k/=5) s="+<>][".charAt(k%5)+s; Stack<Integer>y=new Stack<Integer>(); Map<Integer,Integer>f=new HashMap<>(),b=new HashMap<>(); for(int m=0; m<s.length();m++){ char c=s.charAt(m); if(c=='[')y.push(m); if(c==']'){int n=y.pop();f.put(n, m);b.put(m, n);} } if(y.size()>0) continue; boolean[] t= new boolean[s.length()]; int l=0,n=0; for(long m=0;l<s.length()&m<(long)i*(long)i;l++,m++){ switch(s.charAt(l)){ case'+':t[n]=!t[n];break; case'>':n++;break; case'<':n--; if(n < 0)continue l;break; case'[':if(!t[n])l=f.get(l);break; case']':l=b.get(l)-1;break; } } if(l>=s.length()){ System.out.println(s); } } catch(Exception e){continue;} } } } 

Try it online!

Java (OpenJDK 8), Score: ???

This clocks in at 980 bytes, since I had so much to work with I decided to make it a little more readable. Basically I'm generating all the possible programs for length n and iterating them n^x times for some x. x is currently 3 but it can be modified arbitrarily to any size, limited only by the limitation of the JVM's precission. This will work for arbitrarily large input values if x is increased, but I have it set to 3 for tio.

import java.util.*; public class Main{ public static void main(String[] args){ int i = new Scanner(System.in).nextInt(); int x = 3; l:for(int j=0;j<Math.pow(5, i);j++){ try { String s=""; for(int k=j;s.length()<i;k/=5) s="+<>][".charAt(k%5)+s; Stack<Integer>y=new Stack<Integer>(); Map<Integer,Integer>f=new HashMap<>(),b=new HashMap<>(); for(int m=0; m<s.length();m++){ char c=s.charAt(m); if(c=='[')y.push(m); if(c==']'){int n=y.pop();f.put(n, m);b.put(m, n);} } if(y.size()>0) continue; boolean[] t= new boolean[s.length()]; int l=0,n=0; for(long m=0;l<s.length()&m<Math.pow(i,x);l++,m++){ switch(s.charAt(l)){ case'+':t[n]=!t[n];break; case'>':n++;break; case'<':n--; if(n < 0)continue l;break; case'[':if(!t[n])l=f.get(l);break; case']':l=b.get(l)-1;break; } } if(l>=s.length()){ System.out.println(s); } } catch(Exception e){continue;} } } } 

Try it online!

wording cleanup
Source Link
PunPun1000
  • 993
  • 4
  • 7

Java (OpenJDK 8), Score: ??? (possibly 2^31)

This clocks in at 956969 bytes, since I had so much to work with I decided to make it a little more readable. Basically I'm generating all the possible programs for length n and iterating them for n*n times. Intuitively a smallfuck program length n which runs longer than n*n steps should be in an infinite loop, due to the fact that since the tape can only contain Boolean values, however I have not yet proven it. Without higher test cases I'm not sure where it fails to generate all the possible outcomes, if ever. If all smallfuck programs of length n terminate within n*n steps, this will work for all positive ints java can handle, i.e. 1 to 2^31-1

import java.util.*; public class Main{ 	public public static void main(String[] args){ 		int int i = new Scanner(System.in).nextInt(); 		l l:for(int j=0;j<Math.pow(5, i);j++){ 			try  try { 				String s=""; String s=""; 				for for(int k=j;s.length()<i;k/=5) 					s="+<>][" s="+<>][".charAt(k%5)+s; 				Stack<Integer>y=new  Stack<Integer>y=new Stack<Integer>(); 				Map<Integer Map<Integer,Integer>f=new HashMap<>(),b=new HashMap<>(); 				for for(int m=0; m<s.length();m++){ 					char  char c=s.charAt(m); 					if if(c=='[')y.push(m); 					if if(c==']'){int n=y.pop();f.put(n, m);b.put(m, n);} 				 } 				if if(y.size()>0) 					continue; continue; 				boolean[]  boolean[] t= new boolean[s.length()]; 				int l=0; 				for( int m=0l=0,n=0;l<sn=0; for(long m=0;l<s.length()&m<i*i;l++&m<(long)i*(long)i;l++,m++){ 					switch switch(s.charAt(l)){ 					case'+' case'+':t[n]=!t[n];break; 					case'>' case'>':n++;break; 					case'<' case'<':n--; if(n < 0)continue l;break; 					case'[' case'[':if(!t[n])l=f.get(l);break; 					case']' case']':l=b.get(l)-1;break; 					 } 				 } 				if if(l>=s.length()){ 					System System.out.println(s); 				 } 			 } catch(Exception e){continue;} 		 } 	 } } 

Try it online!Try it online!

Java (OpenJDK 8), Score: ???

This clocks in at 956 bytes, since I had so much to work with I decided to make it a little more readable. Basically I'm generating all the possible programs for length n and iterating them for n*n times. Intuitively a smallfuck program length n which runs longer than n*n steps should be in an infinite loop, due to the fact that the tape can only contain Boolean values, however I have not yet proven it. Without higher test cases I'm not sure where it fails to generate all the possible outcomes, if ever.

import java.util.*; public class Main{ 	public static void main(String[] args){ 		int i = new Scanner(System.in).nextInt(); 		l:for(int j=0;j<Math.pow(5, i);j++){ 			try { 				String s=""; 				for(int k=j;s.length()<i;k/=5) 					s="+<>][".charAt(k%5)+s; 				Stack<Integer>y=new Stack<Integer>(); 				Map<Integer,Integer>f=new HashMap<>(),b=new HashMap<>(); 				for(int m=0; m<s.length();m++){ 					char c=s.charAt(m); 					if(c=='[')y.push(m); 					if(c==']'){int n=y.pop();f.put(n, m);b.put(m, n);} 				} 				if(y.size()>0) 					continue; 				boolean[] t= new boolean[s.length()]; 				int l=0; 				for(int m=0,n=0;l<s.length()&m<i*i;l++,m++){ 					switch(s.charAt(l)){ 					case'+':t[n]=!t[n];break; 					case'>':n++;break; 					case'<':n--; if(n < 0)continue l;break; 					case'[':if(!t[n])l=f.get(l);break; 					case']':l=b.get(l)-1;break; 					} 				} 				if(l>=s.length()){ 					System.out.println(s); 				} 			} catch(Exception e){continue;} 		} 	} } 

Try it online!

Java (OpenJDK 8), Score: ??? (possibly 2^31)

This clocks in at 969 bytes, since I had so much to work with I decided to make it a little more readable. Basically I'm generating all the possible programs for length n and iterating them for n*n times. Intuitively a smallfuck program length n which runs longer than n*n steps should be in an infinite loop since the tape can only contain Boolean values, however I have not proven it. Without higher test cases I'm not sure where it fails to generate all the possible outcomes, if ever. If all smallfuck programs of length n terminate within n*n steps, this will work for all positive ints java can handle, i.e. 1 to 2^31-1

import java.util.*; public class Main{  public static void main(String[] args){  int i = new Scanner(System.in).nextInt();  l:for(int j=0;j<Math.pow(5, i);j++){   try {  String s="";  for(int k=j;s.length()<i;k/=5)  s="+<>][".charAt(k%5)+s;   Stack<Integer>y=new Stack<Integer>();  Map<Integer,Integer>f=new HashMap<>(),b=new HashMap<>();  for(int m=0; m<s.length();m++){   char c=s.charAt(m);  if(c=='[')y.push(m);  if(c==']'){int n=y.pop();f.put(n, m);b.put(m, n);}  }  if(y.size()>0)  continue;   boolean[] t= new boolean[s.length()];  int l=0,n=0; for(long m=0;l<s.length()&m<(long)i*(long)i;l++,m++){  switch(s.charAt(l)){  case'+':t[n]=!t[n];break;  case'>':n++;break;  case'<':n--; if(n < 0)continue l;break;  case'[':if(!t[n])l=f.get(l);break;  case']':l=b.get(l)-1;break;  }  }  if(l>=s.length()){  System.out.println(s);  }  } catch(Exception e){continue;}  }  } } 

Try it online!

Source Link
PunPun1000
  • 993
  • 4
  • 7

Java (OpenJDK 8), Score: ???

This clocks in at 956 bytes, since I had so much to work with I decided to make it a little more readable. Basically I'm generating all the possible programs for length n and iterating them for n*n times. Intuitively a smallfuck program length n which runs longer than n*n steps should be in an infinite loop, due to the fact that the tape can only contain Boolean values, however I have not yet proven it. Without higher test cases I'm not sure where it fails to generate all the possible outcomes, if ever.

import java.util.*; public class Main{ 	public static void main(String[] args){ 		int i = new Scanner(System.in).nextInt(); 		l:for(int j=0;j<Math.pow(5, i);j++){ 			try { 				String s=""; 				for(int k=j;s.length()<i;k/=5) 					s="+<>][".charAt(k%5)+s; 				Stack<Integer>y=new Stack<Integer>(); 				Map<Integer,Integer>f=new HashMap<>(),b=new HashMap<>(); 				for(int m=0; m<s.length();m++){ 					char c=s.charAt(m); 					if(c=='[')y.push(m); 					if(c==']'){int n=y.pop();f.put(n, m);b.put(m, n);} 				} 				if(y.size()>0) 					continue; 				boolean[] t= new boolean[s.length()]; 				int l=0; 				for(int m=0,n=0;l<s.length()&m<i*i;l++,m++){ 					switch(s.charAt(l)){ 					case'+':t[n]=!t[n];break; 					case'>':n++;break; 					case'<':n--; if(n < 0)continue l;break; 					case'[':if(!t[n])l=f.get(l);break; 					case']':l=b.get(l)-1;break; 					} 				} 				if(l>=s.length()){ 					System.out.println(s); 				} 			} catch(Exception e){continue;} 		} 	} } 

Try it online!