VirtualMini

Everything in the world !

code golf simple string reflection - Search

The code golf simple string reflection searched through all the site information that is gathered from around the web. To view the complete news story please click on the title link.



code golf - simple string reflection


let's start by defining a reflection of a character in a string:given a string with distinct lowercase alphabetical letters with no spaces such as abcdefg, define a reflection of a letter in the string c as moving it (without changing the order of any other letter) to a new place in the string such that the number of letters originally to the right of it is now the number of letters to the left of it.thus, a reflection of the letter c in abcdefg would be abdecfg. explanation: there were 4 letters to the right of c and now, there are 4 letters to the left of c.some more examples:reflecting the character e in myfriend would form the string myefrindreflecting the character a in axyz would form the string xyza.reflecting the character b in abc would form the string abc.reflect...






code golf - create an alphabet song


_=>btoa`pb è¡záî"âh*"è1£b:ãúa¤hj$âru^yåúaæb`.replace(/(.)./g,`$1 is for $&t `) an anonymous function returning a string. contains unprintables; here's a version that doesn't:_=>btoa`\x02pb \x80è\x11¡z\x18áî"âh*"è1£b:ãúa¤hj$âru^yåúaæb`.replace(/(.)./g,`$1 is for $&t `) this uses @jonathanallen's technique, using only three-letter words that end in t. the string decompresses to anbicodoea ohuisjokilomanioupaqarositiunvewexayezi.i tried chaining two-letter pairs like so:ace bee cee dew ewe ... i made it all the way to w but got stuck on x; as far as i can tell, the only valid three-letter x words are xis and xat, the only w-words leading into either of these are wha and wai, the only v-word there is via, and no u-word ends in an i.for the record, the full string was ceeeweeereue






code golf - how many blackjack sequences in that list?


lambda x:len({x[i:j]for i in range(12)for j in range(13)if sum(min(26,ord(c)-48)%16for c in x[i:j])in([11,21][~('a'in x[i:j]):])}) try it online!how?an unnamed function, taking the string of length 12 as x.x[i:j] is a slice of the string from the i+1th to the jth character.slices are taken such that we have all sublists by traversing from i=0 to i=11 with for i in range(12), for each of which we traverse from j=0 to j=12 with for j in range(13).(we only need j=i+1 and up, but slices with j<=i are just empty strings, so we can golf off 4 bytes from for j in range(i+1,13))these are filtered for those with the correct sum...valid sums are 11 and 21 if there is an ace in a slice, or just 21 if not. 'a'in x[i:j] gives us this information and ~(v) performs -1-v, which we use to slice [11,21]






string - from programming puzzles to code golf


with spaces:`co¸{s}golf`r `pžgÿmúá puzz¤s try it online!without spaces:`co¸{s}golf`r`pžgÿmúápuzz¤s try it online!this takes advantage of the fact that in japt, a space closes a method call. with spaces, the code is roughly equivalent to this javascript code:("code"+(s)+"golf").r(),"programming puzzles" this is evaluated as javascript, and the result is sent to stdout. since the last expression is "programming puzzles", that string is printed.without spaces, the code is roughly equivalent to:("code"+(s)+"golf").r("programmingpuzzles") (if you haven't figured it out by now, the s variable is a single space.) the .r() method on a string, if given one argument, removes all instances of that argument from the string. since "code golf" does not contain "...






code golf - as easy as a-b-c


inputa string that contains at most one of each of the letters a, b, and c. they may be in any order. the empty string is valid input.note: a previous version of this challenge used the letters lej instead of abc and they may still be used if desired.outputa string of the a, b, c letters that were not present in the input. they may be in any order.if the output would be the empty string then simply giving no output is valid, if that makes sense for your implementation. (e.g. you don't need to actually call print on an empty string.)examplesif the input is b then the output should either be ca or ac since a and c are not present in the input.if the input is the empty string then the output should be abc or any permutation since none of the three letters are present in the input.if the input






code golf - as easy as a-b-c


inputa string that contains at most one of each of the letters a, b, and c. they may be in any order. the empty string is valid input.outputa string of the a, b, c letters that were not present in the input. they may be in any order.if the output would be the empty string then simply giving no output is valid, if that makes sense for your implementation. (e.g. you don't need to actually call print on an empty string.)examplesif the input is b then the output should either be ca or ac since a and c are not present in the input.if the input is the empty string then the output should be abc or any permutation since none of the three letters are present in the input.if the input is cab then the output should be the empty string because all three letters are present in the input.test casesthere






code golf - create an alphabet song


0..25|%{($i=[char]($_+65))+" is for $i"+-join('ddadadadeladabadtsetitetadetiladatatatadrnatetisesit')[($_*=2)..++$_]} try it online!loops from 0 to 25 (i.e., the length of the alphabet). each iteration, we turn the integer into the appropriate char (i.e., ascii 65 for a), save that into $i for use later, string-concatenate that with is for $i, and then tack on the suffix of the appropriate word. that's done by indexing into a lengthy string, where every word is two letters long, by multiplying the current number by 2, and taking the next letter ..++$_ as well. note we need to -join that together, else it doesn't string concatenate right.the resulting strings are all left on the pipeline, and an implicit write-output at the end prints them with newlines in between.saved a bunch of bytes tha






code golf - (a[l(t[e(r)n]e)s]t) a string!


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top (a[l(t[e(r)n]e)s]t) a string!up vote20down votefavorite3alternesting, is the act of taking a string and nesting it in alternating brackets. here is how you alternest a string.for a string of length n, take the center n characters, and surround them in...






code golf - (a[l(t[e(r)n]e)s]t) a string!


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top (a[l(t[e(r)n]e)s]t) a string!up vote22down votefavorite3alternesting, is the act of taking a string and nesting it in alternating brackets. here is how you alternest a string.for a string of length n, take the center n characters, and surround them in...






code golf - (a[l(t[e(r)n]e)s]t) a string!


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top (a[l(t[e(r)n]e)s]t) a string!up vote20down votefavorite2alternesting, is the act of taking a string and nesting it in alternating brackets. here is how you alternest a string.for a string of length n, take the center n characters, and surround them in...






code golf - (a[l(t[e(r)n]e)s]t) a string!


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top (a[l(t[e(r)n]e)s]t) a string!up vote19down votefavorite2alternesting, is the act of taking a string and nesting it in alternating brackets. here is how you alternest a string.for a string of length n, take the center n characters, and surround them in...






code golf - (a[l(t[e(r)n]e)s]t) a string!


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top (a[l(t[e(r)n]e)s]t) a string!up vote16down votefavorite2alternesting, is the act of taking a string and nesting it in alternating brackets. here is how you alternest a string.for a string of length n, take the center n characters, and surround them in...






code golf - recursive string substitution


the taskwrite a program or function that given three strings a, b, c produces an output string where each instance of b in a has been recursively substituted with c. recursively substituting means repeating a substitution where at each step all non-overlapping instances of b in a (chosen greedily from left to right) are replaced with c until b is no more contained in a.input/outputyou may use any of the default methods for i/o.strings will contain only printable ascii characters (and may contain any of them) .b will never be an empty string, while a and c might be.strings are to be considered plaintext, you can't for example treat b as a regex pattern.some combinations of inputs will never terminate. your program can do anything in those cases.test casesthese are in the format: a/b/c\noutp






code golf - fold a string into a triangle


given a string whose length is divisible by 4, make a triangle as demonstrate below.if the string is abcdefghijkl, then the triangle would be: a b l c k defghij if the string is iamastringwithalengthdivisiblebyfour, then the triangle would be: i a r m u a o s f t y r b i e n l gwithalengthdivisib if the string is thisrepresentationisnotatriangle, then the triangle would be: t h e i l s g r n e a p i r r esentationisnotat the string will only consist of characters from a to z.leading/trailing whitespaces and newlines are allowed as long as the shape is not broken.a list of strings as output is allowed.this is code-golf. shortest answer in bytes wins. standard loopholes apply.






code golf - accessories after the fact!


this challenge is inspired by mathematics is fact. programming is not.the mathematical notation for a factorial, or a fact is an exclamation mark !. the exclamation mark is also a common symbol for not in many programming languages.challenge:take a string, containing numerals, and the characters: + ! as input and output the following: everything in front of an exclamation mark should be evaluated as a mathematical expression, so 2+2 would be 4.everything after a single exclamation mark should be appended as accessories to whatever is in front of it, so: 2+2!5 should give 45, because 2+2=4, and 5 is an accessory. 2+2!5+5 should give 410. since ! also means not, anything that's not an accessory after the fact should not be appended. so, 2+2!!5 should give 4, since 5 is not an accessory. now,






code golf - make string waves


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top make string wavesup vote11down votefavorite1given a string as input, output the string with the following algorithm applied:1. split the string by " " (find the words): "hello world" -> ["hello","world"] 2. find the vowel count of each comp...






code golf - make string waves


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top make string wavesup vote14down votefavorite1given a string as input, output the string with the following algorithm applied:1. split the string by " " (find the words): "hello world" -> ["hello","world"] 2. find the vowel count of each comp...






code golf - make string waves


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top make string wavesup vote14down votefavorite1given a string as input, output the string with the following algorithm applied:1. split the string by " " (find the words): "hello world" -> ["hello","world"] 2. find the vowel count of each comp...






code golf - make string waves


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top make string wavesup vote13down votefavorite1given a string as input, output the string with the following algorithm applied:1. split the string by " " (find the words): "hello world" -> ["hello","world"] 2. find the vowel count of each comp...






code golf - make string waves


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top make string wavesup vote14down votefavorite1given a string as input, output the string with the following algorithm applied:1. split the string by " " (find the words): "hello world" -> ["hello","world"] 2. find the vowel count of each comp...






code golf - make string waves


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top make string wavesup vote14down votefavorite1given a string as input, output the string with the following algorithm applied:1. split the string by " " (find the words): "hello world" -> ["hello","world"] 2. find the vowel count of each comp...






code golf - make string waves


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top make string wavesup vote15down votefavorite1given a string as input, output the string with the following algorithm applied:1. split the string by " " (find the words): "hello world" -> ["hello","world"] 2. find the vowel count of each comp...






code golf - make string waves


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top make string wavesup vote12down votefavorite1given a string as input, output the string with the following algorithm applied:1. split the string by " " (find the words): "hello world" -> ["hello","world"] 2. find the vowel count of each comp...






code golf - make string waves


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top make string wavesup vote15down votefavorite1given a string as input, output the string with the following algorithm applied:1. split the string by " " (find the words): "hello world" -> ["hello","world"] 2. find the vowel count of each comp...






code golf - make string waves


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top make string wavesup vote15down votefavorite1given a string as input, output the string with the following algorithm applied:1. split the string by " " (find the words): "hello world" -> ["hello","world"] 2. find the vowel count of each comp...






code golf - make string waves


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top make string wavesup vote15down votefavorite1given a string as input, output the string with the following algorithm applied:1. split the string by " " (find the words): "hello world" -> ["hello","world"] 2. find the vowel count of each comp...






code golf - make string waves


sign up or log in to customize your list. stack exchangeinboxreputation and badges programming puzzles & code golf questions tags users badges unanswered ask question_ programming puzzles & code golf stack exchange is a question and answer site for programming puzzle enthusiasts and code golfers. join them; it only takes a minute: sign uphere's how it works: anybody can ask a question anybody can answer the best answers are voted up and rise to the top make string wavesup vote9down votefavorite1given a string as input, output the string with the following algorithm applied:1. split the string by " " (find the words): "hello world" -> ["hello","world"] 2. find the vowel count of each compo...






code golf - find all the anagrams!


despite having 17 questions tagged anagrams, we still don't have this question, so here it is. your taskyou must write a program or function that, when receiving a string, prints out all possible anagrams of it. for the purpose of this question, an anagram is a string that contains the same character as the original string, but is not the original string. an anagram does not have to be or contain actual words. inputyou may accept the string, which may be of any length > 0, by any standard input method. it may contain any ascii characters. outputyou may output all of the possible anagrams of the inputted string in any standard way. you must not output the same string twice, or output a string equal to the input. other rulesstandard loopholes are disallowedscoringthis is code-golf, least by.






code golf - find all the anagrams!


despite having 17 questions tagged anagrams, we still don't have this question, so here it is. your taskyou must write a program or function that, when receiving a string, prints out all possible anagrams of it. for the purpose of this question, an anagram is a string that contains the same character as the original string, but is not the original string. an anagram does not have to be or contain actual words. inputyou may accept the string, which may be of any length > 0, by any standard input method. outputyou may output all of the possible anagrams of the inputted string in any standard way. you must not output the same string twice, or output a string equal to the input. other rulesstandard loopholes are disallowedscoringthis is code-golf, least bytes wins.






code golf - mathematics is fact. programming is not


lambda s:(s[1::2]>s[::2])^ord(s[-1])%2 tryitonline!an unnamed function taking an input string s and returning an integer 0 or 1.s[1::2] is a slice of the input string that starts at index 1 and has a step size of two:'like this' -> 'ieti's[::2] is similar but starts at the default index of 0:'like this' -> 'lk hs'the test (s[1::2]>s[::2]) checks if the 0-based index of the '0' or '1' is odd, i.e. if we need to complement.this works because the ordering of strings is checked lexicog hically with any non-empty string greater than the empty string, and with ascii ordering, so '1'>'0'>'!'. this is a byte shorter than the simpler s.index(max(s))%2.the ord(s[-1])%2 checks to see if the last character is not a '0' (for valid input), and results in an integer (whereas the same le






code golf - reverse two sections of a string around a pivot


backgroundi am currently in an ap comp sci a: java class, and i want to start some of my friends on code golfing. i have a challenge from the course, and i would like to see how many bytes the community can do this challenge in. challenge details:given two input strings, the main string and the pivot string, do the following:if the pivot string is exactly once as a substring of the main string, the part of the main string that comes before the pivot string shall be swapped with the part that comes after, while preserving the order within said subtrings being swapped.for example: if the pivot string is empty or the pivot string is not found within the main string, the program does not have to have defined behavior.if there is more than one instance of the pivot string, the split should occu






code golf - rebuild a rectangular array from a corner


\%`$ $^$` vs` try it online!explanation\%`$ $^$` on each line (%), match the end of the line ($), and insert the reverse ($^) of the entire line ($`) and print the result with a trailing linefeed (\). this does the reflection along the vertical axis and prints the first half of the output.vs` this just reverses the entire string, which is equivalent to a 180° degree rotation, or in our case (due to the horizontal symmetry) a reflection along the horizontal axis. this way this works is that v's (reverse) default regex is (?m:^.*$), which normally matches each line of the string. however, we activate the singleline option s, which makes . match linefeeds as well and therefore this default regex actually matches the entire string.the result of this is printed automatica...






code golf - generate tiny text


challengeyour program needs to take an input of a string, where the string has only letters, no special characters, no numbers, and no accents (they look all weird).then, your program should output a superscript version.exampleinput: hello worldoutput: ʰᵉᶫᶫᵒ ʷᵒʳᶫᵈtest caseshello - ʰᵉᶫᶫᵒ code - ᶜᵒᵈᵉ golf - ᵍᵒᶫᶠ asdf - ᵃˢᵈᶠ qwerty - ᑫʷᵉʳᵗʸ abcdefghijklmnopqrstuvwxyz - ᵃᵇᶜᵈᵉᶠᵍʰᶦʲᵏᶫᵐᶰᵒᵖᑫʳˢᵗᵘᵛʷˣʸᶻ helpif you need help understanding check out this website, it's a translator: http://txtn.us/tiny-textcode golfthis is a code golf, so the shortest code wins!good luck!editsedit #1: there will be no caps, since i just realized they look weird.






code golf - is my os 32-bit or 64-bit?


so, with all the challenges out, i'm surprised this one isn't here yet.it's not too important anymore, but occasionally somebody needs to know.here is a simple golf: taking no user input, tell me if the computer on which the code is ran is on a 64-bit operating system, or a 32-bit operating system!if the code is ran on a 32-bit operating system, print "32", if the code is ran on a 64 bit operating system, output "64". print any other non-empty string of alphanumeric characters if it's neither 32 or 64 bit.please note that a 32 bit program running on a computer with a 64 bit operating system should output "64". you can assume that users will use 64 bit software whenever possible. to be eligible for entry, your code must be able to run on windows 4.10 or newer, and at least one fla...






code golf - reverse two sections of a string around a pivot


backgroundi am currently in an ap comp sci a: java class, and i want to start some of my friends on code golfing. i have a challenge from the course, and i would like to see how many bytes the community can do this challenge in. challenge details:given two input strings, the main string and the pivot string, do the following:if the pivot string is exactly once as a substring of the main string, the part of the main string that comes before the pivot string shall be swapped with the part that comes after, while preserving the order within said subtrings being swapped.for example: given the main string onetwothree and the pivot string "two", the output should be threetwoone. given the main string the rabbit is faster than the turtle and the pivot string is faster than (note the single ...






code golf - print invisible text


given a string as input, output a number of whitespace characters (0x0a and 0x20) equal to the length of the string.for example, given the string hello, world! your code would need to output exactly 13 whitespace characters and nothing else. these can be any mix of spaces and newlines.your code should not output any additional trailing newlines or spaces.testcases: input -> amount of whitespace to output "hello, world!" -> 13 "hi" -> 2 " don't forget about existing whitespace! " -> 45 "" -> 0 " " -> 13 " " -> 1 scoring:this is code-golf so fewest bytes wins!






signing day ceremonies from d.c., maryland and virginia


be the first to know about new stories from powerpost. sign up to follow, and we’ll e-mail you free updates as they’re published. you’ll receive free e-mail news updates each time a new story is published. you’re all set!