Skip to main content
Commonmark migration
Source Link

In that Coding Golf, you should convert one coding convention with TitleCase to lower_case_with_underscores. And... vice versa!

#Specification

Specification

Change the casing in a following way:

  • If underscore character is a delimiter, change the casing to Title Case without any of delimiter.
  • If there are multiple words with no delimiter, change the casing to lower case and add an underscore character as a delimiter.
  • In case of only one word (or one character): change the casing to Title Case if the word starts with lower case; change the casing to lower case if the word starts with the upper case.

Allowed characters:

  • A to Z
  • a to z
  • underscore (_).

Input with mixed cased words are disallowed. Examples of disallowed cases:

  • Coding_Convention_Conversion
  • a_BC

#Example Cases

Example Cases

Input                        | Expected Output
===========================================================
CodingConventionConversion   | coding_convention_conversion
coding_convention_conversion | CodingConventionConversion
abc                          | Abc
Abc                          | abc
ABC                          | a_b_c
a_b_c                        | ABC
a                            | A
A                            | a

Rules

  • It is allowed to use ToUpper, ToLower and ToTitleCase functions.
  • Using regular expressions is allowed.
  • : shortest code in bytes wins!

In that Coding Golf, you should convert one coding convention with TitleCase to lower_case_with_underscores. And... vice versa!

#Specification

Change the casing in a following way:

  • If underscore character is a delimiter, change the casing to Title Case without any of delimiter.
  • If there are multiple words with no delimiter, change the casing to lower case and add an underscore character as a delimiter.
  • In case of only one word (or one character): change the casing to Title Case if the word starts with lower case; change the casing to lower case if the word starts with the upper case.

Allowed characters:

  • A to Z
  • a to z
  • underscore (_).

Input with mixed cased words are disallowed. Examples of disallowed cases:

  • Coding_Convention_Conversion
  • a_BC

#Example Cases

Input                        | Expected Output
===========================================================
CodingConventionConversion   | coding_convention_conversion
coding_convention_conversion | CodingConventionConversion
abc                          | Abc
Abc                          | abc
ABC                          | a_b_c
a_b_c                        | ABC
a                            | A
A                            | a

Rules

  • It is allowed to use ToUpper, ToLower and ToTitleCase functions.
  • Using regular expressions is allowed.
  • : shortest code in bytes wins!

In that Coding Golf, you should convert one coding convention with TitleCase to lower_case_with_underscores. And... vice versa!

Specification

Change the casing in a following way:

  • If underscore character is a delimiter, change the casing to Title Case without any of delimiter.
  • If there are multiple words with no delimiter, change the casing to lower case and add an underscore character as a delimiter.
  • In case of only one word (or one character): change the casing to Title Case if the word starts with lower case; change the casing to lower case if the word starts with the upper case.

Allowed characters:

  • A to Z
  • a to z
  • underscore (_).

Input with mixed cased words are disallowed. Examples of disallowed cases:

  • Coding_Convention_Conversion
  • a_BC

Example Cases

Input                        | Expected Output
===========================================================
CodingConventionConversion   | coding_convention_conversion
coding_convention_conversion | CodingConventionConversion
abc                          | Abc
Abc                          | abc
ABC                          | a_b_c
a_b_c                        | ABC
a                            | A
A                            | a

Rules

  • It is allowed to use ToUpper, ToLower and ToTitleCase functions.
  • Using regular expressions is allowed.
  • : shortest code in bytes wins!
added 15 characters in body
Source Link
Dariusz Woźniak
  • 1.3k
  • 1
  • 12
  • 16

In that Coding Golf, you should convert one coding convention with TitleCase to lower_case_with_underscores. And... vice versa!

#Specification

Change the casing in a following way:

  • If underscore character is a delimiter, change the casing to Title Case without any of delimiter.
  • If there are multiple words with no delimiter, change the casing to lower case and add an underscore character as a delimiter.
  • In case of only one word (or one character): change the casing to Title Case if the word starts with lower case; change the casing to lower case if the word starts with the upper case.

Allowed characters:

  • A to Z
  • a to z
  • underscore (_).

Input with mixed cased words are disallowed. Examples of disallowed cases:

  • Coding_Convention_Conversion
  • a_BC

#Example Cases

Input                        | Expected Output
===========================================================
CodingConventionConversion   | coding_convention_conversion
coding_convention_conversion | CodingConventionConversion
abc                          | Abc
Abc                          | abc
ABC                          | a_b_c
a_b_c                        | ABC
a                            | A
A                            | a

Rules

  • It is allowed to use ToUpper and, ToLower and ToTitleCase functions.
  • Using regular expressions is allowed.
  • : shortest code in bytes wins!

In that Coding Golf, you should convert one coding convention with TitleCase to lower_case_with_underscores. And... vice versa!

#Specification

Change the casing in a following way:

  • If underscore character is a delimiter, change the casing to Title Case without any of delimiter.
  • If there are multiple words with no delimiter, change the casing to lower case and add an underscore character as a delimiter.
  • In case of only one word (or one character): change the casing to Title Case if the word starts with lower case; change the casing to lower case if the word starts with the upper case.

Allowed characters:

  • A to Z
  • a to z
  • underscore (_).

Input with mixed cased words are disallowed. Examples of disallowed cases:

  • Coding_Convention_Conversion
  • a_BC

#Example Cases

Input                        | Expected Output
===========================================================
CodingConventionConversion   | coding_convention_conversion
coding_convention_conversion | CodingConventionConversion
abc                          | Abc
Abc                          | abc
ABC                          | a_b_c
a_b_c                        | ABC
a                            | A
A                            | a

Rules

  • It is allowed to use ToUpper and ToLower functions.
  • Using regular expressions is allowed.
  • : shortest code in bytes wins!

In that Coding Golf, you should convert one coding convention with TitleCase to lower_case_with_underscores. And... vice versa!

#Specification

Change the casing in a following way:

  • If underscore character is a delimiter, change the casing to Title Case without any of delimiter.
  • If there are multiple words with no delimiter, change the casing to lower case and add an underscore character as a delimiter.
  • In case of only one word (or one character): change the casing to Title Case if the word starts with lower case; change the casing to lower case if the word starts with the upper case.

Allowed characters:

  • A to Z
  • a to z
  • underscore (_).

Input with mixed cased words are disallowed. Examples of disallowed cases:

  • Coding_Convention_Conversion
  • a_BC

#Example Cases

Input                        | Expected Output
===========================================================
CodingConventionConversion   | coding_convention_conversion
coding_convention_conversion | CodingConventionConversion
abc                          | Abc
Abc                          | abc
ABC                          | a_b_c
a_b_c                        | ABC
a                            | A
A                            | a

Rules

  • It is allowed to use ToUpper, ToLower and ToTitleCase functions.
  • Using regular expressions is allowed.
  • : shortest code in bytes wins!
deleted 61 characters in body
Source Link
Dariusz Woźniak
  • 1.3k
  • 1
  • 12
  • 16

In that Coding Golf, you should convert one coding convention with TitleCase to lower_case_with_underscores. And... vice versa!

#Specification

Change the casing in a following way:

  • If underscore character is a delimiter, change the casing to Title Case without any of delimiter.
  • If there are multiple words with no delimiter, change the casing to lower case and add an underscore character as a delimiter.
  • In case of only one word (or one character): change the casing to Title Case if the word starts with lower case; change the casing to lower case if the word starts with the upper case.

Allowed characters:

  • A to Z
  • a to z
  • underscore (_).

Input with mixed cased words are disallowed. Examples of disallowed cases:

  • Coding_Convention_Conversion
  • a_BC

#Example Cases

Input                        | Expected Output
===========================================================
CodingConventionConversion   | coding_convention_conversion
coding_convention_conversion | CodingConventionConversion
abc                          | Abc
Abc                          | abc
ABC                          | a_b_c
a_b_c                        | ABC
a                            | A
A                            | a

Rules

  • It is allowed to use ToUpper and ToLower functions.
  • However, it is not allowed to use ToTitleCase function.
  • Using regular expressions is allowed.
  • : shortest code in bytes wins!

In that Coding Golf, you should convert one coding convention with TitleCase to lower_case_with_underscores. And... vice versa!

#Specification

Change the casing in a following way:

  • If underscore character is a delimiter, change the casing to Title Case without any of delimiter.
  • If there are multiple words with no delimiter, change the casing to lower case and add an underscore character as a delimiter.
  • In case of only one word (or one character): change the casing to Title Case if the word starts with lower case; change the casing to lower case if the word starts with the upper case.

Allowed characters:

  • A to Z
  • a to z
  • underscore (_).

Input with mixed cased words are disallowed. Examples of disallowed cases:

  • Coding_Convention_Conversion
  • a_BC

#Example Cases

Input                        | Expected Output
===========================================================
CodingConventionConversion   | coding_convention_conversion
coding_convention_conversion | CodingConventionConversion
abc                          | Abc
Abc                          | abc
ABC                          | a_b_c
a_b_c                        | ABC
a                            | A
A                            | a

Rules

  • It is allowed to use ToUpper and ToLower functions.
  • However, it is not allowed to use ToTitleCase function.
  • Using regular expressions is allowed.
  • : shortest code in bytes wins!

In that Coding Golf, you should convert one coding convention with TitleCase to lower_case_with_underscores. And... vice versa!

#Specification

Change the casing in a following way:

  • If underscore character is a delimiter, change the casing to Title Case without any of delimiter.
  • If there are multiple words with no delimiter, change the casing to lower case and add an underscore character as a delimiter.
  • In case of only one word (or one character): change the casing to Title Case if the word starts with lower case; change the casing to lower case if the word starts with the upper case.

Allowed characters:

  • A to Z
  • a to z
  • underscore (_).

Input with mixed cased words are disallowed. Examples of disallowed cases:

  • Coding_Convention_Conversion
  • a_BC

#Example Cases

Input                        | Expected Output
===========================================================
CodingConventionConversion   | coding_convention_conversion
coding_convention_conversion | CodingConventionConversion
abc                          | Abc
Abc                          | abc
ABC                          | a_b_c
a_b_c                        | ABC
a                            | A
A                            | a

Rules

  • It is allowed to use ToUpper and ToLower functions.
  • Using regular expressions is allowed.
  • : shortest code in bytes wins!
added 59 characters in body
Source Link
Dariusz Woźniak
  • 1.3k
  • 1
  • 12
  • 16
Loading
Tweeted twitter.com/StackCodeGolf/status/691827999373680640
Source Link
Dariusz Woźniak
  • 1.3k
  • 1
  • 12
  • 16
Loading