All SolutionsAll Solutions
🔗
URL Shortener
Week 11, 2026
Python - Encode & Check | BMC | Python Solutions
increment = 2611
start = 0
ans = []
def encode_to_base36(n):
if n == 0: return "0"
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
base36 = ""
while n:
n, rem = divmod(n, 36)
base36 = alphabet[rem] + base36
return base36
for x in range(increment):
temp = x
temp36 = encode_to_base36(temp)
while len(str(temp36)) <= 3:
ans.append([temp, (str("000")+str(temp36))[-3:]])
temp += increment
temp36 = encode_to_base36(temp)
file = open("ans.txt", 'w')
for a in ans:
file.write(f"{a[0]} : {a[1]}" + '\n')
file.close()
General solution for any alphabet, step and len | greenya | Odin Solutions
package main
import "core:fmt"
import "core:strings"
import "core:slice"
main :: proc () {
SEQ_ABC :: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
SEQ_STEP :: 2611
SEQ_LEN :: 3
b: strings.Builder
next_k: for k in 0 ..< SEQ_STEP {
for n := k ;; n += SEQ_STEP {
s := int_to_base(n, &b, SEQ_ABC, SEQ_LEN)
if len(s) == SEQ_LEN {
fmt.printfln("%d: %s", n, s)
} else {
continue next_k
}
}
}
}
int_to_base :: proc (n: int, b: ^strings.Builder, abc: string, min_len: int) -> string {
base := len(abc)
assert(base >= 2)
assert(min_len >= 1)
strings.builder_reset(b)
if n > 0 {
for r := n; r > 0; r /= base {
i := r % base
strings.write_byte(b, abc[i])
}
} else {
strings.write_byte(b, abc[0])
}
for len(b.buf) < min_len {
strings.write_byte(b, abc[0])
}
slice.reverse(b.buf[:])
return strings.to_string(b^)
}
The hard way - a lot of string manipulation | Draw6 | C++ Solutions
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
void strev(char *str);
char* fromDeciCh(char res[], int base, int inputNum);
char reVal(int num);
string fromDeciStr(string& res, int base, int inputNum);
int SetNextIncr(int incr);
int main()
{
int base = 36;
char res[100];
string resStr = "";
int inputNum = 0;
int increment = 0;
string incrStr = "";
string returnDeclStr;
string altstr = "";
int strlength = 0;
for(int second = 0; second < 2611; second++)
{
increment = second;
incrStr = fromDeciStr(resStr, base, second);
strlength = strlen(incrStr.c_str());
if( second == 0)
{
cout << "0: 000\n";
}
else
{
if(strlength == 1)
{
altstr = to_string(second) + ": 00" + incrStr + "\n";
cout << altstr;
}
else if(strlength == 2)
{
altstr = to_string(second) + ": 0" + incrStr + "\n";
cout << altstr;
}
else
{
cout << second << ": " << incrStr << "\n";
}
}
resStr = "";
for(int first = 0; first < 18; first++)
{
increment = SetNextIncr(increment);
if(increment < 46656)
{
inputNum = increment;
cout << increment << ": ";
returnDeclStr = fromDeciStr(resStr, base, inputNum);
cout << returnDeclStr << "\n";
resStr = "";
}
}
}
return 0;
}
//-----------------------------------------------------------
void strev(char *str)
{
int len = strlen(str);
int i;
for (i = 0; i < len/2; i++)
{
char temp = str[i];
str[i] = str[len-i-1];
str[len-i-1] = temp;
}
}
//----------------------------------------------------------
char reVal(int num)
{
if (num >= 0 && num <= 9)
return (char)(num + '0');
else
return (char)(num - 10 + 'A');
}
//---------------------------------------------------------
string fromDeciStr(string& res, int base, int inputNum)
{
int index = 0;
while (inputNum > 0) {
res.push_back(reVal(inputNum % base));
index++;
inputNum /= base;
}
reverse(res.begin(), res.end());
return res;
}
//---------------------------------------------------------
int SetNextIncr(int incr)
{
int inc = incr + 2611;
return inc;
}