Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Java 10, (削除) 356 (削除ここまで)(削除) 342 (削除ここまで)(削除) 284 (削除ここまで)(削除) 275 (削除ここまで)(削除) 233 (削除ここまで)(削除) 225 (削除ここまで) 220 bytes

Java 10, (削除) 356 (削除ここまで)(削除) 342 (削除ここまで)(削除) 284 (削除ここまで)(削除) 275 (削除ここまで)(削除) 233 (削除ここまで)(削除) 225 (削除ここまで) 220 bytes

#Java 10, (削除) 356 (削除ここまで)(削除) 342 (削除ここまで)(削除) 284 (削除ここまで)(削除) 275 (削除ここまで)(削除) 233 (削除ここまで)(削除) 225 (削除ここまで) 220 bytes

Java 10, (削除) 356 (削除ここまで)(削除) 342 (削除ここまで)(削除) 284 (削除ここまで)(削除) 275 (削除ここまで)(削除) 233 (削除ここまで)(削除) 225 (削除ここまで) 220 bytes

added 13 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

#Java 10, (削除) 356 (削除ここまで) (削除) 342 (削除ここまで) (削除) 284 (削除ここまで) (削除) 275 (削除ここまで) (削除) 233 (削除ここまで) 225(削除) 225 (削除ここまで) 220 bytes

import java.util.*;List S;kS;r->r>k->{S=new Stack();p("",k);int c=0;for;k=0;for(var p:S)c+=k+=(p+"").matches(r.replaceAll("\\{,(,\\d+\\})","{0,1ドル"01ドル"))?1:0;return c;k;}void p(String p,int k){if(k<1)S.add(p);else for(char i=32;i<127;)p(p+i++,k-1);}

Try it online. Try it online.

import java.util.*; // Required import for Stack and List
List S; // List on class-level, uninitialized
k->r->{ // Method with integer and String parameter and integer return-type
 S=new Stack(); // Create a new List
 p("",k); // Put all permutations of length `k` consisting of printable ASCII
 // characters in this list
 intk=0; c=0; // CounterRe-use `k` as counter-integer, starting at 0
 for(var p:S) // Loop over all permutations in the List:
 c+=k+= // Increase the countcounter by:
 (p+"") // Convert the permutation from Object to String
 .matches(r // If it matches the input-regex,
 .replaceAll("\\{,(,\\d+\\})","{0,1ドル"01ドル"))?
 // after we've replaced all {,m} with {0,m}
 1 // Increase the counter by 1
 : // Else:
 0; // Leave the count the same by increasing with 0
 return c;k;} // And return the counter as result
void p( // Separated method with two parameters and no return-type, where:
 String p, // `p` is the prefix-String, starting empty
 int k){ // `k` is the length the permutations we want to generate
 if(k<1) // If `k` is 0:
 S.add(p); // Add the current prefix-String to the List
 else // Else:
 for(char i=32;i<127;)
 // Loop over the printable ASCII characters:
 p( // And do a recursive call, with:
 p+i++, // The prefix-String appended with the current character
 k-1);} // And `k` decreased by 1

#Java 10, (削除) 356 (削除ここまで) (削除) 342 (削除ここまで) (削除) 284 (削除ここまで) (削除) 275 (削除ここまで) (削除) 233 (削除ここまで) 225 bytes

import java.util.*;List S;k->r->{S=new Stack();p("",k);int c=0;for(var p:S)c+=(p+"").matches(r.replaceAll("\\{,(\\d+\\})","{0,1ドル"))?1:0;return c;}void p(String p,int k){if(k<1)S.add(p);else for(char i=32;i<127;)p(p+i++,k-1);}

Try it online.

import java.util.*; // Required import for Stack and List
List S; // List on class-level, uninitialized
k->r->{ // Method with integer and String parameter and integer return-type
 S=new Stack(); // Create a new List
 p("",k); // Put all permutations of length `k` consisting of printable ASCII
 // characters in this list
 int c=0; // Counter-integer, starting at 0
 for(var p:S) // Loop over all permutations in the List:
 c+= // Increase the count by:
 (p+"") // Convert the permutation from Object to String
 .matches(r // If it matches the input-regex,
 .replaceAll("\\{,(\\d+\\})","{0,1ドル"))?
 // after we've replaced all {,m} with {0,m}
 1 // Increase the counter by 1
 : // Else:
 0; // Leave the count the same by increasing with 0
 return c;} // And return the counter as result
void p( // Separated method with two parameters and no return-type, where:
 String p, // `p` is the prefix-String, starting empty
 int k){ // `k` is the length the permutations we want to generate
 if(k<1) // If `k` is 0:
 S.add(p); // Add the current prefix-String to the List
 else // Else:
 for(char i=32;i<127;)
 // Loop over the printable ASCII characters:
 p( // And do a recursive call, with:
 p+i++, // The prefix-String appended with the current character
 k-1);} // And `k` decreased by 1

#Java 10, (削除) 356 (削除ここまで) (削除) 342 (削除ここまで) (削除) 284 (削除ここまで) (削除) 275 (削除ここまで) (削除) 233 (削除ここまで) (削除) 225 (削除ここまで) 220 bytes

import java.util.*;List S;r->k->{S=new Stack();p("",k);k=0;for(var p:S)k+=(p+"").matches(r.replaceAll("\\{(,\\d+\\})","{01ドル"))?1:0;return k;}void p(String p,int k){if(k<1)S.add(p);else for(char i=32;i<127;)p(p+i++,k-1);}

Try it online.

import java.util.*; // Required import for Stack and List
List S; // List on class-level, uninitialized
k->r->{ // Method with integer and String parameter and integer return-type
 S=new Stack(); // Create a new List
 p("",k); // Put all permutations of length `k` consisting of printable ASCII
 // characters in this list
 k=0; // Re-use `k` as counter-integer, starting at 0
 for(var p:S) // Loop over all permutations in the List:
 k+= // Increase the counter by:
 (p+"") // Convert the permutation from Object to String
 .matches(r // If it matches the input-regex,
 .replaceAll("\\{(,\\d+\\})","{01ドル"))?
 // after we've replaced all {,m} with {0,m}
 1 // Increase the counter by 1
 : // Else:
 0; // Leave the count the same by increasing with 0
 return k;} // And return the counter as result
void p( // Separated method with two parameters and no return-type, where:
 String p, // `p` is the prefix-String, starting empty
 int k){ // `k` is the length the permutations we want to generate
 if(k<1) // If `k` is 0:
 S.add(p); // Add the current prefix-String to the List
 else // Else:
 for(char i=32;i<127;)
 // Loop over the printable ASCII characters:
 p( // And do a recursive call, with:
 p+i++, // The prefix-String appended with the current character
 k-1);} // And `k` decreased by 1
deleted 48 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

#Java 10, (削除) 356 (削除ここまで) (削除) 342 (削除ここまで) (削除) 284 (削除ここまで) (削除) 275 (削除ここまで) 233(削除) 233 (削除ここまで) 225 bytes

import java.util.*;k*;List S;k->r->{var S=new Stack();p(S,"",k);int c=0;for(var p:S)c+=(p+"").matches(r.replaceAll("\\{,(\\d+\\})","{0,1ドル"))?1:0;return c;}void p(List S,String p,int k){if(k<1)S.add(p);else for(char i=32;i<127;)p(S,p+i++,k-1);}

Try it online. Try it online.

import java.util.*; // Required import for Stack and List
List S;  // List on class-level, uninitialized
k->r->{ // Method with integer and String parameter and integer return-type
 var S=new Stack(); // Create a new List
 p(S,"",k); // Put all permutations of length `k` consisting of printable ASCII
 // characters in this list
 int c=0; // Counter-integer, starting at 0
 for(var p:S) // Loop over all permutations in the List:
 c+= c+= // Increase the count by:
 (p+"") // Convert the permutation from Object to String
 .matches(r // If it matches the input-regex,
 .replaceAll("\\{,(\\d+\\})","{0,1ドル"))?
 // after we've replaced all {,m} with {0,m}
 1 // Increase the counter by 1
 : // Else:
 0; // Leave the count the same by increasing with 0
 return c;} // And return the counter as result
void p( // Separated method with threetwo parameters and no return-type, where:
 List S, // `S` is the List to put every permutation-String in
 String p, // `p` is the prefix-String, starting empty
 int k){ // `k` is the length the permutations we want to generate
 if(k<1) // If `k` is 0:
 S.add(p); // Add the current prefix-String to Listthe `S`List
 else // Else:
 for(char i=32;i<127;)
 // Loop over the printable ASCII characters:
 p( // And do a recursive call, with:
 S,p+i++, // The prefix-String appended with the current character
 k-1);} // And `k` decreased by 1

#Java 10, (削除) 356 (削除ここまで) (削除) 342 (削除ここまで) (削除) 284 (削除ここまで) (削除) 275 (削除ここまで) 233 bytes

import java.util.*;k->r->{var S=new Stack();p(S,"",k);int c=0;for(var p:S)c+=(p+"").matches(r.replaceAll("\\{,(\\d+\\})","{0,1ドル"))?1:0;return c;}void p(List S,String p,int k){if(k<1)S.add(p);else for(char i=32;i<127;)p(S,p+i++,k-1);}

Try it online.

import java.util.*; // Required import for Stack and List
k->r->{ // Method with integer and String parameter and integer return-type
 var S=new Stack(); // Create a List
 p(S,"",k); // Put all permutations of length `k` consisting of printable ASCII
 // characters in this list
 int c=0; // Counter-integer, starting at 0
 for(var p:S) // Loop over all permutations c+= // Increase the count by:
 (p+"") // Convert the permutation from Object to String
 .matches(r // If it matches the input-regex,
 .replaceAll("\\{,(\\d+\\})","{0,1ドル"))?
 // after we've replaced all {,m} with {0,m}
 1 // Increase the counter by 1
 : // Else:
 0; // Leave the count the same by increasing with 0
 return c;} // And return the counter as result
void p( // Separated method with three parameters and no return-type, where:
 List S, // `S` is the List to put every permutation-String in
 String p, // `p` is the prefix-String, starting empty
 int k){ // `k` is the length the permutations we want to generate
 if(k<1) // If `k` is 0:
 S.add(p); // Add the current prefix-String to List `S`
 else // Else:
 for(char i=32;i<127;)
 // Loop over the printable ASCII characters:
 p( // And do a recursive call, with:
 S,p+i++, // The prefix-String appended with the current character
 k-1);} // And `k` decreased by 1

#Java 10, (削除) 356 (削除ここまで) (削除) 342 (削除ここまで) (削除) 284 (削除ここまで) (削除) 275 (削除ここまで) (削除) 233 (削除ここまで) 225 bytes

import java.util.*;List S;k->r->{S=new Stack();p("",k);int c=0;for(var p:S)c+=(p+"").matches(r.replaceAll("\\{,(\\d+\\})","{0,1ドル"))?1:0;return c;}void p(String p,int k){if(k<1)S.add(p);else for(char i=32;i<127;)p(p+i++,k-1);}

Try it online.

import java.util.*; // Required import for Stack and List
List S;  // List on class-level, uninitialized
k->r->{ // Method with integer and String parameter and integer return-type
 S=new Stack(); // Create a new List
 p("",k); // Put all permutations of length `k` consisting of printable ASCII
 // characters in this list
 int c=0; // Counter-integer, starting at 0
 for(var p:S) // Loop over all permutations in the List:
 c+= // Increase the count by:
 (p+"") // Convert the permutation from Object to String
 .matches(r // If it matches the input-regex,
 .replaceAll("\\{,(\\d+\\})","{0,1ドル"))?
 // after we've replaced all {,m} with {0,m}
 1 // Increase the counter by 1
 : // Else:
 0; // Leave the count the same by increasing with 0
 return c;} // And return the counter as result
void p( // Separated method with two parameters and no return-type, where:
 String p, // `p` is the prefix-String, starting empty
 int k){ // `k` is the length the permutations we want to generate
 if(k<1) // If `k` is 0:
 S.add(p); // Add the current prefix-String to the List
 else // Else:
 for(char i=32;i<127;)
 // Loop over the printable ASCII characters:
 p( // And do a recursive call, with:
 p+i++, // The prefix-String appended with the current character
 k-1);} // And `k` decreased by 1
deleted 254 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
deleted 404 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
deleted 404 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
deleted 404 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
added 2178 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading

AltStyle によって変換されたページ (->オリジナル) /