Skip to main content
Tweeted twitter.com/StackCodeGolf/status/1006721962239053824

This is inspired by an 05AB1E answer by Magic Octupus Urn.

Given two arguments, a positive integer and a string/list of characters:

  1. Translate the number to base-n, where n is the length of the string.
  2. For each character, replace every appearance of the index of that character in the base-n number with that character.
  3. Print or return the new string.

###Examples:

Input:
2740, ["|","_"]
2740 -> 101010110100 in base 2
     -> Replace 0s with "_""|" and 1s with "|""_"
Output: _|_|_|__|_||

Input:
698911, ["c","h","a","o"]
698911 ->  2222220133 in base 4
       ->  Replace 0s with "c", 1s with "h", 2s with "a", and 3s with "o"
Output -> "aaaaaachoo"

Input:
1928149325670647244912100789213626616560861130859431492905908574660758972167966, [" ","\n","|","_","-"]
Output:
    __   __    
   |  |_|  |   
___|       |___
-   -   -   -  
 - - - - - - - 
- - - - - - - -
_______________

Input: 3446503265645381015412, [':', '\n', '.', '_', '=', ' ', ')', '(', ',']
Output:
_===_
(.,.)
( : )
( : )

Rules:

  • IO is flexible.
  • You can take the number in any base, as long as it is consistent between inputs
  • The list of characters has to be 0-indexed though, where 0 is the first character and n-1 is the last
  • Possible characters can be any printable ASCII, along with whitespace such as tabs and newlines
  • The given list of characters will have a length in the range 2-10 inclusive. That is, the smallest base is binary and the largest is decimal (no pesky letters here)
  • Standard loopholes are forbidden
  • Feel free to answer even if your language can't handle the larger test cases.

As this is , the shortest code for each language wins. (I know all you golfing languages have one byte built-ins ready to go ;)

This is inspired by an 05AB1E answer by Magic Octupus Urn.

Given two arguments, a positive integer and a string/list of characters:

  1. Translate the number to base-n, where n is the length of the string.
  2. For each character, replace every appearance of the index of that character in the base-n number with that character.
  3. Print or return the new string.

###Examples:

Input:
2740, ["|","_"]
2740 -> 101010110100 in base 2
     -> Replace 0s with "_" and 1s with "|"
Output: _|_|_|__|_||

Input:
698911, ["c","h","a","o"]
698911 ->  2222220133 in base 4
Output -> "aaaaaachoo"

Input:
1928149325670647244912100789213626616560861130859431492905908574660758972167966, [" ","\n","|","_","-"]
Output:
    __   __    
   |  |_|  |   
___|       |___
-   -   -   -  
 - - - - - - - 
- - - - - - - -
_______________

Input: 3446503265645381015412, [':', '\n', '.', '_', '=', ' ', ')', '(', ',']
Output:
_===_
(.,.)
( : )
( : )

Rules:

  • IO is flexible.
  • You can take the number in any base, as long as it is consistent between inputs
  • The list of characters has to be 0-indexed though, where 0 is the first character and n-1 is the last
  • Possible characters can be any printable ASCII, along with whitespace such as tabs and newlines
  • The given list of characters will have a length in the range 2-10 inclusive. That is, the smallest base is binary and the largest is decimal (no pesky letters here)
  • Standard loopholes are forbidden
  • Feel free to answer even if your language can't handle the larger test cases.

As this is , the shortest code for each language wins. (I know all you golfing languages have one byte built-ins ready to go ;)

This is inspired by an 05AB1E answer by Magic Octupus Urn.

Given two arguments, a positive integer and a string/list of characters:

  1. Translate the number to base-n, where n is the length of the string.
  2. For each character, replace every appearance of the index of that character in the base-n number with that character.
  3. Print or return the new string.

###Examples:

Input:
2740, ["|","_"]
2740 -> 101010110100 in base 2
     -> Replace 0s with "|" and 1s with "_"
Output: _|_|_|__|_||

Input:
698911, ["c","h","a","o"]
698911 ->  2222220133 in base 4
       ->  Replace 0s with "c", 1s with "h", 2s with "a", and 3s with "o"
Output -> "aaaaaachoo"

Input:
1928149325670647244912100789213626616560861130859431492905908574660758972167966, [" ","\n","|","_","-"]
Output:
    __   __    
   |  |_|  |   
___|       |___
-   -   -   -  
 - - - - - - - 
- - - - - - - -
_______________

Input: 3446503265645381015412, [':', '\n', '.', '_', '=', ' ', ')', '(', ',']
Output:
_===_
(.,.)
( : )
( : )

Rules:

  • IO is flexible.
  • You can take the number in any base, as long as it is consistent between inputs
  • The list of characters has to be 0-indexed though, where 0 is the first character and n-1 is the last
  • Possible characters can be any printable ASCII, along with whitespace such as tabs and newlines
  • The given list of characters will have a length in the range 2-10 inclusive. That is, the smallest base is binary and the largest is decimal (no pesky letters here)
  • Standard loopholes are forbidden
  • Feel free to answer even if your language can't handle the larger test cases.

As this is , the shortest code for each language wins. (I know all you golfing languages have one byte built-ins ready to go ;)

added 81 characters in body
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186

This is inspired by an 05AB1E answer by Magic Octupus Urn.

Given two arguments, a positive integer and a string/list of characters:

  1. Translate the number to base-n, where n is the length of the string.
  2. For each character, replace every appearance of the index of that character in the base-n number with that character.
  3. Print or return the new string.

###Examples:

Input:
2740, ["|","_"]
2740 -> 101010110100 in base 2
     -> Replace 0s with "_" and 1s with "|"
Output: _|_|_|__|_||

Input:
698911, ["c","h","a","o"]
698911 ->  2222220133 in base 4
Output -> "aaaaaachoo"

Input:
1928149325670647244912100789213626616560861130859431492905908574660758972167966, [" ","\n","|","_","-"]
Output:
    __   __    
   |  |_|  |   
___|       |___
-   -   -   -  
 - - - - - - - 
- - - - - - - -
_______________

Input: 3446503265645381015412, [':', '\n', '.', '_', '=', ' ', ')', '(', ',']
Output:
_===_
(.,.)
( : )
( : )

Rules:

  • IO is flexible.
  • You can take the number in any base, as long as it is consistent between inputs
  • The list of characters has to be 0-indexed though, where 0 is the first character and n-1 is the last
  • Possible characters can be any printable ASCII, along with whitespace such as tabs and newlines
  • The given list of characters will have a length in the range 2-10 inclusive. That is, the smallest base is binary and the largest is decimal (no pesky letters here)
  • Standard loopholes are forbidden
  • Feel free to answer even if your language can't handle the larger test cases.

As this is , the shortest code for each language wins. (I know all you golfing languages have one byte built-ins ready to go ;)

This is inspired by an 05AB1E answer by Magic Octupus Urn.

Given two arguments, a positive integer and a string/list of characters:

  1. Translate the number to base-n, where n is the length of the string.
  2. For each character, replace every appearance of the index of that character in the base-n number with that character.
  3. Print or return the new string.

###Examples:

Input:
2740, ["|","_"]
2740 -> 101010110100 in base 2
     -> Replace 0s with "_" and 1s with "|"
Output: _|_|_|__|_||

Input:
698911, ["c","h","a","o"]
698911 ->  2222220133 in base 4
Output -> "aaaaaachoo"

Input:
1928149325670647244912100789213626616560861130859431492905908574660758972167966, [" ","\n","|","_","-"]
Output:
    __   __    
   |  |_|  |   
___|       |___
-   -   -   -  
 - - - - - - - 
- - - - - - - -
_______________

Input: 3446503265645381015412, [':', '\n', '.', '_', '=', ' ', ')', '(', ',']
Output:
_===_
(.,.)
( : )
( : )

Rules:

  • IO is flexible.
  • You can take the number in any base, as long as it is consistent between inputs
  • The list of characters has to be 0-indexed though, where 0 is the first character and n-1 is the last
  • Possible characters can be any printable ASCII, along with whitespace such as tabs and newlines
  • The given list of characters will have a length in the range 2-10 inclusive. That is, the smallest base is binary and the largest is decimal (no pesky letters here)
  • Standard loopholes are forbidden

As this is , the shortest code for each language wins. (I know all you golfing languages have one byte built-ins ready to go ;)

This is inspired by an 05AB1E answer by Magic Octupus Urn.

Given two arguments, a positive integer and a string/list of characters:

  1. Translate the number to base-n, where n is the length of the string.
  2. For each character, replace every appearance of the index of that character in the base-n number with that character.
  3. Print or return the new string.

###Examples:

Input:
2740, ["|","_"]
2740 -> 101010110100 in base 2
     -> Replace 0s with "_" and 1s with "|"
Output: _|_|_|__|_||

Input:
698911, ["c","h","a","o"]
698911 ->  2222220133 in base 4
Output -> "aaaaaachoo"

Input:
1928149325670647244912100789213626616560861130859431492905908574660758972167966, [" ","\n","|","_","-"]
Output:
    __   __    
   |  |_|  |   
___|       |___
-   -   -   -  
 - - - - - - - 
- - - - - - - -
_______________

Input: 3446503265645381015412, [':', '\n', '.', '_', '=', ' ', ')', '(', ',']
Output:
_===_
(.,.)
( : )
( : )

Rules:

  • IO is flexible.
  • You can take the number in any base, as long as it is consistent between inputs
  • The list of characters has to be 0-indexed though, where 0 is the first character and n-1 is the last
  • Possible characters can be any printable ASCII, along with whitespace such as tabs and newlines
  • The given list of characters will have a length in the range 2-10 inclusive. That is, the smallest base is binary and the largest is decimal (no pesky letters here)
  • Standard loopholes are forbidden
  • Feel free to answer even if your language can't handle the larger test cases.

As this is , the shortest code for each language wins. (I know all you golfing languages have one byte built-ins ready to go ;)

added 148 characters in body
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186

This is inspired by an 05AB1E answer by Magic Octupus Urn.

Given two arguments, a positive integer and a string/list of characters:

  1. Translate the number to base-n, where n is the length of the string.
  2. For each character, replace every appearance of the index of that character in the base-n number with that character.
  3. Print or return the new string.

###Examples:

Input:
2740, ["|","_"]
2740 -> 101010110100 in base 2
     -> Replace 0s with "_" and 1s with "|"
Output: _|_|_|__|_||

Input:
698911, ["c","h","a","o"]
698911 ->  2222220133 in base 4
Output -> "aaaaaachoo"

Input:
1928149325670647244912100789213626616560861130859431492905908574660758972167966, [" ","\n","|","_","-"]
Output:
    __   __    
   |  |_|  |   
___|       |___
-   -   -   -  
 - - - - - - - 
- - - - - - - -
_______________

Input: 3446503265645381015412, [':', '\n', '.', '_', '=', ' ', ')', '(', ',']
Output:
_===_
(.,.)
( : )
( : )

Rules:

  • IO is flexibleIO is flexible.
  • You can take the number in any base, as long as it is consistent between inputs
  • The list of characters has to be 0-indexed though, where 0 is the first character and n-1 is the last
  • Possible characters can be any printable ASCII, along with whitespace such as tabs and newlines
  • The given list of characters will have a length in the range 2-10 inclusive. That is, the smallest base is binary and the largest is decimal (no pesky letters here)
  • Standard loopholes are forbidden

As this is , the shortest code for each language wins. (I know all you golfing languages have one byte built-ins ready to go ;)

This is inspired by an 05AB1E answer by Magic Octupus Urn.

Given two arguments, a positive integer and a string/list of characters:

  1. Translate the number to base-n, where n is the length of the string.
  2. For each character, replace every appearance of the index of that character in the base-n number with that character.
  3. Print or return the new string.

###Examples:

Input:
2740, ["|","_"]
2740 -> 101010110100 in base 2
     -> Replace 0s with "_" and 1s with "|"
Output: _|_|_|__|_||

Input:
698911, ["c","h","a","o"]
698911 ->  2222220133 in base 4
Output -> "aaaaaachoo"

Input:
1928149325670647244912100789213626616560861130859431492905908574660758972167966, [" ","\n","|","_","-"]
Output:
    __   __    
   |  |_|  |   
___|       |___
-   -   -   -  
 - - - - - - - 
- - - - - - - -
_______________

Input: 3446503265645381015412, [':', '\n', '.', '_', '=', ' ', ')', '(', ',']
Output:
_===_
(.,.)
( : )
( : )

Rules:

  • IO is flexible.
  • You can take the number in any base, as long as it is consistent between inputs
  • The list of characters has to be 0-indexed though, where 0 is the first character and n-1 is the last
  • Possible characters can be any printable ASCII, along with whitespace such as tabs and newlines
  • The given list of characters will have a length in the range 2-10 inclusive. That is, the smallest base is binary and the largest is decimal (no pesky letters here)

As this is , the shortest code for each language wins. (I know all you golfing languages have one byte built-ins ready to go ;)

This is inspired by an 05AB1E answer by Magic Octupus Urn.

Given two arguments, a positive integer and a string/list of characters:

  1. Translate the number to base-n, where n is the length of the string.
  2. For each character, replace every appearance of the index of that character in the base-n number with that character.
  3. Print or return the new string.

###Examples:

Input:
2740, ["|","_"]
2740 -> 101010110100 in base 2
     -> Replace 0s with "_" and 1s with "|"
Output: _|_|_|__|_||

Input:
698911, ["c","h","a","o"]
698911 ->  2222220133 in base 4
Output -> "aaaaaachoo"

Input:
1928149325670647244912100789213626616560861130859431492905908574660758972167966, [" ","\n","|","_","-"]
Output:
    __   __    
   |  |_|  |   
___|       |___
-   -   -   -  
 - - - - - - - 
- - - - - - - -
_______________

Input: 3446503265645381015412, [':', '\n', '.', '_', '=', ' ', ')', '(', ',']
Output:
_===_
(.,.)
( : )
( : )

Rules:

  • IO is flexible.
  • You can take the number in any base, as long as it is consistent between inputs
  • The list of characters has to be 0-indexed though, where 0 is the first character and n-1 is the last
  • Possible characters can be any printable ASCII, along with whitespace such as tabs and newlines
  • The given list of characters will have a length in the range 2-10 inclusive. That is, the smallest base is binary and the largest is decimal (no pesky letters here)
  • Standard loopholes are forbidden

As this is , the shortest code for each language wins. (I know all you golfing languages have one byte built-ins ready to go ;)

Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186
Loading