Programming Challenge from Kattis: Distinctive CharactersHackers Ranking String SimilarityRemoving accents from certain charactersFinding longest substring containing k distinct charactersFunny String Java SolutionProgramming Challenge from Kattis: ApparatusReturn characters in a string in alphabetical orderLeetcode: String to Integer (atoi)Sliding window to solve “longest substring, no repeating chars”Morgan and a String HackerRank challengeProgramming Challenge from Kattis: Watchdog
How is it possible to have an ability score that is less than 3?
Are the number of citations and number of published articles the most important criteria for a tenure promotion?
Could an aircraft fly or hover using only jets of compressed air?
What typically incentivizes a professor to change jobs to a lower ranking university?
Rock identification in KY
DC-DC converter from low voltage at high current, to high voltage at low current
Is it unprofessional to ask if a job posting on GlassDoor is real?
Convert two switches to a dual stack, and add outlet - possible here?
Are astronomers waiting to see something in an image from a gravitational lens that they've already seen in an adjacent image?
When a company launches a new product do they "come out" with a new product or do they "come up" with a new product?
What's the output of a record needle playing an out-of-speed record
Arrow those variables!
How much RAM could one put in a typical 80386 setup?
LWC SFDX source push error TypeError: LWC1009: decl.moveTo is not a function
Why is 150k or 200k jobs considered good when there's 300k+ births a month?
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?
High voltage LED indicator 40-1000 VDC without additional power supply
Is it inappropriate for a student to attend their mentor's dissertation defense?
How can bays and straits be determined in a procedurally generated map?
Why do I get two different answers for this counting problem?
dbcc cleantable batch size explanation
Why can't I see bouncing of switch on oscilloscope screen?
Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?
Programming Challenge from Kattis: Distinctive Characters
Hackers Ranking String SimilarityRemoving accents from certain charactersFinding longest substring containing k distinct charactersFunny String Java SolutionProgramming Challenge from Kattis: ApparatusReturn characters in a string in alphabetical orderLeetcode: String to Integer (atoi)Sliding window to solve “longest substring, no repeating chars”Morgan and a String HackerRank challengeProgramming Challenge from Kattis: Watchdog
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
I'm currently working on this problem from Kattis. In short, we're supposed to find the string that has the least similarity to any other string given. Every element of a string is either 0 or 1. Similarity between two strings is measured by increasing the similarity by 1 if both strings have the same character in the same position. E.g: "01001" "11110" has similarity 1, because they both have 1 in their 2nd position, and for every other position they have different characters. An input starts with one line giving two numbers N and P, being first the number of strings in the list, and then the length of each string. The rest of the input is then N lines of single strings. The output should be a string that has the least possible similarity to any string in the input.
I'd like suggestions on how to reduce the number of calls I'm doing in my solution to this problem. Likely by some algorithmic magic.
Example input:
3 5
01001
11100
10111
Example output:
00010
My code:
import sys
import itertools
def similarity(sx, sy):
'''Naively calculates similarity between two
strings.'''
result = 0
for i in range(n_feat):
if sx[i] == sy[i]:
result += 1
return result
line_1 = sys.stdin.readline()
line_1 = line_1.split()
N = int(line_1[0])
n_feat = int(line_1[1])
characters = set()
for i in range(N):
characters.add(str(sys.stdin.readline()))
# Generate all possible ways to write n_feat long string with alphabet 0,1
all_pos_chars = ["".join(seq) for seq in itertools.product("01", repeat=n_feat)]
# Subset actually possible (removed ones have similarity == n_feat)
pos_chars = [pos_char for pos_char in all_pos_chars if pos_char not in characters]
# Impossibly high starting-point.
curr_min = n_feat+1
curr_small = ""
for pos_char in pos_chars:
curr = max(similarity(pos_char, character) for character in characters)
if curr == 0:
curr_small = pos_char
break;
if curr <= curr_min:
curr_min = curr
curr_small = pos_char
print(curr_small)
This solution works fine for smaller inputs. For example, I ran python -m cProfile -s cumtime dischar.py < 1.in
where 1.in is the example input given above and received this:
300 function calls in 0.001 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.001 0.001 built-in method builtins.exec
1 0.000 0.000 0.001 0.001 dischar2.py:1(<module>)
1 0.000 0.000 0.000 0.000 built-in method builtins.print
31 0.000 0.000 0.000 0.000 built-in method builtins.max
124 0.000 0.000 0.000 0.000 dischar2.py:34(<genexpr>)
93 0.000 0.000 0.000 0.000 dischar2.py:5(similarity)
4 0.000 0.000 0.000 0.000 method 'readline' of '_io.TextIOWrapper' objects
1 0.000 0.000 0.000 0.000 dischar2.py:26(<listcomp>)
2 0.000 0.000 0.000 0.000 cp1252.py:22(decode)
32 0.000 0.000 0.000 0.000 method 'join' of 'str' objects
1 0.000 0.000 0.000 0.000 dischar2.py:28(<listcomp>)
2 0.000 0.000 0.000 0.000 built-in method _codecs.charmap_decode
2 0.000 0.000 0.000 0.000 codecs.py:281(getstate)
1 0.000 0.000 0.000 0.000 method 'split' of 'str' objects
3 0.000 0.000 0.000 0.000 method 'add' of 'set' objects
1 0.000 0.000 0.000 0.000 method 'disable' of '_lsprof.Profiler' objects
But I was worried about the number of calls at line:34, which is this bit of code: curr = max(similarity(pos_char, character) for character in characters)
, and then onwards to line:5 which is the similartiy-function. I made a 6.in, where the first line is 10000 20
, and the next 10000 lines are 20 zeros:
python -m cProfile -s cumtime dischar2.py < 6.in
11111111111111111111
7360118 function calls in 9.280 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 9.280 9.280 built-in method builtins.exec
1 0.756 0.756 9.280 9.280 dischar2.py:1(<module>)
1048575 0.663 0.000 7.700 0.000 built-in method builtins.max
3145725 0.777 0.000 7.037 0.000 dischar2.py:34(<genexpr>)
2097150 6.260 0.000 6.260 0.000 dischar2.py:5(similarity)
1 0.325 0.325 0.656 0.656 dischar2.py:26(<listcomp>)
1048576 0.332 0.000 0.332 0.000 method 'join' of 'str' objects
1 0.161 0.161 0.161 0.161 dischar2.py:28(<listcomp>)
10001 0.004 0.000 0.005 0.000 method 'readline' of '_io.TextIOWrapper' objects
10000 0.001 0.000 0.001 0.000 method 'add' of 'set' objects
28 0.000 0.000 0.001 0.000 cp1252.py:22(decode)
28 0.001 0.000 0.001 0.000 built-in method _codecs.charmap_decode
1 0.000 0.000 0.000 0.000 built-in method builtins.print
28 0.000 0.000 0.000 0.000 codecs.py:281(getstate)
1 0.000 0.000 0.000 0.000 method 'split' of 'str' objects
1 0.000 0.000 0.000 0.000 method 'disable' of '_lsprof.Profiler' objects
As you can see, this adds up quickly! I think my solution is sound, it provides the correct output for every case I can test for. But there has to be some trick that I'm not seeing, because Kattis expects the solution to run within 2 CPU-seconds. Any suggestions?
python performance algorithm python-3.x programming-challenge
New contributor
$endgroup$
add a comment |
$begingroup$
I'm currently working on this problem from Kattis. In short, we're supposed to find the string that has the least similarity to any other string given. Every element of a string is either 0 or 1. Similarity between two strings is measured by increasing the similarity by 1 if both strings have the same character in the same position. E.g: "01001" "11110" has similarity 1, because they both have 1 in their 2nd position, and for every other position they have different characters. An input starts with one line giving two numbers N and P, being first the number of strings in the list, and then the length of each string. The rest of the input is then N lines of single strings. The output should be a string that has the least possible similarity to any string in the input.
I'd like suggestions on how to reduce the number of calls I'm doing in my solution to this problem. Likely by some algorithmic magic.
Example input:
3 5
01001
11100
10111
Example output:
00010
My code:
import sys
import itertools
def similarity(sx, sy):
'''Naively calculates similarity between two
strings.'''
result = 0
for i in range(n_feat):
if sx[i] == sy[i]:
result += 1
return result
line_1 = sys.stdin.readline()
line_1 = line_1.split()
N = int(line_1[0])
n_feat = int(line_1[1])
characters = set()
for i in range(N):
characters.add(str(sys.stdin.readline()))
# Generate all possible ways to write n_feat long string with alphabet 0,1
all_pos_chars = ["".join(seq) for seq in itertools.product("01", repeat=n_feat)]
# Subset actually possible (removed ones have similarity == n_feat)
pos_chars = [pos_char for pos_char in all_pos_chars if pos_char not in characters]
# Impossibly high starting-point.
curr_min = n_feat+1
curr_small = ""
for pos_char in pos_chars:
curr = max(similarity(pos_char, character) for character in characters)
if curr == 0:
curr_small = pos_char
break;
if curr <= curr_min:
curr_min = curr
curr_small = pos_char
print(curr_small)
This solution works fine for smaller inputs. For example, I ran python -m cProfile -s cumtime dischar.py < 1.in
where 1.in is the example input given above and received this:
300 function calls in 0.001 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.001 0.001 built-in method builtins.exec
1 0.000 0.000 0.001 0.001 dischar2.py:1(<module>)
1 0.000 0.000 0.000 0.000 built-in method builtins.print
31 0.000 0.000 0.000 0.000 built-in method builtins.max
124 0.000 0.000 0.000 0.000 dischar2.py:34(<genexpr>)
93 0.000 0.000 0.000 0.000 dischar2.py:5(similarity)
4 0.000 0.000 0.000 0.000 method 'readline' of '_io.TextIOWrapper' objects
1 0.000 0.000 0.000 0.000 dischar2.py:26(<listcomp>)
2 0.000 0.000 0.000 0.000 cp1252.py:22(decode)
32 0.000 0.000 0.000 0.000 method 'join' of 'str' objects
1 0.000 0.000 0.000 0.000 dischar2.py:28(<listcomp>)
2 0.000 0.000 0.000 0.000 built-in method _codecs.charmap_decode
2 0.000 0.000 0.000 0.000 codecs.py:281(getstate)
1 0.000 0.000 0.000 0.000 method 'split' of 'str' objects
3 0.000 0.000 0.000 0.000 method 'add' of 'set' objects
1 0.000 0.000 0.000 0.000 method 'disable' of '_lsprof.Profiler' objects
But I was worried about the number of calls at line:34, which is this bit of code: curr = max(similarity(pos_char, character) for character in characters)
, and then onwards to line:5 which is the similartiy-function. I made a 6.in, where the first line is 10000 20
, and the next 10000 lines are 20 zeros:
python -m cProfile -s cumtime dischar2.py < 6.in
11111111111111111111
7360118 function calls in 9.280 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 9.280 9.280 built-in method builtins.exec
1 0.756 0.756 9.280 9.280 dischar2.py:1(<module>)
1048575 0.663 0.000 7.700 0.000 built-in method builtins.max
3145725 0.777 0.000 7.037 0.000 dischar2.py:34(<genexpr>)
2097150 6.260 0.000 6.260 0.000 dischar2.py:5(similarity)
1 0.325 0.325 0.656 0.656 dischar2.py:26(<listcomp>)
1048576 0.332 0.000 0.332 0.000 method 'join' of 'str' objects
1 0.161 0.161 0.161 0.161 dischar2.py:28(<listcomp>)
10001 0.004 0.000 0.005 0.000 method 'readline' of '_io.TextIOWrapper' objects
10000 0.001 0.000 0.001 0.000 method 'add' of 'set' objects
28 0.000 0.000 0.001 0.000 cp1252.py:22(decode)
28 0.001 0.000 0.001 0.000 built-in method _codecs.charmap_decode
1 0.000 0.000 0.000 0.000 built-in method builtins.print
28 0.000 0.000 0.000 0.000 codecs.py:281(getstate)
1 0.000 0.000 0.000 0.000 method 'split' of 'str' objects
1 0.000 0.000 0.000 0.000 method 'disable' of '_lsprof.Profiler' objects
As you can see, this adds up quickly! I think my solution is sound, it provides the correct output for every case I can test for. But there has to be some trick that I'm not seeing, because Kattis expects the solution to run within 2 CPU-seconds. Any suggestions?
python performance algorithm python-3.x programming-challenge
New contributor
$endgroup$
add a comment |
$begingroup$
I'm currently working on this problem from Kattis. In short, we're supposed to find the string that has the least similarity to any other string given. Every element of a string is either 0 or 1. Similarity between two strings is measured by increasing the similarity by 1 if both strings have the same character in the same position. E.g: "01001" "11110" has similarity 1, because they both have 1 in their 2nd position, and for every other position they have different characters. An input starts with one line giving two numbers N and P, being first the number of strings in the list, and then the length of each string. The rest of the input is then N lines of single strings. The output should be a string that has the least possible similarity to any string in the input.
I'd like suggestions on how to reduce the number of calls I'm doing in my solution to this problem. Likely by some algorithmic magic.
Example input:
3 5
01001
11100
10111
Example output:
00010
My code:
import sys
import itertools
def similarity(sx, sy):
'''Naively calculates similarity between two
strings.'''
result = 0
for i in range(n_feat):
if sx[i] == sy[i]:
result += 1
return result
line_1 = sys.stdin.readline()
line_1 = line_1.split()
N = int(line_1[0])
n_feat = int(line_1[1])
characters = set()
for i in range(N):
characters.add(str(sys.stdin.readline()))
# Generate all possible ways to write n_feat long string with alphabet 0,1
all_pos_chars = ["".join(seq) for seq in itertools.product("01", repeat=n_feat)]
# Subset actually possible (removed ones have similarity == n_feat)
pos_chars = [pos_char for pos_char in all_pos_chars if pos_char not in characters]
# Impossibly high starting-point.
curr_min = n_feat+1
curr_small = ""
for pos_char in pos_chars:
curr = max(similarity(pos_char, character) for character in characters)
if curr == 0:
curr_small = pos_char
break;
if curr <= curr_min:
curr_min = curr
curr_small = pos_char
print(curr_small)
This solution works fine for smaller inputs. For example, I ran python -m cProfile -s cumtime dischar.py < 1.in
where 1.in is the example input given above and received this:
300 function calls in 0.001 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.001 0.001 built-in method builtins.exec
1 0.000 0.000 0.001 0.001 dischar2.py:1(<module>)
1 0.000 0.000 0.000 0.000 built-in method builtins.print
31 0.000 0.000 0.000 0.000 built-in method builtins.max
124 0.000 0.000 0.000 0.000 dischar2.py:34(<genexpr>)
93 0.000 0.000 0.000 0.000 dischar2.py:5(similarity)
4 0.000 0.000 0.000 0.000 method 'readline' of '_io.TextIOWrapper' objects
1 0.000 0.000 0.000 0.000 dischar2.py:26(<listcomp>)
2 0.000 0.000 0.000 0.000 cp1252.py:22(decode)
32 0.000 0.000 0.000 0.000 method 'join' of 'str' objects
1 0.000 0.000 0.000 0.000 dischar2.py:28(<listcomp>)
2 0.000 0.000 0.000 0.000 built-in method _codecs.charmap_decode
2 0.000 0.000 0.000 0.000 codecs.py:281(getstate)
1 0.000 0.000 0.000 0.000 method 'split' of 'str' objects
3 0.000 0.000 0.000 0.000 method 'add' of 'set' objects
1 0.000 0.000 0.000 0.000 method 'disable' of '_lsprof.Profiler' objects
But I was worried about the number of calls at line:34, which is this bit of code: curr = max(similarity(pos_char, character) for character in characters)
, and then onwards to line:5 which is the similartiy-function. I made a 6.in, where the first line is 10000 20
, and the next 10000 lines are 20 zeros:
python -m cProfile -s cumtime dischar2.py < 6.in
11111111111111111111
7360118 function calls in 9.280 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 9.280 9.280 built-in method builtins.exec
1 0.756 0.756 9.280 9.280 dischar2.py:1(<module>)
1048575 0.663 0.000 7.700 0.000 built-in method builtins.max
3145725 0.777 0.000 7.037 0.000 dischar2.py:34(<genexpr>)
2097150 6.260 0.000 6.260 0.000 dischar2.py:5(similarity)
1 0.325 0.325 0.656 0.656 dischar2.py:26(<listcomp>)
1048576 0.332 0.000 0.332 0.000 method 'join' of 'str' objects
1 0.161 0.161 0.161 0.161 dischar2.py:28(<listcomp>)
10001 0.004 0.000 0.005 0.000 method 'readline' of '_io.TextIOWrapper' objects
10000 0.001 0.000 0.001 0.000 method 'add' of 'set' objects
28 0.000 0.000 0.001 0.000 cp1252.py:22(decode)
28 0.001 0.000 0.001 0.000 built-in method _codecs.charmap_decode
1 0.000 0.000 0.000 0.000 built-in method builtins.print
28 0.000 0.000 0.000 0.000 codecs.py:281(getstate)
1 0.000 0.000 0.000 0.000 method 'split' of 'str' objects
1 0.000 0.000 0.000 0.000 method 'disable' of '_lsprof.Profiler' objects
As you can see, this adds up quickly! I think my solution is sound, it provides the correct output for every case I can test for. But there has to be some trick that I'm not seeing, because Kattis expects the solution to run within 2 CPU-seconds. Any suggestions?
python performance algorithm python-3.x programming-challenge
New contributor
$endgroup$
I'm currently working on this problem from Kattis. In short, we're supposed to find the string that has the least similarity to any other string given. Every element of a string is either 0 or 1. Similarity between two strings is measured by increasing the similarity by 1 if both strings have the same character in the same position. E.g: "01001" "11110" has similarity 1, because they both have 1 in their 2nd position, and for every other position they have different characters. An input starts with one line giving two numbers N and P, being first the number of strings in the list, and then the length of each string. The rest of the input is then N lines of single strings. The output should be a string that has the least possible similarity to any string in the input.
I'd like suggestions on how to reduce the number of calls I'm doing in my solution to this problem. Likely by some algorithmic magic.
Example input:
3 5
01001
11100
10111
Example output:
00010
My code:
import sys
import itertools
def similarity(sx, sy):
'''Naively calculates similarity between two
strings.'''
result = 0
for i in range(n_feat):
if sx[i] == sy[i]:
result += 1
return result
line_1 = sys.stdin.readline()
line_1 = line_1.split()
N = int(line_1[0])
n_feat = int(line_1[1])
characters = set()
for i in range(N):
characters.add(str(sys.stdin.readline()))
# Generate all possible ways to write n_feat long string with alphabet 0,1
all_pos_chars = ["".join(seq) for seq in itertools.product("01", repeat=n_feat)]
# Subset actually possible (removed ones have similarity == n_feat)
pos_chars = [pos_char for pos_char in all_pos_chars if pos_char not in characters]
# Impossibly high starting-point.
curr_min = n_feat+1
curr_small = ""
for pos_char in pos_chars:
curr = max(similarity(pos_char, character) for character in characters)
if curr == 0:
curr_small = pos_char
break;
if curr <= curr_min:
curr_min = curr
curr_small = pos_char
print(curr_small)
This solution works fine for smaller inputs. For example, I ran python -m cProfile -s cumtime dischar.py < 1.in
where 1.in is the example input given above and received this:
300 function calls in 0.001 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.001 0.001 built-in method builtins.exec
1 0.000 0.000 0.001 0.001 dischar2.py:1(<module>)
1 0.000 0.000 0.000 0.000 built-in method builtins.print
31 0.000 0.000 0.000 0.000 built-in method builtins.max
124 0.000 0.000 0.000 0.000 dischar2.py:34(<genexpr>)
93 0.000 0.000 0.000 0.000 dischar2.py:5(similarity)
4 0.000 0.000 0.000 0.000 method 'readline' of '_io.TextIOWrapper' objects
1 0.000 0.000 0.000 0.000 dischar2.py:26(<listcomp>)
2 0.000 0.000 0.000 0.000 cp1252.py:22(decode)
32 0.000 0.000 0.000 0.000 method 'join' of 'str' objects
1 0.000 0.000 0.000 0.000 dischar2.py:28(<listcomp>)
2 0.000 0.000 0.000 0.000 built-in method _codecs.charmap_decode
2 0.000 0.000 0.000 0.000 codecs.py:281(getstate)
1 0.000 0.000 0.000 0.000 method 'split' of 'str' objects
3 0.000 0.000 0.000 0.000 method 'add' of 'set' objects
1 0.000 0.000 0.000 0.000 method 'disable' of '_lsprof.Profiler' objects
But I was worried about the number of calls at line:34, which is this bit of code: curr = max(similarity(pos_char, character) for character in characters)
, and then onwards to line:5 which is the similartiy-function. I made a 6.in, where the first line is 10000 20
, and the next 10000 lines are 20 zeros:
python -m cProfile -s cumtime dischar2.py < 6.in
11111111111111111111
7360118 function calls in 9.280 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 9.280 9.280 built-in method builtins.exec
1 0.756 0.756 9.280 9.280 dischar2.py:1(<module>)
1048575 0.663 0.000 7.700 0.000 built-in method builtins.max
3145725 0.777 0.000 7.037 0.000 dischar2.py:34(<genexpr>)
2097150 6.260 0.000 6.260 0.000 dischar2.py:5(similarity)
1 0.325 0.325 0.656 0.656 dischar2.py:26(<listcomp>)
1048576 0.332 0.000 0.332 0.000 method 'join' of 'str' objects
1 0.161 0.161 0.161 0.161 dischar2.py:28(<listcomp>)
10001 0.004 0.000 0.005 0.000 method 'readline' of '_io.TextIOWrapper' objects
10000 0.001 0.000 0.001 0.000 method 'add' of 'set' objects
28 0.000 0.000 0.001 0.000 cp1252.py:22(decode)
28 0.001 0.000 0.001 0.000 built-in method _codecs.charmap_decode
1 0.000 0.000 0.000 0.000 built-in method builtins.print
28 0.000 0.000 0.000 0.000 codecs.py:281(getstate)
1 0.000 0.000 0.000 0.000 method 'split' of 'str' objects
1 0.000 0.000 0.000 0.000 method 'disable' of '_lsprof.Profiler' objects
As you can see, this adds up quickly! I think my solution is sound, it provides the correct output for every case I can test for. But there has to be some trick that I'm not seeing, because Kattis expects the solution to run within 2 CPU-seconds. Any suggestions?
python performance algorithm python-3.x programming-challenge
python performance algorithm python-3.x programming-challenge
New contributor
New contributor
New contributor
asked 4 mins ago
RoyMRoyM
284
284
New contributor
New contributor
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
);
);
, "mathjax-editing");
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
RoyM is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216960%2fprogramming-challenge-from-kattis-distinctive-characters%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
RoyM is a new contributor. Be nice, and check out our Code of Conduct.
RoyM is a new contributor. Be nice, and check out our Code of Conduct.
RoyM is a new contributor. Be nice, and check out our Code of Conduct.
RoyM is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216960%2fprogramming-challenge-from-kattis-distinctive-characters%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown